diff --git a/.gitattributes b/.gitattributes index 0c10a94057d..399d03cc5eb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ *.go -text diff=golang - lib/runtime/test_data/kusama/ filter=lfs diff=lfs merge=lfs -text lib/runtime/test_data/polkadot/ filter=lfs diff=lfs merge=lfs -text +lib/runtime/test_data/westend/block8077850.zip filter=lfs diff=lfs merge=lfs -text diff --git a/lib/runtime/test_data/westend/block8077850.zip b/lib/runtime/test_data/westend/block8077850.zip new file mode 100644 index 00000000000..3ff85db9147 --- /dev/null +++ b/lib/runtime/test_data/westend/block8077850.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3abf74e0f1078c5287ee5f7642e79771a629d892783f1772903f9b00252fb8db +size 161571390 diff --git a/lib/runtime/wazero/imports.go b/lib/runtime/wazero/imports.go index 9092e42ef1e..a206609b6b0 100644 --- a/lib/runtime/wazero/imports.go +++ b/lib/runtime/wazero/imports.go @@ -4,6 +4,7 @@ package wazero_runtime import ( + "bytes" "context" "crypto/rand" "encoding/binary" @@ -32,7 +33,8 @@ var ( log.AddContext("module", "wazero"), ) - noneEncoded []byte = []byte{0x00} + noneEncoded []byte = []byte{0x00} + allZeroesBytes = [32]byte{} ) const ( @@ -710,6 +712,18 @@ func ext_crypto_sr25519_verify_version_2(ctx context.Context, m api.Module, sig panic("nil runtime context") } + pubKeyBytes, ok := m.Memory().Read(key, 32) + if !ok { + panic("read overflow") + } + + // prevents Polkadot zero-address crash using + // ext_crypto_sr25519_verify_version_1 + // https://pacna.org/dot-zero-addr/ + if bytes.Equal(pubKeyBytes, allZeroesBytes[:]) { + return ext_crypto_sr25519_verify_version_1(ctx, m, sig, msg, key) + } + sigVerifier := rtCtx.SigVerifier message := read(m, msg) @@ -718,10 +732,6 @@ func ext_crypto_sr25519_verify_version_2(ctx context.Context, m api.Module, sig panic("read overflow") } - pubKeyBytes, ok := m.Memory().Read(key, 32) - if !ok { - panic("read overflow") - } pub, err := sr25519.NewPublicKey(pubKeyBytes) if err != nil { logger.Error("invalid sr25519 public key") diff --git a/lib/runtime/wazero/instance_test.go b/lib/runtime/wazero/instance_test.go index 204266e1c88..aef093e1eb5 100644 --- a/lib/runtime/wazero/instance_test.go +++ b/lib/runtime/wazero/instance_test.go @@ -4,13 +4,16 @@ package wazero_runtime import ( + "archive/zip" "bytes" "encoding/json" + "io" "math/big" "os" "path/filepath" "testing" + "github.com/ChainSafe/gossamer/dot/network" "github.com/ChainSafe/gossamer/dot/types" "github.com/ChainSafe/gossamer/internal/log" "github.com/ChainSafe/gossamer/lib/common" @@ -403,6 +406,79 @@ func TestInstance_BabeConfiguration_WestendRuntime_NoAuthorities(t *testing.T) { require.Equal(t, expected, cfg) } +func extractZippedState(t *testing.T, zippedFile, destPath string) { + r, err := zip.OpenReader(zippedFile) + require.NoError(t, err) + defer r.Close() + + for _, f := range r.File { + outFile, err := os.OpenFile(destPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()) + require.NoError(t, err) + + defer outFile.Close() + + rc, err := f.Open() + require.NoError(t, err) + defer rc.Close() + + _, err = io.Copy(outFile, rc) + require.NoError(t, err) + + // File extracted, no need to loop further + return + } +} + +func TestInstance_ExecuteBlock_WestendRuntime_WestendBlock8077850(t *testing.T) { + stateTrieFile := t.TempDir() + "block8077850.txt" + extractZippedState(t, "../test_data/westend/block8077850.zip", stateTrieFile) + + gossTrie8077850 := newTrieFromScaledPairs(t, stateTrieFile) + expectedRoot := common.MustHexToHash("0x731cea81940165128e1ffdfc5b4207e2ad84548377899b392dc497b1c166dc1f") + + require.Equal(t, expectedRoot, gossTrie8077850.MustHash()) + + // set state to genesis state + state8077850 := storage.NewTrieState(gossTrie8077850) + cfg := Config{ + Storage: state8077850, + LogLvl: log.Critical, + } + + instance, err := NewInstanceFromTrie(gossTrie8077850, cfg) + require.NoError(t, err) + + entireBlockData := []byte{10, 145, 25, 10, 32, 11, 146, 32, 18, 124, 216, 103, 54, 86, 76, 220, 10, 81, 63, 13, 190, 172, 49, 219, 250, 166, 49, 204, 47, 60, 218, 91, 89, 65, 181, 209, 63, 18, 160, 2, 175, 118, 225, 235, 187, 192, 11, 26, 115, 129, 172, 137, 84, 115, 109, 176, 65, 229, 57, 91, 74, 154, 86, 230, 224, 93, 51, 144, 254, 16, 23, 246, 106, 8, 237, 1, 111, 188, 129, 22, 65, 72, 127, 226, 37, 135, 40, 234, 64, 215, 232, 164, 70, 159, 220, 9, 183, 227, 249, 144, 40, 62, 11, 199, 211, 38, 18, 189, 86, 196, 133, 36, 243, 107, 42, 3, 255, 158, 204, 130, 202, 177, 128, 147, 36, 24, 26, 232, 5, 88, 174, 70, 249, 227, 47, 33, 96, 213, 45, 127, 8, 6, 66, 65, 66, 69, 181, 1, 3, 2, 0, 0, 0, 13, 89, 64, 16, 0, 0, 0, 0, 46, 55, 172, 197, 232, 47, 252, 200, 169, 85, 67, 49, 172, 84, 71, 147, 147, 43, 113, 218, 251, 229, 121, 96, 2, 143, 174, 52, 166, 55, 12, 39, 239, 51, 22, 241, 206, 221, 93, 193, 69, 172, 61, 24, 22, 181, 20, 76, 140, 220, 81, 163, 198, 168, 46, 159, 195, 241, 100, 239, 244, 167, 73, 14, 142, 146, 140, 196, 160, 240, 171, 238, 170, 252, 56, 153, 149, 203, 148, 192, 135, 235, 125, 78, 140, 122, 239, 179, 79, 106, 210, 178, 80, 92, 237, 9, 5, 66, 65, 66, 69, 1, 1, 194, 5, 155, 37, 93, 12, 210, 230, 125, 30, 8, 53, 22, 207, 48, 223, 175, 199, 105, 27, 105, 114, 63, 135, 226, 130, 184, 70, 200, 181, 214, 48, 180, 113, 0, 14, 143, 141, 161, 238, 41, 46, 173, 95, 46, 46, 61, 165, 158, 197, 211, 226, 30, 191, 212, 56, 163, 240, 165, 80, 127, 161, 134, 136, 26, 11, 40, 4, 2, 0, 11, 180, 32, 39, 228, 124, 1, 26, 167, 21, 149, 42, 4, 45, 0, 64, 20, 5, 0, 0, 0, 0, 244, 88, 24, 239, 152, 25, 113, 0, 202, 96, 54, 243, 229, 247, 176, 66, 54, 123, 87, 90, 125, 109, 80, 30, 57, 113, 87, 242, 22, 250, 90, 6, 167, 193, 169, 11, 30, 11, 190, 17, 141, 28, 248, 39, 240, 91, 86, 85, 2, 81, 111, 183, 225, 140, 44, 10, 47, 95, 69, 210, 203, 202, 238, 139, 20, 5, 1, 0, 0, 0, 0, 33, 98, 139, 168, 31, 87, 75, 117, 6, 26, 244, 22, 190, 139, 12, 223, 107, 73, 99, 202, 95, 235, 164, 6, 180, 253, 7, 44, 88, 187, 98, 248, 250, 89, 254, 185, 222, 8, 226, 64, 221, 210, 198, 106, 17, 143, 158, 72, 66, 115, 125, 206, 106, 137, 117, 185, 167, 144, 251, 177, 245, 23, 138, 20, 5, 2, 0, 0, 0, 106, 138, 122, 226, 15, 122, 32, 99, 29, 154, 68, 219, 203, 80, 3, 177, 55, 70, 26, 23, 69, 60, 160, 214, 40, 70, 220, 117, 23, 17, 167, 69, 117, 156, 221, 235, 69, 22, 186, 153, 251, 233, 92, 105, 173, 64, 70, 222, 204, 211, 40, 136, 243, 212, 16, 118, 167, 159, 112, 11, 20, 44, 122, 134, 20, 5, 3, 0, 0, 0, 22, 46, 74, 193, 129, 129, 103, 15, 220, 207, 207, 9, 49, 240, 87, 51, 188, 112, 50, 29, 138, 67, 129, 110, 21, 9, 239, 80, 66, 122, 79, 50, 50, 176, 137, 44, 115, 247, 28, 124, 152, 49, 112, 156, 203, 165, 190, 247, 98, 179, 183, 26, 215, 86, 18, 94, 96, 191, 107, 149, 127, 251, 249, 133, 20, 5, 4, 0, 0, 0, 234, 214, 58, 36, 153, 250, 15, 26, 201, 14, 175, 40, 78, 98, 208, 0, 152, 54, 234, 242, 212, 186, 71, 215, 229, 59, 99, 214, 184, 164, 146, 9, 198, 3, 196, 253, 199, 29, 102, 122, 33, 195, 221, 82, 184, 82, 216, 198, 49, 219, 204, 89, 102, 197, 214, 222, 244, 207, 175, 140, 138, 139, 113, 133, 20, 5, 5, 0, 0, 0, 246, 40, 137, 18, 82, 230, 239, 122, 106, 139, 113, 21, 148, 48, 107, 247, 141, 38, 202, 235, 11, 14, 64, 202, 89, 118, 255, 77, 110, 184, 186, 3, 151, 189, 29, 44, 79, 7, 215, 104, 72, 204, 166, 217, 68, 227, 237, 97, 101, 76, 247, 26, 66, 66, 151, 201, 148, 91, 20, 118, 89, 215, 35, 139, 20, 1, 6, 0, 0, 0, 124, 240, 172, 211, 154, 161, 82, 29, 142, 120, 115, 236, 105, 225, 183, 147, 177, 104, 133, 23, 161, 38, 206, 1, 164, 169, 72, 13, 90, 222, 22, 46, 194, 185, 223, 199, 92, 198, 90, 102, 161, 165, 152, 86, 45, 97, 215, 102, 179, 217, 186, 155, 79, 52, 51, 232, 166, 169, 53, 113, 209, 185, 83, 140, 20, 5, 7, 0, 0, 0, 202, 155, 108, 121, 156, 216, 29, 53, 87, 111, 239, 92, 110, 232, 116, 18, 182, 115, 207, 1, 67, 137, 42, 186, 152, 203, 49, 71, 245, 209, 253, 44, 2, 18, 217, 156, 207, 101, 215, 114, 128, 169, 154, 188, 0, 128, 50, 244, 238, 227, 249, 67, 170, 63, 89, 157, 118, 77, 249, 56, 79, 36, 46, 138, 20, 0, 8, 0, 0, 0, 114, 132, 25, 201, 23, 39, 240, 61, 106, 167, 216, 88, 188, 46, 140, 110, 157, 186, 145, 14, 68, 66, 252, 69, 6, 183, 48, 139, 202, 111, 46, 28, 105, 48, 207, 190, 62, 146, 189, 58, 251, 185, 233, 146, 109, 59, 202, 188, 120, 217, 255, 109, 60, 107, 39, 201, 14, 81, 117, 22, 125, 140, 203, 128, 20, 5, 9, 0, 0, 0, 16, 127, 40, 188, 209, 216, 6, 113, 201, 7, 111, 14, 153, 196, 187, 28, 112, 243, 51, 109, 72, 93, 6, 72, 164, 96, 205, 154, 24, 20, 2, 38, 93, 21, 183, 126, 64, 147, 142, 150, 178, 243, 221, 192, 246, 171, 66, 191, 214, 39, 0, 65, 234, 221, 78, 85, 115, 117, 28, 105, 251, 10, 117, 139, 20, 5, 10, 0, 0, 0, 146, 222, 162, 150, 12, 209, 251, 40, 120, 174, 41, 92, 211, 115, 212, 33, 75, 170, 38, 143, 49, 55, 71, 85, 103, 127, 108, 245, 106, 49, 108, 72, 46, 30, 118, 126, 71, 216, 151, 196, 24, 150, 151, 127, 110, 27, 199, 67, 81, 116, 159, 224, 196, 53, 7, 131, 82, 56, 80, 112, 179, 19, 248, 143, 20, 5, 11, 0, 0, 0, 76, 50, 55, 68, 158, 129, 149, 202, 202, 141, 202, 228, 63, 1, 49, 166, 145, 91, 144, 219, 144, 219, 30, 204, 30, 138, 142, 221, 57, 236, 130, 74, 197, 109, 236, 1, 175, 35, 85, 136, 14, 28, 228, 45, 168, 247, 253, 63, 237, 192, 217, 217, 185, 113, 212, 83, 153, 202, 157, 211, 231, 191, 53, 138, 20, 5, 12, 0, 0, 0, 126, 60, 184, 144, 83, 77, 88, 58, 66, 43, 70, 67, 197, 141, 160, 177, 160, 80, 12, 238, 51, 77, 198, 142, 16, 224, 102, 221, 235, 69, 16, 90, 146, 178, 43, 201, 66, 69, 9, 64, 220, 35, 13, 97, 90, 90, 104, 101, 135, 171, 100, 226, 239, 59, 108, 63, 253, 250, 219, 68, 3, 37, 25, 131, 20, 5, 13, 0, 0, 0, 182, 16, 222, 207, 85, 111, 10, 81, 184, 200, 168, 158, 126, 20, 127, 40, 158, 23, 118, 10, 132, 149, 251, 73, 102, 185, 236, 91, 196, 253, 44, 114, 240, 74, 249, 125, 71, 186, 252, 213, 211, 150, 109, 105, 91, 114, 252, 62, 82, 117, 128, 186, 244, 248, 144, 254, 50, 191, 23, 17, 36, 251, 64, 136, 20, 5, 14, 0, 0, 0, 182, 164, 224, 23, 213, 126, 28, 11, 100, 170, 208, 127, 147, 246, 215, 88, 61, 175, 133, 145, 84, 187, 194, 35, 143, 212, 72, 227, 178, 59, 175, 118, 9, 54, 147, 196, 235, 236, 192, 200, 232, 183, 154, 86, 193, 21, 129, 44, 247, 70, 55, 27, 2, 151, 149, 38, 113, 143, 88, 34, 29, 99, 79, 142, 20, 5, 15, 0, 0, 0, 62, 10, 132, 250, 119, 253, 166, 252, 100, 87, 78, 115, 178, 74, 102, 43, 82, 49, 23, 55, 224, 230, 226, 101, 79, 82, 44, 69, 181, 175, 171, 92, 17, 62, 158, 155, 130, 177, 224, 179, 134, 130, 222, 125, 189, 113, 205, 249, 250, 243, 248, 84, 193, 2, 32, 95, 98, 35, 76, 120, 152, 180, 215, 131, 8, 37, 8, 0, 0, 175, 118, 225, 235, 187, 192, 11, 26, 115, 129, 172, 137, 84, 115, 109, 176, 65, 229, 57, 91, 74, 154, 86, 230, 224, 93, 51, 144, 254, 16, 23, 246, 112, 58, 90, 78, 74, 0, 214, 52, 242, 221, 240, 126, 177, 243, 248, 250, 139, 82, 218, 226, 155, 163, 8, 105, 248, 182, 174, 168, 180, 104, 8, 97, 60, 115, 174, 249, 84, 132, 133, 51, 105, 238, 134, 0, 94, 24, 147, 107, 18, 126, 249, 116, 194, 88, 78, 93, 62, 98, 58, 157, 36, 87, 255, 10, 104, 29, 99, 148, 92, 152, 71, 37, 254, 168, 212, 111, 27, 213, 114, 227, 162, 229, 22, 245, 49, 115, 253, 90, 215, 191, 164, 98, 171, 221, 8, 174, 237, 29, 46, 129, 126, 171, 165, 86, 62, 242, 251, 254, 216, 246, 50, 97, 158, 218, 162, 137, 162, 156, 94, 225, 223, 140, 80, 225, 249, 20, 195, 175, 130, 68, 145, 47, 182, 111, 47, 72, 14, 86, 228, 175, 114, 54, 181, 215, 249, 172, 165, 141, 228, 32, 162, 58, 133, 184, 160, 95, 166, 138, 111, 50, 190, 35, 181, 201, 151, 144, 174, 214, 247, 70, 205, 232, 255, 255, 160, 119, 124, 119, 170, 168, 187, 61, 124, 180, 17, 100, 181, 167, 154, 14, 115, 142, 139, 239, 247, 45, 55, 69, 197, 103, 62, 42, 114, 125, 158, 78, 15, 73, 53, 175, 254, 149, 98, 19, 30, 234, 164, 182, 181, 114, 155, 175, 123, 39, 29, 132, 36, 97, 97, 11, 59, 8, 198, 202, 156, 246, 161, 2, 113, 158, 110, 103, 198, 114, 244, 73, 251, 143, 251, 60, 230, 224, 175, 50, 54, 176, 0, 0, 0, 233, 2, 172, 105, 10, 42, 119, 74, 4, 193, 25, 40, 217, 109, 200, 49, 68, 184, 108, 147, 201, 33, 176, 158, 243, 243, 139, 196, 105, 175, 104, 197, 35, 84, 22, 38, 14, 0, 239, 164, 26, 248, 187, 41, 196, 244, 107, 253, 5, 148, 149, 209, 243, 187, 244, 18, 186, 27, 60, 225, 247, 55, 79, 116, 138, 14, 234, 84, 101, 167, 102, 213, 118, 81, 144, 175, 253, 229, 43, 41, 242, 75, 241, 89, 38, 229, 165, 84, 122, 211, 202, 124, 92, 63, 207, 95, 55, 247, 101, 172, 220, 115, 8, 6, 97, 117, 114, 97, 32, 134, 44, 32, 8, 0, 0, 0, 0, 5, 97, 117, 114, 97, 1, 1, 40, 57, 30, 247, 197, 252, 101, 55, 227, 113, 208, 156, 160, 24, 42, 92, 216, 200, 252, 99, 89, 104, 210, 134, 232, 49, 50, 126, 218, 196, 39, 78, 73, 201, 88, 216, 63, 32, 181, 239, 27, 23, 111, 180, 91, 163, 106, 162, 102, 126, 16, 73, 116, 152, 242, 235, 186, 228, 129, 139, 111, 253, 168, 141, 0, 0, 0, 0, 25, 66, 123, 0, 12, 1, 0, 160, 139, 229, 62, 216, 203, 144, 104, 17, 69, 8, 79, 40, 19, 37, 65, 98, 238, 73, 185, 234, 144, 224, 78, 98, 104, 215, 20, 97, 113, 60, 239, 66, 39, 44, 80, 81, 224, 254, 129, 109, 119, 184, 63, 28, 190, 119, 112, 238, 179, 136, 20, 233, 244, 254, 23, 203, 151, 182, 254, 203, 165, 136, 2, 134, 197, 223, 40, 200, 200, 162, 89, 231, 163, 172, 221, 191, 55, 58, 167, 77, 22, 85, 255, 73, 105, 125, 80, 231, 48, 83, 38, 139, 167, 57, 62, 106, 59, 156, 112, 90, 145, 226, 224, 201, 221, 155, 223, 122, 13, 226, 205, 123, 86, 136, 74, 191, 231, 106, 61, 132, 231, 98, 154, 73, 197, 94, 143, 1, 240, 142, 190, 26, 77, 110, 2, 244, 142, 218, 128, 63, 37, 92, 68, 234, 247, 36, 166, 156, 207, 219, 68, 93, 34, 60, 184, 52, 46, 54, 114, 5, 224, 208, 181, 28, 158, 79, 46, 188, 111, 9, 171, 140, 58, 104, 94, 167, 73, 108, 105, 9, 46, 47, 162, 237, 54, 248, 164, 11, 238, 79, 96, 140, 12, 7, 54, 8, 0, 0, 175, 118, 225, 235, 187, 192, 11, 26, 115, 129, 172, 137, 84, 115, 109, 176, 65, 229, 57, 91, 74, 154, 86, 230, 224, 93, 51, 144, 254, 16, 23, 246, 146, 152, 92, 218, 164, 118, 97, 235, 181, 172, 190, 80, 136, 159, 123, 129, 105, 31, 108, 6, 13, 240, 118, 154, 219, 73, 79, 100, 218, 62, 87, 11, 240, 240, 73, 35, 226, 192, 112, 65, 155, 19, 52, 40, 246, 195, 42, 4, 206, 47, 11, 185, 116, 228, 12, 168, 125, 32, 228, 4, 146, 10, 156, 67, 152, 173, 126, 206, 160, 177, 56, 60, 11, 212, 71, 123, 183, 130, 92, 32, 240, 189, 45, 59, 194, 110, 168, 126, 76, 166, 48, 250, 50, 223, 215, 156, 234, 4, 18, 122, 21, 42, 232, 20, 168, 183, 254, 211, 180, 175, 78, 253, 172, 39, 197, 89, 23, 92, 202, 87, 206, 182, 159, 112, 144, 45, 179, 205, 28, 21, 138, 241, 252, 127, 198, 2, 222, 167, 240, 150, 193, 91, 158, 10, 198, 144, 131, 98, 241, 180, 104, 31, 94, 2, 114, 54, 18, 40, 174, 94, 104, 19, 30, 203, 169, 164, 4, 249, 94, 239, 87, 56, 128, 183, 187, 131, 192, 226, 135, 47, 98, 139, 26, 34, 173, 63, 146, 16, 146, 183, 225, 134, 30, 168, 221, 138, 200, 100, 57, 156, 189, 187, 192, 223, 138, 33, 149, 30, 80, 24, 69, 233, 176, 177, 182, 48, 209, 125, 238, 107, 149, 97, 180, 134, 105, 11, 49, 138, 17, 233, 236, 131, 88, 50, 63, 24, 58, 218, 5, 84, 87, 101, 91, 164, 221, 29, 25, 226, 80, 26, 217, 109, 34, 91, 43, 217, 0, 0, 0, 225, 2, 181, 231, 10, 56, 62, 156, 230, 221, 14, 56, 109, 162, 136, 91, 149, 254, 181, 164, 179, 56, 209, 216, 245, 251, 211, 178, 213, 56, 49, 223, 253, 111, 121, 22, 214, 154, 192, 47, 193, 75, 27, 57, 151, 217, 92, 239, 142, 185, 134, 183, 249, 236, 22, 241, 141, 104, 3, 130, 230, 184, 211, 49, 136, 15, 69, 158, 149, 35, 4, 228, 125, 116, 200, 85, 188, 161, 117, 239, 242, 122, 231, 208, 234, 231, 170, 54, 4, 246, 141, 113, 29, 162, 14, 85, 108, 174, 238, 132, 8, 6, 97, 117, 114, 97, 32, 134, 44, 32, 8, 0, 0, 0, 0, 5, 97, 117, 114, 97, 1, 1, 108, 251, 167, 35, 120, 146, 115, 29, 12, 128, 245, 15, 82, 66, 228, 86, 200, 227, 202, 152, 108, 101, 59, 133, 134, 140, 252, 156, 212, 85, 64, 20, 27, 211, 210, 186, 167, 156, 1, 191, 25, 153, 42, 104, 192, 82, 56, 108, 105, 99, 27, 102, 248, 252, 212, 124, 86, 206, 226, 38, 6, 70, 171, 142, 0, 0, 0, 0, 25, 66, 123, 0, 8, 1, 68, 219, 120, 157, 247, 162, 60, 48, 60, 99, 72, 115, 67, 63, 153, 15, 252, 153, 199, 7, 189, 199, 58, 46, 10, 86, 41, 227, 188, 72, 246, 4, 83, 244, 105, 193, 127, 140, 227, 239, 56, 245, 124, 87, 216, 164, 166, 144, 107, 40, 176, 40, 137, 79, 33, 230, 82, 127, 181, 37, 72, 41, 147, 138, 2, 68, 49, 73, 231, 222, 99, 247, 86, 246, 67, 6, 142, 82, 1, 197, 16, 55, 77, 222, 17, 99, 110, 25, 124, 42, 177, 76, 84, 21, 232, 99, 12, 131, 15, 33, 179, 198, 109, 139, 31, 144, 213, 138, 220, 1, 65, 12, 154, 120, 6, 71, 185, 184, 44, 240, 35, 151, 253, 112, 83, 2, 91, 114, 138, 12, 3, 0, 246, 216, 92, 103, 88, 45, 98, 187, 149, 189, 55, 94, 250, 40, 99, 140, 220, 37, 229, 34, 240, 3, 41, 170, 15, 4, 77, 245, 108, 228, 167, 96, 102, 8, 237, 1, 115, 28, 234, 129, 148, 1, 101, 18, 142, 31, 253, 252, 91, 66, 7, 226, 173, 132, 84, 131, 119, 137, 155, 57, 45, 196, 151, 177, 193, 102, 220, 31, 133, 232, 162, 144, 38, 133, 83, 170, 65, 18, 246, 24, 5, 193, 167, 217, 127, 79, 125, 77, 243, 98, 31, 193, 187, 14, 26, 198, 243, 44, 131, 6, 8, 6, 66, 65, 66, 69, 181, 1, 3, 5, 0, 0, 0, 12, 89, 64, 16, 0, 0, 0, 0, 58, 102, 213, 95, 227, 27, 5, 141, 153, 63, 92, 162, 176, 229, 244, 17, 31, 226, 40, 0, 121, 158, 27, 23, 245, 67, 152, 83, 58, 113, 158, 82, 126, 103, 120, 164, 98, 178, 148, 152, 155, 46, 68, 9, 252, 128, 62, 37, 112, 183, 117, 30, 29, 147, 22, 63, 160, 179, 155, 116, 47, 204, 92, 12, 86, 79, 97, 43, 223, 216, 196, 122, 119, 152, 83, 155, 212, 73, 145, 42, 133, 106, 86, 163, 99, 39, 62, 75, 113, 54, 8, 252, 208, 202, 82, 8, 5, 66, 65, 66, 69, 1, 1, 44, 114, 48, 165, 157, 36, 194, 83, 104, 47, 128, 136, 158, 247, 92, 166, 10, 243, 174, 36, 103, 104, 100, 71, 98, 84, 109, 67, 140, 35, 132, 20, 150, 17, 47, 5, 190, 188, 210, 7, 172, 127, 20, 55, 53, 102, 190, 148, 206, 241, 116, 49, 18, 123, 195, 249, 93, 35, 126, 238, 5, 171, 233, 138, 26, 146, 1, 65, 2, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 68, 211, 237, 210, 119, 8, 83, 243, 27, 94, 38, 113, 202, 174, 146, 68, 202, 114, 24, 94, 232, 254, 98, 159, 190, 53, 121, 147, 146, 233, 108, 19, 96, 143, 11, 58, 36, 149, 57, 203, 238, 189, 204, 2, 18, 234, 19, 154, 83, 105, 239, 129, 17, 85, 122, 33, 57, 48, 207, 65, 193, 218, 60, 131, 69, 1, 0, 0, 18, 2, 4, 59, 106, 39, 188, 206, 182, 164, 45, 98, 163, 168, 208, 42, 111, 13, 115, 101, 50, 21, 119, 29, 226, 67, 166, 58, 192, 72, 161, 139, 89, 218, 41, 1, 0, 0, 0, 0, 0} + blockResponseData := new(network.BlockResponseMessage) + err = blockResponseData.Decode(entireBlockData) + require.NoError(t, err) + + block := &types.Block{ + Header: *blockResponseData.BlockData[0].Header, + Body: *blockResponseData.BlockData[0].Body, + } + + exts, err := block.Body.AsEncodedExtrinsics() + require.NoError(t, err) + + expectedExtrinsics := []string{ + "0x8bea0528dc1e7b07896a36d6d2ecb86c6cccbda21064089b5212a081d8b62631", + "0xc0014ff921c3bf55333621237f3058af2d2a696bddf5f703338a7c3b11c1965f", + "0x41b93a99fee24501ddeb1cc2dcfbec938c99a3d94531c7e16b4f4e102a9df38a", + } + + bodyExtrinsicHashes := []string{} + for _, ext := range exts { + bodyExtrinsicHashes = append(bodyExtrinsicHashes, ext.Hash().String()) + } + + require.Equal(t, expectedExtrinsics, bodyExtrinsicHashes) + + _, err = instance.ExecuteBlock(block) + require.NoError(t, err) + +} + func TestInstance_BabeConfiguration_WestendRuntime_WithAuthorities(t *testing.T) { tt := trie.NewEmptyTrie() @@ -967,6 +1043,22 @@ func newTrieFromPairs(t *testing.T, filename string) *trie.Trie { return &tr } +func newTrieFromScaledPairs(t *testing.T, filename string) *trie.Trie { + data, err := os.ReadFile(filename) + require.NoError(t, err) + + decoded := make([][2][]byte, 0) + err = scale.Unmarshal(data, &decoded) + require.NoError(t, err) + + trie, err := trie.LoadFromEntries(decoded) + if err != nil { + panic(err) + } + + return trie +} + func TestInstance_TransactionPaymentCallApi_QueryCallInfo(t *testing.T) { ins := NewTestInstance(t, runtime.WESTEND_RUNTIME_v0929) tests := []struct {