Skip to content

Commit

Permalink
refactor(runtimes): remove deprecated nodes runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
dimartiro committed Mar 28, 2023
1 parent e028a1b commit 26a03ca
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 126 deletions.
2 changes: 1 addition & 1 deletion cmd/gossamer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ func TestGlobalNodeName_WhenNodeAlreadyHasStoredName(t *testing.T) {
cfg := newTestConfig(t, westendDevConfig)
cfg.Global.Name = globalName

runtimeFilePath, err := runtime.GetRuntime(context.Background(), runtime.NODE_RUNTIME)
runtimeFilePath, err := runtime.GetRuntime(context.Background(), runtime.WESTEND_RUNTIME_v0929)
require.NoError(t, err)
runtimeData, err := os.ReadFile(runtimeFilePath)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion dot/core/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func TestHandleChainReorg_WithReorg_Transactions(t *testing.T) {
t.Skip() // need to update this test to use a valid transaction

cfg := &Config{
Runtime: wasmer.NewTestInstance(t, runtime.NODE_RUNTIME),
Runtime: wasmer.NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929),
}

s := NewTestService(t, cfg)
Expand Down
2 changes: 1 addition & 1 deletion dot/node_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func TestNode_PersistGlobalName_WhenInitialize(t *testing.T) {
// newTestGenesisAndRuntime create a new test runtime and a new test genesis
// file with the test runtime stored in raw data and returns the genesis file
func newTestGenesisAndRuntime(t *testing.T) (filename string) {
runtimeFilePath, err := runtime.GetRuntime(context.Background(), runtime.NODE_RUNTIME)
runtimeFilePath, err := runtime.GetRuntime(context.Background(), runtime.WESTEND_RUNTIME_v0929)
require.NoError(t, err)
runtimeData, err := os.ReadFile(runtimeFilePath)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion dot/rpc/modules/dev_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func newBABEService(t *testing.T) *babe.Service {

bs, es := newState(t)
tt := trie.NewEmptyTrie()
rt := wasmer.NewTestInstanceWithTrie(t, runtime.NODE_RUNTIME, tt)
rt := wasmer.NewTestInstanceWithTrie(t, runtime.WESTEND_RUNTIME_v0929, tt)
bs.StoreRuntime(bs.GenesisHash(), rt)
tt.Put(
common.MustHexToBytes("0x886726f904d8372fdabb7707870c2fad"),
Expand Down
2 changes: 1 addition & 1 deletion dot/rpc/modules/system_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ func setupSystemModule(t *testing.T) *SystemModule {
func newCoreService(t *testing.T, srvc *state.Service) *core.Service {
// setup service
tt := trie.NewEmptyTrie()
rt := wasmer.NewTestInstanceWithTrie(t, runtime.NODE_RUNTIME, tt)
rt := wasmer.NewTestInstanceWithTrie(t, runtime.WESTEND_RUNTIME_v0929, tt)
ks := keystore.NewGlobalKeystore()
t.Cleanup(func() {
rt.Stop()
Expand Down
10 changes: 0 additions & 10 deletions lib/runtime/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ package runtime

//nolint:revive
const (
// v0.9 substrate runtime
NODE_RUNTIME = "node_runtime"
NODE_RUNTIME_FP = "node_runtime.compact.wasm"
NODE_RUNTIME_URL = "https://github.com/noot/substrate/blob/noot/v0.9/target/debug/wbuild/node-runtime/node_runtime.compact.wasm?raw=true" //nolint:lll

// v0.9.8 substrate runtime
NODE_RUNTIME_v098 = "node_runtime-v0.9.8"
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.9.10 polkadot runtime
POLKADOT_RUNTIME_v0910 = "polkadot_runtime-v9100"
POLKADOT_RUNTIME_FP_v0910 = "polkadot_runtime-v9100.compact.wasm"
Expand Down
6 changes: 0 additions & 6 deletions lib/runtime/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ func GetRuntime(ctx context.Context, runtime string) (

var runtimeFilename, url string
switch runtime {
case NODE_RUNTIME:
runtimeFilename = NODE_RUNTIME_FP
url = NODE_RUNTIME_URL
case NODE_RUNTIME_v098:
runtimeFilename = NODE_RUNTIME_FP_v098
url = NODE_RUNTIME_URL_v098
case POLKADOT_RUNTIME_v0925:
runtimeFilename = POLKADOT_RUNTIME_FP_v0925
url = POLKADOT_RUNTIME_URL_v0925
Expand Down
125 changes: 21 additions & 104 deletions lib/runtime/wasmer/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,62 +70,6 @@ func Test_Instance_Version(t *testing.T) {
TransactionVersion: 1,
},
},
"node_v098": {
instanceBuilder: func(t *testing.T) instanceVersioner {
return NewTestInstance(t, runtime.NODE_RUNTIME_v098)
},
expectedVersion: runtime.Version{
SpecName: []byte("node"),
ImplName: []byte("substrate-node"),
AuthoringVersion: 10,
SpecVersion: 267,
ImplVersion: 0,
APIItems: []runtime.APIItem{
{Name: [8]uint8{0xdf, 0x6a, 0xcb, 0x68, 0x99, 0x7, 0x60, 0x9b}, Ver: 0x3},
{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: 0x5},
{Name: [8]uint8{0xd2, 0xbc, 0x98, 0x97, 0xee, 0xd0, 0x8f, 0x15}, Ver: 0x2},
{Name: [8]uint8{0xf7, 0x8b, 0x27, 0x8b, 0xe5, 0x3f, 0x45, 0x4c}, Ver: 0x2},
{Name: [8]uint8{0xed, 0x99, 0xc5, 0xac, 0xb2, 0x5e, 0xed, 0xf5}, Ver: 0x2},
{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{0xbc, 0x9d, 0x89, 0x90, 0x4f, 0x5b, 0x92, 0x3f}, Ver: 0x1},
{Name: [8]uint8{0x68, 0xb6, 0x6b, 0xa1, 0x22, 0xc9, 0x3f, 0xa7}, Ver: 0x1},
{Name: [8]uint8{0x37, 0xc8, 0xbb, 0x13, 0x50, 0xa9, 0xa2, 0xa8}, Ver: 0x1},
{Name: [8]uint8{0x91, 0xd5, 0xdf, 0x18, 0xb0, 0xd2, 0xcf, 0x58}, Ver: 0x1},
{Name: [8]uint8{0xab, 0x3c, 0x5, 0x72, 0x29, 0x1f, 0xeb, 0x8b}, Ver: 0x1},
},
TransactionVersion: 2,
},
},
"node": {
instanceBuilder: func(t *testing.T) instanceVersioner {
return NewTestInstance(t, runtime.NODE_RUNTIME)
},
expectedVersion: runtime.Version{
SpecName: []byte("node"),
ImplName: []byte("substrate-node"),
AuthoringVersion: 10,
SpecVersion: 264,
ImplVersion: 0,
APIItems: []runtime.APIItem{
{Name: [8]uint8{0xdf, 0x6a, 0xcb, 0x68, 0x99, 0x7, 0x60, 0x9b}, Ver: 0x3},
{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{0xf7, 0x8b, 0x27, 0x8b, 0xe5, 0x3f, 0x45, 0x4c}, Ver: 0x2},
{Name: [8]uint8{0xed, 0x99, 0xc5, 0xac, 0xb2, 0x5e, 0xed, 0xf5}, Ver: 0x2},
{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{0xbc, 0x9d, 0x89, 0x90, 0x4f, 0x5b, 0x92, 0x3f}, Ver: 0x1},
{Name: [8]uint8{0x68, 0xb6, 0x6b, 0xa1, 0x22, 0xc9, 0x3f, 0xa7}, Ver: 0x1},
{Name: [8]uint8{0x37, 0xc8, 0xbb, 0x13, 0x50, 0xa9, 0xa2, 0xa8}, Ver: 0x1},
{Name: [8]uint8{0x91, 0xd5, 0xdf, 0x18, 0xb0, 0xd2, 0xcf, 0x58}, Ver: 0x1},
{Name: [8]uint8{0xab, 0x3c, 0x5, 0x72, 0x29, 0x1f, 0xeb, 0x8b}, Ver: 0x1},
},
TransactionVersion: 2,
},
},
"kusama": {
instanceBuilder: func(t *testing.T) instanceVersioner {
genesisPath := utils.GetKusamaGenesisPath(t)
Expand Down Expand Up @@ -220,34 +164,6 @@ func Test_Instance_Version(t *testing.T) {
TransactionVersion: 8,
},
},
"runtime_v0980": {
instanceBuilder: func(t *testing.T) instanceVersioner {
return NewTestInstance(t, runtime.NODE_RUNTIME_v098)
},
expectedVersion: runtime.Version{
SpecName: []byte("node"),
ImplName: []byte("substrate-node"),
AuthoringVersion: 10,
SpecVersion: 267,
ImplVersion: 0,
APIItems: []runtime.APIItem{
{Name: [8]uint8{0xdf, 0x6a, 0xcb, 0x68, 0x99, 0x7, 0x60, 0x9b}, Ver: 0x3},
{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: 0x5},
{Name: [8]uint8{0xd2, 0xbc, 0x98, 0x97, 0xee, 0xd0, 0x8f, 0x15}, Ver: 0x2},
{Name: [8]uint8{0xf7, 0x8b, 0x27, 0x8b, 0xe5, 0x3f, 0x45, 0x4c}, Ver: 0x2},
{Name: [8]uint8{0xed, 0x99, 0xc5, 0xac, 0xb2, 0x5e, 0xed, 0xf5}, Ver: 0x2},
{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{0xbc, 0x9d, 0x89, 0x90, 0x4f, 0x5b, 0x92, 0x3f}, Ver: 0x1},
{Name: [8]uint8{0x68, 0xb6, 0x6b, 0xa1, 0x22, 0xc9, 0x3f, 0xa7}, Ver: 0x1},
{Name: [8]uint8{0x37, 0xc8, 0xbb, 0x13, 0x50, 0xa9, 0xa2, 0xa8}, Ver: 0x1},
{Name: [8]uint8{0x91, 0xd5, 0xdf, 0x18, 0xb0, 0xd2, 0xcf, 0x58}, Ver: 0x1},
{Name: [8]uint8{0xab, 0x3c, 0x5, 0x72, 0x29, 0x1f, 0xeb, 0x8b}, Ver: 0x1},
},
TransactionVersion: 2,
},
},
"polkadot_v0917": {
instanceBuilder: func(t *testing.T) instanceVersioner {
return NewTestInstance(t, runtime.POLKADOT_RUNTIME_v0917)
Expand Down Expand Up @@ -373,7 +289,7 @@ func TestInstance_GrandpaAuthorities_NodeRuntime(t *testing.T) {
key := common.MustHexToBytes(genesis.GrandpaAuthoritiesKeyHex)
tt.Put(key, value)

rt := NewTestInstanceWithTrie(t, runtime.NODE_RUNTIME, tt)
rt := NewTestInstanceWithTrie(t, runtime.WESTEND_RUNTIME_v0929, tt)

auths, err := rt.GrandpaAuthorities()
require.NoError(t, err)
Expand Down Expand Up @@ -509,19 +425,19 @@ func TestInstance_BabeSubmitReportEquivocationUnsignedExtrinsic(t *testing.T) {
}
}

func TestInstance_BabeConfiguration_NodeRuntime_NoAuthorities(t *testing.T) {
rt := NewTestInstance(t, runtime.NODE_RUNTIME)
func TestInstance_BabeConfiguration_WestendRuntime_NoAuthorities(t *testing.T) {
rt := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)
cfg, err := rt.BabeConfiguration()
require.NoError(t, err)

expected := &types.BabeConfiguration{
SlotDuration: 3000,
EpochLength: 200,
SlotDuration: 6000,
EpochLength: 600,
C1: 1,
C2: 2,
C2: 4,
GenesisAuthorities: nil,
Randomness: [32]byte{},
SecondarySlots: 1,
SecondarySlots: 2,
}
require.Equal(t, expected, cfg)
}
Expand All @@ -544,7 +460,7 @@ func TestInstance_BabeConfiguration_DevRuntime_NoAuthorities(t *testing.T) {
require.Equal(t, expected, cfg)
}

func TestInstance_BabeConfiguration_NodeRuntime_WithAuthorities(t *testing.T) {
func TestInstance_BabeConfiguration_WestendRuntime_WithAuthorities(t *testing.T) {
tt := trie.NewEmptyTrie()

randomnessValue, err := common.HexToHash("0x01")
Expand All @@ -558,7 +474,7 @@ func TestInstance_BabeConfiguration_NodeRuntime_WithAuthorities(t *testing.T) {
key = common.MustHexToBytes(genesis.BABEAuthoritiesKeyHex)
tt.Put(key, authorityValue)

rt := NewTestInstanceWithTrie(t, runtime.NODE_RUNTIME, tt)
rt := NewTestInstanceWithTrie(t, runtime.WESTEND_RUNTIME_v0929, tt)

cfg, err := rt.BabeConfiguration()
require.NoError(t, err)
Expand All @@ -572,20 +488,20 @@ func TestInstance_BabeConfiguration_NodeRuntime_WithAuthorities(t *testing.T) {
}

expected := &types.BabeConfiguration{
SlotDuration: 3000,
EpochLength: 200,
SlotDuration: 6000,
EpochLength: 600,
C1: 1,
C2: 2,
C2: 4,
GenesisAuthorities: expectedAuthData,
Randomness: [32]byte{1},
SecondarySlots: 1,
SecondarySlots: 2,
}

require.Equal(t, expected, cfg)
}

func TestInstance_InitializeBlock_NodeRuntime(t *testing.T) {
rt := NewTestInstance(t, runtime.NODE_RUNTIME)
rt := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)

header := &types.Header{
Number: 1,
Expand Down Expand Up @@ -1052,14 +968,14 @@ func TestInstance_ExecuteBlock_PolkadotBlock1089328(t *testing.T) {
}

func TestInstance_DecodeSessionKeys(t *testing.T) {
keys := "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d34309a9d2a24213896ff06895db16aade8b6502f3a71cf56374cc3852042602634309a9d2a24213896ff06895db16aade8b6502f3a71cf56374cc3852042602634309a9d2a24213896ff06895db16aade8b6502f3a71cf56374cc38520426026" //nolint:lll
keys := "0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d34309a9d2a24213896ff06895db16aade8b6502f3a71cf56374cc3852042602634309a9d2a24213896ff06895db16aade8b6502f3a71cf56374cc3852042602634309a9d2a24213896ff06895db16aade8b6502f3a71cf56374cc3852042602634309a9d2a24213896ff06895db16aade8b6502f3a71cf56374cc3852042602634309a9d2a24213896ff06895db16aade8b6502f3a71cf56374cc38520426026" //nolint:lll
pubkeys, err := common.HexToBytes(keys)
require.NoError(t, err)

pukeysBytes, err := scale.Marshal(pubkeys)
require.NoError(t, err)

instance := NewTestInstance(t, runtime.NODE_RUNTIME_v098)
instance := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)
decoded, err := instance.DecodeSessionKeys(pukeysBytes)
require.NoError(t, err)

Expand All @@ -1071,7 +987,8 @@ func TestInstance_DecodeSessionKeys(t *testing.T) {
err = scale.Unmarshal(decoded, &decodedKeys)
require.NoError(t, err)

require.Len(t, *decodedKeys, 4)
require.NotNil(t, decodedKeys)
require.Len(t, *decodedKeys, 6)
}

func TestInstance_PaymentQueryInfo(t *testing.T) {
Expand All @@ -1085,11 +1002,11 @@ func TestInstance_PaymentQueryInfo(t *testing.T) {
// Was made with @polkadot/api on https://github.com/danforbes/polkadot-js-scripts/tree/create-signed-tx
ext: "0xd1018400d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01bc2b6e35929aabd5b8bc4e5b0168c9bee59e2bb9d6098769f6683ecf73e44c776652d947a270d59f3d37eb9f9c8c17ec1b4cc473f2f9928ffdeef0f3abd43e85d502000000012844616e20466f72626573", //nolint:lll
expect: &types.RuntimeDispatchInfo{
Weight: 1973000,
Weight: 0,
Class: 0,
PartialFee: &scale.Uint128{
Upper: 0,
Lower: uint64(1180126973000),
Lower: uint64(12800000000),
},
},
},
Expand Down Expand Up @@ -1118,7 +1035,7 @@ func TestInstance_PaymentQueryInfo(t *testing.T) {
require.NoError(t, err)
}

ins := NewTestInstance(t, runtime.NODE_RUNTIME)
ins := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)
info, err := ins.PaymentQueryInfo(extBytes)

if test.errMessage != "" {
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime/wasmer/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

// test used for ensuring runtime exec calls can me made concurrently
func TestConcurrentRuntimeCalls(t *testing.T) {
instance := NewTestInstance(t, runtime.NODE_RUNTIME)
instance := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929)

// execute 2 concurrent calls to the runtime
go func() {
Expand Down

0 comments on commit 26a03ca

Please sign in to comment.