diff --git a/dot/core/service_test.go b/dot/core/service_test.go index 49fd1252d79..965aa6a5d70 100644 --- a/dot/core/service_test.go +++ b/dot/core/service_test.go @@ -289,6 +289,7 @@ func TestHandleChainReorg_WithReorg_Transactions(t *testing.T) { // create extrinsic enc, err := scale.Marshal([]byte("nootwashere")) require.NoError(t, err) + // we prefix with []byte{2} here since that's the enum index for the old IncludeDataExt extrinsic tx := append([]byte{2}, enc...) bhash := s.blockState.BestBlockHash() diff --git a/lib/runtime/life/exports.go b/lib/runtime/life/exports.go index e7382c674e2..a25475853b8 100644 --- a/lib/runtime/life/exports.go +++ b/lib/runtime/life/exports.go @@ -37,12 +37,13 @@ func (in *Instance) Version() (runtime.Version, error) { version := &runtime.VersionData{} err = version.Decode(res) // error comes from scale now, so do a string check - if strings.Contains(fmt.Sprintf("%s", err), "EOF") { - // TODO: kusama seems to use the legacy version format - lversion := &runtime.LegacyVersionData{} - err = lversion.Decode(res) - return lversion, err - } else if err != nil { + if err != nil { + if strings.Contains(err.Error(), "EOF") { + // TODO: kusama seems to use the legacy version format + lversion := &runtime.LegacyVersionData{} + err = lversion.Decode(res) + return lversion, err + } return nil, err } diff --git a/lib/runtime/life/exports_test.go b/lib/runtime/life/exports_test.go index 3604d9bfa76..88a9dcb6281 100644 --- a/lib/runtime/life/exports_test.go +++ b/lib/runtime/life/exports_test.go @@ -237,11 +237,7 @@ func TestInstance_ExecuteBlock_KusamaRuntime_KusamaBlock1(t *testing.T) { // block data is received from querying a polkadot node body := []byte{8, 40, 4, 2, 0, 11, 144, 17, 14, 179, 110, 1, 16, 4, 20, 0, 0} var exts [][]byte -<<<<<<< HEAD - err = scale2.Unmarshal(body, &exts) -======= err = scale.Unmarshal(body, &exts) ->>>>>>> d2357261 (lib/runtime/life updates) require.NoError(t, err) require.Equal(t, 2, len(exts)) @@ -291,11 +287,7 @@ func TestInstance_ExecuteBlock_PolkadotRuntime_PolkadotBlock1(t *testing.T) { // block data is received from querying a polkadot node body := []byte{8, 40, 4, 3, 0, 11, 80, 149, 160, 81, 114, 1, 16, 4, 20, 0, 0} var exts [][]byte -<<<<<<< HEAD - err = scale2.Unmarshal(body, &exts) -======= err = scale.Unmarshal(body, &exts) ->>>>>>> d2357261 (lib/runtime/life updates) require.NoError(t, err) require.Equal(t, 2, len(exts)) diff --git a/lib/runtime/life/resolver.go b/lib/runtime/life/resolver.go index 0700430ca65..2bf0e709480 100644 --- a/lib/runtime/life/resolver.go +++ b/lib/runtime/life/resolver.go @@ -431,8 +431,13 @@ func storageAppend(storage runtime.Storage, key, valueToAppend []byte) error { return nil } - // append new item, pop off first byte now, since we're not using old scale.Decoder - valueRes = append(valueCurr[1:], valueToAppend...) + lengthBytes, err := scale.Marshal(currLength) + if err != nil { + return err + } + // append new item, pop off number of bytes required for length encoding, + // since we're not using old scale.Decoder + valueRes = append(valueCurr[len(lengthBytes):], valueToAppend...) // increase length by 1 nextLength = big.NewInt(0).Add(currLength, big.NewInt(1)) diff --git a/lib/runtime/wasmer/exports.go b/lib/runtime/wasmer/exports.go index d689303e0a1..6e4ed7e5266 100644 --- a/lib/runtime/wasmer/exports.go +++ b/lib/runtime/wasmer/exports.go @@ -58,12 +58,13 @@ func (in *Instance) Version() (runtime.Version, error) { version := &runtime.VersionData{} err = version.Decode(res) // error comes from scale now, so do a string check - if strings.Contains(fmt.Sprintf("%s", err), "EOF") { - // TODO: kusama seems to use the legacy version format - lversion := &runtime.LegacyVersionData{} - err = lversion.Decode(res) - return lversion, err - } else if err != nil { + if err != nil { + if strings.Contains(err.Error(), "EOF") { + // TODO: kusama seems to use the legacy version format + lversion := &runtime.LegacyVersionData{} + err = lversion.Decode(res) + return lversion, err + } return nil, err } diff --git a/lib/runtime/wasmer/imports.go b/lib/runtime/wasmer/imports.go index dafcbc2a545..2bfed970265 100644 --- a/lib/runtime/wasmer/imports.go +++ b/lib/runtime/wasmer/imports.go @@ -1569,8 +1569,13 @@ func storageAppend(storage runtime.Storage, key, valueToAppend []byte) error { return nil } - // append new item, pop off first byte now, since we're not using old scale.Decoder - valueRes = append(valueCurr[1:], valueToAppend...) + lengthBytes, err := scale.Marshal(currLength) + if err != nil { + return err + } + // append new item, pop off number of bytes required for length encoding, + // since we're not using old scale.Decoder + valueRes = append(valueCurr[len(lengthBytes):], valueToAppend...) // increase length by 1 nextLength = big.NewInt(0).Add(currLength, big.NewInt(1))