Skip to content

Commit

Permalink
refactor(runtimes): Replace polkadot runtime v0.8 by v0.9.29
Browse files Browse the repository at this point in the history
  • Loading branch information
dimartiro committed Mar 30, 2023
1 parent fa1267f commit 28b78b9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 40 deletions.
4 changes: 2 additions & 2 deletions dot/core/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ func TestService_HandleRuntimeChanges(t *testing.T) {
func TestService_HandleCodeSubstitutes(t *testing.T) {
s := NewTestService(t, nil)

runtimeFilepath, err := runtime.GetRuntime(context.Background(), runtime.POLKADOT_RUNTIME)
runtimeFilepath, err := runtime.GetRuntime(context.Background(), runtime.POLKADOT_RUNTIME_v0929)
require.NoError(t, err)
testRuntime, err := os.ReadFile(runtimeFilepath)
require.NoError(t, err)
Expand Down Expand Up @@ -623,7 +623,7 @@ func TestService_HandleRuntimeChangesAfterCodeSubstitutes(t *testing.T) {
require.NoError(t, err)
require.Equal(t, codeHashBefore, parentRt.GetCodeHash()) // codeHash should remain unchanged after code substitute

runtimeFilepath, err := runtime.GetRuntime(context.Background(), runtime.POLKADOT_RUNTIME)
runtimeFilepath, err := runtime.GetRuntime(context.Background(), runtime.POLKADOT_RUNTIME_v0929)
require.NoError(t, err)
testRuntime, err := os.ReadFile(runtimeFilepath)
require.NoError(t, err)
Expand Down
20 changes: 12 additions & 8 deletions dot/rpc/subscription/listeners_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func TestRuntimeChannelListener_Listen(t *testing.T) {
expectedInitialResponse.Method = "state_runtimeVersion"
expectedInitialResponse.Params.Result = expectedInitialVersion

polkadotRuntimeFilepath, err := runtime.GetRuntime(context.Background(), runtime.POLKADOT_RUNTIME)
polkadotRuntimeFilepath, err := runtime.GetRuntime(context.Background(), runtime.POLKADOT_RUNTIME_v0929)
require.NoError(t, err)
code, err := os.ReadFile(polkadotRuntimeFilepath)
require.NoError(t, err)
Expand All @@ -327,22 +327,26 @@ func TestRuntimeChannelListener_Listen(t *testing.T) {
SpecName: "polkadot",
ImplName: "parity-polkadot",
AuthoringVersion: 0,
SpecVersion: 25,
SpecVersion: 9290,
ImplVersion: 0,
TransactionVersion: 5,
TransactionVersion: 14,
Apis: []interface{}{
[]interface{}{"0xdf6acb689907609b", uint32(0x3)},
[]interface{}{"0xdf6acb689907609b", uint32(0x4)},
[]interface{}{"0x37e397fc7c91f5e4", uint32(0x1)},
[]interface{}{"0x40fe3ad401f8959a", uint32(0x4)},
[]interface{}{"0xd2bc9897eed08f15", uint32(0x2)},
[]interface{}{"0x40fe3ad401f8959a", uint32(0x6)},
[]interface{}{"0x17a6bc0d0062aeb3", uint32(0x1)},
[]interface{}{"0xd2bc9897eed08f15", uint32(0x3)},
[]interface{}{"0xf78b278be53f454c", uint32(0x2)},
[]interface{}{"0xaf2c0297a23e6d3d", uint32(0x1)},
[]interface{}{"0xed99c5acb25eedf5", uint32(0x2)},
[]interface{}{"0xaf2c0297a23e6d3d", uint32(0x2)},
[]interface{}{"0x49eaaf1b548a0cb0", uint32(0x1)},
[]interface{}{"0x91d5df18b0d2cf58", uint32(0x1)},
[]interface{}{"0xed99c5acb25eedf5", uint32(0x3)},
[]interface{}{"0xcbca25e39f142387", uint32(0x2)},
[]interface{}{"0x687ad44ad37f03c2", uint32(0x1)},
[]interface{}{"0xab3c0572291feb8b", uint32(0x1)},
[]interface{}{"0xbc9d89904f5b923f", uint32(0x1)},
[]interface{}{"0x37c8bb1350a9a2a8", uint32(0x1)},
[]interface{}{"0xf3ff14d5ab527059", uint32(0x1)},
},
}

Expand Down
5 changes: 0 additions & 5 deletions lib/runtime/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ const (
NODE_RUNTIME_FP_v098 = "node_runtime-v0.9.8.compact.wasm"
NODE_RUNTIME_URL_v098 = "https://github.com/noot/substrate/blob/noot/v0.9.8/target/debug/wbuild/node-runtime/node_runtime.compact.wasm?raw=true" //nolint:lll

// v0.8 polkadot runtime
POLKADOT_RUNTIME = "polkadot_runtime"
POLKADOT_RUNTIME_FP = "polkadot_runtime.compact.wasm"
POLKADOT_RUNTIME_URL = "https://github.com/noot/polkadot/blob/noot/v0.8.25/polkadot_runtime.wasm?raw=true"

// v0.9 test API wasm
HOST_API_TEST_RUNTIME = "hostapi_runtime"
HOST_API_TEST_RUNTIME_FP = "hostapi_runtime.compact.wasm"
Expand Down
3 changes: 0 additions & 3 deletions lib/runtime/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ func GetRuntime(ctx context.Context, runtime string) (
case NODE_RUNTIME_v098:
runtimeFilename = NODE_RUNTIME_FP_v098
url = NODE_RUNTIME_URL_v098
case POLKADOT_RUNTIME:
runtimeFilename = POLKADOT_RUNTIME_FP
url = POLKADOT_RUNTIME_URL
case HOST_API_TEST_RUNTIME:
runtimeFilename = HOST_API_TEST_RUNTIME_FP
url = HOST_API_TEST_RUNTIME_URL
Expand Down
30 changes: 17 additions & 13 deletions lib/runtime/wasmer/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,35 @@ func Test_Instance_Version(t *testing.T) {
},
},
},
"polkadot_v0825": {
"polkadot_v0929": {
instanceBuilder: func(t *testing.T) instanceVersioner {
return NewTestInstance(t, runtime.POLKADOT_RUNTIME)
return NewTestInstance(t, runtime.POLKADOT_RUNTIME_v0929)
},
expectedVersion: runtime.Version{
SpecName: []byte("polkadot"),
ImplName: []byte("parity-polkadot"),
AuthoringVersion: 0,
SpecVersion: 25,
SpecVersion: 9290,
ImplVersion: 0,
APIItems: []runtime.APIItem{
{Name: [8]uint8{0xdf, 0x6a, 0xcb, 0x68, 0x99, 0x7, 0x60, 0x9b}, Ver: 0x3},
{Name: [8]uint8{0xdf, 0x6a, 0xcb, 0x68, 0x99, 0x7, 0x60, 0x9b}, Ver: 0x4},
{Name: [8]uint8{0x37, 0xe3, 0x97, 0xfc, 0x7c, 0x91, 0xf5, 0xe4}, Ver: 0x1},
{Name: [8]uint8{0x40, 0xfe, 0x3a, 0xd4, 0x1, 0xf8, 0x95, 0x9a}, Ver: 0x4},
{Name: [8]uint8{0xd2, 0xbc, 0x98, 0x97, 0xee, 0xd0, 0x8f, 0x15}, Ver: 0x2},
{Name: [8]uint8{0x40, 0xfe, 0x3a, 0xd4, 0x1, 0xf8, 0x95, 0x9a}, Ver: 0x6},
{Name: [8]uint8{0x17, 0xa6, 0xbc, 0xd, 0x0, 0x62, 0xae, 0xb3}, Ver: 0x1},
{Name: [8]uint8{0xd2, 0xbc, 0x98, 0x97, 0xee, 0xd0, 0x8f, 0x15}, Ver: 0x3},
{Name: [8]uint8{0xf7, 0x8b, 0x27, 0x8b, 0xe5, 0x3f, 0x45, 0x4c}, Ver: 0x2},
{Name: [8]uint8{0xaf, 0x2c, 0x2, 0x97, 0xa2, 0x3e, 0x6d, 0x3d}, Ver: 0x1},
{Name: [8]uint8{0xed, 0x99, 0xc5, 0xac, 0xb2, 0x5e, 0xed, 0xf5}, Ver: 0x2},
{Name: [8]uint8{0xaf, 0x2c, 0x2, 0x97, 0xa2, 0x3e, 0x6d, 0x3d}, Ver: 0x2},
{Name: [8]uint8{0x49, 0xea, 0xaf, 0x1b, 0x54, 0x8a, 0xc, 0xb0}, Ver: 0x1},
{Name: [8]uint8{0x91, 0xd5, 0xdf, 0x18, 0xb0, 0xd2, 0xcf, 0x58}, Ver: 0x1},
{Name: [8]uint8{0xed, 0x99, 0xc5, 0xac, 0xb2, 0x5e, 0xed, 0xf5}, Ver: 0x3},
{Name: [8]uint8{0xcb, 0xca, 0x25, 0xe3, 0x9f, 0x14, 0x23, 0x87}, Ver: 0x2},
{Name: [8]uint8{0x68, 0x7a, 0xd4, 0x4a, 0xd3, 0x7f, 0x3, 0xc2}, Ver: 0x1},
{Name: [8]uint8{0xab, 0x3c, 0x5, 0x72, 0x29, 0x1f, 0xeb, 0x8b}, Ver: 0x1},
{Name: [8]uint8{0xbc, 0x9d, 0x89, 0x90, 0x4f, 0x5b, 0x92, 0x3f}, Ver: 0x1},
{Name: [8]uint8{0x37, 0xc8, 0xbb, 0x13, 0x50, 0xa9, 0xa2, 0xa8}, Ver: 0x1},
{Name: [8]uint8{0xf3, 0xff, 0x14, 0xd5, 0xab, 0x52, 0x70, 0x59}, Ver: 0x1},
},
TransactionVersion: 5,
TransactionVersion: 14,
},
},
"runtime_v0980": {
Expand Down Expand Up @@ -344,7 +348,7 @@ func TestInstance_BabeGenerateKeyOwnershipProof(t *testing.T) {
}{
{
name: "with_polkadot_runtime",
targetRuntime: runtime.POLKADOT_RUNTIME,
targetRuntime: runtime.POLKADOT_RUNTIME_v0929,
},
{
name: "with_westend_runtime",
Expand Down Expand Up @@ -394,7 +398,7 @@ func TestInstance_BabeSubmitReportEquivocationUnsignedExtrinsic(t *testing.T) {
}{
{
name: "with_polkadot_runtime",
targetRuntime: runtime.POLKADOT_RUNTIME,
targetRuntime: runtime.POLKADOT_RUNTIME_v0929,
},
{
name: "with_westend_runtime",
Expand Down Expand Up @@ -512,7 +516,7 @@ func TestInstance_InitializeBlock_NodeRuntime(t *testing.T) {
}

func TestInstance_InitializeBlock_PolkadotRuntime(t *testing.T) {
rt := NewTestInstance(t, runtime.POLKADOT_RUNTIME)
rt := NewTestInstance(t, runtime.POLKADOT_RUNTIME_v0929)

header := &types.Header{
Number: 1,
Expand Down Expand Up @@ -580,7 +584,7 @@ func TestInstance_ApplyExtrinsic_WestendRuntime(t *testing.T) {
func TestInstance_ExecuteBlock_PolkadotRuntime(t *testing.T) {
DefaultTestLogLvl = 0

instance := NewTestInstance(t, runtime.POLKADOT_RUNTIME)
instance := NewTestInstance(t, runtime.POLKADOT_RUNTIME_v0929)

block := runtime.InitializeRuntimeToTest(t, instance, &types.Header{})

Expand Down
22 changes: 13 additions & 9 deletions lib/runtime/wasmer/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestConcurrentRuntimeCalls(t *testing.T) {

func Test_GetRuntimeVersion(t *testing.T) {
polkadotRuntimeFilepath, err := runtime.GetRuntime(
context.Background(), runtime.POLKADOT_RUNTIME)
context.Background(), runtime.POLKADOT_RUNTIME_v0929)
require.NoError(t, err)
code, err := os.ReadFile(polkadotRuntimeFilepath)
require.NoError(t, err)
Expand All @@ -40,31 +40,35 @@ func Test_GetRuntimeVersion(t *testing.T) {
SpecName: []byte("polkadot"),
ImplName: []byte("parity-polkadot"),
AuthoringVersion: 0,
SpecVersion: 25,
SpecVersion: 9290,
ImplVersion: 0,
APIItems: []runtime.APIItem{
{Name: [8]uint8{0xdf, 0x6a, 0xcb, 0x68, 0x99, 0x7, 0x60, 0x9b}, Ver: 0x3},
{Name: [8]uint8{0xdf, 0x6a, 0xcb, 0x68, 0x99, 0x7, 0x60, 0x9b}, Ver: 0x4},
{Name: [8]uint8{0x37, 0xe3, 0x97, 0xfc, 0x7c, 0x91, 0xf5, 0xe4}, Ver: 0x1},
{Name: [8]uint8{0x40, 0xfe, 0x3a, 0xd4, 0x1, 0xf8, 0x95, 0x9a}, Ver: 0x4},
{Name: [8]uint8{0xd2, 0xbc, 0x98, 0x97, 0xee, 0xd0, 0x8f, 0x15}, Ver: 0x2},
{Name: [8]uint8{0x40, 0xfe, 0x3a, 0xd4, 0x1, 0xf8, 0x95, 0x9a}, Ver: 0x6},
{Name: [8]uint8{0x17, 0xa6, 0xbc, 0xd, 0x0, 0x62, 0xae, 0xb3}, Ver: 0x1},
{Name: [8]uint8{0xd2, 0xbc, 0x98, 0x97, 0xee, 0xd0, 0x8f, 0x15}, Ver: 0x3},
{Name: [8]uint8{0xf7, 0x8b, 0x27, 0x8b, 0xe5, 0x3f, 0x45, 0x4c}, Ver: 0x2},
{Name: [8]uint8{0xaf, 0x2c, 0x2, 0x97, 0xa2, 0x3e, 0x6d, 0x3d}, Ver: 0x1},
{Name: [8]uint8{0xed, 0x99, 0xc5, 0xac, 0xb2, 0x5e, 0xed, 0xf5}, Ver: 0x2},
{Name: [8]uint8{0xaf, 0x2c, 0x2, 0x97, 0xa2, 0x3e, 0x6d, 0x3d}, Ver: 0x2},
{Name: [8]uint8{0x49, 0xea, 0xaf, 0x1b, 0x54, 0x8a, 0xc, 0xb0}, Ver: 0x1},
{Name: [8]uint8{0x91, 0xd5, 0xdf, 0x18, 0xb0, 0xd2, 0xcf, 0x58}, Ver: 0x1},
{Name: [8]uint8{0xed, 0x99, 0xc5, 0xac, 0xb2, 0x5e, 0xed, 0xf5}, Ver: 0x3},
{Name: [8]uint8{0xcb, 0xca, 0x25, 0xe3, 0x9f, 0x14, 0x23, 0x87}, Ver: 0x2},
{Name: [8]uint8{0x68, 0x7a, 0xd4, 0x4a, 0xd3, 0x7f, 0x3, 0xc2}, Ver: 0x1},
{Name: [8]uint8{0xab, 0x3c, 0x5, 0x72, 0x29, 0x1f, 0xeb, 0x8b}, Ver: 0x1},
{Name: [8]uint8{0xbc, 0x9d, 0x89, 0x90, 0x4f, 0x5b, 0x92, 0x3f}, Ver: 0x1},
{Name: [8]uint8{0x37, 0xc8, 0xbb, 0x13, 0x50, 0xa9, 0xa2, 0xa8}, Ver: 0x1},
{Name: [8]uint8{0xf3, 0xff, 0x14, 0xd5, 0xab, 0x52, 0x70, 0x59}, Ver: 0x1},
},
TransactionVersion: 5,
TransactionVersion: 14,
}

require.Equal(t, expected, version)
}

func Benchmark_GetRuntimeVersion(b *testing.B) {
polkadotRuntimeFilepath, err := runtime.GetRuntime(
context.Background(), runtime.POLKADOT_RUNTIME)
context.Background(), runtime.POLKADOT_RUNTIME_v0929)
require.NoError(b, err)

b.ResetTimer()
Expand Down

0 comments on commit 28b78b9

Please sign in to comment.