diff --git a/.vscode/launch.json b/.vscode/launch.json index badfa419..7b7eff1c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -38,6 +38,17 @@ "sourceMaps": true, "cwd": "${workspaceRoot}", "protocol": "inspector" + }, + { + "type": "node", + "request": "launch", + "name": "Debug Current Test File", + "autoAttachChildProcesses": true, + "skipFiles": ["/**", "**/node_modules/**"], + "program": "${workspaceRoot}/node_modules/vitest/vitest.mjs", + "args": ["run", "${relativeFile}"], + "smartStep": true, + "console": "integratedTerminal" } ] } diff --git a/e2e/__snapshots__/author.test.ts.snap b/e2e/__snapshots__/author.test.ts.snap index 1aab21d0..ff54fa24 100644 --- a/e2e/__snapshots__/author.test.ts.snap +++ b/e2e/__snapshots__/author.test.ts.snap @@ -137,7 +137,7 @@ exports[`author rpc > works 2`] = ` "block": { "extrinsics": [ "0x280401000b207230268401", - "0x352c04a000e902d94d2e18b4a8a88d9b21cb03bbe4df4431a93718c2c602c13043d595e8b8735a3e910b0021c0ecb97a4c7cc86aa22eeb2db02b60829551cf67bdc490f0948ac009f6c0801257ffee8b177dab50e7b537ccbd2d1ffcd8a0068a08d57a92ce367e4e0f52e1080661757261209aa0470800000000056175726101013aefb1326d057c6d6d174f1565404a8b1a6ab45c941fa89bd8a56ac401226d1b0d96a6e436d7021dd097d316f07fe554fc35c92e1966e8a9b6ebc4de15e57886901e070049416764844ff0d8bad851e8abe686dff9dd2de78621180ef8e9f99bb7a480f10000500050c45e414cb008e0e61e46722aa60abdd67280bd82018ee510cf360e1a460326ef53dde570b25b9e835fc045551ffe4e88fe08c85e77dfdb8adb10f78f10a5df8742c5458401df75b8601e1b21393fc7772afc0788aa25e88713977d61495fabb2550af5c835c45ee678799d3eff024253b90e84927cc6807ed4bd40e4853d40a1fd44e7128aa75ded4660543dc48918f507ac56fbef7d9745035f04b49d95320d9021994c850f25b8e385f902000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000150180001480451c10fa62e420ae9678ed9e9f7f19e3e39be3a38ed4e3fe314234f3e6fed31780d3dac5ff6c2ce4154f56c20524e2dd095001f40b34d7c8afca34011128bc86201501800110800641aad9b51d5b63bd72bc66e847b8b6b6506b467a5a2cbf21d34ca91182cf72800ebe650369ce0e3ce85b22816181f598cc6ecf7a3b22314357ab4181b9ccb867150180011080ace5323aee784b03389c0e2cc68d81973f8fa26d395f333ecad7399271c781e1808e5db75be813c05205986cbd6fdede707a4d26816063a41eb42ebc262c734fad1d028004648086a9239b72237f5bf119e2a880c32f5866460632700509cb874c60f67fe815ea80f6f6801e4b41e2e6d8ec194dba122bfb9eb33feb2545ef5144cea79551f7cc5280c629a7e712d763fe83b35d2a082430af6737a89f23219c0eb3051c83bc5af5ad80fed5ecd6097308a6540f8cf31aeaad186e6898d2ecc0e623767c521c70e399531501800804809f3ada68c357b5e0a3ebb39ef181acfa9943af4725c244330a4b2c60837612e88082ad3fbdf392429afeacc70177704b760bb145547c1f152e1fcf651916b43820dc8008208042793f557c1d003b647e2eda79c2b5088c7d8cab2e82c1dcc87f4343cca91ae4485ead6eef5c4b1c68eaa71ea17a02d9de0400a102801017806ad8bda250a43737b26933c1b7bebe6f4fe689b2888ff5ab4833d7394853350f8038f5c136db5bdb74d6a62722e6ea23af4fe820eb7fe28dee3a5f76d637dd3376803419c1ea3c5c7873325866f82a3d4bd7d3f222733227fcf3af1423fed4781c998065a1214a991ac85d93f38385d6f52af7b4ddcf56e589fcb92c8d9e8f27291c92805c5a7c2cdb53c4196aff4e5ce6da4b8d22a62c80db5ef5d0940ae4c1a4322b55990180210280de38445d825563f8e218255a417c16971afa85b4f2ef18fbe08fbc5b976dc0d6801a2ff24096295cfccf1adda80b8dfffe380b9f3b54d7a3cdb67864a4655e62968022a699b2cc90a6654c84163d2a498506b192afe7cd9777227e5288e8ff069c0f150180400180ebebd1a1cd0bbc6714b7fb0ac854cca5a4c4e34e69485da48be3c8087b56e09b80128645c79ca6581c248a412fd7b8bc532a187600e6e1cc20c915538ba4df6a79450780ffbe80d9302a505e2b1ac931f539aed33bf791d1982906ae64c7197324044f191e9bca80972cd2f703f9c94fd516e14b7013c6f1545095855b6c4b36f21d89dad30aa54d80b2495ce4d07001927bb0857611f8d3a1449e791d0b010e3861c32dec0c44179680f5929c8ef9b0ac6ec8a529c91348d8cd6c169920dd37d055544a6c31c53b11e380402a0bf7ff07cee790d9cc065fc138ff6afa7db016d898d65b2b716af354c6f68042aef1dafffd1d9debbb8e6c4eb48b5c141ddf0aad2b0f3f4ddf53e6b38e65c080b31fa0392c1abdce1aa29d1544c94634ecab87ecaba6409db33aaa7621992a8280b1f4de7c3ac5665016d561a60659cd2d8f2d3e0a97e2ea9749279bd8e35eb1f180816ac87a2893694016b21768137a76ea459190ea0fc3c645d85e1a3d4eb194fe802e563b43e7334454c841953424be8c2b7a1c3295dbc391045cb6b88388ad5e7080b1ed3b02e5989b7d134ca056c778f1f5b6ffd377b2d8064483da6e94b82b0e40800cb3299c44a5db8fdcb4932e1b6ab0385d6ef1c9f8d85e0a75b787b6f4fd6c3c805a44c30e2676dc2d4c17451f51d9502e85064387999f366e6f3d404509a7780f80d6788ca71c6aabe421c352027acdb9532563dc5f1b25e6154b721f431e9990edf1019d0da05ca59913bc38a8630590f2627c154080834dda0ba5adf00d798e981a28a13e728cf83e35aefc87318440a61869f724474c5f0a351b6a99a5b21324516e668bb86a570400505f0e7b9012096b41c4eb3aaf947f6ea4290800007c7700e67da63472835bb0b737093a19ad4c63f5a4efb16ffa83d00700000400ec9e207f03cfdce586301014700e2c25931040505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f0ec2d17a76153ff51817f12d9cfc3c7f040085049e710b30bd2eab0352ddcc26417aa1945fc180699a53b51a9709a3a86039c49b5ef278e9fc244dae27e1a0380c91bff5b0488580c0d4096d94e724b8e86f952e5456c7253776de04c405582d2c350ee172d3eaa77c77081e0bfde17b36573208a06cb5cfba6b63f5a4efb16ffa83d00700000402803d0ae0b8f6832e8fabf0ec62521c2487c58b69eb97060faa8059b00ff6b7262d505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f03c716fb8fff3de61a883bb76adb34a20400806c8122e0f7f786071d6a51b330d612eccdcbe8d8f79936accabd640506dffdf380a6abfb72ed49b586829cca4ce631c092d45a017ab0d68288d308873025cfe5d280521b868fc212b25f021984cf02ced547cd45952b88360766839dfde7d4683e61f9049eb6f36e027abb2091cfb5110ab5087ff96c685f06155b3cd9a8c9e5e9a23fd5dc13a5ed2037418f1000000000685f08316cbf8fa0da822a20ac1c55bf1be3208212000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080e63c6175a901b4879d3c394e46980fb04e78755f0835d3bbf7c5f414cba07df280a75b29e0e24889a69c6b8c37a437692b76ca9aa52ab78997098b79da5c34a31a80740bfbe51a080a46d5c79a4b185680b175abb3ccdb602dbdba7552f7172ed8c1800f52715d71fe1c37787c148742c2476aadc24f49210fbc78bc78548c1a9544b6808f85bb9e09b1dc3958541a079dedea1ebb40e90bb6128b956104ed2447a777bf80546f9de70a2056a16cff4eddf15b5b5ca69a495225f8e8be67c90184fdd1af38685f090e2fbf2d792cb324bffa9427fe1f0e202a1e07008e1e070021019ede3d8a54d27e44a9d5ce189618f22d1008505f0e7b9012096b41c4eb3aaf947f6ea42908010080c74756edffa217dfb07ab596d82753deff985ac215e5cc2997d29afe1d397c161d019ef78c98723ddc9073523ef3beefda0c1004505f0e7b9012096b41c4eb3aaf947f6ea4290800007c77095dac46c07a40d91506e7637ec4ba5763f5a4efb16ffa83d007000004000000", + "0xa91704a000e902d94d2e18b4a8a88d9b21cb03bbe4df4431a93718c2c602c13043d595e8b8735a3e910b0021c0ecb97a4c7cc86aa22eeb2db02b60829551cf67bdc490f0948ac009f6c0801257ffee8b177dab50e7b537ccbd2d1ffcd8a0068a08d57a92ce367e4e0f52e1080661757261209aa0470800000000056175726101013aefb1326d057c6d6d174f1565404a8b1a6ab45c941fa89bd8a56ac401226d1b0d96a6e436d7021dd097d316f07fe554fc35c92e1966e8a9b6ebc4de15e57886901e07009c325649c4ebff345980ea29b5fb7b60a9af1f8cb26e5d9403418e89aee6d5c80000500034c45e414cb008e0e61e46722aa60abdd67280bd82018ee510cf360e1a460326ef53dde570b25b9e835fc045551ffe4e88fe08c45ee678799d3eff024253b90e84927cc6807ed4bd40e4853d40a1fd44e7128aa75ded4660543dc48918f507ac56fbef7d97cc5f0077dfdb8adb10f78f10a5df8742c5458401df75b8601e1b21393fc7772afc0788aa25e88713977d61495fabb2550af5c83545035f04b49d95320d9021994c850f25b8e385f902000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000150180001480451c10fa62e420ae9678ed9e9f7f19e3e39be3a38ed4e3fe314234f3e6fed31780d3dac5ff6c2ce4154f56c20524e2dd095001f40b34d7c8afca34011128bc86201501800804809f3ada68c357b5e0a3ebb39ef181acfa9943af4725c244330a4b2c60837612e88097425c486ee3f57ab095f94c7dc030d79c63147ff57c50c90a577e2ad727d2e2a10280439080216c4ed723e0a878bd96314428b2b7cb9727481f149f84011c0405423bb94e26805bd412b85f2239198146f1fe278f482ed1e54fff8aab83ff5278486f27553e5180118f288193e4da2abce3289ebcfe1b730737e817b189512053eb437b1211c9f6807a4cfe27b7daddf656ec94d5b0d02fa22183c8bcdadf8364f236cbe956cc8f9e80c3485bf9a1e0e78ac17578cca0d0b0cd5f632bd925284c5f54decc00e6f44aae6d019e0da05ca59913bc38a8630590f2627c14404c5f0a351b6a99a5b21324516e668bb86a570400505f0e7b9012096b41c4eb3aaf947f6ea4290800007c7700e67da63472835bb0b737093a19ad4c63f5a4efb16ffa83d007000004001d019ef78c98723ddc9073523ef3beefda0c1004505f0e7b9012096b41c4eb3aaf947f6ea4290800007c77095dac46c07a40d91506e7637ec4ba5763f5a4efb16ffa83d00700000400f09f05207f03cfdce586301014700e2c25931040505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f0ec2d17a76153ff51817f12d9cfc3c7f040025019f06de3d8a54d27e44a9d5ce189618f22d1008505f0e7b9012096b41c4eb3aaf947f6ea42908010080c74756edffa217dfb07ab596d82753deff985ac215e5cc2997d29afe1d397c16ed029f0cb6f36e027abb2091cfb5110ab5087f9960685f06155b3cd9a8c9e5e9a23fd5dc13a5ed2037418f1000000000685f08316cbf8fa0da822a20ac1c55bf1be3208212000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080740bfbe51a080a46d5c79a4b185680b175abb3ccdb602dbdba7552f7172ed8c180fddafc590530ce9037825fac38ceee0615edf7def5fd0af0bacb16f7d47f9859685f090e2fbf2d792cb324bffa9427fe1f0e202a1e07008e1e0700c1019f0d710b30bd2eab0352ddcc26417aa19454807c77081e0bfde17b36573208a06cb5cfba6b63f5a4efb16ffa83d00700000402505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f03c716fb8fff3de61a883bb76adb34a204004c5f0dad6eef5c4b1c68eaa71ea17a02d9de04000000", "0x3102840088dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee00f7b92e81c4c3678cf2bd0ce0774782709b8792d46abcb381c5617fd79550a7b3a0d0cd858419dbadbb4e763960b710e2265e0d21bf33ba1009184859d9618d06040100000a0000d17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae699101", ], "header": { @@ -334,7 +334,7 @@ exports[`author rpc > works 6`] = ` "block": { "extrinsics": [ "0x280401000b40c030268401", - "0x352c04a000e902d94d2e18b4a8a88d9b21cb03bbe4df4431a93718c2c602c13043d595e8b8735a3e910b0021c0ecb97a4c7cc86aa22eeb2db02b60829551cf67bdc490f0948ac009f6c0801257ffee8b177dab50e7b537ccbd2d1ffcd8a0068a08d57a92ce367e4e0f52e1080661757261209aa0470800000000056175726101013aefb1326d057c6d6d174f1565404a8b1a6ab45c941fa89bd8a56ac401226d1b0d96a6e436d7021dd097d316f07fe554fc35c92e1966e8a9b6ebc4de15e57886921e070049416764844ff0d8bad851e8abe686dff9dd2de78621180ef8e9f99bb7a480f10000500050c45e414cb008e0e61e46722aa60abdd67280bd82018ee510cf360e1a460326ef53dde570b25b9e835fc045551ffe4e88fe08c85e77dfdb8adb10f78f10a5df8742c5458401df75b8601e1b21393fc7772afc0788aa25e88713977d61495fabb2550af5c835c45ee678799d3eff024253b90e84927cc6807ed4bd40e4853d40a1fd44e7128aa75ded4660543dc48918f507ac56fbef7d9745035f04b49d95320d9021994c850f25b8e385f902000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000150180001480451c10fa62e420ae9678ed9e9f7f19e3e39be3a38ed4e3fe314234f3e6fed31780d3dac5ff6c2ce4154f56c20524e2dd095001f40b34d7c8afca34011128bc86201501800110800641aad9b51d5b63bd72bc66e847b8b6b6506b467a5a2cbf21d34ca91182cf72800ebe650369ce0e3ce85b22816181f598cc6ecf7a3b22314357ab4181b9ccb867150180011080ace5323aee784b03389c0e2cc68d81973f8fa26d395f333ecad7399271c781e1808e5db75be813c05205986cbd6fdede707a4d26816063a41eb42ebc262c734fad1d028004648086a9239b72237f5bf119e2a880c32f5866460632700509cb874c60f67fe815ea80f6f6801e4b41e2e6d8ec194dba122bfb9eb33feb2545ef5144cea79551f7cc5280c629a7e712d763fe83b35d2a082430af6737a89f23219c0eb3051c83bc5af5ad80fed5ecd6097308a6540f8cf31aeaad186e6898d2ecc0e623767c521c70e399531501800804809f3ada68c357b5e0a3ebb39ef181acfa9943af4725c244330a4b2c60837612e88082ad3fbdf392429afeacc70177704b760bb145547c1f152e1fcf651916b43820dc8008208042793f557c1d003b647e2eda79c2b5088c7d8cab2e82c1dcc87f4343cca91ae4485ead6eef5c4b1c68eaa71ea17a02d9de0400a102801017806ad8bda250a43737b26933c1b7bebe6f4fe689b2888ff5ab4833d7394853350f8038f5c136db5bdb74d6a62722e6ea23af4fe820eb7fe28dee3a5f76d637dd3376803419c1ea3c5c7873325866f82a3d4bd7d3f222733227fcf3af1423fed4781c998065a1214a991ac85d93f38385d6f52af7b4ddcf56e589fcb92c8d9e8f27291c92805c5a7c2cdb53c4196aff4e5ce6da4b8d22a62c80db5ef5d0940ae4c1a4322b55990180210280de38445d825563f8e218255a417c16971afa85b4f2ef18fbe08fbc5b976dc0d6801a2ff24096295cfccf1adda80b8dfffe380b9f3b54d7a3cdb67864a4655e62968022a699b2cc90a6654c84163d2a498506b192afe7cd9777227e5288e8ff069c0f150180400180ebebd1a1cd0bbc6714b7fb0ac854cca5a4c4e34e69485da48be3c8087b56e09b80128645c79ca6581c248a412fd7b8bc532a187600e6e1cc20c915538ba4df6a79450780ffbe80d9302a505e2b1ac931f539aed33bf791d1982906ae64c7197324044f191e9bca80972cd2f703f9c94fd516e14b7013c6f1545095855b6c4b36f21d89dad30aa54d80b2495ce4d07001927bb0857611f8d3a1449e791d0b010e3861c32dec0c44179680f5929c8ef9b0ac6ec8a529c91348d8cd6c169920dd37d055544a6c31c53b11e380402a0bf7ff07cee790d9cc065fc138ff6afa7db016d898d65b2b716af354c6f68042aef1dafffd1d9debbb8e6c4eb48b5c141ddf0aad2b0f3f4ddf53e6b38e65c080b31fa0392c1abdce1aa29d1544c94634ecab87ecaba6409db33aaa7621992a8280b1f4de7c3ac5665016d561a60659cd2d8f2d3e0a97e2ea9749279bd8e35eb1f180816ac87a2893694016b21768137a76ea459190ea0fc3c645d85e1a3d4eb194fe802e563b43e7334454c841953424be8c2b7a1c3295dbc391045cb6b88388ad5e7080b1ed3b02e5989b7d134ca056c778f1f5b6ffd377b2d8064483da6e94b82b0e40800cb3299c44a5db8fdcb4932e1b6ab0385d6ef1c9f8d85e0a75b787b6f4fd6c3c805a44c30e2676dc2d4c17451f51d9502e85064387999f366e6f3d404509a7780f80d6788ca71c6aabe421c352027acdb9532563dc5f1b25e6154b721f431e9990edf1019d0da05ca59913bc38a8630590f2627c154080834dda0ba5adf00d798e981a28a13e728cf83e35aefc87318440a61869f724474c5f0a351b6a99a5b21324516e668bb86a570400505f0e7b9012096b41c4eb3aaf947f6ea4290800007c7700e67da63472835bb0b737093a19ad4c63f5a4efb16ffa83d00700000400ec9e207f03cfdce586301014700e2c25931040505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f0ec2d17a76153ff51817f12d9cfc3c7f040085049e710b30bd2eab0352ddcc26417aa1945fc180699a53b51a9709a3a86039c49b5ef278e9fc244dae27e1a0380c91bff5b0488580c0d4096d94e724b8e86f952e5456c7253776de04c405582d2c350ee172d3eaa77c77081e0bfde17b36573208a06cb5cfba6b63f5a4efb16ffa83d00700000402803d0ae0b8f6832e8fabf0ec62521c2487c58b69eb97060faa8059b00ff6b7262d505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f03c716fb8fff3de61a883bb76adb34a20400806c8122e0f7f786071d6a51b330d612eccdcbe8d8f79936accabd640506dffdf380a6abfb72ed49b586829cca4ce631c092d45a017ab0d68288d308873025cfe5d280521b868fc212b25f021984cf02ced547cd45952b88360766839dfde7d4683e61f9049eb6f36e027abb2091cfb5110ab5087ff96c685f06155b3cd9a8c9e5e9a23fd5dc13a5ed2037418f1000000000685f08316cbf8fa0da822a20ac1c55bf1be3208212000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080e63c6175a901b4879d3c394e46980fb04e78755f0835d3bbf7c5f414cba07df280a75b29e0e24889a69c6b8c37a437692b76ca9aa52ab78997098b79da5c34a31a80740bfbe51a080a46d5c79a4b185680b175abb3ccdb602dbdba7552f7172ed8c1800f52715d71fe1c37787c148742c2476aadc24f49210fbc78bc78548c1a9544b6808f85bb9e09b1dc3958541a079dedea1ebb40e90bb6128b956104ed2447a777bf80546f9de70a2056a16cff4eddf15b5b5ca69a495225f8e8be67c90184fdd1af38685f090e2fbf2d792cb324bffa9427fe1f0e202a1e07008e1e070021019ede3d8a54d27e44a9d5ce189618f22d1008505f0e7b9012096b41c4eb3aaf947f6ea42908010080c74756edffa217dfb07ab596d82753deff985ac215e5cc2997d29afe1d397c161d019ef78c98723ddc9073523ef3beefda0c1004505f0e7b9012096b41c4eb3aaf947f6ea4290800007c77095dac46c07a40d91506e7637ec4ba5763f5a4efb16ffa83d007000004000000", + "0xa91704a000e902d94d2e18b4a8a88d9b21cb03bbe4df4431a93718c2c602c13043d595e8b8735a3e910b0021c0ecb97a4c7cc86aa22eeb2db02b60829551cf67bdc490f0948ac009f6c0801257ffee8b177dab50e7b537ccbd2d1ffcd8a0068a08d57a92ce367e4e0f52e1080661757261209aa0470800000000056175726101013aefb1326d057c6d6d174f1565404a8b1a6ab45c941fa89bd8a56ac401226d1b0d96a6e436d7021dd097d316f07fe554fc35c92e1966e8a9b6ebc4de15e57886921e07009c325649c4ebff345980ea29b5fb7b60a9af1f8cb26e5d9403418e89aee6d5c80000500034c45e414cb008e0e61e46722aa60abdd67280bd82018ee510cf360e1a460326ef53dde570b25b9e835fc045551ffe4e88fe08c45ee678799d3eff024253b90e84927cc6807ed4bd40e4853d40a1fd44e7128aa75ded4660543dc48918f507ac56fbef7d97cc5f0077dfdb8adb10f78f10a5df8742c5458401df75b8601e1b21393fc7772afc0788aa25e88713977d61495fabb2550af5c83545035f04b49d95320d9021994c850f25b8e385f902000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000150180001480451c10fa62e420ae9678ed9e9f7f19e3e39be3a38ed4e3fe314234f3e6fed31780d3dac5ff6c2ce4154f56c20524e2dd095001f40b34d7c8afca34011128bc86201501800804809f3ada68c357b5e0a3ebb39ef181acfa9943af4725c244330a4b2c60837612e88097425c486ee3f57ab095f94c7dc030d79c63147ff57c50c90a577e2ad727d2e2a10280439080216c4ed723e0a878bd96314428b2b7cb9727481f149f84011c0405423bb94e26805bd412b85f2239198146f1fe278f482ed1e54fff8aab83ff5278486f27553e5180118f288193e4da2abce3289ebcfe1b730737e817b189512053eb437b1211c9f6807a4cfe27b7daddf656ec94d5b0d02fa22183c8bcdadf8364f236cbe956cc8f9e80c3485bf9a1e0e78ac17578cca0d0b0cd5f632bd925284c5f54decc00e6f44aae6d019e0da05ca59913bc38a8630590f2627c14404c5f0a351b6a99a5b21324516e668bb86a570400505f0e7b9012096b41c4eb3aaf947f6ea4290800007c7700e67da63472835bb0b737093a19ad4c63f5a4efb16ffa83d007000004001d019ef78c98723ddc9073523ef3beefda0c1004505f0e7b9012096b41c4eb3aaf947f6ea4290800007c77095dac46c07a40d91506e7637ec4ba5763f5a4efb16ffa83d00700000400f09f05207f03cfdce586301014700e2c25931040505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f0ec2d17a76153ff51817f12d9cfc3c7f040025019f06de3d8a54d27e44a9d5ce189618f22d1008505f0e7b9012096b41c4eb3aaf947f6ea42908010080c74756edffa217dfb07ab596d82753deff985ac215e5cc2997d29afe1d397c16ed029f0cb6f36e027abb2091cfb5110ab5087f9960685f06155b3cd9a8c9e5e9a23fd5dc13a5ed2037418f1000000000685f08316cbf8fa0da822a20ac1c55bf1be3208212000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080740bfbe51a080a46d5c79a4b185680b175abb3ccdb602dbdba7552f7172ed8c180fddafc590530ce9037825fac38ceee0615edf7def5fd0af0bacb16f7d47f9859685f090e2fbf2d792cb324bffa9427fe1f0e202a1e07008e1e0700c1019f0d710b30bd2eab0352ddcc26417aa19454807c77081e0bfde17b36573208a06cb5cfba6b63f5a4efb16ffa83d00700000402505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f03c716fb8fff3de61a883bb76adb34a204004c5f0dad6eef5c4b1c68eaa71ea17a02d9de04000000", "0x3102840088dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee00ac0122165c15db54e67d09a8f7aa0651c39c80bc775483f15a06dab12f7214019d6ae60ef92f4218819d4ddd2e2726bf500e82e405de7306aecbd6959701ef08140104000a0000d17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae692103", ], "header": { @@ -531,7 +531,7 @@ exports[`author rpc > works 10`] = ` "block": { "extrinsics": [ "0x280401000b600e31268401", - "0x352c04a000e902d94d2e18b4a8a88d9b21cb03bbe4df4431a93718c2c602c13043d595e8b8735a3e910b0021c0ecb97a4c7cc86aa22eeb2db02b60829551cf67bdc490f0948ac009f6c0801257ffee8b177dab50e7b537ccbd2d1ffcd8a0068a08d57a92ce367e4e0f52e1080661757261209aa0470800000000056175726101013aefb1326d057c6d6d174f1565404a8b1a6ab45c941fa89bd8a56ac401226d1b0d96a6e436d7021dd097d316f07fe554fc35c92e1966e8a9b6ebc4de15e57886941e070049416764844ff0d8bad851e8abe686dff9dd2de78621180ef8e9f99bb7a480f10000500050c45e414cb008e0e61e46722aa60abdd67280bd82018ee510cf360e1a460326ef53dde570b25b9e835fc045551ffe4e88fe08c85e77dfdb8adb10f78f10a5df8742c5458401df75b8601e1b21393fc7772afc0788aa25e88713977d61495fabb2550af5c835c45ee678799d3eff024253b90e84927cc6807ed4bd40e4853d40a1fd44e7128aa75ded4660543dc48918f507ac56fbef7d9745035f04b49d95320d9021994c850f25b8e385f902000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000150180001480451c10fa62e420ae9678ed9e9f7f19e3e39be3a38ed4e3fe314234f3e6fed31780d3dac5ff6c2ce4154f56c20524e2dd095001f40b34d7c8afca34011128bc86201501800110800641aad9b51d5b63bd72bc66e847b8b6b6506b467a5a2cbf21d34ca91182cf72800ebe650369ce0e3ce85b22816181f598cc6ecf7a3b22314357ab4181b9ccb867150180011080ace5323aee784b03389c0e2cc68d81973f8fa26d395f333ecad7399271c781e1808e5db75be813c05205986cbd6fdede707a4d26816063a41eb42ebc262c734fad1d028004648086a9239b72237f5bf119e2a880c32f5866460632700509cb874c60f67fe815ea80f6f6801e4b41e2e6d8ec194dba122bfb9eb33feb2545ef5144cea79551f7cc5280c629a7e712d763fe83b35d2a082430af6737a89f23219c0eb3051c83bc5af5ad80fed5ecd6097308a6540f8cf31aeaad186e6898d2ecc0e623767c521c70e399531501800804809f3ada68c357b5e0a3ebb39ef181acfa9943af4725c244330a4b2c60837612e88082ad3fbdf392429afeacc70177704b760bb145547c1f152e1fcf651916b43820dc8008208042793f557c1d003b647e2eda79c2b5088c7d8cab2e82c1dcc87f4343cca91ae4485ead6eef5c4b1c68eaa71ea17a02d9de0400a102801017806ad8bda250a43737b26933c1b7bebe6f4fe689b2888ff5ab4833d7394853350f8038f5c136db5bdb74d6a62722e6ea23af4fe820eb7fe28dee3a5f76d637dd3376803419c1ea3c5c7873325866f82a3d4bd7d3f222733227fcf3af1423fed4781c998065a1214a991ac85d93f38385d6f52af7b4ddcf56e589fcb92c8d9e8f27291c92805c5a7c2cdb53c4196aff4e5ce6da4b8d22a62c80db5ef5d0940ae4c1a4322b55990180210280de38445d825563f8e218255a417c16971afa85b4f2ef18fbe08fbc5b976dc0d6801a2ff24096295cfccf1adda80b8dfffe380b9f3b54d7a3cdb67864a4655e62968022a699b2cc90a6654c84163d2a498506b192afe7cd9777227e5288e8ff069c0f150180400180ebebd1a1cd0bbc6714b7fb0ac854cca5a4c4e34e69485da48be3c8087b56e09b80128645c79ca6581c248a412fd7b8bc532a187600e6e1cc20c915538ba4df6a79450780ffbe80d9302a505e2b1ac931f539aed33bf791d1982906ae64c7197324044f191e9bca80972cd2f703f9c94fd516e14b7013c6f1545095855b6c4b36f21d89dad30aa54d80b2495ce4d07001927bb0857611f8d3a1449e791d0b010e3861c32dec0c44179680f5929c8ef9b0ac6ec8a529c91348d8cd6c169920dd37d055544a6c31c53b11e380402a0bf7ff07cee790d9cc065fc138ff6afa7db016d898d65b2b716af354c6f68042aef1dafffd1d9debbb8e6c4eb48b5c141ddf0aad2b0f3f4ddf53e6b38e65c080b31fa0392c1abdce1aa29d1544c94634ecab87ecaba6409db33aaa7621992a8280b1f4de7c3ac5665016d561a60659cd2d8f2d3e0a97e2ea9749279bd8e35eb1f180816ac87a2893694016b21768137a76ea459190ea0fc3c645d85e1a3d4eb194fe802e563b43e7334454c841953424be8c2b7a1c3295dbc391045cb6b88388ad5e7080b1ed3b02e5989b7d134ca056c778f1f5b6ffd377b2d8064483da6e94b82b0e40800cb3299c44a5db8fdcb4932e1b6ab0385d6ef1c9f8d85e0a75b787b6f4fd6c3c805a44c30e2676dc2d4c17451f51d9502e85064387999f366e6f3d404509a7780f80d6788ca71c6aabe421c352027acdb9532563dc5f1b25e6154b721f431e9990edf1019d0da05ca59913bc38a8630590f2627c154080834dda0ba5adf00d798e981a28a13e728cf83e35aefc87318440a61869f724474c5f0a351b6a99a5b21324516e668bb86a570400505f0e7b9012096b41c4eb3aaf947f6ea4290800007c7700e67da63472835bb0b737093a19ad4c63f5a4efb16ffa83d00700000400ec9e207f03cfdce586301014700e2c25931040505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f0ec2d17a76153ff51817f12d9cfc3c7f040085049e710b30bd2eab0352ddcc26417aa1945fc180699a53b51a9709a3a86039c49b5ef278e9fc244dae27e1a0380c91bff5b0488580c0d4096d94e724b8e86f952e5456c7253776de04c405582d2c350ee172d3eaa77c77081e0bfde17b36573208a06cb5cfba6b63f5a4efb16ffa83d00700000402803d0ae0b8f6832e8fabf0ec62521c2487c58b69eb97060faa8059b00ff6b7262d505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f03c716fb8fff3de61a883bb76adb34a20400806c8122e0f7f786071d6a51b330d612eccdcbe8d8f79936accabd640506dffdf380a6abfb72ed49b586829cca4ce631c092d45a017ab0d68288d308873025cfe5d280521b868fc212b25f021984cf02ced547cd45952b88360766839dfde7d4683e61f9049eb6f36e027abb2091cfb5110ab5087ff96c685f06155b3cd9a8c9e5e9a23fd5dc13a5ed2037418f1000000000685f08316cbf8fa0da822a20ac1c55bf1be3208212000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080e63c6175a901b4879d3c394e46980fb04e78755f0835d3bbf7c5f414cba07df280a75b29e0e24889a69c6b8c37a437692b76ca9aa52ab78997098b79da5c34a31a80740bfbe51a080a46d5c79a4b185680b175abb3ccdb602dbdba7552f7172ed8c1800f52715d71fe1c37787c148742c2476aadc24f49210fbc78bc78548c1a9544b6808f85bb9e09b1dc3958541a079dedea1ebb40e90bb6128b956104ed2447a777bf80546f9de70a2056a16cff4eddf15b5b5ca69a495225f8e8be67c90184fdd1af38685f090e2fbf2d792cb324bffa9427fe1f0e202a1e07008e1e070021019ede3d8a54d27e44a9d5ce189618f22d1008505f0e7b9012096b41c4eb3aaf947f6ea42908010080c74756edffa217dfb07ab596d82753deff985ac215e5cc2997d29afe1d397c161d019ef78c98723ddc9073523ef3beefda0c1004505f0e7b9012096b41c4eb3aaf947f6ea4290800007c77095dac46c07a40d91506e7637ec4ba5763f5a4efb16ffa83d007000004000000", + "0xa91704a000e902d94d2e18b4a8a88d9b21cb03bbe4df4431a93718c2c602c13043d595e8b8735a3e910b0021c0ecb97a4c7cc86aa22eeb2db02b60829551cf67bdc490f0948ac009f6c0801257ffee8b177dab50e7b537ccbd2d1ffcd8a0068a08d57a92ce367e4e0f52e1080661757261209aa0470800000000056175726101013aefb1326d057c6d6d174f1565404a8b1a6ab45c941fa89bd8a56ac401226d1b0d96a6e436d7021dd097d316f07fe554fc35c92e1966e8a9b6ebc4de15e57886941e07009c325649c4ebff345980ea29b5fb7b60a9af1f8cb26e5d9403418e89aee6d5c80000500034c45e414cb008e0e61e46722aa60abdd67280bd82018ee510cf360e1a460326ef53dde570b25b9e835fc045551ffe4e88fe08c45ee678799d3eff024253b90e84927cc6807ed4bd40e4853d40a1fd44e7128aa75ded4660543dc48918f507ac56fbef7d97cc5f0077dfdb8adb10f78f10a5df8742c5458401df75b8601e1b21393fc7772afc0788aa25e88713977d61495fabb2550af5c83545035f04b49d95320d9021994c850f25b8e385f902000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000150180001480451c10fa62e420ae9678ed9e9f7f19e3e39be3a38ed4e3fe314234f3e6fed31780d3dac5ff6c2ce4154f56c20524e2dd095001f40b34d7c8afca34011128bc86201501800804809f3ada68c357b5e0a3ebb39ef181acfa9943af4725c244330a4b2c60837612e88097425c486ee3f57ab095f94c7dc030d79c63147ff57c50c90a577e2ad727d2e2a10280439080216c4ed723e0a878bd96314428b2b7cb9727481f149f84011c0405423bb94e26805bd412b85f2239198146f1fe278f482ed1e54fff8aab83ff5278486f27553e5180118f288193e4da2abce3289ebcfe1b730737e817b189512053eb437b1211c9f6807a4cfe27b7daddf656ec94d5b0d02fa22183c8bcdadf8364f236cbe956cc8f9e80c3485bf9a1e0e78ac17578cca0d0b0cd5f632bd925284c5f54decc00e6f44aae6d019e0da05ca59913bc38a8630590f2627c14404c5f0a351b6a99a5b21324516e668bb86a570400505f0e7b9012096b41c4eb3aaf947f6ea4290800007c7700e67da63472835bb0b737093a19ad4c63f5a4efb16ffa83d007000004001d019ef78c98723ddc9073523ef3beefda0c1004505f0e7b9012096b41c4eb3aaf947f6ea4290800007c77095dac46c07a40d91506e7637ec4ba5763f5a4efb16ffa83d00700000400f09f05207f03cfdce586301014700e2c25931040505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f0ec2d17a76153ff51817f12d9cfc3c7f040025019f06de3d8a54d27e44a9d5ce189618f22d1008505f0e7b9012096b41c4eb3aaf947f6ea42908010080c74756edffa217dfb07ab596d82753deff985ac215e5cc2997d29afe1d397c16ed029f0cb6f36e027abb2091cfb5110ab5087f9960685f06155b3cd9a8c9e5e9a23fd5dc13a5ed2037418f1000000000685f08316cbf8fa0da822a20ac1c55bf1be3208212000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080740bfbe51a080a46d5c79a4b185680b175abb3ccdb602dbdba7552f7172ed8c180fddafc590530ce9037825fac38ceee0615edf7def5fd0af0bacb16f7d47f9859685f090e2fbf2d792cb324bffa9427fe1f0e202a1e07008e1e0700c1019f0d710b30bd2eab0352ddcc26417aa19454807c77081e0bfde17b36573208a06cb5cfba6b63f5a4efb16ffa83d00700000402505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f03c716fb8fff3de61a883bb76adb34a204004c5f0dad6eef5c4b1c68eaa71ea17a02d9de04000000", "0x3102840088dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee007aa899b75e856b8caa34caec04857abe9f7d921b1e92e6867f7e906211d0f9e977d10c4d26e1a254708e77168f506e9a711369993025ccb379dc695f935b540f240108000a0000d17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69b104", ], "header": { diff --git a/e2e/__snapshots__/chain.test.ts.snap b/e2e/__snapshots__/chain.test.ts.snap index 5d39b9b8..3e382d7c 100644 --- a/e2e/__snapshots__/chain.test.ts.snap +++ b/e2e/__snapshots__/chain.test.ts.snap @@ -241,7 +241,7 @@ exports[`chain rpc > getXXX 12`] = ` "block": { "extrinsics": [ "0x280401000b207230268401", - "0x352c04a000e902d94d2e18b4a8a88d9b21cb03bbe4df4431a93718c2c602c13043d595e8b8735a3e910b0021c0ecb97a4c7cc86aa22eeb2db02b60829551cf67bdc490f0948ac009f6c0801257ffee8b177dab50e7b537ccbd2d1ffcd8a0068a08d57a92ce367e4e0f52e1080661757261209aa0470800000000056175726101013aefb1326d057c6d6d174f1565404a8b1a6ab45c941fa89bd8a56ac401226d1b0d96a6e436d7021dd097d316f07fe554fc35c92e1966e8a9b6ebc4de15e57886901e070049416764844ff0d8bad851e8abe686dff9dd2de78621180ef8e9f99bb7a480f10000500050c45e414cb008e0e61e46722aa60abdd67280bd82018ee510cf360e1a460326ef53dde570b25b9e835fc045551ffe4e88fe08c85e77dfdb8adb10f78f10a5df8742c5458401df75b8601e1b21393fc7772afc0788aa25e88713977d61495fabb2550af5c835c45ee678799d3eff024253b90e84927cc6807ed4bd40e4853d40a1fd44e7128aa75ded4660543dc48918f507ac56fbef7d9745035f04b49d95320d9021994c850f25b8e385f902000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000150180001480451c10fa62e420ae9678ed9e9f7f19e3e39be3a38ed4e3fe314234f3e6fed31780d3dac5ff6c2ce4154f56c20524e2dd095001f40b34d7c8afca34011128bc86201501800110800641aad9b51d5b63bd72bc66e847b8b6b6506b467a5a2cbf21d34ca91182cf72800ebe650369ce0e3ce85b22816181f598cc6ecf7a3b22314357ab4181b9ccb867150180011080ace5323aee784b03389c0e2cc68d81973f8fa26d395f333ecad7399271c781e1808e5db75be813c05205986cbd6fdede707a4d26816063a41eb42ebc262c734fad1d028004648086a9239b72237f5bf119e2a880c32f5866460632700509cb874c60f67fe815ea80f6f6801e4b41e2e6d8ec194dba122bfb9eb33feb2545ef5144cea79551f7cc5280c629a7e712d763fe83b35d2a082430af6737a89f23219c0eb3051c83bc5af5ad80fed5ecd6097308a6540f8cf31aeaad186e6898d2ecc0e623767c521c70e399531501800804809f3ada68c357b5e0a3ebb39ef181acfa9943af4725c244330a4b2c60837612e88082ad3fbdf392429afeacc70177704b760bb145547c1f152e1fcf651916b43820dc8008208042793f557c1d003b647e2eda79c2b5088c7d8cab2e82c1dcc87f4343cca91ae4485ead6eef5c4b1c68eaa71ea17a02d9de0400a102801017806ad8bda250a43737b26933c1b7bebe6f4fe689b2888ff5ab4833d7394853350f8038f5c136db5bdb74d6a62722e6ea23af4fe820eb7fe28dee3a5f76d637dd3376803419c1ea3c5c7873325866f82a3d4bd7d3f222733227fcf3af1423fed4781c998065a1214a991ac85d93f38385d6f52af7b4ddcf56e589fcb92c8d9e8f27291c92805c5a7c2cdb53c4196aff4e5ce6da4b8d22a62c80db5ef5d0940ae4c1a4322b55990180210280de38445d825563f8e218255a417c16971afa85b4f2ef18fbe08fbc5b976dc0d6801a2ff24096295cfccf1adda80b8dfffe380b9f3b54d7a3cdb67864a4655e62968022a699b2cc90a6654c84163d2a498506b192afe7cd9777227e5288e8ff069c0f150180400180ebebd1a1cd0bbc6714b7fb0ac854cca5a4c4e34e69485da48be3c8087b56e09b80128645c79ca6581c248a412fd7b8bc532a187600e6e1cc20c915538ba4df6a79450780ffbe80d9302a505e2b1ac931f539aed33bf791d1982906ae64c7197324044f191e9bca80972cd2f703f9c94fd516e14b7013c6f1545095855b6c4b36f21d89dad30aa54d80b2495ce4d07001927bb0857611f8d3a1449e791d0b010e3861c32dec0c44179680f5929c8ef9b0ac6ec8a529c91348d8cd6c169920dd37d055544a6c31c53b11e380402a0bf7ff07cee790d9cc065fc138ff6afa7db016d898d65b2b716af354c6f68042aef1dafffd1d9debbb8e6c4eb48b5c141ddf0aad2b0f3f4ddf53e6b38e65c080b31fa0392c1abdce1aa29d1544c94634ecab87ecaba6409db33aaa7621992a8280b1f4de7c3ac5665016d561a60659cd2d8f2d3e0a97e2ea9749279bd8e35eb1f180816ac87a2893694016b21768137a76ea459190ea0fc3c645d85e1a3d4eb194fe802e563b43e7334454c841953424be8c2b7a1c3295dbc391045cb6b88388ad5e7080b1ed3b02e5989b7d134ca056c778f1f5b6ffd377b2d8064483da6e94b82b0e40800cb3299c44a5db8fdcb4932e1b6ab0385d6ef1c9f8d85e0a75b787b6f4fd6c3c805a44c30e2676dc2d4c17451f51d9502e85064387999f366e6f3d404509a7780f80d6788ca71c6aabe421c352027acdb9532563dc5f1b25e6154b721f431e9990edf1019d0da05ca59913bc38a8630590f2627c154080834dda0ba5adf00d798e981a28a13e728cf83e35aefc87318440a61869f724474c5f0a351b6a99a5b21324516e668bb86a570400505f0e7b9012096b41c4eb3aaf947f6ea4290800007c7700e67da63472835bb0b737093a19ad4c63f5a4efb16ffa83d00700000400ec9e207f03cfdce586301014700e2c25931040505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f0ec2d17a76153ff51817f12d9cfc3c7f040085049e710b30bd2eab0352ddcc26417aa1945fc180699a53b51a9709a3a86039c49b5ef278e9fc244dae27e1a0380c91bff5b0488580c0d4096d94e724b8e86f952e5456c7253776de04c405582d2c350ee172d3eaa77c77081e0bfde17b36573208a06cb5cfba6b63f5a4efb16ffa83d00700000402803d0ae0b8f6832e8fabf0ec62521c2487c58b69eb97060faa8059b00ff6b7262d505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f03c716fb8fff3de61a883bb76adb34a20400806c8122e0f7f786071d6a51b330d612eccdcbe8d8f79936accabd640506dffdf380a6abfb72ed49b586829cca4ce631c092d45a017ab0d68288d308873025cfe5d280521b868fc212b25f021984cf02ced547cd45952b88360766839dfde7d4683e61f9049eb6f36e027abb2091cfb5110ab5087ff96c685f06155b3cd9a8c9e5e9a23fd5dc13a5ed2037418f1000000000685f08316cbf8fa0da822a20ac1c55bf1be3208212000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080e63c6175a901b4879d3c394e46980fb04e78755f0835d3bbf7c5f414cba07df280a75b29e0e24889a69c6b8c37a437692b76ca9aa52ab78997098b79da5c34a31a80740bfbe51a080a46d5c79a4b185680b175abb3ccdb602dbdba7552f7172ed8c1800f52715d71fe1c37787c148742c2476aadc24f49210fbc78bc78548c1a9544b6808f85bb9e09b1dc3958541a079dedea1ebb40e90bb6128b956104ed2447a777bf80546f9de70a2056a16cff4eddf15b5b5ca69a495225f8e8be67c90184fdd1af38685f090e2fbf2d792cb324bffa9427fe1f0e202a1e07008e1e070021019ede3d8a54d27e44a9d5ce189618f22d1008505f0e7b9012096b41c4eb3aaf947f6ea42908010080c74756edffa217dfb07ab596d82753deff985ac215e5cc2997d29afe1d397c161d019ef78c98723ddc9073523ef3beefda0c1004505f0e7b9012096b41c4eb3aaf947f6ea4290800007c77095dac46c07a40d91506e7637ec4ba5763f5a4efb16ffa83d007000004000000", + "0xa91704a000e902d94d2e18b4a8a88d9b21cb03bbe4df4431a93718c2c602c13043d595e8b8735a3e910b0021c0ecb97a4c7cc86aa22eeb2db02b60829551cf67bdc490f0948ac009f6c0801257ffee8b177dab50e7b537ccbd2d1ffcd8a0068a08d57a92ce367e4e0f52e1080661757261209aa0470800000000056175726101013aefb1326d057c6d6d174f1565404a8b1a6ab45c941fa89bd8a56ac401226d1b0d96a6e436d7021dd097d316f07fe554fc35c92e1966e8a9b6ebc4de15e57886901e07009c325649c4ebff345980ea29b5fb7b60a9af1f8cb26e5d9403418e89aee6d5c80000500034c45e414cb008e0e61e46722aa60abdd67280bd82018ee510cf360e1a460326ef53dde570b25b9e835fc045551ffe4e88fe08c45ee678799d3eff024253b90e84927cc6807ed4bd40e4853d40a1fd44e7128aa75ded4660543dc48918f507ac56fbef7d97cc5f0077dfdb8adb10f78f10a5df8742c5458401df75b8601e1b21393fc7772afc0788aa25e88713977d61495fabb2550af5c83545035f04b49d95320d9021994c850f25b8e385f902000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000150180001480451c10fa62e420ae9678ed9e9f7f19e3e39be3a38ed4e3fe314234f3e6fed31780d3dac5ff6c2ce4154f56c20524e2dd095001f40b34d7c8afca34011128bc86201501800804809f3ada68c357b5e0a3ebb39ef181acfa9943af4725c244330a4b2c60837612e88097425c486ee3f57ab095f94c7dc030d79c63147ff57c50c90a577e2ad727d2e2a10280439080216c4ed723e0a878bd96314428b2b7cb9727481f149f84011c0405423bb94e26805bd412b85f2239198146f1fe278f482ed1e54fff8aab83ff5278486f27553e5180118f288193e4da2abce3289ebcfe1b730737e817b189512053eb437b1211c9f6807a4cfe27b7daddf656ec94d5b0d02fa22183c8bcdadf8364f236cbe956cc8f9e80c3485bf9a1e0e78ac17578cca0d0b0cd5f632bd925284c5f54decc00e6f44aae6d019e0da05ca59913bc38a8630590f2627c14404c5f0a351b6a99a5b21324516e668bb86a570400505f0e7b9012096b41c4eb3aaf947f6ea4290800007c7700e67da63472835bb0b737093a19ad4c63f5a4efb16ffa83d007000004001d019ef78c98723ddc9073523ef3beefda0c1004505f0e7b9012096b41c4eb3aaf947f6ea4290800007c77095dac46c07a40d91506e7637ec4ba5763f5a4efb16ffa83d00700000400f09f05207f03cfdce586301014700e2c25931040505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f0ec2d17a76153ff51817f12d9cfc3c7f040025019f06de3d8a54d27e44a9d5ce189618f22d1008505f0e7b9012096b41c4eb3aaf947f6ea42908010080c74756edffa217dfb07ab596d82753deff985ac215e5cc2997d29afe1d397c16ed029f0cb6f36e027abb2091cfb5110ab5087f9960685f06155b3cd9a8c9e5e9a23fd5dc13a5ed2037418f1000000000685f08316cbf8fa0da822a20ac1c55bf1be3208212000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080740bfbe51a080a46d5c79a4b185680b175abb3ccdb602dbdba7552f7172ed8c180fddafc590530ce9037825fac38ceee0615edf7def5fd0af0bacb16f7d47f9859685f090e2fbf2d792cb324bffa9427fe1f0e202a1e07008e1e0700c1019f0d710b30bd2eab0352ddcc26417aa19454807c77081e0bfde17b36573208a06cb5cfba6b63f5a4efb16ffa83d00700000402505f0e7b9012096b41c4eb3aaf947f6ea4290800004c5f03c716fb8fff3de61a883bb76adb34a204004c5f0dad6eef5c4b1c68eaa71ea17a02d9de04000000", ], "header": { "digest": { diff --git a/e2e/upgrade.test.ts b/e2e/upgrade.test.ts new file mode 100644 index 00000000..798726e9 --- /dev/null +++ b/e2e/upgrade.test.ts @@ -0,0 +1,35 @@ +import { blake2AsHex } from '@polkadot/util-crypto' +import { describe, expect, it } from 'vitest' +import { readFileSync } from 'node:fs' +import path from 'node:path' + +import { api, chain, dev, setupApi, testingPairs } from './helper' + +setupApi({ + endpoint: 'wss://acala-rpc-1.aca-api.network', + blockHash: '0x663c25dc86521f4b7f74dcbc26224bb0fac40e316e6b0bcf6a51de373f37afac', +}) + +describe('upgrade', () => { + const { alice } = testingPairs() + it('setCode works', async () => { + await dev.setStorages({ + Sudo: { + Key: alice.address, + }, + System: { + Account: [[[alice.address], { data: { free: 1000 * 1e12 } }]], + }, + }) + + const runtime = String(readFileSync(path.join(__dirname, './blobs/acala-runtime-2101.txt'))).trim() + + expect(await chain.head.runtimeVersion).toContain({ specVersion: 2096 }) + await api.tx.sudo.sudo(api.tx.parachainSystem.authorizeUpgrade(blake2AsHex(runtime))).signAndSend(alice) + await dev.newBlock() + await api.tx.sudo.sudoUncheckedWeight(api.tx.system.setCode(runtime), '0').signAndSend(alice) + await dev.newBlock() + await dev.newBlock() + expect(await chain.head.runtimeVersion).toContain({ specVersion: 2101 }) + }) +}) diff --git a/executor/Cargo.lock b/executor/Cargo.lock index a2a99641..206fd688 100644 --- a/executor/Cargo.lock +++ b/executor/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + [[package]] name = "aead" version = "0.4.3" @@ -50,9 +59,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.65" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "arrayref" @@ -75,6 +84,66 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +[[package]] +name = "async-channel" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +dependencies = [ + "concurrent-queue 2.0.0", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" +dependencies = [ + "async-task", + "concurrent-queue 1.2.4", + "fastrand", + "futures-lite", + "once_cell", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +dependencies = [ + "async-channel", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", +] + +[[package]] +name = "async-io" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e21f3a490c72b3b0cf44962180e60045de2925d8dff97918f7ee43c8f637c7" +dependencies = [ + "autocfg", + "concurrent-queue 1.2.4", + "futures-lite", + "libc", + "log", + "once_cell", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "winapi", +] + [[package]] name = "async-lock" version = "2.5.0" @@ -84,6 +153,38 @@ dependencies = [ "event-listener", ] +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-task" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" + [[package]] name = "async-trait" version = "0.1.57" @@ -104,6 +205,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + [[package]] name = "atty" version = "0.2.14" @@ -136,6 +243,15 @@ dependencies = [ "serde", ] +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bip39" version = "1.0.1" @@ -195,6 +311,20 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" +dependencies = [ + "async-channel", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", + "once_cell", +] + [[package]] name = "bs58" version = "0.4.0" @@ -225,6 +355,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +[[package]] +name = "cache-padded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" + [[package]] name = "cc" version = "1.0.73" @@ -266,6 +402,7 @@ dependencies = [ name = "chopsticks-executor" version = "0.2.0" dependencies = [ + "arrayvec 0.7.2", "clap", "console_error_panic_hook", "console_log", @@ -330,6 +467,24 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "concurrent-queue" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +dependencies = [ + "cache-padded", +] + +[[package]] +name = "concurrent-queue" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -378,6 +533,15 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + [[package]] name = "cpufeatures" version = "0.2.5" @@ -387,11 +551,133 @@ dependencies = [ "libc", ] +[[package]] +name = "cranelift-bforest" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62c772976416112fa4484cbd688cb6fb35fd430005c1c586224fc014018abad" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b40ed2dd13c2ac7e24f88a3090c68ad3414eb1d066a95f8f1f7b3b819cb4e46" +dependencies = [ + "arrayvec 0.7.2", + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-egraph", + "cranelift-entity", + "cranelift-isle", + "gimli", + "log", + "regalloc2", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb927a8f1c27c34ee3759b6b0ffa528d2330405d5cc4511f0cab33fe2279f4b5" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43dfa417b884a9ab488d95fd6b93b25e959321fe7bfd7a0a960ba5d7fb7ab927" + +[[package]] +name = "cranelift-egraph" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a66b39785efd8513d2cca967ede56d6cc57c8d7986a595c7c47d0c78de8dce" +dependencies = [ + "cranelift-entity", + "fxhash", + "hashbrown 0.12.3", + "indexmap", + "log", + "smallvec", +] + +[[package]] +name = "cranelift-entity" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0637ffde963cb5d759bc4d454cfa364b6509e6c74cdaa21298add0ed9276f346" +dependencies = [ + "serde", +] + +[[package]] +name = "cranelift-frontend" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb72b8342685e850cb037350418f62cc4fc55d6c2eb9c7ca01b82f9f1a6f3d56" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "850579cb9e4b448f7c301f1e6e6cbad99abe3f1f1d878a4994cb66e33c6db8cd" + +[[package]] +name = "cranelift-native" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d0a279e5bcba3e0466c734d8d8eb6bfc1ad29e95c37f3e4955b492b5616335e" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.90.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6b8c5e7ffb754093fb89ec4bd4f9dbb9f1c955427299e334917d284745835c2" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + [[package]] name = "crossbeam-queue" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd42583b04998a5363558e5f9291ee5a5ff6b49944332103f251e7479a82aa7" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" dependencies = [ "cfg-if", "crossbeam-utils", @@ -432,6 +718,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "ctr" version = "0.8.0" @@ -526,7 +822,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" dependencies = [ "curve25519-dalek 3.2.0", - "hashbrown", + "hashbrown 0.12.3", "hex", "rand_core 0.6.4", "sha2 0.9.9", @@ -539,12 +835,48 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "event-listener" version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + [[package]] name = "fnv" version = "1.0.7" @@ -591,6 +923,7 @@ dependencies = [ "futures-core", "futures-task", "futures-util", + "num_cpus", ] [[package]] @@ -599,6 +932,21 @@ version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + [[package]] name = "futures-macro" version = "0.3.25" @@ -650,6 +998,15 @@ dependencies = [ "slab", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.6" @@ -683,6 +1040,17 @@ dependencies = [ "polyval", ] +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "gloo-net" version = "0.2.4" @@ -735,6 +1103,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" +dependencies = [ "serde", ] @@ -823,6 +1199,32 @@ dependencies = [ "syn", ] +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ce5ef949d49ee85593fc4d3f3f95ad61657076395cbbce23e2121fc5542074" + [[package]] name = "itertools" version = "0.10.5" @@ -849,9 +1251,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bd0d559d5e679b1ab2f869b486a11182923863b1b3ee8b421763cdd707b783a" +checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" dependencies = [ "jsonrpsee-core", "jsonrpsee-proc-macros", @@ -863,9 +1265,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8752740ecd374bcbf8b69f3e80b0327942df76f793f8d4e60d3355650c31fb74" +checksum = "965de52763f2004bc91ac5bcec504192440f0b568a5d621c59d9dbd6f886c3fb" dependencies = [ "anyhow", "futures-channel", @@ -888,9 +1290,9 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3dc3e9cf2ba50b7b1d7d76a667619f82846caa39e8e8daa8a4962d74acaddca" +checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" dependencies = [ "anyhow", "async-lock", @@ -906,16 +1308,16 @@ dependencies = [ "thiserror", "tokio", "tracing", - "tracing-futures", "wasm-bindgen-futures", ] [[package]] name = "jsonrpsee-proc-macros" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd67957d4280217247588ac86614ead007b301ca2fa9f19c19f880a536f029e3" +checksum = "baa6da1e4199c10d7b1d0a6e5e8bd8e55f351163b6f4b3cbb044672a69bd4c1c" dependencies = [ + "heck", "proc-macro-crate", "proc-macro2", "quote", @@ -924,9 +1326,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e290bba767401b646812f608c099b922d8142603c9e73a50fb192d3ac86f4a0d" +checksum = "5bd522fe1ce3702fd94812965d7bb7a3364b1c9aba743944c5a00529aae80f8c" dependencies = [ "anyhow", "beef", @@ -938,9 +1340,9 @@ dependencies = [ [[package]] name = "jsonrpsee-wasm-client" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597b4eb94730e7695d0a2a429bc37a12e6e84d12680fdafb9b8f5f53652aab57" +checksum = "a77310456f43c6c89bcba1f6b2fc2a28300da7c341f320f5128f8c83cc63232d" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -949,9 +1351,9 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.15.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ee5feddd5188e62ac08fcf0e56478138e581509d4730f3f7be9b57dd402a4ff" +checksum = "0b83daeecfc6517cfe210df24e570fb06213533dfb990318fae781f4c7119dd9" dependencies = [ "http", "jsonrpsee-client-transport", @@ -965,6 +1367,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -1031,6 +1442,12 @@ dependencies = [ "libsecp256k1-core", ] +[[package]] +name = "linux-raw-sys" +version = "0.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" + [[package]] name = "lock_api" version = "0.4.9" @@ -1048,6 +1465,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", + "value-bag", +] + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", ] [[package]] @@ -1056,6 +1483,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "memory_units" version = "0.3.0" @@ -1177,6 +1613,18 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "crc32fast", + "hashbrown 0.12.3", + "indexmap", + "memchr", +] + [[package]] name = "once_cell" version = "1.15.0" @@ -1231,6 +1679,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1254,6 +1708,12 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + [[package]] name = "pbkdf2" version = "0.11.0" @@ -1295,6 +1755,20 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "polling" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "166ca89eb77fd403230b9c156612965a81e094ec6ec3aa13663d4c8b113fa748" +dependencies = [ + "autocfg", + "cfg-if", + "libc", + "log", + "wepoll-ffi", + "windows-sys 0.42.0", +] + [[package]] name = "poly1305" version = "0.7.2" @@ -1368,6 +1842,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + [[package]] name = "quote" version = "1.0.21" @@ -1428,6 +1911,18 @@ dependencies = [ "bitflags", ] +[[package]] +name = "regalloc2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91b2eab54204ea0117fe9a060537e0b07a4e72f7c7d182361ecc346cab2240e5" +dependencies = [ + "fxhash", + "log", + "slice-group-by", + "smallvec", +] + [[package]] name = "ring" version = "0.16.20" @@ -1443,6 +1938,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1458,6 +1959,20 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.35.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.42.0", +] + [[package]] name = "rustls" version = "0.20.7" @@ -1587,9 +2102,9 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] @@ -1607,9 +2122,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -1618,9 +2133,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" dependencies = [ "itoa", "ryu", @@ -1688,6 +2203,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slice-group-by" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" + [[package]] name = "smallvec" version = "1.10.0" @@ -1696,9 +2217,11 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "smoldot" -version = "0.4.0" +version = "0.5.0" dependencies = [ + "anyhow", "arrayvec 0.7.2", + "async-std", "atomic", "base64", "bip39", @@ -1711,7 +2234,7 @@ dependencies = [ "event-listener", "fnv", "futures", - "hashbrown", + "hashbrown 0.13.1", "hex", "hmac 0.12.1", "itertools", @@ -1724,6 +2247,7 @@ dependencies = [ "num-traits", "parity-scale-codec", "pbkdf2", + "pin-project", "rand", "rand_chacha", "ruzstd", @@ -1735,9 +2259,11 @@ dependencies = [ "slab", "smallvec", "snow", + "soketto", "tiny-keccak", "twox-hash", "wasmi", + "wasmtime", ] [[package]] @@ -1787,6 +2313,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "static_assertions" version = "1.1.0" @@ -1813,9 +2345,9 @@ checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" [[package]] name = "syn" -version = "1.0.102" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" dependencies = [ "proc-macro2", "quote", @@ -1834,6 +2366,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "target-lexicon" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" + [[package]] name = "termcolor" version = "1.1.3" @@ -1969,16 +2507,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - [[package]] name = "twox-hash" version = "1.6.3" @@ -2023,12 +2551,28 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "value-bag" +version = "1.0.0-alpha.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" +dependencies = [ + "ctor", + "version_check", +] + [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2127,6 +2671,186 @@ dependencies = [ "parity-wasm", ] +[[package]] +name = "wasmparser" +version = "0.93.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5a4460aa3e271fa180b6a5d003e728f3963fb30e3ba0fa7c9634caa06049328" +dependencies = [ + "indexmap", +] + +[[package]] +name = "wasmtime" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d18265705b1c49218776577d9f301d79ab06888c7f4a32e2ed24e68a55738ce7" +dependencies = [ + "anyhow", + "async-trait", + "bincode", + "cfg-if", + "indexmap", + "libc", + "log", + "object", + "once_cell", + "paste", + "psm", + "serde", + "target-lexicon", + "wasmparser", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit", + "wasmtime-runtime", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a201583f6c79b96e74dcce748fa44fb2958f474ef13c93f880ea4d3bed31ae4f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-cranelift" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe208297e045ea0ee6702be88772ea40f918d55fbd4163981a4699aff034b634" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "object", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-environ" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754b97f7441ac780a7fa738db5b9c23c1b70ef4abccd8ad205ada5669d196ba2" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-fiber" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5f54abc960b4a055ba16b942cbbd1da641e0ad44cc97a7608f3d43c069b120e" +dependencies = [ + "cc", + "cfg-if", + "rustix", + "wasmtime-asm-macros", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-jit" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32800cb6e29faabab7056593f70a4c00c65c75c365aaf05406933f2169d0c22f" +dependencies = [ + "addr2line", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli", + "log", + "object", + "rustc-demangle", + "serde", + "target-lexicon", + "thiserror", + "wasmtime-environ", + "wasmtime-jit-icache-coherence", + "wasmtime-runtime", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe057012a0ba6cee3685af1e923d6e0a6cb9baf15fb3ffa4be3d7f712c7dec42" +dependencies = [ + "once_cell", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6bbabb309c06cc238ee91b1455b748c45f0bdcab0dda2c2db85b0a1e69fcb66" +dependencies = [ + "cfg-if", + "libc", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-runtime" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a23b6e138e89594c0189162e524a29e217aec8f9a4e1959a34f74c64e8d17d" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "indexmap", + "libc", + "log", + "mach", + "memoffset", + "paste", + "rand", + "rustix", + "thiserror", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit-debug", + "windows-sys 0.36.1", +] + +[[package]] +name = "wasmtime-types" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ec7615fde8c79737f1345d81f0b18da83b3db929a87b4604f27c932246d1e2" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser", +] + [[package]] name = "web-sys" version = "0.3.60" @@ -2156,6 +2880,15 @@ dependencies = [ "webpki", ] +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/executor/Cargo.toml b/executor/Cargo.toml index a59f58a6..76abdc92 100644 --- a/executor/Cargo.toml +++ b/executor/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib"] [dependencies] getrandom = { version = "0.2", default-features = false, features = ["js"] } -jsonrpsee = { version = "0.15.1", default-features = false, features = ["wasm-client", "macros"] } +jsonrpsee = { version = "0.16.2", default-features = false, features = ["wasm-client", "macros"] } serde = { version = "1.0.136", default-features = false } serde_json = { version = "1.0", default-features = false } hex = { version = "0.4.3", default-features = false } @@ -28,10 +28,17 @@ tokio = { version = "1.21.2", features = ["full"], optional = true } smoldot = { path = '../vendor/smoldot', default-features = false } +[dev-dependencies] +arrayvec = { version = "0.7.2", default-features = false } + [features] default = ["std"] std = [ "clap", "tokio", - "jsonrpsee/ws-client" + "jsonrpsee/ws-client", + "smoldot/std" ] + +[package.metadata.wasm-pack.profile.release] +wasm-opt = false diff --git a/executor/pkg/package.json b/executor/pkg/package.json index 68ae8aff..38dd7519 100644 --- a/executor/pkg/package.json +++ b/executor/pkg/package.json @@ -8,4 +8,4 @@ ], "main": "chopsticks_executor.js", "types": "chopsticks_executor.d.ts" -} \ No newline at end of file +} diff --git a/executor/src/lib.rs b/executor/src/lib.rs index 2da86d34..44598b29 100644 --- a/executor/src/lib.rs +++ b/executor/src/lib.rs @@ -2,12 +2,14 @@ extern crate console_error_panic_hook; use futures::prelude::*; use jsonrpsee::core::client::Client; +use std::collections::BTreeMap; use wasm_bindgen::prelude::*; +mod proof; mod runner_api; mod task; use crate::runner_api::RpcApiClient; -use smoldot::json_rpc::methods::HexString; +use smoldot::json_rpc::methods::{HashHexString, HexString}; #[wasm_bindgen] pub async fn get_metadata(code: &str) -> Result { @@ -47,6 +49,39 @@ pub async fn calculate_state_root(entries: JsValue) -> Result Ok(hash.to_string().into()) } +#[wasm_bindgen] +pub async fn decode_proof( + root_trie_hash: JsValue, + keys: JsValue, + nodes: JsValue, +) -> Result { + std::panic::set_hook(Box::new(console_error_panic_hook::hook)); + _ = console_log::init_with_level(log::Level::Debug); + let root_trie_hash = serde_wasm_bindgen::from_value::(root_trie_hash)?; + let keys = serde_wasm_bindgen::from_value::>(keys)?; + let nodes = serde_wasm_bindgen::from_value::(nodes)?; + let entries = proof::decode_proof(root_trie_hash, keys, nodes.0).map_err(|e| e.to_string())?; + let result = serde_wasm_bindgen::to_value(&entries)?; + Ok(result) +} + +#[wasm_bindgen] +pub async fn create_proof( + root_trie_hash: JsValue, + nodes: JsValue, + entries: JsValue, +) -> Result { + std::panic::set_hook(Box::new(console_error_panic_hook::hook)); + _ = console_log::init_with_level(log::Level::Debug); + let root_trie_hash = serde_wasm_bindgen::from_value::(root_trie_hash)?; + let proof = serde_wasm_bindgen::from_value::(nodes)?; + let entries = serde_wasm_bindgen::from_value::>(entries)?; + let entries = BTreeMap::from_iter(entries.into_iter().map(|(key, value)| (key.0, value.0))); + let proof = proof::create_proof(root_trie_hash, proof.0, entries).map_err(|e| e.to_string())?; + let result = serde_wasm_bindgen::to_value(&proof)?; + Ok(result) +} + #[wasm_bindgen] pub async fn run_task(task_id: u32, ws_url: &str) -> Result<(), JsValue> { std::panic::set_hook(Box::new(console_error_panic_hook::hook)); diff --git a/executor/src/proof.rs b/executor/src/proof.rs new file mode 100644 index 00000000..29581321 --- /dev/null +++ b/executor/src/proof.rs @@ -0,0 +1,298 @@ +use jsonrpsee::core::Error; +use smoldot::json_rpc::methods::{HashHexString, HexString}; +use smoldot::trie::{ + bytes_to_nibbles, + proof_decode::{decode_and_verify_proof, Config}, + proof_encode::ProofBuilder, + proof_node_codec, trie_structure, Nibble, +}; +use std::collections::BTreeMap; + +pub fn decode_proof( + hash: HashHexString, + keys: Vec, + proof: Vec, +) -> Result)>, Error> { + let config = Config::> { + trie_root_hash: &hash.0, + proof, + }; + let decoded = decode_and_verify_proof(config).map_err(|e| Error::Custom(e.to_string()))?; + + let entries = keys + .into_iter() + .map(|key| { + let value = decoded.storage_value(key.as_ref()); + if let Some(value) = value { + return (key, value.map(|value| HexString(value.to_owned()))); + } + (key, None) + }) + .collect::>(); + + Ok(entries) +} + +pub fn create_proof( + hash: HashHexString, + proof: Vec, + entries: BTreeMap, Vec>, +) -> Result<(HashHexString, Vec), Error> { + let config = Config::> { + trie_root_hash: &hash.0, + proof, + }; + let decoded = decode_and_verify_proof(config).map_err(|e| Error::Custom(e.to_string()))?; + let mut proof_builder = ProofBuilder::new(); + + let mut trie = trie_structure::TrieStructure::new(); + + for (key, value) in entries { + trie.node(bytes_to_nibbles(key.iter().cloned())) + .into_vacant() + .unwrap() + .insert_storage_value() + .insert(value.to_vec(), vec![]); + } + + for (key, value) in decoded.iter_ordered() { + let decoded_value = proof_node_codec::decode(value.node_value).unwrap(); + + if let trie_structure::Entry::Vacant(vacant) = trie.node(key.iter().map(|x| x.to_owned())) { + if let proof_node_codec::StorageValue::Unhashed(value) = decoded_value.storage_value { + vacant.insert_storage_value().insert(value.to_vec(), vec![]); + } + } + } + + for node_index in trie.clone().iter_unordered() { + let key = trie + .node_full_key_by_index(node_index) + .unwrap() + .collect::>(); + + let has_storage_value = trie.node_by_index(node_index).unwrap().has_storage_value(); + let storage_value = if has_storage_value { + trie.node_by_index(node_index) + .unwrap() + .into_storage() + .unwrap() + .user_data() + .clone() + } else { + vec![] + }; + + let decoded = proof_node_codec::Decoded { + children: std::array::from_fn(|nibble| { + let nibble = Nibble::try_from(u8::try_from(nibble).unwrap()).unwrap(); + if trie + .node_by_index(node_index) + .unwrap() + .child_user_data(nibble) + .is_some() + { + Some(&[][..]) + } else { + None + } + }), + partial_key: trie + .node_by_index(node_index) + .unwrap() + .partial_key() + .collect::>() + .into_iter(), + storage_value: if has_storage_value { + proof_node_codec::StorageValue::Unhashed(&storage_value[..]) + } else { + proof_node_codec::StorageValue::None + }, + }; + + proof_builder.set_node_value(&key, &proof_node_codec::encode_to_vec(decoded), None) + } + + assert!(proof_builder.missing_node_values().next().is_none()); + proof_builder.make_coherent(); + let trie_root_hash = proof_builder.trie_root_hash().unwrap(); + + let nodes = proof_builder + .build() + .map(|x| HexString(x.as_ref().to_vec())) + .into_iter() + .skip(1) // length of nodes + .enumerate() + .filter(|(i, _)| i % 2 != 0) // length of each nodes + .map(|(_, v)| v) // node itself + .collect::>(); + + Ok((HashHexString(trie_root_hash), nodes)) +} + +#[test] +fn create_proof_works() { + use hex_literal::hex; + + let root = HashHexString(hex!( + "4a8902b29241020b24b4a1620d0154f756b81ffbcf739a9f06d3447df8123ebd" + )); + + let entries = BTreeMap::, Vec>::from([ + ( + hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385").to_vec(), + hex!("000030000080000008000000000010000000100005000000050000000a0000000a000000000050000000100000e8764817000000040000000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000400000000001000b0040000000000000000000014000000040000000400000000000000010100000000060000006400000002000000c8000000020000001900000000000000020000000200000000c817a804000000").to_vec() + ), + ( + hex!("cd710b30bd2eab0352ddcc26417aa1949e94c040f5e73d9b7addd6cb603d15d363f5a4efb16ffa83d0070000").to_vec(), + hex!("01").to_vec() + ) + ]); + + let (hash, nodes) = create_proof(root, get_proof(), entries).unwrap(); + + let keys = vec![ + HexString( + hex!("63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce563f5a4efb16ffa83d0070000").to_vec(), + ), + HexString( + hex!("06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385").to_vec(), + ), + HexString( + hex!("cd710b30bd2eab0352ddcc26417aa1949e94c040f5e73d9b7addd6cb603d15d363f5a4efb16ffa83d0070000").to_vec() + ) + ]; + let decoded = decode_proof( + hash, + keys, + encode_proofs(nodes.iter().map(|x| x.0.clone()).collect::>()), + ) + .unwrap(); + let (key, value) = decoded[0].to_owned(); + assert_eq!(key, HexString(hex!("63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce563f5a4efb16ffa83d0070000").to_vec())); + assert_eq!( + value, + Some(HexString( + hex!("d205bfd64a59c64fe84480fda7dafd773cb029530c4efe8441bf1f4332bfa48a").to_vec() + )) + ); +} + +#[cfg(test)] +/// Returns a buffer containing the SCALE-compact encoding of the parameter. +fn encode_scale_compact_usize(mut value: usize) -> impl AsRef<[u8]> + Clone { + const MAX_BITS: usize = 1 + (usize::BITS as usize) / 8; + let mut array = arrayvec::ArrayVec::::new(); + + if value < 64 { + array.push(u8::try_from(value).unwrap() << 2); + } else if value < (1 << 14) { + array.push((u8::try_from(value & 0b111111).unwrap() << 2) | 0b01); + array.push(u8::try_from((value >> 6) & 0xff).unwrap()); + } else if value < (1 << 30) { + array.push((u8::try_from(value & 0b111111).unwrap() << 2) | 0b10); + array.push(u8::try_from((value >> 6) & 0xff).unwrap()); + array.push(u8::try_from((value >> 14) & 0xff).unwrap()); + array.push(u8::try_from((value >> 22) & 0xff).unwrap()); + } else { + array.push(0); + while value != 0 { + array.push(u8::try_from(value & 0xff).unwrap()); + value >>= 8; + } + array[0] = (u8::try_from(array.len() - 1 - 4).unwrap() << 2) | 0b11; + } + + array +} + +#[test] +fn decode_proof_works() { + use hex_literal::hex; + + let root = HashHexString(hex!( + "4a8902b29241020b24b4a1620d0154f756b81ffbcf739a9f06d3447df8123ebd" + )); + let keys = vec![ + HexString(hex!("63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce563f5a4efb16ffa83d0070000").to_vec()), HexString( + hex!("cd710b30bd2eab0352ddcc26417aa1949e94c040f5e73d9b7addd6cb603d15d363f5a4efb16ffa83d0070000").to_vec() + )]; + let result = decode_proof(root, keys, get_proof()).unwrap(); + println!("{:#?}", result); +} + +#[cfg(test)] +fn encode_proofs(nodes: Vec>) -> Vec { + let mut proof = encode_scale_compact_usize(nodes.len()).as_ref().to_vec(); + for mut node in nodes { + let mut node_length = encode_scale_compact_usize(node.len()).as_ref().to_vec(); + proof.append(&mut node_length); + proof.append(&mut node); + } + proof +} + +#[cfg(test)] +fn get_proof() -> Vec { + use hex_literal::hex; + let nodes = vec![ + hex!("5703f5a4efb16ffa83d007000080d205bfd64a59c64fe84480fda7dafd773cb029530c4efe8441bf1f4332bfa48a").to_vec(), + hex!("5703f5a4efb16ffa83d00700008420e8030000d4070000d6070000db070000dc070000f0070000f2070000f3070000").to_vec(), + hex!("5c8c2de8299067f3070000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5d0452a22bee61fad0070000f20700005501e80300000090010000900100000000000000000001e41d29d36ff0b7c6007ec17b68ba6165066170fc67eb9755fbd7ed60bef647c100e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5d04d2a15ab51127e8030000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5d07edc4cbc65e03d0070000d40700005501e80300000090010000900100000000000000000001708391b220ce64bab1cc4f79559352e59882ee5bb58329085c2400079c56153a00e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5d0b652b2ae6ed1ddc070000d00700005501e803000000900100009001000000000000000000010a492e67d36615052a89ba50498ed5cf0a587b31fd6f3da464e5d111e4e8a81c00e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5d0be1ee506d55f8d0070000f3070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5d0c472775baca93f0070000d00700005501e803000000900100009001000000000000000000013b264b3f72ecfeddbdad3b409887206a18d387f1b81856c0383014c9f559992000e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5e046fae65527199f2070000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5e057a605f506cfcd4070000d00700005501e80300000090010000900100000000000000000001d3772d60305c2cbd7acf502a11881e0eef47fdfc85c7d2a0d6241e06ea4a971000e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5e36ad4314650419d0070000f00700005501e80300000090010000900100000000000000000001de18e43e692ffe15ea7a85abbce774e6944c56270a846777352827c7596f6c3e00e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5e36c65ca123d5fbd0070000dc0700005501e80300000090010000900100000000000000000001c5120071fe1663a5a21b96d87446ac903ef1bf87dd729b8b9e92ca42ca303e7400e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5e414cb008e0e61e46722aa60abdd67280b46e626e564d1385d21257d8cb59236ca125657f2a14bebd1af174317ca1055c").to_vec(), + hex!("5e4361975d97255ddb070000d00700005501e803000000900100009001000000000000000000018c74408c28f6627f58a8e10b3ec06b98b0166bfb148641a35c5cdfc7a56e68fb00e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5e4f36708366b722d0070000e8030000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5e55c8e02d73966fd6070000d00700005501e803000000900100009001000000000000000000019a436c9ae233f8b3cc6a379dc35ff6a3c4153b22a96db9fc81c9cee506a252b900e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5e77dfdb8adb10f78f10a5df8742c545840159a565b0fb89d8eec07b522e4e30e8bc29489ef7a9609dfec01855bd125d2e33").to_vec(), + hex!("5ea99274c2ff3639d0070000d60700005501e80300000090010000900100000000000000000001d10c375b7f3756dd38a6fd0967fa4a92199606619c76c5aedc139eb584e8628b00e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5ec648b30353eed1d0070000db0700005501e8030000009001000090010000000000000000000100382d804f7b02c95c2d6b3b6a9cad2c97c2d7570bdfd32f8e8d961754b74b6d00e8764817000000000000000000000000e87648170000000000000000000000").to_vec(), + hex!("5ee678799d3eff024253b90e84927cc68013c6d5340826d75f6258aad1cf4478c20cae5bbaf189e2fe6e0c997aec0a8c3c").to_vec(), + hex!("5f04b49d95320d9021994c850f25b8e3852d030000a000005000000a00000000c8000000c800000a0000000a00000040380000580200000000500000c8000000e87648170000001e0000000000000000e8764817000000000000000000000000e87648170000000000000000000000e8030000009001001e00000000000000009001004038000000000000000000000a0000000a0000000a00000001000000010500000001c8000000060000005802000002000000580200000200000059000000000000001e0000002800000000c817a804000000000200000014000000").to_vec(), + hex!("800014808fc31cedc9f5a694fdde1823788928749f52e1c637dfbf315637fd89eace451c80b58f7e709e14c8ad32651a7b6f13b2ee8aa4a9566413b985e64eb5f3918a58e9").to_vec(), + hex!("800102802dcdd284f422a6ebda6a6f25c88e3ffe11d1adba81950ba92c640b042c250b1080c3883d3173954c1f95c3cb0612d3445f79eaf866255c3261671c3d50a480dcca").to_vec(), + hex!("80011080453fad35c0a01e1a2af068a21c24622fe089db8330ff1c3d52d3a00c7504e515800ebe650369ce0e3ce85b22816181f598cc6ecf7a3b22314357ab4181b9ccb867").to_vec(), + hex!("80011080bfead2545bbb18bbeccbbc42e419ce81be803a019bc10bc035e040209109ca708029f01a3bcd0dedb0dd8e6953b1c52deb161fb6f06b943a1934bd80506ac8f8ff").to_vec(), + hex!("80046480f2126bccffb3e85172709b56414860c2d5aef6fbdca97efb91b0c7989b2e767c809bbc710130cd3fd1008762577f5a4f1959819fefe31aa2eb38c950b5b0ac16748022cba5584bc0982277b50978b65dd7c8c3702937804ae5b16b7b2dbae18122ff80c2e805afdfad80977cb420fe3c56c481131d8e6575e9dac18bfb48ee70bc5a93").to_vec(), + hex!("80080480b64e0437daeee2d16022caa8e4cb67d9bfff7c5feb34dbbe044da77783421f78809ffe6dc440b4ca64053f01647b2e2d3284a4be15517f6693ee26fe4a84cc8a7b").to_vec(), + hex!("8008208057bb9d54329c52084dafd34bb7a12ae243ed81b29438b7941ad6b08bc0aab080485ead6eef5c4b1c68eaa71ea17a02d9de0400").to_vec(), + hex!("8008c280666c2b4c33ef871664a1cd5f75688bd687415a95f52a12fdaff5e1bb1d714f958049da90db410ddc5fcb63a6ba31fff1140f1f027eab9f575207946938a6dff0498032b1eb1b88050e8be5253bc631c21e5bb73b440ae1188f1da9e141aea5050345800892f12109affae95d1fa83c3e98639ce4aa22b3317846989ac8cc46a37ff2bf").to_vec(), + hex!("801017800bd4a887368b253b446f6743e0b8b47e3384a11be255c56869ac5c22c8989dd8800bce23fe3d2d5b8d0e3a26b96ca234ad713326991a44cb1f30acd20cb8eb400080b47bdf3c44e033a0f6273db0e4d3c805462f92c8ec58046e6ece49d93264edaf80ea85a25e4978d8d9281242dec4943257cfb4d14f3408640b5e643f247d38a91c808a15b3c07f5df5f0771146cf6adb06d2d2af1c9c569c70e42d3d881e60c49cb8").to_vec(), + hex!("801040809d953a8e74f031a6e10d7532012f6e655a37c85c4e37454174b98a7b92ced3f9805f738e2d7016159bb83f0acfc05b94f3bfed39826328fbea9a5a6844b0ee9f62").to_vec(), + hex!("801200802c2bdbfc1bde7cdde01a4db7315c02e0373e1c8b826258e135ded3ca12b9b0e580a18673b451b154098a7a400495526a375c86a62e3c8f6def0a67b00eb6d26e87").to_vec(), + hex!("80132680db8ba95d9fa6771a636c09a99827a9ef71777f6507eb4f789de5e137a7250d3780d99bcdfbfe4d2ba16f4dfaa93a02a3853cbc7912bad01d8f89acd4a18e318e9d807e84d35633382d5c74d5c446d26db1cc01db605ba0c12d399849032872bb731280ac082de8a8e688e9aa6c8d9f06576be0b982e6f7229e7b1f3a0d0cbff4e9cbce80e8f2d389ed545a028c6321d265c650179ed1c671fcfbc417185682c21667059b80a512dfa55fcf04f7e26b5ccdc14466086df66928a4f54dfb12b9873108dbfe88").to_vec(), + hex!("8028388028462a6785718dce363f9fa86db6e6885c1df439739c06df2670b71ca7d1d6ab80f12b3be1de5704b86affeaf4178a0ca8dea056893c12a03c3500ca8af78c128080ae634ca22841dbcd3de33dfcd0730d87335dc93786dec63ff9ff5c494b1c32d2802166c372b218427bae449c6e50a075b4bc604253cea4ad0ee8ee7c16b498f3e9808b81a047e908564423ad8d63ef1677199bb5d41570df5ce359ec0cdc5a66fc06").to_vec(), + hex!("80324680aa309aa88e45c23a7b3361cb9ac5bde5896dde657e8a562ce46cd5587674824080f7f61a745a9fefb91f35658a78ebc397ad0514232c0eec10344331b9a29195b680480c6b47252c3414177fcd8441cc689703241343e1ef84be0b206cc24b043f1c80608329e88f9837bedc55fa039c1c5468fe76304edacab49f89a35685ce0492748043a4144332df717cb9ac20b2b490345f22543965ea5272ce3511fa98f4ddfdcb80c62f5d20c25775fb8a8abded53ae1f6abd8fb9f9d75e306a1973194a9a739f73").to_vec(), + hex!("804008804c9c79007d5b06217f77869639dbf475761b1d45115441ea15641d7db01d2425808c68f773671aec1db46b2c37b4c827e64aa7290d65e305cdaaa6b175596256f1").to_vec(), + hex!("8041088041558830b346eebf7648fb84310d961de185de6ebc1bd22d114980d7793d6ee1804e23dcce96d9e514271688cf0bc5581e5e6e74cc4e079c39e75490ac45272f668071daa4762bcd3732d275bee68e3bb098a140029d7b01e82b4cd106924313f9f6").to_vec(), + hex!("80505480a1fc2c779380c33b94b304c281e55ca5a0807804fe9530c22fdfa76628beb42680a1a8a2d4670241007470d59433dc876b10443654c68ee2c22e43f0505fb7081380cbc649bccb6cbe2678b258eb56b9985865852f8dc3ca4ac4608b46dc9a61a56580379357c2c5523ead8e26c2bd4d0ce06ca7f1726b09ef513a7d501aaa5752368280692755c9209155bd724071de137657f492de5bb5479738d1af7119739b4df473").to_vec(), + hex!("80650080021eceb7212a84c0ce28538807a932d56f7ca04ad18a37eb5a3d81cf2d3a1e888028c2012c52668080a70a29a2704a0e1d108658aa94f21e0dcd5103401c52fff3809264b71d425330b4faf06bc3855662ae7511e854ed5387b3ee8c3fafcd6772d080af579d5ddc5c697d42bfc014076594e66c7b324cfd3017810c4e93e4f6f0ae9e").to_vec(), + hex!("8080018068269bb8490669b94a5f1e0c3b4864e03224a2048271f11b8a95ea6168756573805dc031eeca4040dfb7be6e148287360e67d5ce62125f23d912e7ba6b5e1c3ea8").to_vec(), + hex!("8086108046ea793674e4b7c40067c83aa00ac2fbbf3d2ebd57e01d5065909769da0ea9a2801eacd1970b27e7428c46fc7a1cd539390d664880f8665d1f5d9df711aef78ffc807b7ad6eb73914fd07fc55ad89ba771070c1da532a9269475dc64f1995d4d92668044a0d27ae2362402e5ac6666cbfd7bcaa530f2ea97a73b328a13ece4264ea290").to_vec(), + hex!("80a06b8001abdee51ff39c1b87147abb00a81ce05a7b7bbd43dc1509cb4d97acdf3f8e6d80a296acd1c3810d5724e101343410a44934ed827a0c6931e538c2fc095adac046806661dfd17874a64f7f8e2a1e88db6fe81031f845e8705d6470bd48bef2d9615080df3c444cc602cfb8e35514a12c70fe2f5b2ec2683a3e19889c2bce42e8df423180decf6a9a942e385c520acce9b20917c7a516fee686baab2ca15379828a54ec09808cc9995c94f73aec7861dcd2bb4e389eefad87f4d8c1ece831dbcae8c85f2ab4808bbdb281c19f2e0405ebdcdd3eed583c83be8c5bf317070ab8e144c77aecab54").to_vec(), + hex!("80a090809d70976e45bed6bfbe01cc3a2d2fc8d707784be7b54c5910eda9d60dbaa8dcda80c7d17ef601008c6b5fb577a67c8c0ed8f8a1b4eea0109830cddfc3d05c5955b8808fac6f5b26a0a091512ba579c768e78cd75b5f91ff02dcd27a011a1b9d3f8ca0805fc8b08bf7e5d96506fca5e15f58b00e5857510be132ddf21222fdc441242af5").to_vec(), + hex!("80ffff80c66d277de66aaf06e0d6a1fc26ce21d8f6ef50ff28e14dbccfb2fa5bfbd0e5d680f219622acbd014476d4edb56ff6b86554c683a93a217b9ee5449d5f97350aba980daacb402b9d9534826030a1a087c3a6064f823d9578216b50dcc839b4a1cb4f080538c5f0315259d01b9589faf05886e3222ad437f11afbc79f8ca8fd1a706948b803b47dc6cc57a291d93e562eb748a4f6d5ba08cbd1b4b9980117eceff1ce541f08080b4dd653d14508ffe4e711984c6daebb8c53ffc701bc6c390f170524fe6067e806881eae5c901b2f9da23fc14a7b5c5adddf42803d9e6f6457502263d5c20d1b180552af8589e75bd85f77e14ad29a64b58bf27795087e0f8405f00e0af8c44769180f778234884d04539ae5ee94481786900f08bec239bc9e8a495e44f56ae62bd6f8058c056dc712c11a8aacceb99692e0b12b11fa7d127c512373d6a9312e4b7aa12800b7d692bbe193862e80155a0c60d515e359fc0711797aa73b963f8de206372318032b4da4f9707c28268fda915bad17740b2f29044af3426b93dddb1525d9119a180712826eb964d50810e03c64f0465e9d0aefba0975922e3546c1dd289ae6485ab803fc6afb3bb1a772c1b7865d617175918a1e561e7f9f6d4b3727e2e77d8cd54fd80b84b7a6e9b8ac582dfe53a66e6da54a2bc42162390b409a4fb1cb4d99e823334805ab928b4a3b5103f34f6d934e7c2a71a08f6160242d5a25e8d395f022137b544").to_vec(), + hex!("8109400180c7192966ab02c8fe706a869d280b1f9e4100cd344a11d14d330d2691c06d838080cc5ba161e4197291e156c96df507a376d778fdd94adb9db8cc0f457222957ed9").to_vec(), + hex!("810f080880d066a00dc79b0a8601ea466d09a4c969c246ed7d8b4f029afcd41944e33ae8b08063fee100c551b8c3283651ee6d6aad37bbe2abd5830b3c17785b691c63857dc5").to_vec(), + hex!("9d0da05ca59913bc38a8630590f2627c07d980d131600ec39249fb7e25ce8b2759cbe5d9d22d65865cbdc5d5b6b43442a037a28064d55117d3f84fb235f2051b42475f6a3c165cb066016a54582116560d278c0180868f6dfc79ccadf3a96cf90a2b80fcc7fe47c77e30cbb2c8b88a6f3ee21a7c0a8039ebc92b31a26e4935b2e3ac747dfd531b73be08467c9918cc70090e0ae8859b80090170c9487096f84239151a9ecf92c1efeece708d87844f19f56988ec479a0d80a83b5e3737bfc99ede5e597406cf5b001b7949a5315953134fc321fc8992c0bd80fe20d9a744142b01474930a28d8b9a5ef3c851504a99fed5a4fec46d0533c7d88015dd6cf6cccb6c66a9e56feb41c47cf30a31d39fa77ec8b2eb55dd742db53921").to_vec(), + hex!("9e207f03cfdce586301014700e2c2593414080776fdf331ededb557c273c87efa8d2e3919d6745e8645214665bf43afed8b5e9685f0d9ef3b78afddab7f5c7142131132ad42001000000000000004c5f0ec2d17a76153ff51817f12d9cfc3c7f0400").to_vec(), + hex!("9e710b30bd2eab0352ddcc26417aa1944fc380926c6b63b2fdc00d98403a06793b323674ed75b32e75389a2c9d19140f48d07b80db9c2d25d50f7d4f8c69ee037a096b488bc42e33d2cfeeeff1fe8fc22c8cc1788034979b2e5ea91011d05f74f35d25c5b0da29c03c2c0e8e6b9f0a49ca32f46e58800e21335793e29a09c8eac52a4ed197378fd1ac3552ff31aecddb063d3f2c2f314c5f03c716fb8fff3de61a883bb76adb34a20400803587aeceb149eff2f59b5270a01e8c4fd19d1722eab53bcd8b5fd2aee0606fc14c5f0f4993f016e2d2f8e5f43be7bb2594860400807d9800e301836dcc17032891ceff52fc4029dcef8fc74a471e164eb06eecadaf80ac20693eb2298f6f300752834c3fc31a3c075a4e9a77a67d7ee3d6982d70e3e1").to_vec(), + hex!("9eb6f36e027abb2091cfb5110ab5087ff96e685f06155b3cd9a8c9e5e9a23fd5dc13a5ed20873c991000000000685f08316cbf8fa0da822a20ac1c55bf1be320cc15000000000000505f0e7b9012096b41c4eb3aaf947f6ea429080000805788707c580bffc1660dc8c31ca562b5adf72d7dda390c9016319224cedab6c08084a80a22d77d8016adc89610b528c15ba17e4522a53faec0e60d84f5130362a580950cc9876d11a25f6c56e833f048b7fc32caf0bfbb8d9ff4b6ea993f4e984698800d49fef039517cc312c00412803ca1df50ac6d90c50541f649a9c85b83c0fdd8807a5d73d6c6a648545a7a8de535f9a12c2f7105d012e0eb272d91fb8ec018a2bf80cc59c8e5010713cf8876c314769c49fbe0b9a6e131ebf5a9774f52fe73d9ac66800c999e682e20f4c5ab236641829330b52e9a60e3bb8295c671ae10b0078b1b39685f090e2fbf2d792cb324bffa9427fe1f0e20b94ccb00fa55cb00").to_vec(), + hex!("9ede3d8a54d27e44a9d5ce189618f22d3008505f0e7b9012096b41c4eb3aaf947f6ea4290802004c5f03b4123b2e186e07fb7bad5dda5f55c00400806b5403551f8463a3ddf5063c0454a5bd46c9c3d2e1030a6a838a27cc0c4b983a").to_vec(), + hex!("9ef78c98723ddc9073523ef3beefda0c1004809efa6d0e486c88a89d0cec81b8d06f9b5b1dcff9db2c44a9bca135e300ee700c80a8a03c435efb3b22807974e7d4ef1ebad070a3e9c608ed0e5112c1d7223ca5ea").to_vec(), + hex!("9f012b746dcf32e843354583c9702cc020cabb80ff9bed925038b8804f63090b1e2cf36d0d987e2e85b24f046ceee2d849dd69ff80d11d71ea91a8cbe9858770d23355ed19ad19a263b94d55f6d6f503c17eb3dd5280bb7fd6b2fa22db69bca4f70304addc539798fc6174ddae0c5865c71ff96e53415c5700bd9a93e85e3ce1d20700002408d6070000dc07000080b67cef76f1fdf97b48c1fcba9594f1ae40742c195b8d950ae7f08e4b3314fb2780fd53aee7d7ccb0767af55024401273b0a9437c5917cdd60d406dac4aab722333801bff773d6d6d765292b4e595ee0cd425bebe341c2f21af1768896cbfb71cc5d04c57077a93d174890f1ff20700001404d0070000806e5feeb98858d49ab4f600b9337280df82041595257c4d566175cbf59cc105f680f44d2eba0587ca4f414fe092f163abb43531c554c28cfcc26cf032083a7af9b4").to_vec(), + hex!("9f06604cff828a6e3f579ca6c59ace013df7ff801afb0ed9ee8eab53f55af9e9f1c49736c6186c5852d7bba27baeab053a2d22fc809c793f0292c00ae878a17876cc7fe3343623734664aeb50333eac67dd4077b40808aaa7d061d20c8b96edc45a36746cfc2f8645b20db12f51ca020ed4967049c20804c9d12d0f9b7ab988d1ed94f3972945784bf8fb75767e41b3dc5f12410377c5c8048ddad220fd43771ed93688597e2e167308755101c343e6d465739e1f748a699806ae40eb731b53990d314bc9635edeb0f4f45870cf3d6db37bf48d2343547d2cf8005198aaee0fd5761c623207eea8ad53f057e9de0446cd00c23da5ff1c8183ec7809621a90e7fa3e8ed459a6e474ef84a300363f0d245d36a0851a191240462d6e680e2d358899753b8e0b96e95191efba0fba2333c8e526737b6976fa7b413cfa3b980f42207a985ccdcd35ae1ff027a2611b93edb846fe723806a980b082e6328715f809e314bdc1d2c60c13fd046b06bc81c65bcaad55d821e83a9c2dc31293e5ae21780f08e4a062dfbb903d956382db84eadd0bf0a7b2b8468d8cfed83802de874a67b80424742990c218a746f5754b3a2c769a9ecbb457500412b0281ebb4304054067880b5407c24baa40b063e62c1d162c55f4a646edd70607bcbaef3808211db13013780eba4585adb29d3256f8059f81a40517e63b12c41ef7c0a8726a4ba62701e3598").to_vec(), + hex!("9f0d3719f5b0b12c7105c073c507445948cabb800ff6a2c0cf1c6e2dd1cad56d23aa6f51a78d85792606966afc176ecb4101e51b802db7d1beaf4152abcbe2d72358d938f31eef2e6f9adb322dd6316cd211dfe79580bb7fd6b2fa22db69bca4f70304addc539798fc6174ddae0c5865c71ff96e53415c5700bd9a93e85e3ce1d20700002408d6070000dc07000080054bc6bd08b77192f231932a6e63a3f54a48d954725a2198a762781089bf150980fd53aee7d7ccb0767af55024401273b0a9437c5917cdd60d406dac4aab7223338019cbbdbf60cd90027c802d921f737c07a073bb4bed3b9ff0c37b26506e6aafc94c57077a93d174890f1ff20700001404d0070000806e5feeb98858d49ab4f600b9337280df82041595257c4d566175cbf59cc105f680f44d2eba0587ca4f414fe092f163abb43531c554c28cfcc26cf032083a7af9b4").to_vec(), + hex!("9f0d7fefc408aac59dbfe80a72ac8e3ce5cebf80b9cbd0d700a17a0e4c717af58b887e80c0bce7832e64817caa8b47152baf5ba0807e1ee2c8362cd0745aa0c58780b99fefa1024c1b472d3386a2319e71b68028a68012d23785dbec11744e5f0fef2c34efcb738891240cd4ad63bb101bd4c2512a0980152c557d36cdee4289c8b2c42462576e238b62422b257e91773a473f49c3858680a8842b069c158af198d7d570838f69a2f4c9a218d51c69ad60361a873a11bbea80f08851397f0db3ac9785de1017f41cb5b073b92ecf6b4653d1f38d4993028e4680117820f0023f9e54736ad10ecae8806bcf1cc8b4ed694aa530ed85e6361db7ea80be32eae63e4a223cdf5cbf90b66f48665668ec0bedbb6b76302768ea6f3b19cc8030b143a144cc26437db830e7d750f21dbc87cf3140097b1fdbddb697782a237180ec76035be1c7d52a15dcf76aaf69fced1772f1464ec7886952dada14030ad4fc809b912d6aa76e61c4b515535db14d28490924ef2007cf19e0022b5a089b6d010380f28a57be8a23f6a2588595e53cb640bbeeee2ef9ddc962a6672ac98bd2d6ea4e").to_vec(), + ].into_iter().collect::>(); + encode_proofs(nodes) +} diff --git a/executor/src/task.rs b/executor/src/task.rs index 0eeaf398..239aa3d8 100644 --- a/executor/src/task.rs +++ b/executor/src/task.rs @@ -66,7 +66,7 @@ pub struct TaskCall { block_hash: HexString, calls: Option>, mock_signature_host: bool, - allow_unresolved_imports: bool, + allow_unresolved_imports: bool, } #[derive(Serialize, Deserialize, Debug)] diff --git a/src/__snapshots__/executor.test.ts.snap b/src/__snapshots__/executor.test.ts.snap new file mode 100644 index 00000000..eca7372d --- /dev/null +++ b/src/__snapshots__/executor.test.ts.snap @@ -0,0 +1,123 @@ +// Vitest Snapshot v1 + +exports[`wasm > decode & create proof works 1`] = ` +{ + "0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385": "0x0000a000005000000a00000000c8000000c800000a0000000a00000040380000580200000000500000c8000000e87648170000001e0000000000000000e8764817000000000000000000000000e87648170000000000000000000000e8030000009001001e00000000000000009001004038000000000000000000000a0000000a0000000a00000001000000010500000001c8000000060000005802000002000000580200000200000059000000000000001e0000002800000000c817a804000000000200000014000000", + "0x1cb6f36e027abb2091cfb5110ab5087f06155b3cd9a8c9e5e9a23fd5dc13a5ed": "0x873c991000000000", + "0x1cb6f36e027abb2091cfb5110ab5087f38316cbf8fa0da822a20ac1c55bf1be3": "0xcc15000000000000", + "0x1cb6f36e027abb2091cfb5110ab5087f7a414cb008e0e61e46722aa60abdd672": "0xb46e626e564d1385d21257d8cb59236ca125657f2a14bebd1af174317ca1055c", + "0x1cb6f36e027abb2091cfb5110ab5087f7ce678799d3eff024253b90e84927cc6": "0x13c6d5340826d75f6258aad1cf4478c20cae5bbaf189e2fe6e0c997aec0a8c3c", + "0x1cb6f36e027abb2091cfb5110ab5087fd077dfdb8adb10f78f10a5df8742c545": "0x0159a565b0fb89d8eec07b522e4e30e8bc29489ef7a9609dfec01855bd125d2e33", + "0x63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce563f5a4efb16ffa83d0070000": "0xd205bfd64a59c64fe84480fda7dafd773cb029530c4efe8441bf1f4332bfa48a", + "0x6a0da05ca59913bc38a8630590f2627c1d3719f5b0b12c7105c073c50744594863f5a4efb16ffa83d0070000": "0x20e8030000d4070000d6070000db070000dc070000f0070000f2070000f3070000", + "0x6a0da05ca59913bc38a8630590f2627cf12b746dcf32e843354583c9702cc02063f5a4efb16ffa83d0070000": "0x20e8030000d4070000d6070000db070000dc070000f0070000f2070000f3070000", + "0xcd710b30bd2eab0352ddcc26417aa1949e94c040f5e73d9b7addd6cb603d15d363f5a4efb16ffa83d0070000": undefined, +} +`; + +exports[`wasm > decode & create proof works 2`] = ` +{ + "chainAvailabilityPeriod": 10, + "codeRetentionPeriod": 0, + "disputeConclusionByTimeOutPeriod": 600, + "disputeMaxSpamSlots": 2, + "disputePeriod": 6, + "disputePostConclusionAcceptancePeriod": 600, + "groupRotationFrequency": 10, + "hrmpChannelMaxCapacity": 102400, + "hrmpChannelMaxMessageSize": 14400, + "hrmpChannelMaxTotalSize": 30, + "hrmpMaxMessageNumPerCandidate": 10, + "hrmpMaxParachainInboundChannels": 0, + "hrmpMaxParachainOutboundChannels": 30, + "hrmpMaxParathreadInboundChannels": 102400, + "hrmpMaxParathreadOutboundChannels": 0, + "hrmpOpenRequestTtl": 1215752192, + "hrmpRecipientDeposit": "0x000003e8000000000000000000000017", + "hrmpSenderDeposit": "0x4876e800000000000000000000000017", + "maxCodeSize": 10485760, + "maxDownwardMessageSize": 51200, + "maxHeadDataSize": 20480, + "maxPovSize": 5242880, + "maxUpwardMessageNumPerCandidate": 10, + "maxUpwardMessageSize": 51200, + "maxUpwardQueueCount": 10, + "maxUpwardQueueSize": 51200, + "maxValidators": 200, + "maxValidatorsPerCore": null, + "nDelayTranches": 89, + "neededApprovals": 30, + "noShowSlots": 2, + "parathreadCores": 0, + "parathreadRetries": 10, + "preferredDispatchableUpwardMessagesStepWeight": 100000000000, + "relayVrfModuloSamples": 40, + "schedulingLookahead": 1281, + "threadAvailabilityPeriod": 1, + "validationUpgradeDelay": 600, + "validationUpgradeFrequency": 14400, + "zerothDelayTrancheWidth": 0, +} +`; + +exports[`wasm > decode & create proof works 3`] = `"0xfc0b4018744f7cf8390204c6d2fbef8ede8c556942e5f5c63bd4f36075897bb3"`; + +exports[`wasm > decode & create proof works 4`] = ` +[ + "0x5703f5a4efb16ffa83d00700008420e8030000d4070000d6070000db070000dc070000f0070000f2070000f3070000", + "0x5f0fb7edc4cbc65e03d0070000d40700005501e80300000090010000900100000000000000000001708391b220ce64bab1cc4f79559352e59882ee5bb58329085c2400079c56153a00e8764817000000000000000000000000e87648170000000000000000000000", + "0x5e057a605f506cfcd4070000d00700005501e80300000090010000900100000000000000000001d3772d60305c2cbd7acf502a11881e0eef47fdfc85c7d2a0d6241e06ea4a971000e8764817000000000000000000000000e87648170000000000000000000000", + "0x5ee678799d3eff024253b90e84927cc68013c6d5340826d75f6258aad1cf4478c20cae5bbaf189e2fe6e0c997aec0a8c3c", + "0x8000c0787694c040f5e73d9b7addd6cb603d15d363f5a4efb16ffa83d00700000401485e4993f016e2d2f8e5f43be7bb2594860400", + "0x80204080480c6b47252c3414177fcd8441cc689703241343e1ef84be0b206cc24b043f1c801f33c1df517954d9820ca15fa6afb41e88a4d9101e0839a6b162f4eeba54804a", + "0x5e8b652b2ae6ed1ddc070000d00700005501e803000000900100009001000000000000000000010a492e67d36615052a89ba50498ed5cf0a587b31fd6f3da464e5d111e4e8a81c00e8764817000000000000000000000000e87648170000000000000000000000", + "0x5f0077dfdb8adb10f78f10a5df8742c545840159a565b0fb89d8eec07b522e4e30e8bc29489ef7a9609dfec01855bd125d2e33", + "0x8000c08090ebabb34893b8aef39ad17e906edea21d557366f6c759432622d651ef85d15880427ca6704596351b770d9c0a79343f2c1570d2bf146bf8dbd0115e4c853f3a4e", + "0x5f050452a22bee61fad0070000f20700005501e80300000090010000900100000000000000000001e41d29d36ff0b7c6007ec17b68ba6165066170fc67eb9755fbd7ed60bef647c100e8764817000000000000000000000000e87648170000000000000000000000", + "0x5e4f36708366b722d0070000e8030000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000", + "0x80004280df3c444cc602cfb8e35514a12c70fe2f5b2ec2683a3e19889c2bce42e8df4231808bbdb281c19f2e0405ebdcdd3eed583c83be8c5bf317070ab8e144c77aecab54", + "0x9f0cb6f36e027abb2091cfb5110ab5087f9960685f06155b3cd9a8c9e5e9a23fd5dc13a5ed20873c991000000000685f08316cbf8fa0da822a20ac1c55bf1be320cc15000000000000505f0e7b9012096b41c4eb3aaf947f6ea42908000080950cc9876d11a25f6c56e833f048b7fc32caf0bfbb8d9ff4b6ea993f4e984698806edd811d66d803965303f11c4bce3a94b9af68520b9c75e3b60b46b9961c3932685f090e2fbf2d792cb324bffa9427fe1f0e20b94ccb00fa55cb00", + "0x9f06de3d8a54d27e44a9d5ce189618f22d3008505f0e7b9012096b41c4eb3aaf947f6ea4290802004c5f03b4123b2e186e07fb7bad5dda5f55c0040080f71eda18869d6ad02c744d873d72c05d01fa458c4da7038805af33d407c65c7b", + "0x5e36c65ca123d5fbd0070000dc0700005501e80300000090010000900100000000000000000001c5120071fe1663a5a21b96d87446ac903ef1bf87dd729b8b9e92ca42ca303e7400e8764817000000000000000000000000e87648170000000000000000000000", + "0x5e4361975d97255ddb070000d00700005501e803000000900100009001000000000000000000018c74408c28f6627f58a8e10b3ec06b98b0166bfb148641a35c5cdfc7a56e68fb00e8764817000000000000000000000000e87648170000000000000000000000", + "0x804390801737775bc254f18aa4a817286d58a84638bd49932cd69e763be2107bfd65a5c3803be255b7e517fdbbb01870006388d720dc86fab24cb17c563e80638471f3b7fd80ee94abc5b7c0aa800c057463ac4b0e4cee6bda525cfe5608717c8c5378ed053a80910c01e2f75ba76fa6a60c7cd8849c5c4745ce479199be8b04c32f17a4fc616680da68cf8effc6c5ec15c0f401c4ee20e662248c1c185495886f6f92b51744d3cc", + "0x7f17f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce563f5a4efb16ffa83d007000080d205bfd64a59c64fe84480fda7dafd773cb029530c4efe8441bf1f4332bfa48a", + "0x5ec648b30353eed1d0070000db0700005501e8030000009001000090010000000000000000000100382d804f7b02c95c2d6b3b6a9cad2c97c2d7570bdfd32f8e8d961754b74b6d00e8764817000000000000000000000000e87648170000000000000000000000", + "0x5e36ad4314650419d0070000f00700005501e80300000090010000900100000000000000000001de18e43e692ffe15ea7a85abbce774e6944c56270a846777352827c7596f6c3e00e8764817000000000000000000000000e87648170000000000000000000000", + "0x80104080a1fc2c779380c33b94b304c281e55ca5a0807804fe9530c22fdfa76628beb42680692755c9209155bd724071de137657f492de5bb5479738d1af7119739b4df473", + "0x9f05207f03cfdce586301014700e2c25934040685f0d9ef3b78afddab7f5c7142131132ad42001000000000000004c5f0ec2d17a76153ff51817f12d9cfc3c7f0400", + "0x9f012b746dcf32e843354583c9702cc020c01080bb7fd6b2fa22db69bca4f70304addc539798fc6174ddae0c5865c71ff96e53415c5700bd9a93e85e3ce1d20700002408d6070000dc0700004c57077a93d174890f1ff20700001404d0070000", + "0x5e046fae65527199f2070000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000", + "0x5f09a99274c2ff3639d0070000d60700005501e80300000090010000900100000000000000000001d10c375b7f3756dd38a6fd0967fa4a92199606619c76c5aedc139eb584e8628b00e8764817000000000000000000000000e87648170000000000000000000000", + "0x9f06604cff828a6e3f579ca6c59ace013d15af80501a70ba3d699bb9126e453b817d3594618486b7455fb052fab74ed939c8db6580a4c3594adfbea64ada3d4b236078605e76b6c08582af892ffe107e2be422384280d5f81eca86aee22ba30e880daf0795627f12862c94a6d6add61790d47cc4174780eaca9a51c780ffcf7f2075adef97b380408d38589e510e2a158e078b1cbd05a580e450c660302bd7ac657ccc169f4a3542dea29d4e3b07d14fe0565e790586ef2e808b324b7e3655d04c92725d3982a8fc54a6d7219215caaa1274c161d16a606ff780768c9728ddfa5bde58b60116f5a720e912ba2dad17b047967c6fcd63ee0e9aa080e83e651d1018ce1a41f9635bc29355efeeadf688ab261358f5d84630c184d22a80cd7728c9b53ec87bc6b1011aa31c30a4493a3282a701edcdfc3fd2460d16c936", + "0x800410801eacd1970b27e7428c46fc7a1cd539390d664880f8665d1f5d9df711aef78ffc806dfac4a6f21c63e0cee19d347063fd8cdd56b9741d81c5842d27abed9542be5f", + "0x9f0d710b30bd2eab0352ddcc26417aa19440824c5f03c716fb8fff3de61a883bb76adb34a20400807840ffa4227d602af6d5bd8e9a5c9abbf856ebd961515e561b9f8bd10877d31c4c5f0dad6eef5c4b1c68eaa71ea17a02d9de0400", + "0x5e1c472775baca93f0070000d00700005501e803000000900100009001000000000000000000013b264b3f72ecfeddbdad3b409887206a18d387f1b81856c0383014c9f559992000e8764817000000000000000000000000e87648170000000000000000000000", + "0x5e968c2de8299067f3070000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000", + "0x5e55c8e02d73966fd6070000d00700005501e803000000900100009001000000000000000000019a436c9ae233f8b3cc6a379dc35ff6a3c4153b22a96db9fc81c9cee506a252b900e8764817000000000000000000000000e87648170000000000000000000000", + "0x9f0d3719f5b0b12c7105c073c507445948c01080bb7fd6b2fa22db69bca4f70304addc539798fc6174ddae0c5865c71ff96e53415c5700bd9a93e85e3ce1d20700002408d6070000dc0700004c57077a93d174890f1ff20700001404d0070000", + "0x9e0da05ca59913bc38a8630590f2627c02888081036a00b8dc7fbcf94f6630e920116e4d272ddcceab72b3bf2ab4f420a361ae8094da7ace1d340bf65922ea519cc3ba35a47fbc93054b01e28976b253faf5a51780f47f9f2800119f22dbcd10050587ab9a8ced42ea869506c63ff6b62c7ba24252", + "0x5f04b49d95320d9021994c850f25b8e385e9020000a000005000000a00000000c8000000c800000a0000000a00000040380000580200000000500000c8000000e87648170000001e0000000000000000e8764817000000000000000000000000e87648170000000000000000000000e8030000009001001e00000000000000009001004038000000000000000000000a0000000a0000000a00000001000000010500000001c8000000060000005802000002000000580200000200000059000000000000001e00000028000000", + "0x5e414cb008e0e61e46722aa60abdd67280b46e626e564d1385d21257d8cb59236ca125657f2a14bebd1af174317ca1055c", + "0x5e04d2a15ab51127e8030000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000", + "0x5e4be1ee506d55f8d0070000f3070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000", + "0x80203080f12b3be1de5704b86affeaf4178a0ca8dea056893c12a03c3500ca8af78c1280802166c372b218427bae449c6e50a075b4bc604253cea4ad0ee8ee7c16b498f3e980750fa8bb7472874648dae3648edb7c4900fd5b779b1df2ed102069dfda793608", + "0x800014808fc31cedc9f5a694fdde1823788928749f52e1c637dfbf315637fd89eace451c80b58f7e709e14c8ad32651a7b6f13b2ee8aa4a9566413b985e64eb5f3918a58e9", + "0x800804802942f9dc1f55813e7f51d1e2e2144fe439074c4f5cdc26ecf1fe8339da8b3b1c80d0d1055f2e6a21fa35bf8b8f3811e00185a1b3564ce394e5f1004284c578a883", +] +`; + +exports[`wasm > decode & create proof works 5`] = ` +{ + "0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385": "0x0000a000005000000a00000000c8000000c800000a0000000a00000040380000580200000000500000c8000000e87648170000001e0000000000000000e8764817000000000000000000000000e87648170000000000000000000000e8030000009001001e00000000000000009001004038000000000000000000000a0000000a0000000a00000001000000010500000001c8000000060000005802000002000000580200000200000059000000000000001e00000028000000", + "0x1cb6f36e027abb2091cfb5110ab5087f06155b3cd9a8c9e5e9a23fd5dc13a5ed": "0x873c991000000000", + "0x1cb6f36e027abb2091cfb5110ab5087f38316cbf8fa0da822a20ac1c55bf1be3": "0xcc15000000000000", + "0x1cb6f36e027abb2091cfb5110ab5087f7a414cb008e0e61e46722aa60abdd672": "0xb46e626e564d1385d21257d8cb59236ca125657f2a14bebd1af174317ca1055c", + "0x1cb6f36e027abb2091cfb5110ab5087f7ce678799d3eff024253b90e84927cc6": "0x13c6d5340826d75f6258aad1cf4478c20cae5bbaf189e2fe6e0c997aec0a8c3c", + "0x1cb6f36e027abb2091cfb5110ab5087fd077dfdb8adb10f78f10a5df8742c545": "0x0159a565b0fb89d8eec07b522e4e30e8bc29489ef7a9609dfec01855bd125d2e33", + "0x63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce563f5a4efb16ffa83d0070000": "0xd205bfd64a59c64fe84480fda7dafd773cb029530c4efe8441bf1f4332bfa48a", + "0x6a0da05ca59913bc38a8630590f2627c1d3719f5b0b12c7105c073c50744594863f5a4efb16ffa83d0070000": "0x20e8030000d4070000d6070000db070000dc070000f0070000f2070000f3070000", + "0x6a0da05ca59913bc38a8630590f2627cf12b746dcf32e843354583c9702cc02063f5a4efb16ffa83d0070000": "0x20e8030000d4070000d6070000db070000dc070000f0070000f2070000f3070000", + "0xcd710b30bd2eab0352ddcc26417aa1949e94c040f5e73d9b7addd6cb603d15d363f5a4efb16ffa83d0070000": "0x01", +} +`; diff --git a/src/blockchain/inherents.ts b/src/blockchain/inherents.ts index 98977061..c70bcc02 100644 --- a/src/blockchain/inherents.ts +++ b/src/blockchain/inherents.ts @@ -1,7 +1,12 @@ import { Block } from './block' import { DecoratedMeta } from '@polkadot/types/metadata/decorate/types' import { GenericExtrinsic } from '@polkadot/types' +import { HexString } from '@polkadot/util/types' import { TaskManager } from '../task' +import { compactHex } from '../utils' +import { createProof } from '../executor' +import { hexToU8a } from '@polkadot/util' +import { upgradeGoAheadSignal } from '../utils/proof' export interface CreateInherents { createInherents(meta: DecoratedMeta, timestamp: number, parent: Block): Promise @@ -102,13 +107,33 @@ export class SetValidationData implements CreateInherents { newData = MOCK_VALIDATION_DATA } else { const method = meta.registry.createType('GenericExtrinsic', extrinsics[this.#expectedIndex]) - const validationData = method.args[0].toJSON() as typeof MOCK_VALIDATION_DATA + const extrinsic = method.args[0].toJSON() as typeof MOCK_VALIDATION_DATA + + const newEntries: [HexString, HexString][] = [] + const upgrade = await parentBlock.get(compactHex(meta.query.parachainSystem.pendingValidationCode())) + if (upgrade) { + const paraIdStorage = await parentBlock.get(compactHex(meta.query.parachainInfo.parachainId())) + const paraId = meta.registry.createType('u32', hexToU8a(paraIdStorage as any)) + const upgradeKey = upgradeGoAheadSignal(paraId) + const goAhead = meta.registry.createType('UpgradeGoAhead', 'GoAhead') + newEntries.push([upgradeKey, goAhead.toHex()]) + } + + const { trieRootHash, nodes } = await createProof( + extrinsic.validationData.relayParentStorageRoot as HexString, + extrinsic.relayChainState.trieNodes as HexString[], + newEntries + ) newData = { - ...validationData, + ...extrinsic, validationData: { - ...validationData.validationData, - relayParentNumber: validationData.validationData.relayParentNumber + 2, + ...extrinsic.validationData, + relayParentStorageRoot: trieRootHash, + relayParentNumber: extrinsic.validationData.relayParentNumber + 2, + }, + relayChainState: { + trieNodes: nodes, }, } } diff --git a/src/blockchain/txpool.ts b/src/blockchain/txpool.ts index 45b77479..33f9f058 100644 --- a/src/blockchain/txpool.ts +++ b/src/blockchain/txpool.ts @@ -134,18 +134,6 @@ export class TxPool { } } - if (meta.query.parachainSystem?.validationData) { - // this is a parachain - const validationDataKey = compactHex(meta.query.parachainSystem.validationData()) - const validationData = await newBlock.get(validationDataKey) - if (!validationData) { - // there is no set validation data inherent - // so we need to restore the old validation data to make the on_finalize check happy - const oldValidationData = await head.get(validationDataKey) - newBlock.pushStorageLayer().set(validationDataKey, oldValidationData) - } - } - for (const extrinsic of extrinsics) { try { const resp = await newBlock.call('BlockBuilder_apply_extrinsic', extrinsic) diff --git a/src/executor.test.ts b/src/executor.test.ts index 6fd3b5a7..3e8bd351 100644 --- a/src/executor.test.ts +++ b/src/executor.test.ts @@ -1,12 +1,20 @@ import { HexString } from '@polkadot/util/types' import { Metadata } from '@polkadot/types/metadata' import { TypeRegistry } from '@polkadot/types' -import { calculateStateRoot, getMetadata, getRuntimeVersion } from './executor' import { decorateStorage } from '@polkadot/types/metadata/decorate' import { describe, expect, it } from 'vitest' import { readFileSync } from 'node:fs' import path from 'node:path' +import { + WELL_KNOWN_KEYS, + dmqMqcHead, + hrmpEgressChannelIndex, + hrmpIngressChannelIndex, + upgradeGoAheadSignal, +} from './utils/proof' +import { calculateStateRoot, createProof, decodeProof, getMetadata, getRuntimeVersion } from './executor' + describe('wasm', () => { it('get metadata from wasm runtime', async () => { const code = String(readFileSync(path.join(__dirname, 'runtime.example'))).trim() @@ -56,4 +64,102 @@ describe('wasm', () => { const b = await calculateStateRoot([['0x5301bf5ff0298f5c7b93a446709f8e885f772afdd0d8ba3d4d559a06f0742f12', '0x02']]) expect(a).to.not.eq(b) }) + + it('decode & create proof works', async () => { + // from acala chain + const ROOT_TRIE_HASH = '0x4a8902b29241020b24b4a1620d0154f756b81ffbcf739a9f06d3447df8123ebd' as HexString + const NODES: HexString[] = [ + '0x5703f5a4efb16ffa83d007000080d205bfd64a59c64fe84480fda7dafd773cb029530c4efe8441bf1f4332bfa48a', + '0x5703f5a4efb16ffa83d00700008420e8030000d4070000d6070000db070000dc070000f0070000f2070000f3070000', + '0x5c8c2de8299067f3070000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000', + '0x5d0452a22bee61fad0070000f20700005501e80300000090010000900100000000000000000001e41d29d36ff0b7c6007ec17b68ba6165066170fc67eb9755fbd7ed60bef647c100e8764817000000000000000000000000e87648170000000000000000000000', + '0x5d04d2a15ab51127e8030000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000', + '0x5d07edc4cbc65e03d0070000d40700005501e80300000090010000900100000000000000000001708391b220ce64bab1cc4f79559352e59882ee5bb58329085c2400079c56153a00e8764817000000000000000000000000e87648170000000000000000000000', + '0x5d0b652b2ae6ed1ddc070000d00700005501e803000000900100009001000000000000000000010a492e67d36615052a89ba50498ed5cf0a587b31fd6f3da464e5d111e4e8a81c00e8764817000000000000000000000000e87648170000000000000000000000', + '0x5d0be1ee506d55f8d0070000f3070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000', + '0x5d0c472775baca93f0070000d00700005501e803000000900100009001000000000000000000013b264b3f72ecfeddbdad3b409887206a18d387f1b81856c0383014c9f559992000e8764817000000000000000000000000e87648170000000000000000000000', + '0x5e046fae65527199f2070000d0070000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000', + '0x5e057a605f506cfcd4070000d00700005501e80300000090010000900100000000000000000001d3772d60305c2cbd7acf502a11881e0eef47fdfc85c7d2a0d6241e06ea4a971000e8764817000000000000000000000000e87648170000000000000000000000', + '0x5e36ad4314650419d0070000f00700005501e80300000090010000900100000000000000000001de18e43e692ffe15ea7a85abbce774e6944c56270a846777352827c7596f6c3e00e8764817000000000000000000000000e87648170000000000000000000000', + '0x5e36c65ca123d5fbd0070000dc0700005501e80300000090010000900100000000000000000001c5120071fe1663a5a21b96d87446ac903ef1bf87dd729b8b9e92ca42ca303e7400e8764817000000000000000000000000e87648170000000000000000000000', + '0x5e414cb008e0e61e46722aa60abdd67280b46e626e564d1385d21257d8cb59236ca125657f2a14bebd1af174317ca1055c', + '0x5e4361975d97255ddb070000d00700005501e803000000900100009001000000000000000000018c74408c28f6627f58a8e10b3ec06b98b0166bfb148641a35c5cdfc7a56e68fb00e8764817000000000000000000000000e87648170000000000000000000000', + '0x5e4f36708366b722d0070000e8030000d4e8030000009001000090010000000000000000000000e8764817000000000000000000000000e87648170000000000000000000000', + '0x5e55c8e02d73966fd6070000d00700005501e803000000900100009001000000000000000000019a436c9ae233f8b3cc6a379dc35ff6a3c4153b22a96db9fc81c9cee506a252b900e8764817000000000000000000000000e87648170000000000000000000000', + '0x5e77dfdb8adb10f78f10a5df8742c545840159a565b0fb89d8eec07b522e4e30e8bc29489ef7a9609dfec01855bd125d2e33', + '0x5ea99274c2ff3639d0070000d60700005501e80300000090010000900100000000000000000001d10c375b7f3756dd38a6fd0967fa4a92199606619c76c5aedc139eb584e8628b00e8764817000000000000000000000000e87648170000000000000000000000', + '0x5ec648b30353eed1d0070000db0700005501e8030000009001000090010000000000000000000100382d804f7b02c95c2d6b3b6a9cad2c97c2d7570bdfd32f8e8d961754b74b6d00e8764817000000000000000000000000e87648170000000000000000000000', + '0x5ee678799d3eff024253b90e84927cc68013c6d5340826d75f6258aad1cf4478c20cae5bbaf189e2fe6e0c997aec0a8c3c', + '0x5f04b49d95320d9021994c850f25b8e3852d030000a000005000000a00000000c8000000c800000a0000000a00000040380000580200000000500000c8000000e87648170000001e0000000000000000e8764817000000000000000000000000e87648170000000000000000000000e8030000009001001e00000000000000009001004038000000000000000000000a0000000a0000000a00000001000000010500000001c8000000060000005802000002000000580200000200000059000000000000001e0000002800000000c817a804000000000200000014000000', + '0x800014808fc31cedc9f5a694fdde1823788928749f52e1c637dfbf315637fd89eace451c80b58f7e709e14c8ad32651a7b6f13b2ee8aa4a9566413b985e64eb5f3918a58e9', + '0x800102802dcdd284f422a6ebda6a6f25c88e3ffe11d1adba81950ba92c640b042c250b1080c3883d3173954c1f95c3cb0612d3445f79eaf866255c3261671c3d50a480dcca', + '0x80011080453fad35c0a01e1a2af068a21c24622fe089db8330ff1c3d52d3a00c7504e515800ebe650369ce0e3ce85b22816181f598cc6ecf7a3b22314357ab4181b9ccb867', + '0x80011080bfead2545bbb18bbeccbbc42e419ce81be803a019bc10bc035e040209109ca708029f01a3bcd0dedb0dd8e6953b1c52deb161fb6f06b943a1934bd80506ac8f8ff', + '0x80046480f2126bccffb3e85172709b56414860c2d5aef6fbdca97efb91b0c7989b2e767c809bbc710130cd3fd1008762577f5a4f1959819fefe31aa2eb38c950b5b0ac16748022cba5584bc0982277b50978b65dd7c8c3702937804ae5b16b7b2dbae18122ff80c2e805afdfad80977cb420fe3c56c481131d8e6575e9dac18bfb48ee70bc5a93', + '0x80080480b64e0437daeee2d16022caa8e4cb67d9bfff7c5feb34dbbe044da77783421f78809ffe6dc440b4ca64053f01647b2e2d3284a4be15517f6693ee26fe4a84cc8a7b', + '0x8008208057bb9d54329c52084dafd34bb7a12ae243ed81b29438b7941ad6b08bc0aab080485ead6eef5c4b1c68eaa71ea17a02d9de0400', + '0x8008c280666c2b4c33ef871664a1cd5f75688bd687415a95f52a12fdaff5e1bb1d714f958049da90db410ddc5fcb63a6ba31fff1140f1f027eab9f575207946938a6dff0498032b1eb1b88050e8be5253bc631c21e5bb73b440ae1188f1da9e141aea5050345800892f12109affae95d1fa83c3e98639ce4aa22b3317846989ac8cc46a37ff2bf', + '0x801017800bd4a887368b253b446f6743e0b8b47e3384a11be255c56869ac5c22c8989dd8800bce23fe3d2d5b8d0e3a26b96ca234ad713326991a44cb1f30acd20cb8eb400080b47bdf3c44e033a0f6273db0e4d3c805462f92c8ec58046e6ece49d93264edaf80ea85a25e4978d8d9281242dec4943257cfb4d14f3408640b5e643f247d38a91c808a15b3c07f5df5f0771146cf6adb06d2d2af1c9c569c70e42d3d881e60c49cb8', + '0x801040809d953a8e74f031a6e10d7532012f6e655a37c85c4e37454174b98a7b92ced3f9805f738e2d7016159bb83f0acfc05b94f3bfed39826328fbea9a5a6844b0ee9f62', + '0x801200802c2bdbfc1bde7cdde01a4db7315c02e0373e1c8b826258e135ded3ca12b9b0e580a18673b451b154098a7a400495526a375c86a62e3c8f6def0a67b00eb6d26e87', + '0x80132680db8ba95d9fa6771a636c09a99827a9ef71777f6507eb4f789de5e137a7250d3780d99bcdfbfe4d2ba16f4dfaa93a02a3853cbc7912bad01d8f89acd4a18e318e9d807e84d35633382d5c74d5c446d26db1cc01db605ba0c12d399849032872bb731280ac082de8a8e688e9aa6c8d9f06576be0b982e6f7229e7b1f3a0d0cbff4e9cbce80e8f2d389ed545a028c6321d265c650179ed1c671fcfbc417185682c21667059b80a512dfa55fcf04f7e26b5ccdc14466086df66928a4f54dfb12b9873108dbfe88', + '0x8028388028462a6785718dce363f9fa86db6e6885c1df439739c06df2670b71ca7d1d6ab80f12b3be1de5704b86affeaf4178a0ca8dea056893c12a03c3500ca8af78c128080ae634ca22841dbcd3de33dfcd0730d87335dc93786dec63ff9ff5c494b1c32d2802166c372b218427bae449c6e50a075b4bc604253cea4ad0ee8ee7c16b498f3e9808b81a047e908564423ad8d63ef1677199bb5d41570df5ce359ec0cdc5a66fc06', + '0x80324680aa309aa88e45c23a7b3361cb9ac5bde5896dde657e8a562ce46cd5587674824080f7f61a745a9fefb91f35658a78ebc397ad0514232c0eec10344331b9a29195b680480c6b47252c3414177fcd8441cc689703241343e1ef84be0b206cc24b043f1c80608329e88f9837bedc55fa039c1c5468fe76304edacab49f89a35685ce0492748043a4144332df717cb9ac20b2b490345f22543965ea5272ce3511fa98f4ddfdcb80c62f5d20c25775fb8a8abded53ae1f6abd8fb9f9d75e306a1973194a9a739f73', + '0x804008804c9c79007d5b06217f77869639dbf475761b1d45115441ea15641d7db01d2425808c68f773671aec1db46b2c37b4c827e64aa7290d65e305cdaaa6b175596256f1', + '0x8041088041558830b346eebf7648fb84310d961de185de6ebc1bd22d114980d7793d6ee1804e23dcce96d9e514271688cf0bc5581e5e6e74cc4e079c39e75490ac45272f668071daa4762bcd3732d275bee68e3bb098a140029d7b01e82b4cd106924313f9f6', + '0x80505480a1fc2c779380c33b94b304c281e55ca5a0807804fe9530c22fdfa76628beb42680a1a8a2d4670241007470d59433dc876b10443654c68ee2c22e43f0505fb7081380cbc649bccb6cbe2678b258eb56b9985865852f8dc3ca4ac4608b46dc9a61a56580379357c2c5523ead8e26c2bd4d0ce06ca7f1726b09ef513a7d501aaa5752368280692755c9209155bd724071de137657f492de5bb5479738d1af7119739b4df473', + '0x80650080021eceb7212a84c0ce28538807a932d56f7ca04ad18a37eb5a3d81cf2d3a1e888028c2012c52668080a70a29a2704a0e1d108658aa94f21e0dcd5103401c52fff3809264b71d425330b4faf06bc3855662ae7511e854ed5387b3ee8c3fafcd6772d080af579d5ddc5c697d42bfc014076594e66c7b324cfd3017810c4e93e4f6f0ae9e', + '0x8080018068269bb8490669b94a5f1e0c3b4864e03224a2048271f11b8a95ea6168756573805dc031eeca4040dfb7be6e148287360e67d5ce62125f23d912e7ba6b5e1c3ea8', + '0x8086108046ea793674e4b7c40067c83aa00ac2fbbf3d2ebd57e01d5065909769da0ea9a2801eacd1970b27e7428c46fc7a1cd539390d664880f8665d1f5d9df711aef78ffc807b7ad6eb73914fd07fc55ad89ba771070c1da532a9269475dc64f1995d4d92668044a0d27ae2362402e5ac6666cbfd7bcaa530f2ea97a73b328a13ece4264ea290', + '0x80a06b8001abdee51ff39c1b87147abb00a81ce05a7b7bbd43dc1509cb4d97acdf3f8e6d80a296acd1c3810d5724e101343410a44934ed827a0c6931e538c2fc095adac046806661dfd17874a64f7f8e2a1e88db6fe81031f845e8705d6470bd48bef2d9615080df3c444cc602cfb8e35514a12c70fe2f5b2ec2683a3e19889c2bce42e8df423180decf6a9a942e385c520acce9b20917c7a516fee686baab2ca15379828a54ec09808cc9995c94f73aec7861dcd2bb4e389eefad87f4d8c1ece831dbcae8c85f2ab4808bbdb281c19f2e0405ebdcdd3eed583c83be8c5bf317070ab8e144c77aecab54', + '0x80a090809d70976e45bed6bfbe01cc3a2d2fc8d707784be7b54c5910eda9d60dbaa8dcda80c7d17ef601008c6b5fb577a67c8c0ed8f8a1b4eea0109830cddfc3d05c5955b8808fac6f5b26a0a091512ba579c768e78cd75b5f91ff02dcd27a011a1b9d3f8ca0805fc8b08bf7e5d96506fca5e15f58b00e5857510be132ddf21222fdc441242af5', + '0x80ffff80c66d277de66aaf06e0d6a1fc26ce21d8f6ef50ff28e14dbccfb2fa5bfbd0e5d680f219622acbd014476d4edb56ff6b86554c683a93a217b9ee5449d5f97350aba980daacb402b9d9534826030a1a087c3a6064f823d9578216b50dcc839b4a1cb4f080538c5f0315259d01b9589faf05886e3222ad437f11afbc79f8ca8fd1a706948b803b47dc6cc57a291d93e562eb748a4f6d5ba08cbd1b4b9980117eceff1ce541f08080b4dd653d14508ffe4e711984c6daebb8c53ffc701bc6c390f170524fe6067e806881eae5c901b2f9da23fc14a7b5c5adddf42803d9e6f6457502263d5c20d1b180552af8589e75bd85f77e14ad29a64b58bf27795087e0f8405f00e0af8c44769180f778234884d04539ae5ee94481786900f08bec239bc9e8a495e44f56ae62bd6f8058c056dc712c11a8aacceb99692e0b12b11fa7d127c512373d6a9312e4b7aa12800b7d692bbe193862e80155a0c60d515e359fc0711797aa73b963f8de206372318032b4da4f9707c28268fda915bad17740b2f29044af3426b93dddb1525d9119a180712826eb964d50810e03c64f0465e9d0aefba0975922e3546c1dd289ae6485ab803fc6afb3bb1a772c1b7865d617175918a1e561e7f9f6d4b3727e2e77d8cd54fd80b84b7a6e9b8ac582dfe53a66e6da54a2bc42162390b409a4fb1cb4d99e823334805ab928b4a3b5103f34f6d934e7c2a71a08f6160242d5a25e8d395f022137b544', + '0x8109400180c7192966ab02c8fe706a869d280b1f9e4100cd344a11d14d330d2691c06d838080cc5ba161e4197291e156c96df507a376d778fdd94adb9db8cc0f457222957ed9', + '0x810f080880d066a00dc79b0a8601ea466d09a4c969c246ed7d8b4f029afcd41944e33ae8b08063fee100c551b8c3283651ee6d6aad37bbe2abd5830b3c17785b691c63857dc5', + '0x9d0da05ca59913bc38a8630590f2627c07d980d131600ec39249fb7e25ce8b2759cbe5d9d22d65865cbdc5d5b6b43442a037a28064d55117d3f84fb235f2051b42475f6a3c165cb066016a54582116560d278c0180868f6dfc79ccadf3a96cf90a2b80fcc7fe47c77e30cbb2c8b88a6f3ee21a7c0a8039ebc92b31a26e4935b2e3ac747dfd531b73be08467c9918cc70090e0ae8859b80090170c9487096f84239151a9ecf92c1efeece708d87844f19f56988ec479a0d80a83b5e3737bfc99ede5e597406cf5b001b7949a5315953134fc321fc8992c0bd80fe20d9a744142b01474930a28d8b9a5ef3c851504a99fed5a4fec46d0533c7d88015dd6cf6cccb6c66a9e56feb41c47cf30a31d39fa77ec8b2eb55dd742db53921', + '0x9e207f03cfdce586301014700e2c2593414080776fdf331ededb557c273c87efa8d2e3919d6745e8645214665bf43afed8b5e9685f0d9ef3b78afddab7f5c7142131132ad42001000000000000004c5f0ec2d17a76153ff51817f12d9cfc3c7f0400', + '0x9e710b30bd2eab0352ddcc26417aa1944fc380926c6b63b2fdc00d98403a06793b323674ed75b32e75389a2c9d19140f48d07b80db9c2d25d50f7d4f8c69ee037a096b488bc42e33d2cfeeeff1fe8fc22c8cc1788034979b2e5ea91011d05f74f35d25c5b0da29c03c2c0e8e6b9f0a49ca32f46e58800e21335793e29a09c8eac52a4ed197378fd1ac3552ff31aecddb063d3f2c2f314c5f03c716fb8fff3de61a883bb76adb34a20400803587aeceb149eff2f59b5270a01e8c4fd19d1722eab53bcd8b5fd2aee0606fc14c5f0f4993f016e2d2f8e5f43be7bb2594860400807d9800e301836dcc17032891ceff52fc4029dcef8fc74a471e164eb06eecadaf80ac20693eb2298f6f300752834c3fc31a3c075a4e9a77a67d7ee3d6982d70e3e1', + '0x9eb6f36e027abb2091cfb5110ab5087ff96e685f06155b3cd9a8c9e5e9a23fd5dc13a5ed20873c991000000000685f08316cbf8fa0da822a20ac1c55bf1be320cc15000000000000505f0e7b9012096b41c4eb3aaf947f6ea429080000805788707c580bffc1660dc8c31ca562b5adf72d7dda390c9016319224cedab6c08084a80a22d77d8016adc89610b528c15ba17e4522a53faec0e60d84f5130362a580950cc9876d11a25f6c56e833f048b7fc32caf0bfbb8d9ff4b6ea993f4e984698800d49fef039517cc312c00412803ca1df50ac6d90c50541f649a9c85b83c0fdd8807a5d73d6c6a648545a7a8de535f9a12c2f7105d012e0eb272d91fb8ec018a2bf80cc59c8e5010713cf8876c314769c49fbe0b9a6e131ebf5a9774f52fe73d9ac66800c999e682e20f4c5ab236641829330b52e9a60e3bb8295c671ae10b0078b1b39685f090e2fbf2d792cb324bffa9427fe1f0e20b94ccb00fa55cb00', + '0x9ede3d8a54d27e44a9d5ce189618f22d3008505f0e7b9012096b41c4eb3aaf947f6ea4290802004c5f03b4123b2e186e07fb7bad5dda5f55c00400806b5403551f8463a3ddf5063c0454a5bd46c9c3d2e1030a6a838a27cc0c4b983a', + '0x9ef78c98723ddc9073523ef3beefda0c1004809efa6d0e486c88a89d0cec81b8d06f9b5b1dcff9db2c44a9bca135e300ee700c80a8a03c435efb3b22807974e7d4ef1ebad070a3e9c608ed0e5112c1d7223ca5ea', + '0x9f012b746dcf32e843354583c9702cc020cabb80ff9bed925038b8804f63090b1e2cf36d0d987e2e85b24f046ceee2d849dd69ff80d11d71ea91a8cbe9858770d23355ed19ad19a263b94d55f6d6f503c17eb3dd5280bb7fd6b2fa22db69bca4f70304addc539798fc6174ddae0c5865c71ff96e53415c5700bd9a93e85e3ce1d20700002408d6070000dc07000080b67cef76f1fdf97b48c1fcba9594f1ae40742c195b8d950ae7f08e4b3314fb2780fd53aee7d7ccb0767af55024401273b0a9437c5917cdd60d406dac4aab722333801bff773d6d6d765292b4e595ee0cd425bebe341c2f21af1768896cbfb71cc5d04c57077a93d174890f1ff20700001404d0070000806e5feeb98858d49ab4f600b9337280df82041595257c4d566175cbf59cc105f680f44d2eba0587ca4f414fe092f163abb43531c554c28cfcc26cf032083a7af9b4', + '0x9f06604cff828a6e3f579ca6c59ace013df7ff801afb0ed9ee8eab53f55af9e9f1c49736c6186c5852d7bba27baeab053a2d22fc809c793f0292c00ae878a17876cc7fe3343623734664aeb50333eac67dd4077b40808aaa7d061d20c8b96edc45a36746cfc2f8645b20db12f51ca020ed4967049c20804c9d12d0f9b7ab988d1ed94f3972945784bf8fb75767e41b3dc5f12410377c5c8048ddad220fd43771ed93688597e2e167308755101c343e6d465739e1f748a699806ae40eb731b53990d314bc9635edeb0f4f45870cf3d6db37bf48d2343547d2cf8005198aaee0fd5761c623207eea8ad53f057e9de0446cd00c23da5ff1c8183ec7809621a90e7fa3e8ed459a6e474ef84a300363f0d245d36a0851a191240462d6e680e2d358899753b8e0b96e95191efba0fba2333c8e526737b6976fa7b413cfa3b980f42207a985ccdcd35ae1ff027a2611b93edb846fe723806a980b082e6328715f809e314bdc1d2c60c13fd046b06bc81c65bcaad55d821e83a9c2dc31293e5ae21780f08e4a062dfbb903d956382db84eadd0bf0a7b2b8468d8cfed83802de874a67b80424742990c218a746f5754b3a2c769a9ecbb457500412b0281ebb4304054067880b5407c24baa40b063e62c1d162c55f4a646edd70607bcbaef3808211db13013780eba4585adb29d3256f8059f81a40517e63b12c41ef7c0a8726a4ba62701e3598', + '0x9f0d3719f5b0b12c7105c073c507445948cabb800ff6a2c0cf1c6e2dd1cad56d23aa6f51a78d85792606966afc176ecb4101e51b802db7d1beaf4152abcbe2d72358d938f31eef2e6f9adb322dd6316cd211dfe79580bb7fd6b2fa22db69bca4f70304addc539798fc6174ddae0c5865c71ff96e53415c5700bd9a93e85e3ce1d20700002408d6070000dc07000080054bc6bd08b77192f231932a6e63a3f54a48d954725a2198a762781089bf150980fd53aee7d7ccb0767af55024401273b0a9437c5917cdd60d406dac4aab7223338019cbbdbf60cd90027c802d921f737c07a073bb4bed3b9ff0c37b26506e6aafc94c57077a93d174890f1ff20700001404d0070000806e5feeb98858d49ab4f600b9337280df82041595257c4d566175cbf59cc105f680f44d2eba0587ca4f414fe092f163abb43531c554c28cfcc26cf032083a7af9b4', + '0x9f0d7fefc408aac59dbfe80a72ac8e3ce5cebf80b9cbd0d700a17a0e4c717af58b887e80c0bce7832e64817caa8b47152baf5ba0807e1ee2c8362cd0745aa0c58780b99fefa1024c1b472d3386a2319e71b68028a68012d23785dbec11744e5f0fef2c34efcb738891240cd4ad63bb101bd4c2512a0980152c557d36cdee4289c8b2c42462576e238b62422b257e91773a473f49c3858680a8842b069c158af198d7d570838f69a2f4c9a218d51c69ad60361a873a11bbea80f08851397f0db3ac9785de1017f41cb5b073b92ecf6b4653d1f38d4993028e4680117820f0023f9e54736ad10ecae8806bcf1cc8b4ed694aa530ed85e6361db7ea80be32eae63e4a223cdf5cbf90b66f48665668ec0bedbb6b76302768ea6f3b19cc8030b143a144cc26437db830e7d750f21dbc87cf3140097b1fdbddb697782a237180ec76035be1c7d52a15dcf76aaf69fced1772f1464ec7886952dada14030ad4fc809b912d6aa76e61c4b515535db14d28490924ef2007cf19e0022b5a089b6d010380f28a57be8a23f6a2588595e53cb640bbeeee2ef9ddc962a6672ac98bd2d6ea4e', + ] + + const registry = new TypeRegistry() + const paraId = registry.createType('u32', 2000) + + const headKey = dmqMqcHead(paraId) + const upgradeKey = upgradeGoAheadSignal(paraId) + const ingressChannelIndexKey = hrmpIngressChannelIndex(paraId) + const egressChannelIndexKey = hrmpEgressChannelIndex(paraId) + + const originalDecoded = await decodeProof( + ROOT_TRIE_HASH, + [headKey, upgradeKey, ingressChannelIndexKey, egressChannelIndexKey, ...Object.values(WELL_KNOWN_KEYS)], + NODES + ) + expect(originalDecoded).toMatchSnapshot() + expect(originalDecoded[upgradeKey]).toBeUndefined() + + const config = registry.createType('HostConfiguration', originalDecoded[WELL_KNOWN_KEYS.ACTIVE_CONFIG]) + expect(config.toJSON()).toMatchSnapshot() + + const goAhead = registry.createType('UpgradeGoAhead', 'GoAhead') + const { trieRootHash, nodes } = await createProof(ROOT_TRIE_HASH, NODES, [ + [WELL_KNOWN_KEYS.ACTIVE_CONFIG, config.toHex()], + [upgradeKey, goAhead.toHex()], + ]) + expect(trieRootHash).toMatchSnapshot() + expect(nodes).toMatchSnapshot() + const decoded = await decodeProof( + trieRootHash, + [headKey, upgradeKey, ingressChannelIndexKey, egressChannelIndexKey, ...Object.values(WELL_KNOWN_KEYS)], + nodes + ) + expect(decoded).toMatchSnapshot() + expect(decoded[upgradeKey]).toBe('0x01') + }) }) diff --git a/src/executor.ts b/src/executor.ts index 6d90a8f3..262e7c5a 100644 --- a/src/executor.ts +++ b/src/executor.ts @@ -1,9 +1,24 @@ import { HexString } from '@polkadot/util/types' import { WebSocket } from 'ws' -import { hexToString, hexToU8a } from '@polkadot/util' +import { + compactAddLength, + compactToU8a, + hexToString, + hexToU8a, + u8aConcat, + u8aConcatStrict, + u8aToHex, +} from '@polkadot/util' global.WebSocket = WebSocket -import { calculate_state_root, get_metadata, get_runtime_version, run_task } from '@acala-network/chopsticks-executor' +import { + calculate_state_root, + create_proof, + decode_proof, + get_metadata, + get_runtime_version, + run_task, +} from '../executor/pkg' import { compactHex } from './utils' export type RuntimeVersion = { @@ -33,4 +48,22 @@ export const calculateStateRoot = async (entries: [HexString, HexString][]): Pro return calculate_state_root(entries) } +const nodesAddLength = (nodes: HexString[]): HexString => { + const nodesWithLength = nodes.map((x) => compactAddLength(hexToU8a(x))) + return u8aToHex(u8aConcatStrict([compactToU8a(nodesWithLength.length), u8aConcat(...nodesWithLength)])) +} + +export const decodeProof = async (trieRootHash: HexString, keys: HexString[], nodes: HexString[]) => { + const decoded: [HexString, HexString | null][] = await decode_proof(trieRootHash, keys, nodesAddLength(nodes)) + return decoded.reduce((accum, [key, value]) => { + accum[key] = value + return accum + }, {} as Record) +} + +export const createProof = async (trieRootHash: HexString, nodes: HexString[], entries: [HexString, HexString][]) => { + const result = await create_proof(trieRootHash, nodesAddLength(nodes), entries) + return { trieRootHash: result[0] as HexString, nodes: result[1] as HexString[] } +} + export { run_task as runTask } diff --git a/src/utils/proof.ts b/src/utils/proof.ts new file mode 100644 index 00000000..65f3725a --- /dev/null +++ b/src/utils/proof.ts @@ -0,0 +1,38 @@ +import { HexString } from '@polkadot/util/types' +import { hexToU8a, u8aConcat, u8aToHex } from '@polkadot/util' +import { u32 } from '@polkadot/types' +import { xxhashAsU8a } from '@polkadot/util-crypto' + +export const WELL_KNOWN_KEYS: Record = { + EPOCH_INDEX: '0x1cb6f36e027abb2091cfb5110ab5087f38316cbf8fa0da822a20ac1c55bf1be3', + CURRENT_BLOCK_RANDOMNESS: '0x1cb6f36e027abb2091cfb5110ab5087fd077dfdb8adb10f78f10a5df8742c545', + ONE_EPOCH_AGO_RANDOMNESS: '0x1cb6f36e027abb2091cfb5110ab5087f7ce678799d3eff024253b90e84927cc6', + TWO_EPOCHS_AGO_RANDOMNESS: '0x1cb6f36e027abb2091cfb5110ab5087f7a414cb008e0e61e46722aa60abdd672', + CURRENT_SLOT: '0x1cb6f36e027abb2091cfb5110ab5087f06155b3cd9a8c9e5e9a23fd5dc13a5ed', + ACTIVE_CONFIG: '0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385', +} + +const prefixWithParaId = (prefix: HexString, paraId: u32) => { + const id = paraId.toU8a() + return u8aToHex(u8aConcat(hexToU8a(prefix), xxhashAsU8a(id, 64), id)) +} + +export const dmqMqcHead = (paraId: u32) => { + const prefix = '0x63f78c98723ddc9073523ef3beefda0c4d7fefc408aac59dbfe80a72ac8e3ce5' + return prefixWithParaId(prefix, paraId) +} + +export const upgradeGoAheadSignal = (paraId: u32) => { + const prefix = '0xcd710b30bd2eab0352ddcc26417aa1949e94c040f5e73d9b7addd6cb603d15d3' + return prefixWithParaId(prefix, paraId) +} + +export const hrmpIngressChannelIndex = (paraId: u32) => { + const prefix = '0x6a0da05ca59913bc38a8630590f2627c1d3719f5b0b12c7105c073c507445948' + return prefixWithParaId(prefix, paraId) +} + +export const hrmpEgressChannelIndex = (paraId: u32) => { + const prefix = '0x6a0da05ca59913bc38a8630590f2627cf12b746dcf32e843354583c9702cc020' + return prefixWithParaId(prefix, paraId) +} diff --git a/vendor/smoldot b/vendor/smoldot index 9f88cc3b..76994b52 160000 --- a/vendor/smoldot +++ b/vendor/smoldot @@ -1 +1 @@ -Subproject commit 9f88cc3b36497827cd5f0774d3488aad983c6c43 +Subproject commit 76994b52cd658a4ac1dc7a08f6bd4eba702e0e87