From 05a94d77f826fddf067c0367d3712f571b8dc710 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jan 2024 21:58:43 +0000 Subject: [PATCH 001/268] Bump evm from 0.36.0 to 0.41.1 in /arbitrator/prover/fuzz Bumps [evm](https://github.com/sorpaas/rust-evm) from 0.36.0 to 0.41.1. - [Commits](https://github.com/sorpaas/rust-evm/commits) --- updated-dependencies: - dependency-name: evm dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- arbitrator/prover/fuzz/Cargo.lock | 372 ++++++++++++++++++++++-------- arbitrator/prover/fuzz/Cargo.toml | 2 +- 2 files changed, 279 insertions(+), 95 deletions(-) diff --git a/arbitrator/prover/fuzz/Cargo.lock b/arbitrator/prover/fuzz/Cargo.lock index 4966a07d3f..f0cc083864 100644 --- a/arbitrator/prover/fuzz/Cargo.lock +++ b/arbitrator/prover/fuzz/Cargo.lock @@ -17,6 +17,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c38b6b6b79f671c25e1a3e785b7b82d7562ffc9cd3efdc98627e5668a2472490" +[[package]] +name = "arbutil" +version = "0.1.0" +dependencies = [ + "digest 0.10.7", + "num_enum", + "sha2", + "sha3 0.10.8", +] + [[package]] name = "arrayvec" version = "0.7.2" @@ -36,14 +46,14 @@ dependencies = [ [[package]] name = "auto_impl" -version = "0.5.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7862e21c893d65a1650125d157eaeec691439379a1cee17ee49031b79236ada4" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -126,9 +136,9 @@ dependencies = [ [[package]] name = "byte-slice-cast" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" @@ -169,6 +179,15 @@ dependencies = [ "vec_map", ] +[[package]] +name = "cpufeatures" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +dependencies = [ + "libc", +] + [[package]] name = "crossbeam-channel" version = "0.5.4" @@ -251,7 +270,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 1.0.109", ] [[package]] @@ -262,7 +281,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -273,7 +292,7 @@ checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -287,9 +306,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.3" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.2", "crypto-common", @@ -307,14 +326,20 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "ethbloom" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11da94e443c60508eb62cf256243a64da87304c2802ac2528847f79d750007ef" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" dependencies = [ "crunchy", - "fixed-hash", + "fixed-hash 0.8.0", "impl-codec", "impl-rlp", "scale-info", @@ -323,9 +348,9 @@ dependencies = [ [[package]] name = "ethereum" -version = "0.12.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23750149fe8834c0e24bb9adcbacbe06c45b9861f15df53e09f26cb7c4ab91ef" +checksum = "2e04d24d20b8ff2235cffbf242d5092de3aa45f77c5270ddbfadd2778ca13fea" dependencies = [ "bytes", "ethereum-types", @@ -333,33 +358,32 @@ dependencies = [ "hash256-std-hasher", "parity-scale-codec", "rlp", - "rlp-derive", "scale-info", "serde", - "sha3 0.10.1", - "triehash", + "sha3 0.10.8", + "trie-root", ] [[package]] name = "ethereum-types" -version = "0.13.1" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2827b94c556145446fcce834ca86b7abf0c39a805883fe20e72c5bfdb5a0dc6" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" dependencies = [ "ethbloom", - "fixed-hash", + "fixed-hash 0.8.0", "impl-codec", "impl-rlp", - "primitive-types", + "primitive-types 0.12.2", "scale-info", "uint", ] [[package]] name = "evm" -version = "0.36.0" +version = "0.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d388bbd18050623b996cc4ba0643971e2978693ad56ca8b7603080cfa5eaf738" +checksum = "767f43e9630cc36cf8ff2777cbb0121b055f0d1fd6eaaa13b46a1808f0d0e7e9" dependencies = [ "auto_impl", "environmental", @@ -369,48 +393,48 @@ dependencies = [ "evm-runtime", "log", "parity-scale-codec", - "primitive-types", + "primitive-types 0.12.2", "rlp", "scale-info", "serde", - "sha3 0.10.1", + "sha3 0.10.8", ] [[package]] name = "evm-core" -version = "0.36.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5fb3a449a544a67c879d2f74e1c3d9022de3ec31c9a20817015816f687aa2af" +checksum = "d1da6cedc5cedb4208e59467106db0d1f50db01b920920589f8e672c02fdc04f" dependencies = [ "parity-scale-codec", - "primitive-types", + "primitive-types 0.12.2", "scale-info", "serde", ] [[package]] name = "evm-gasometer" -version = "0.36.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170a27b6e49b8279016afffcdc6ebae9225d5acff3a546ad8589929b091e7ac5" +checksum = "1dc0eb591abc5cd7b05bef6a036c2bb6c66ab6c5e0c5ce94bfe377ab670b1fd7" dependencies = [ "environmental", "evm-core", "evm-runtime", - "primitive-types", + "primitive-types 0.12.2", ] [[package]] name = "evm-runtime" -version = "0.36.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d48c2545a02e3a4d1a5184a96af11037334dce947b6bdb389b3503b3a6f8dcd" +checksum = "84bbe09b64ae13a29514048c1bb6fda6374ac0b4f6a1f15a443348ab88ef42cd" dependencies = [ "auto_impl", "environmental", "evm-core", - "primitive-types", - "sha3 0.10.1", + "primitive-types 0.12.2", + "sha3 0.10.8", ] [[package]] @@ -435,6 +459,18 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand", + "rustc-hex", + "static_assertions", +] + [[package]] name = "fnv" version = "1.0.7" @@ -470,9 +506,9 @@ dependencies = [ [[package]] name = "hash-db" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" +checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" [[package]] name = "hash256-std-hasher" @@ -489,6 +525,12 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "heck" version = "0.3.3" @@ -545,7 +587,7 @@ checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -561,7 +603,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.11.2", +] + +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", ] [[package]] @@ -572,9 +624,12 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "keccak" -version = "0.1.0" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] [[package]] name = "lazy_static" @@ -582,11 +637,17 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + [[package]] name = "libc" -version = "0.2.125" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libfuzzer-sys" @@ -736,6 +797,27 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683751d591e6d81200c39fb0d1032608b77724f34114db54f571ff1317b337c0" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" +dependencies = [ + "proc-macro-crate 1.1.3", + "proc-macro2", + "quote", + "syn 2.0.46", +] + [[package]] name = "once_cell" version = "1.10.0" @@ -750,9 +832,9 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "parity-scale-codec" -version = "3.1.2" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b44461635bbb1a0300f100a841e571e7d919c81c73075ef5d152ffdb521066" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec", "bitvec", @@ -764,14 +846,14 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.1.2" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c45ed1f39709f5a89338fab50e59816b2e8815f5bb58276e7ddf9afd495f73f8" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.1", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -792,7 +874,18 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" dependencies = [ - "fixed-hash", + "fixed-hash 0.7.0", + "impl-codec", + "uint", +] + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash 0.8.0", "impl-codec", "impl-rlp", "scale-info", @@ -809,6 +902,16 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-crate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +dependencies = [ + "toml_datetime", + "toml_edit", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -818,7 +921,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -835,23 +938,25 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.37" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "prover" version = "0.1.0" dependencies = [ + "arbutil", "bincode", "brotli2", "digest 0.9.0", "eyre", "fnv", "hex", + "lazy_static", "libc", "nom", "nom-leb128", @@ -866,6 +971,7 @@ dependencies = [ "static_assertions", "structopt", "wasmparser", + "wat", ] [[package]] @@ -877,7 +983,7 @@ dependencies = [ "hex", "lazy_static", "libfuzzer-sys", - "primitive-types", + "primitive-types 0.11.1", "prover", "rayon", "serde", @@ -887,9 +993,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.18" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -956,11 +1062,12 @@ dependencies = [ [[package]] name = "rlp" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "999508abb0ae792aabed2460c45b89106d97fe4adac593bdaef433c2605847b5" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" dependencies = [ "bytes", + "rlp-derive", "rustc-hex", ] @@ -972,7 +1079,7 @@ checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1001,9 +1108,9 @@ checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "scale-info" -version = "2.1.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8980cafbe98a7ee7a9cc16b32ebce542c77883f512d83fbf2ddc8f6a85ea74c9" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -1014,14 +1121,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.1.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4260c630e8a8a33429d1688eff2f163f24c65a4e1b1578ef6b565061336e4b6f" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1032,22 +1139,22 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.137" +version = "1.0.194" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.194" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.46", ] [[package]] @@ -1081,7 +1188,18 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", ] [[package]] @@ -1098,11 +1216,11 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.1" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.3", + "digest 0.10.7", "keccak", ] @@ -1154,18 +1272,29 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syn" -version = "1.0.92" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1200,7 +1329,7 @@ checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1232,13 +1361,29 @@ dependencies = [ ] [[package]] -name = "triehash" -version = "0.8.4" +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "trie-root" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" +checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" dependencies = [ "hash-db", - "rlp", ] [[package]] @@ -1249,9 +1394,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "uint" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" dependencies = [ "byteorder", "crunchy", @@ -1259,6 +1404,12 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + [[package]] name = "unicode-segmentation" version = "1.9.0" @@ -1271,12 +1422,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "unicode-xid" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" - [[package]] name = "vec_map" version = "0.8.2" @@ -1295,13 +1440,43 @@ version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +[[package]] +name = "wasm-encoder" +version = "0.38.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad2b51884de9c7f4fe2fd1043fccb8dcad4b1e29558146ee57a144d15779f3f" +dependencies = [ + "leb128", +] + [[package]] name = "wasmparser" version = "0.84.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77dc97c22bb5ce49a47b745bed8812d30206eff5ef3af31424f2c1820c0974b2" dependencies = [ - "indexmap", + "indexmap 1.8.1", +] + +[[package]] +name = "wast" +version = "69.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ee37317321afde358e4d7593745942c48d6d17e0e6e943704de9bbee121e7a" +dependencies = [ + "leb128", + "memchr", + "unicode-width", + "wasm-encoder", +] + +[[package]] +name = "wat" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb338ee8dee4d4cd05e6426683f21c5087dc7cfc8903e839ccf48d43332da3c" +dependencies = [ + "wast", ] [[package]] @@ -1326,6 +1501,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winnow" +version = "0.5.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8434aeec7b290e8da5c3f0d628cb0eac6cabcb31d14bb74f779a08109a5914d6" +dependencies = [ + "memchr", +] + [[package]] name = "wyz" version = "0.5.0" diff --git a/arbitrator/prover/fuzz/Cargo.toml b/arbitrator/prover/fuzz/Cargo.toml index 08fcc863aa..7845b2a38e 100644 --- a/arbitrator/prover/fuzz/Cargo.toml +++ b/arbitrator/prover/fuzz/Cargo.toml @@ -15,7 +15,7 @@ eyre = "0.6.8" tokio = { version = "1.18.5", features = ["rt", "rt-multi-thread"] } serde = { version = "1.0.137", features = ["derive"] } hex = "0.4.3" -evm = "0.36.0" +evm = "0.41.1" serde_json = "1.0.81" primitive-types = "0.11.1" rayon = "1.5.1" From a149ebd73d5022bf64596973397b0139aee38ef9 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Tue, 16 Apr 2024 11:29:27 -0500 Subject: [PATCH 002/268] attempt Cherry-Picked from OffchainLabs/nitro@flatmerkleapril16 --- arbitrator/Cargo.lock | 135 +++++++++++++++- arbitrator/Cargo.toml | 1 + arbitrator/bench/Cargo.toml | 22 +++ arbitrator/bench/src/bin.rs | 76 +++++++++ arbitrator/bench/src/lib.rs | 2 + arbitrator/bench/src/parse_input.rs | 163 +++++++++++++++++++ arbitrator/bench/src/prepare.rs | 69 ++++++++ arbitrator/prover/src/flat_merkle.rs | 226 +++++++++++++++++++++++++++ arbitrator/prover/src/lib.rs | 3 +- arbitrator/prover/src/machine.rs | 14 +- bold | 1 + 11 files changed, 708 insertions(+), 4 deletions(-) create mode 100644 arbitrator/bench/Cargo.toml create mode 100644 arbitrator/bench/src/bin.rs create mode 100644 arbitrator/bench/src/lib.rs create mode 100644 arbitrator/bench/src/parse_input.rs create mode 100644 arbitrator/bench/src/prepare.rs create mode 100644 arbitrator/prover/src/flat_merkle.rs create mode 160000 bold diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index dd6b57e654..dfef9ace1e 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -70,6 +70,54 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +[[package]] +name = "anstream" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "arbutil" version = "0.1.0" @@ -127,6 +175,17 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "bench" +version = "0.1.0" +dependencies = [ + "arbutil", + "clap 4.5.4", + "eyre", + "hex", + "prover", +] + [[package]] name = "bincode" version = "1.3.3" @@ -312,9 +371,59 @@ dependencies = [ "vec_map", ] +[[package]] +name = "clap" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim 0.11.1", +] + +[[package]] +name = "clap_derive" +version = "4.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.45", +] + +[[package]] +name = "clap_lex" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "convert_case" version = "0.4.0" + +[[package]] +name = "corosensei" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" @@ -795,6 +904,18 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.1.19" @@ -1805,13 +1926,19 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "structopt" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap", + "clap 2.33.3", "lazy_static", "structopt-derive", ] @@ -2069,6 +2196,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "vec_map" version = "0.8.2" diff --git a/arbitrator/Cargo.toml b/arbitrator/Cargo.toml index 4676b9cc84..f521f69ad1 100644 --- a/arbitrator/Cargo.toml +++ b/arbitrator/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "arbutil", + "bench", "brotli", "brotli/fuzz", "caller-env", diff --git a/arbitrator/bench/Cargo.toml b/arbitrator/bench/Cargo.toml new file mode 100644 index 0000000000..e0346d7fab --- /dev/null +++ b/arbitrator/bench/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "bench" +version = "0.1.0" +edition = "2021" + +[lib] +name = "bench" +path = "src/lib.rs" + +[[bin]] +name = "benchbin" +path = "src/bin.rs" + +[dependencies] +hex = "0.4.3" +eyre = "0.6.5" +prover = { path = "../prover" } +arbutil = { path = "../arbutil" } +clap = { version = "4.4.8", features = ["derive"] } + +[profile.release] +debug = true \ No newline at end of file diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs new file mode 100644 index 0000000000..81b592fb48 --- /dev/null +++ b/arbitrator/bench/src/bin.rs @@ -0,0 +1,76 @@ +use std::{path::PathBuf, time::Duration}; + +use bench::prepare::*; +use clap::Parser; +use eyre::bail; +use prover::machine::MachineStatus; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct Args { + /// Path to a preimages text file + #[arg(short, long)] + preimages_path: PathBuf, + + /// Path to a machine.wavm.br + #[arg(short, long)] + machine_path: PathBuf, +} + +fn main() -> eyre::Result<()> { + let args = Args::parse(); + let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20]; + let always_merkleize = false; + println!("Running benchmark with always merkleize feature on"); + for step_size in step_sizes { + let mut machine = prepare_machine( + args.preimages_path.clone(), + args.machine_path.clone(), + always_merkleize, + )?; + let _ = machine.hash(); + let mut hash_times = vec![]; + let mut step_times = vec![]; + let mut num_iters = 0; + loop { + let start = std::time::Instant::now(); + machine.step_n(step_size)?; + let step_end_time = start.elapsed(); + step_times.push(step_end_time); + match machine.get_status() { + MachineStatus::Errored => { + println!("Errored"); + break; + // bail!("Machine errored => position {}", machine.get_steps()) + } + MachineStatus::TooFar => { + bail!("Machine too far => position {}", machine.get_steps()) + } + MachineStatus::Running => {} + MachineStatus::Finished => return Ok(()), + } + let start = std::time::Instant::now(); + let _ = machine.hash(); + let hash_end_time = start.elapsed(); + hash_times.push(hash_end_time); + num_iters += 1; + if num_iters == 100 { + break; + } + } + println!( + "avg hash time {:?}, avg step time {:?}, step size {}, num_iters {}", + average(&hash_times), + average(&step_times), + step_size, + num_iters, + ); + } + Ok(()) +} + +fn average(numbers: &[Duration]) -> Duration { + let sum: Duration = numbers.iter().sum(); + let sum: u64 = sum.as_nanos().try_into().unwrap(); + Duration::from_nanos(sum / numbers.len() as u64) +} diff --git a/arbitrator/bench/src/lib.rs b/arbitrator/bench/src/lib.rs new file mode 100644 index 0000000000..5f7c024094 --- /dev/null +++ b/arbitrator/bench/src/lib.rs @@ -0,0 +1,2 @@ +pub mod parse_input; +pub mod prepare; diff --git a/arbitrator/bench/src/parse_input.rs b/arbitrator/bench/src/parse_input.rs new file mode 100644 index 0000000000..9b645850f7 --- /dev/null +++ b/arbitrator/bench/src/parse_input.rs @@ -0,0 +1,163 @@ +use std::io::{self, BufRead}; + +#[derive(Debug, Clone)] +pub struct Preimage { + pub type_: u32, + pub hash: Vec, + pub data: Vec, +} + +#[derive(Debug, Clone)] +pub struct Item { + pub preimages: Vec, +} + +#[derive(Debug)] +pub struct BatchInfo { + pub number: u64, + pub data: Vec, +} + +#[derive(Debug)] +pub struct StartState { + pub block_hash: Vec, + pub send_root: Vec, + pub batch: u64, + pub pos_in_batch: u64, +} + +#[derive(Debug)] +pub struct FileData { + pub id: u64, + pub has_delayed_msg: bool, + pub delayed_msg_nr: u64, + pub items: Vec, + pub batch_info: BatchInfo, + pub delayed_msg: Vec, + pub start_state: StartState, +} + +impl FileData { + pub fn from_reader(mut reader: R) -> io::Result { + let mut items = Vec::new(); + let mut batch_info = BatchInfo { + number: 0, + data: Vec::new(), + }; + let mut id = 0; + let mut has_delayed_msg = false; + let mut delayed_msg_nr = 0; + let mut delayed_msg = Vec::new(); + let mut start_state = StartState { + block_hash: Vec::new(), + send_root: Vec::new(), + batch: 0, + pos_in_batch: 0, + }; + + let mut line = String::new(); + while reader.read_line(&mut line)? > 0 { + if line.starts_with("Id:") { + id = line.split(":").nth(1).unwrap().trim().parse().unwrap(); + } else if line.starts_with("HasDelayedMsg:") { + has_delayed_msg = line.split(":").nth(1).unwrap().trim().parse().unwrap(); + } else if line.starts_with("DelayedMsgNr:") { + delayed_msg_nr = line.split(":").nth(1).unwrap().trim().parse().unwrap(); + } else if line.starts_with("Preimages:") { + items.push(Item::from_reader(&mut reader, &mut line)?); + } else if line.starts_with("BatchInfo:") { + let parts: Vec<_> = line.split(",").collect(); + batch_info.number = parts[0].split(":").nth(2).unwrap().trim().parse().unwrap(); + batch_info.data = hex::decode(parts[1].split(":").nth(1).unwrap().trim()).unwrap(); + } else if line.starts_with("DelayedMsg:") { + delayed_msg = hex::decode(line.split(":").nth(1).unwrap().trim()).unwrap(); + } else if line.starts_with("StartState:") { + let parts: Vec<_> = line.split(",").collect(); + + // Parsing block_hash + let block_hash_str = parts[0].split("BlockHash:").nth(1).unwrap().trim(); + start_state.block_hash = + hex::decode(block_hash_str.strip_prefix("0x").unwrap()).unwrap(); + + // Parsing send_root + let send_root_str = parts[1].split(":").nth(1).unwrap().trim(); + start_state.send_root = + hex::decode(send_root_str.strip_prefix("0x").unwrap()).unwrap(); + + // Parsing batch + start_state.batch = parts[2] + .split(":") + .nth(1) + .unwrap() + .trim() + .parse::() + .unwrap(); + + // Parsing pos_in_batch + start_state.pos_in_batch = parts[3] + .split(":") + .nth(1) + .unwrap() + .trim() + .parse::() + .unwrap(); + } + line.clear(); + } + + Ok(FileData { + id, + has_delayed_msg, + delayed_msg_nr, + items, + batch_info, + delayed_msg, + start_state, + }) + } +} + +impl Item { + pub fn from_reader(reader: &mut R, line: &mut String) -> io::Result { + let mut preimages = Vec::new(); + + loop { + if line.is_empty() + || line.starts_with("BatchInfo:") + || line.starts_with("DelayedMsg:") + || line.starts_with("StartState:") + { + break; + } + if line.starts_with("Preimages:") { + line.clear(); + while reader.read_line(line)? > 0 && line.starts_with("\t") { + let parts: Vec<_> = line.trim().split(",").collect(); + let type_ = parts[0].split(":").nth(1).unwrap().trim().parse().unwrap(); + let hash = hex::decode( + parts[1] + .split(":") + .nth(1) + .unwrap() + .trim() + .strip_prefix("0x") + .unwrap(), + ) + .unwrap(); + let data = hex::decode(parts[2].split(":").nth(1).unwrap().trim()).unwrap(); + preimages.push(Preimage { type_, hash, data }); + line.clear(); + } + continue; // To skip line.clear() at the end of the loop for this case + } + + line.clear(); + if reader.read_line(line)? == 0 { + // If EOF is reached + break; + } + } + + Ok(Item { preimages }) + } +} diff --git a/arbitrator/bench/src/prepare.rs b/arbitrator/bench/src/prepare.rs new file mode 100644 index 0000000000..c6d45dae3b --- /dev/null +++ b/arbitrator/bench/src/prepare.rs @@ -0,0 +1,69 @@ +use arbutil::PreimageType; +use prover::machine::{argument_data_to_inbox, GlobalState, Machine}; +use prover::utils::{Bytes32, CBytes}; +use std::collections::HashMap; +use std::fs::File; +use std::io::BufReader; +use std::path::{Path, PathBuf}; +use std::sync::Arc; + +use crate::parse_input::*; + +pub fn prepare_machine( + preimages: PathBuf, + machines: PathBuf, + always_merkleize: bool, +) -> eyre::Result { + let file = File::open(&preimages)?; + let reader = BufReader::new(file); + + let data = FileData::from_reader(reader)?; + let item = data.items.get(0).unwrap().clone(); + let preimages = item.preimages; + let preimages = preimages + .into_iter() + .map(|preimage| { + let hash: [u8; 32] = preimage.hash.try_into().unwrap(); + let hash: Bytes32 = hash.into(); + (hash, preimage.data) + }) + .collect::>>(); + let preimage_resolver = move |_: u64, _: PreimageType, hash: Bytes32| -> Option { + preimages + .get(&hash) + .map(|data| CBytes::from(data.as_slice())) + }; + let preimage_resolver = Arc::new(Box::new(preimage_resolver)); + + let binary_path = Path::new(&machines); + // println!("Creating machine from binary_path"); + let mut mach = Machine::new_from_wavm(binary_path, always_merkleize)?; + + let block_hash: [u8; 32] = data.start_state.block_hash.try_into().unwrap(); + let block_hash: Bytes32 = block_hash.into(); + let send_root: [u8; 32] = data.start_state.send_root.try_into().unwrap(); + let send_root: Bytes32 = send_root.into(); + let bytes32_vals: [Bytes32; 2] = [block_hash, send_root]; + let u64_vals: [u64; 2] = [data.start_state.batch, data.start_state.pos_in_batch]; + let start_state = GlobalState { + bytes32_vals, + u64_vals, + }; + + //println!("Setting global state"); + mach.set_global_state(start_state); + // println!("After setting global state: {:?}", mach.get_global_state()); + + // println!("Setting preimage resolver"); + mach.set_preimage_resolver(preimage_resolver); + + // println!("Adding sequencer inbox message"); + let identifier = argument_data_to_inbox(0).unwrap(); + mach.add_inbox_msg(identifier, data.batch_info.number, data.batch_info.data); + + // println!("Adding delayed inbox message"); + let identifier = argument_data_to_inbox(1).unwrap(); + mach.add_inbox_msg(identifier, data.delayed_msg_nr, data.delayed_msg); + + Ok(mach) +} diff --git a/arbitrator/prover/src/flat_merkle.rs b/arbitrator/prover/src/flat_merkle.rs new file mode 100644 index 0000000000..022429696e --- /dev/null +++ b/arbitrator/prover/src/flat_merkle.rs @@ -0,0 +1,226 @@ +// Copyright 2021-2022, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +use crate::utils::Bytes32; +use digest::Digest; +// use rayon::prelude::*; +use sha3::Keccak256; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MerkleType { + Empty, + Value, + Function, + Instruction, + Memory, + Table, + TableElement, + Module, +} + +impl Default for MerkleType { + fn default() -> Self { + Self::Empty + } +} + +impl MerkleType { + pub fn get_prefix(self) -> &'static str { + match self { + MerkleType::Empty => panic!("Attempted to get prefix of empty merkle type"), + MerkleType::Value => "Value merkle tree:", + MerkleType::Function => "Function merkle tree:", + MerkleType::Instruction => "Instruction merkle tree:", + MerkleType::Memory => "Memory merkle tree:", + MerkleType::Table => "Table merkle tree:", + MerkleType::TableElement => "Table element merkle tree:", + MerkleType::Module => "Module merkle tree:", + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Default)] +pub struct Merkle { + tree: Vec, + empty_hash: Bytes32, +} + +#[inline] +fn hash_node(a: &[u8], b: &[u8]) -> Bytes32 { + let mut h = Keccak256::new(); + h.update(a); + h.update(b); + h.finalize().into() +} + +impl Merkle { + pub fn new(ty: MerkleType, hashes: Vec) -> Merkle { + Self::new_advanced(ty, hashes, Bytes32::default(), 0) + } + pub fn new_advanced( + ty: MerkleType, + hashes: Vec, + empty_hash: Bytes32, + min_depth: usize, + ) -> Merkle { + if hashes.is_empty() { + return Merkle::default(); + } + + let empty_layer_hash = hash_node(empty_hash.as_slice(), empty_hash.as_slice()); + + let hash_count = hashes.len(); + let mut current_level_size = hash_count; + + // Calculate the total capacity needed for the tree + let mut total_capacity = hash_count * 32; // 32 bytes per hash + let mut depth = min_depth; + while current_level_size > 1 || depth > 0 { + current_level_size = (current_level_size + 1) / 2; + total_capacity += current_level_size * 32; + depth = depth.saturating_sub(1); + } + let mut tree = Vec::with_capacity(total_capacity); + + // Append initial hashes to the tree + for hash in hashes.into_iter() { + tree.extend_from_slice(hash.as_slice()); + } + + let mut next_level_offset = tree.len(); + let mut depth = min_depth; + + while current_level_size > 1 || depth > 0 { + let mut i = next_level_offset - current_level_size * 32; + while i < next_level_offset { + let left = &tree[i..i + 32]; + let right = if i + 32 < next_level_offset { + &tree[i + 32..i + 64] + } else { + empty_layer_hash.as_slice() + }; + + let parent_hash = hash_node(left, right); + tree.extend(parent_hash.as_slice()); + + i += 64; + } + + current_level_size = (current_level_size + 1) / 2; + next_level_offset = tree.len(); + depth = depth.saturating_sub(1); + } + + Merkle { + tree, + empty_hash: empty_layer_hash, + } + } + + pub fn root(&self) -> Bytes32 { + let len = self.tree.len(); + let mut root = [0u8; 32]; + root.copy_from_slice(&self.tree[len - 32..len]); + root.into() + } + + pub fn leaves(&self) -> &[u8] { + let leaf_layer_size = self.calculate_layer_size(0); + &self.tree[..leaf_layer_size * 32] + } + + pub fn prove(&self, idx: usize) -> Option> { + let leaf_count = self.calculate_layer_size(0); + if idx >= leaf_count { + return None; + } + + let mut proof = Vec::new(); + let mut node_index = idx; + let mut layer_start = 0; + + for depth in 0.. { + let layer_size = self.calculate_layer_size(depth); + if layer_size <= 1 { + break; + } + + let sibling_index = if node_index % 2 == 0 { + node_index + 1 + } else { + node_index - 1 + }; + if sibling_index < layer_size { + proof.extend(self.get_node(layer_start, sibling_index)); + } + + node_index /= 2; + layer_start += layer_size * 32; + } + + Some(proof) + } + + // Helper function to get a node from the tree + #[inline(always)] + fn get_node(&self, layer_start: usize, index: usize) -> Bytes32 { + let start = layer_start + index * 32; + let mut node = [0u8; 32]; + node.copy_from_slice(&self.tree[start..start + 32]); + node.into() + } + + pub fn set(&mut self, mut idx: usize, hash: Bytes32) { + // Calculate the offset in the flat tree for the given index + let mut offset = idx * 32; + + // Check if the hash at the calculated position is the same as the input hash + if &self.tree[offset..offset + 32] == hash.as_slice() { + return; + } + + // Copy the new hash into the tree at the calculated position + self.tree[offset..offset + 32].copy_from_slice(hash.as_slice()); + + // Calculate the total number of nodes in the tree + let total_nodes = self.tree.len() / 32; + + // Update parent hashes up the tree + let mut next_hash = hash; + while idx > 0 { + idx = (idx - 1) / 2; // Move to the parent index + offset = idx * 32; + + // Calculate the position of the sibling in the flat tree + let sibling_idx = if idx % 2 == 0 { idx + 1 } else { idx - 1 }; + let sibling_offset = sibling_idx * 32; + + // Handle the case where the sibling index is out of bounds + let sibling_hash = if sibling_offset < total_nodes * 32 { + &self.tree[sibling_offset..sibling_offset + 32] + } else { + self.empty_hash.as_slice() + }; + + // Calculate the parent hash + next_hash = if idx % 2 == 0 { + hash_node(next_hash.as_slice(), sibling_hash) + } else { + hash_node(sibling_hash, next_hash.as_slice()) + }; + + // Update the parent node in the flat tree + self.tree[offset..offset + 32].copy_from_slice(next_hash.as_slice()); + } + } + + // Helper function to calculate the size of a given layer + #[inline(always)] + fn calculate_layer_size(&self, depth: usize) -> usize { + let mut size = self.tree.len() / 32; // Total number of nodes + for _ in 0..depth { + size = (size + 1) / 2; // Size of the current layer + } + size + } +} diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index d2a8a43494..fccd28ff0f 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -4,6 +4,7 @@ #![allow(clippy::missing_safety_doc, clippy::too_many_arguments)] pub mod binary; +pub mod flat_merkle; mod host; #[cfg(feature = "native")] mod kzg; @@ -116,7 +117,7 @@ unsafe fn arbitrator_load_machine_impl( pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char) -> *mut Machine { let binary_path = cstr_to_string(binary_path); let binary_path = Path::new(&binary_path); - match Machine::new_from_wavm(binary_path) { + match Machine::new_from_wavm(binary_path, false) { Ok(mach) => Box::into_raw(Box::new(mach)), Err(err) => { eprintln!("Error loading binary: {err}"); diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index a5fe33ea5c..77fcdca883 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1538,7 +1538,7 @@ impl Machine { Ok(mach) } - pub fn new_from_wavm(wavm_binary: &Path) -> Result { + pub fn new_from_wavm(wavm_binary: &Path, always_merkleize: bool) -> Result { let mut modules: Vec = { let compressed = std::fs::read(wavm_binary)?; let Ok(modules) = brotli::decompress(&compressed, Dictionary::Empty) else { @@ -1564,6 +1564,16 @@ impl Machine { MerkleType::Function, module.funcs.iter().map(Function::hash).collect(), )); + if always_merkleize { + module.memory.cache_merkle_tree(); + } + } + let mut modules_merkle: Option = None; + if always_merkleize { + modules_merkle = Some(Merkle::new( + MerkleType::Module, + modules.iter().map(Module::hash).collect(), + )); } let mut mach = Machine { status: MachineStatus::Running, @@ -1573,7 +1583,7 @@ impl Machine { internal_stack: Vec::new(), frame_stacks: vec![Vec::new()], modules, - modules_merkle: None, + modules_merkle, global_state: Default::default(), pc: ProgramCounter::default(), stdio_output: Vec::new(), diff --git a/bold b/bold new file mode 160000 index 0000000000..f456e2fbfa --- /dev/null +++ b/bold @@ -0,0 +1 @@ +Subproject commit f456e2fbfa8560e52ada5fcc5ce927577d07483d From dec2e824da1bdecc1b880c20cf3b7dfb87f2eea0 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 17 Apr 2024 09:25:53 +0200 Subject: [PATCH 003/268] Make allow_merkleize a command-line switch. --- arbitrator/bench/src/bin.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 81b592fb48..905d202201 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -15,18 +15,25 @@ struct Args { /// Path to a machine.wavm.br #[arg(short, long)] machine_path: PathBuf, + + /// Should the memory tree always Merkleize + #[arg(short, long)] + always_merkleize: bool, } fn main() -> eyre::Result<()> { let args = Args::parse(); let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20]; - let always_merkleize = false; - println!("Running benchmark with always merkleize feature on"); + if args.always_merkleize { + println!("Running benchmark with always merkleize feature on"); + } else { + println!("Running benchmark with always merkleize feature off"); + } for step_size in step_sizes { let mut machine = prepare_machine( args.preimages_path.clone(), args.machine_path.clone(), - always_merkleize, + args.always_merkleize, )?; let _ = machine.hash(); let mut hash_times = vec![]; From 3c3026548a554ecd1c6d07a1896f000e065592cc Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Apr 2024 19:19:20 +0200 Subject: [PATCH 004/268] Add the total time for each step-size. It can be easy to look at small average step and hash times and miss that the total time is what we're really trying to reduce. --- arbitrator/bench/src/bin.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 905d202201..b39e661925 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -30,6 +30,7 @@ fn main() -> eyre::Result<()> { println!("Running benchmark with always merkleize feature off"); } for step_size in step_sizes { + let total = std::time::Instant::now(); let mut machine = prepare_machine( args.preimages_path.clone(), args.machine_path.clone(), @@ -65,12 +66,14 @@ fn main() -> eyre::Result<()> { break; } } + let total_end_time = total.elapsed(); println!( - "avg hash time {:?}, avg step time {:?}, step size {}, num_iters {}", + "avg hash time {:?}, avg step time {:?}, step size {}, num_iters {}, total time {:?}", average(&hash_times), average(&step_times), step_size, num_iters, + total_end_time, ); } Ok(()) From 51069f5ef3e5093067223f02bbd7c0947c55f7bc Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Apr 2024 19:26:26 +0200 Subject: [PATCH 005/268] Add some doc comments and tests to merkle.rs I definitely had some incorrect assumptions about this data structure which made it more difficult to learn. So, I'm documenting how it works and adding some tests. The simple_merkle test is currently failing because the `set` method doesn't allow setting an index larger than the largest currently set leaf's index. There is some debate as to whether or not this is the correct behavior. To run the test, use: ``` $> cargo test -- --include-ignored ``` --- arbitrator/prover/src/merkle.rs | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 16306bd611..bc05d5abe4 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -43,6 +43,15 @@ impl MerkleType { } } +/// A Merkle tree with a fixed number of layers +/// +/// https://en.wikipedia.org/wiki/Merkle_tree +/// +/// Each instance's leaves contain the hashes of a specific [MerkleType]. +/// The tree does not grow. It can be over-provisioned using the +/// [Merkle::new_advanced] method and passing a minimum depth. +/// +/// This structure does not contain the data itself, only the hashes. #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] pub struct Merkle { ty: MerkleType, @@ -60,6 +69,8 @@ fn hash_node(ty: MerkleType, a: Bytes32, b: Bytes32) -> Bytes32 { } impl Merkle { + // Creates a new Merkle tree with the given type and leaf hashes. + // The tree is built up to the minimum depth necessary to hold all the leaves. pub fn new(ty: MerkleType, hashes: Vec) -> Merkle { Self::new_advanced(ty, hashes, Bytes32::default(), 0) } @@ -161,6 +172,8 @@ impl Merkle { *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); } + // Sets the leaf at the given index to the given hash. + // Panics if the index is out of bounds (since the structure doesn't grow). pub fn set(&mut self, mut idx: usize, hash: Bytes32) { if self.layers[0][idx] == hash { return; @@ -187,3 +200,45 @@ impl Merkle { } } } + +#[test] +#[ignore] +fn simple_merkle() { + let hashes = vec![ + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + Bytes32::from([5; 32]), + ]; + let mut expected = hash_node(MerkleType::Value, + hash_node( + MerkleType::Value, + hash_node(MerkleType::Value, Bytes32::from([1; 32]), Bytes32::from([2; 32])), + hash_node(MerkleType::Value, Bytes32::from([3; 32]), Bytes32::from([4; 32]))), + hash_node( + MerkleType::Value, + hash_node(MerkleType::Value, Bytes32::from([5; 32]), Bytes32::from([0; 32])), + hash_node(MerkleType::Value, Bytes32::from([0; 32]), Bytes32::from([0; 32])))); + let mut merkle = Merkle::new(MerkleType::Value, hashes.clone()); + assert_eq!(merkle.root(), expected); + + merkle.set(5, Bytes32::from([6; 32])); + expected = hash_node(MerkleType::Value, + hash_node( + MerkleType::Value, + hash_node(MerkleType::Value, Bytes32::from([1; 32]), Bytes32::from([2; 32])), + hash_node(MerkleType::Value, Bytes32::from([3; 32]), Bytes32::from([4; 32]))), + hash_node( + MerkleType::Value, + hash_node(MerkleType::Value, Bytes32::from([5; 32]), Bytes32::from([6; 32])), + hash_node(MerkleType::Value, Bytes32::from([0; 32]), Bytes32::from([0; 32])))); + assert_eq!(merkle.root(), expected); +} + +#[test] +#[should_panic] +fn set_with_bad_index_panics() { + let mut merkle = Merkle::new(MerkleType::Value, vec![Bytes32::default()]); + merkle.set(1, Bytes32::default()); +} From 2ecc4f54a047407b400f5f60404efa941a7cd164 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 19 Apr 2024 16:06:13 +0200 Subject: [PATCH 006/268] Allow callers to extend the Merkle Tree by adding leaves. At this point, the new root hash is eagerly calculated after each call to `extend`. --- arbitrator/prover/src/merkle.rs | 67 ++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index bc05d5abe4..6570c0e7c3 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -5,7 +5,7 @@ use arbutil::Bytes32; use digest::Digest; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use std::convert::TryFrom; +use std::convert::{TryFrom, TryInto}; #[cfg(feature = "rayon")] use rayon::prelude::*; @@ -48,8 +48,14 @@ impl MerkleType { /// https://en.wikipedia.org/wiki/Merkle_tree /// /// Each instance's leaves contain the hashes of a specific [MerkleType]. -/// The tree does not grow. It can be over-provisioned using the -/// [Merkle::new_advanced] method and passing a minimum depth. +/// The tree does not grow in height, but it can be initialized with fewer +/// leaves than the number that could be contained in its layers. +/// +/// When initialized with [Merkle::new], the tree has the minimum depth +/// necessary to hold all the leaves. (e.g. 5 leaves -> 4 layers.) +/// +/// It can be over-provisioned using the [Merkle::new_advanced] method +/// and passing a minimum depth. /// /// This structure does not contain the data itself, only the hashes. #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] @@ -69,12 +75,15 @@ fn hash_node(ty: MerkleType, a: Bytes32, b: Bytes32) -> Bytes32 { } impl Merkle { - // Creates a new Merkle tree with the given type and leaf hashes. - // The tree is built up to the minimum depth necessary to hold all the leaves. + /// Creates a new Merkle tree with the given type and leaf hashes. + /// The tree is built up to the minimum depth necessary to hold all the + /// leaves. pub fn new(ty: MerkleType, hashes: Vec) -> Merkle { Self::new_advanced(ty, hashes, Bytes32::default(), 0) } + /// Creates a new Merkle tree with the given type, leaf hashes, a hash to + /// use for representing empty leaves, and a minimum depth. pub fn new_advanced( ty: MerkleType, hashes: Vec, @@ -126,6 +135,13 @@ impl Merkle { } } + // Returns the total number of leaves the tree can hold. + #[inline] + fn capacity(&self) -> usize { + let base: usize = 2; + base.pow((self.layers.len() -1).try_into().unwrap()) + } + #[must_use] pub fn prove(&self, idx: usize) -> Option> { if idx >= self.leaves().len() { @@ -199,11 +215,28 @@ impl Merkle { idx >>= 1; } } + + /// Extends the leaves of the tree with the given hashes. + /// + /// Returns the new number of leaves in the tree. + /// Erorrs if the number of hashes plus the current leaves is greater than + /// the capacity of the tree. + pub fn extend(&mut self, hashes: Vec) -> Result { + if hashes.len() > self.capacity() - self.layers[0].len() { + return Err("Cannot extend with more leaves than the capicity of the tree.".to_owned()); + } + let mut idx = self.layers[0].len(); + self.layers[0].resize(idx + hashes.len(), self.empty_layers[0]); + for hash in hashes { + self.set(idx, hash); + idx += 1; + } + return Ok(self.layers[0].len()); + } } #[test] -#[ignore] -fn simple_merkle() { +fn extend_works() { let hashes = vec![ Bytes32::from([1; 32]), Bytes32::from([2; 32]), @@ -221,9 +254,14 @@ fn simple_merkle() { hash_node(MerkleType::Value, Bytes32::from([5; 32]), Bytes32::from([0; 32])), hash_node(MerkleType::Value, Bytes32::from([0; 32]), Bytes32::from([0; 32])))); let mut merkle = Merkle::new(MerkleType::Value, hashes.clone()); + assert_eq!(merkle.capacity(), 8); assert_eq!(merkle.root(), expected); - merkle.set(5, Bytes32::from([6; 32])); + let new_size = match merkle.extend(vec![Bytes32::from([6; 32])]) { + Ok(size) => size, + Err(e) => panic!("{}", e) + }; + assert_eq!(new_size, 6); expected = hash_node(MerkleType::Value, hash_node( MerkleType::Value, @@ -236,9 +274,18 @@ fn simple_merkle() { assert_eq!(merkle.root(), expected); } +#[test] +fn correct_capacity() { + let merkle = Merkle::new(MerkleType::Value, vec![Bytes32::from([1; 32])]); + assert_eq!(merkle.capacity(), 1); + let merkle = Merkle::new_advanced(MerkleType::Memory, vec![Bytes32::from([1; 32])], Bytes32::default(), 11); + assert_eq!(merkle.capacity(), 1024); +} + #[test] #[should_panic] fn set_with_bad_index_panics() { - let mut merkle = Merkle::new(MerkleType::Value, vec![Bytes32::default()]); - merkle.set(1, Bytes32::default()); + let mut merkle = Merkle::new(MerkleType::Value, vec![Bytes32::default(), Bytes32::default()]); + assert_eq!(merkle.capacity(), 2); + merkle.set(2, Bytes32::default()); } From 05b157f5d932a21c2d4c8be7360f5c4edab77b14 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 19 Apr 2024 16:49:08 +0200 Subject: [PATCH 007/268] Extend the memory merkle instead of clearing it. If this happened frequently, it should really improve the perfomance of the machine. However, it looks like it doesn't happen at all with the benchmark inputs. --- arbitrator/prover/src/memory.rs | 11 ++++++----- arbitrator/prover/src/merkle.rs | 5 +++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index bd96221091..ceae141360 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -288,7 +288,7 @@ impl Memory { } pub fn get_range(&self, offset: usize, len: usize) -> Option<&[u8]> { - let end = offset.checked_add(len)?; + let end: usize = offset.checked_add(len)?; if end > self.buffer.len() { return None; } @@ -309,11 +309,12 @@ impl Memory { } pub fn resize(&mut self, new_size: usize) { - let had_merkle_tree = self.merkle.is_some(); - self.merkle = None; + println!("Resizing memory."); self.buffer.resize(new_size, 0); - if had_merkle_tree { - self.cache_merkle_tree(); + if let Some(mut merkle) = self.merkle.take() { + let extra = new_size - merkle.len(); + merkle.extend(vec![hash_leaf([0u8; 32]); extra]) + .expect("Couldn't extend merkle tree"); } } } diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 6570c0e7c3..0a4fb42f08 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -142,6 +142,11 @@ impl Merkle { base.pow((self.layers.len() -1).try_into().unwrap()) } + // Returns the number of leaves in the tree. + pub fn len(&self) -> usize { + self.layers[0].len() + } + #[must_use] pub fn prove(&self, idx: usize) -> Option> { if idx >= self.leaves().len() { From 965a20249e4ca6555a331d6f0672bd755f426173 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Sun, 21 Apr 2024 04:42:09 +0200 Subject: [PATCH 008/268] Fix merge problems from nitro cherry-picks --- arbitrator/Cargo.lock | 121 ++++++++++++++++++++------- arbitrator/bench/src/prepare.rs | 4 +- arbitrator/prover/src/flat_merkle.rs | 2 +- 3 files changed, 95 insertions(+), 32 deletions(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index dfef9ace1e..44ed6f0c01 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -64,12 +64,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "arbitrary" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" - [[package]] name = "anstream" version = "0.6.13" @@ -118,6 +112,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + [[package]] name = "arbutil" version = "0.1.0" @@ -402,7 +402,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.45", + "syn 2.0.52", ] [[package]] @@ -420,10 +420,6 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "convert_case" version = "0.4.0" - -[[package]] -name = "corosensei" -version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" @@ -437,7 +433,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "scopeguard", - "windows-sys", + "windows-sys 0.33.0", ] [[package]] @@ -904,12 +900,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -1394,7 +1384,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1938,7 +1928,7 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap 2.33.3", + "clap 2.34.0", "lazy_static", "structopt-derive", ] @@ -1949,7 +1939,7 @@ version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ - "heck", + "heck 0.3.3", "proc-macro-error", "proc-macro2", "quote", @@ -2190,18 +2180,18 @@ dependencies = [ "ruint2", ] -[[package]] -name = "uuid" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" - [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" + [[package]] name = "vec_map" version = "0.8.2" @@ -2542,27 +2532,58 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + [[package]] name = "windows-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.48.5", "windows_aarch64_msvc 0.48.5", "windows_i686_gnu 0.48.5", "windows_i686_msvc 0.48.5", "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.48.5", "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + [[package]] name = "windows_aarch64_msvc" version = "0.33.0" @@ -2575,6 +2596,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + [[package]] name = "windows_i686_gnu" version = "0.33.0" @@ -2587,6 +2614,18 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + [[package]] name = "windows_i686_msvc" version = "0.33.0" @@ -2599,6 +2638,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + [[package]] name = "windows_x86_64_gnu" version = "0.33.0" @@ -2611,12 +2656,24 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + [[package]] name = "windows_x86_64_msvc" version = "0.33.0" @@ -2629,6 +2686,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + [[package]] name = "winnow" version = "0.5.40" diff --git a/arbitrator/bench/src/prepare.rs b/arbitrator/bench/src/prepare.rs index c6d45dae3b..4004e467a9 100644 --- a/arbitrator/bench/src/prepare.rs +++ b/arbitrator/bench/src/prepare.rs @@ -1,6 +1,6 @@ -use arbutil::PreimageType; +use arbutil::{Bytes32, PreimageType}; use prover::machine::{argument_data_to_inbox, GlobalState, Machine}; -use prover::utils::{Bytes32, CBytes}; +use prover::utils::CBytes; use std::collections::HashMap; use std::fs::File; use std::io::BufReader; diff --git a/arbitrator/prover/src/flat_merkle.rs b/arbitrator/prover/src/flat_merkle.rs index 022429696e..4c46c0b2b6 100644 --- a/arbitrator/prover/src/flat_merkle.rs +++ b/arbitrator/prover/src/flat_merkle.rs @@ -1,7 +1,7 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -use crate::utils::Bytes32; +use arbutil::Bytes32; use digest::Digest; // use rayon::prelude::*; use sha3::Keccak256; From 477e49cb6e71ed50201bff81ce5a8f86807a4a9a Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Sun, 21 Apr 2024 11:20:38 +0200 Subject: [PATCH 009/268] Remove log line about resizing memory. --- arbitrator/prover/src/memory.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index ceae141360..d8cb9cec15 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -309,7 +309,6 @@ impl Memory { } pub fn resize(&mut self, new_size: usize) { - println!("Resizing memory."); self.buffer.resize(new_size, 0); if let Some(mut merkle) = self.merkle.take() { let extra = new_size - merkle.len(); From 15ad8ba9e0496ba56e5bdff5638f3a4f65f8539e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 22 Apr 2024 23:50:08 +0200 Subject: [PATCH 010/268] Introduce mark-and-sweep dirty branch tracking. This change introduces internal mutability to the merkle tree implementation in the form of a dirty_indices HashSet which keeps track of the indices of the parent nodes for leaves which have changed since the last time the hashes for all of the non-leaf nodes in the tree were calculated. The `set` method was changed to only modify the leaf's value and add the parent node to the set of dirty indices. The hashes of all the non-leaf nodes which are dirty and all their ancestors up to the root node are recalcualted just before returning the value of the root. This should allow us to reuse previously allocated merkle trees rather than having to throw them out and recaculate the hashes of all the nodes every time a leaf's value is changed. --- arbitrator/prover/src/memory.rs | 6 +- arbitrator/prover/src/merkle.rs | 152 +++++++++++++++++++++----------- 2 files changed, 102 insertions(+), 56 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index d8cb9cec15..3b42804648 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -234,7 +234,7 @@ impl Memory { let buf = value.to_le_bytes(); self.buffer[idx..end_idx].copy_from_slice(&buf[..bytes.into()]); - if let Some(mut merkle) = self.merkle.take() { + if let Some(merkle) = self.merkle.take() { let start_leaf = idx / Self::LEAF_SIZE; merkle.set(start_leaf, hash_leaf(self.get_leaf_data(start_leaf))); let end_leaf = (end_idx - 1) / Self::LEAF_SIZE; @@ -262,7 +262,7 @@ impl Memory { let end_idx = end_idx as usize; self.buffer[idx..end_idx].copy_from_slice(value); - if let Some(mut merkle) = self.merkle.take() { + if let Some(merkle) = self.merkle.take() { let start_leaf = idx / Self::LEAF_SIZE; merkle.set(start_leaf, hash_leaf(self.get_leaf_data(start_leaf))); // No need for second merkle @@ -310,7 +310,7 @@ impl Memory { pub fn resize(&mut self, new_size: usize) { self.buffer.resize(new_size, 0); - if let Some(mut merkle) = self.merkle.take() { + if let Some(merkle) = self.merkle.take() { let extra = new_size - merkle.len(); merkle.extend(vec![hash_leaf([0u8; 32]); extra]) .expect("Couldn't extend merkle tree"); diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 0a4fb42f08..0c5ea6a956 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -5,7 +5,7 @@ use arbutil::Bytes32; use digest::Digest; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use std::convert::{TryFrom, TryInto}; +use std::{collections::HashSet, convert::{TryFrom, TryInto}, sync::{Arc, Mutex, MutexGuard}}; #[cfg(feature = "rayon")] use rayon::prelude::*; @@ -58,12 +58,15 @@ impl MerkleType { /// and passing a minimum depth. /// /// This structure does not contain the data itself, only the hashes. -#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] +#[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Merkle { ty: MerkleType, - layers: Vec>, + #[serde(with = "arc_mutex_sedre")] + layers: Arc>>>, empty_layers: Vec, min_depth: usize, + #[serde(skip)] + dirty_indices: Arc>>, } fn hash_node(ty: MerkleType, a: Bytes32, b: Bytes32) -> Bytes32 { @@ -74,6 +77,12 @@ fn hash_node(ty: MerkleType, a: Bytes32, b: Bytes32) -> Bytes32 { h.finalize().into() } +#[inline] +fn capacity(layers: &Vec>) -> usize { + let base: usize = 2; + base.pow((layers.len() - 1).try_into().unwrap()) +} + impl Merkle { /// Creates a new Merkle tree with the given type and leaf hashes. /// The tree is built up to the minimum depth necessary to hold all the @@ -112,14 +121,42 @@ impl Merkle { } Merkle { ty, - layers, + layers: Arc::new(Mutex::new(layers)), empty_layers, min_depth, + dirty_indices: Arc::new(Mutex::new(HashSet::new())), + } + } + + fn rehash(&self) { + if self.dirty_indices.lock().unwrap().is_empty() { + return; + } + let mut next_dirty: HashSet = HashSet::new(); + let mut dirty = self.dirty_indices.lock().unwrap(); + let layers = &mut self.layers.lock().unwrap(); + for layer_i in 1..layers.len() { + for idx in dirty.iter() { + let left_child_idx = idx << 1; + let right_child_idx = left_child_idx + 1; + let left = layers[layer_i -1][left_child_idx]; + let right = layers[layer_i-1] + .get(right_child_idx) + .cloned() + .unwrap_or_else(|| self.empty_layers[layer_i - 1]); + layers[layer_i][*idx] = hash_node(self.ty, left, right); + if layer_i < layers.len() - 1 { + next_dirty.insert(idx >> 1); + } + } + dirty.clone_from(&next_dirty); + next_dirty.clear(); } } pub fn root(&self) -> Bytes32 { - if let Some(layer) = self.layers.last() { + self.rehash(); + if let Some(layer) = self.layers.lock().unwrap().last() { assert_eq!(layer.len(), 1); layer[0] } else { @@ -127,29 +164,21 @@ impl Merkle { } } - pub fn leaves(&self) -> &[Bytes32] { - if self.layers.is_empty() { - &[] - } else { - &self.layers[0] - } - } - // Returns the total number of leaves the tree can hold. #[inline] + #[cfg(test)] fn capacity(&self) -> usize { - let base: usize = 2; - base.pow((self.layers.len() -1).try_into().unwrap()) + return capacity(self.layers.lock().unwrap().as_ref()); } // Returns the number of leaves in the tree. pub fn len(&self) -> usize { - self.layers[0].len() + self.layers.lock().unwrap()[0].len() } #[must_use] pub fn prove(&self, idx: usize) -> Option> { - if idx >= self.leaves().len() { + if self.layers.lock().unwrap().is_empty() || idx >= self.layers.lock().unwrap()[0].len() { return None; } Some(self.prove_any(idx)) @@ -158,9 +187,10 @@ impl Merkle { /// creates a merkle proof regardless of if the leaf has content #[must_use] pub fn prove_any(&self, mut idx: usize) -> Vec { - let mut proof = vec![u8::try_from(self.layers.len() - 1).unwrap()]; - for (layer_i, layer) in self.layers.iter().enumerate() { - if layer_i == self.layers.len() - 1 { + let layers = self.layers.lock().unwrap(); + let mut proof = vec![u8::try_from(layers.len() - 1).unwrap()]; + for (layer_i, layer) in layers.iter().enumerate() { + if layer_i == layers.len() - 1 { break; } let counterpart = idx ^ 1; @@ -178,7 +208,7 @@ impl Merkle { /// Adds a new leaf to the merkle /// Currently O(n) in the number of leaves (could be log(n)) pub fn push_leaf(&mut self, leaf: Bytes32) { - let mut leaves = self.layers.swap_remove(0); + let mut leaves = self.layers.lock().unwrap().swap_remove(0); leaves.push(leaf); let empty = self.empty_layers[0]; *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); @@ -187,7 +217,7 @@ impl Merkle { /// Removes the rightmost leaf from the merkle /// Currently O(n) in the number of leaves (could be log(n)) pub fn pop_leaf(&mut self) { - let mut leaves = self.layers.swap_remove(0); + let mut leaves = self.layers.lock().unwrap().swap_remove(0); leaves.pop(); let empty = self.empty_layers[0]; *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); @@ -195,30 +225,17 @@ impl Merkle { // Sets the leaf at the given index to the given hash. // Panics if the index is out of bounds (since the structure doesn't grow). - pub fn set(&mut self, mut idx: usize, hash: Bytes32) { - if self.layers[0][idx] == hash { + pub fn set(&self, idx: usize, hash: Bytes32) { + let mut layers = self.layers.lock().unwrap(); + self.locked_set(&mut layers, idx, hash); + } + + fn locked_set(&self, locked_layers: &mut MutexGuard>>, idx: usize, hash: Bytes32) { + if locked_layers[0][idx] == hash { return; } - let mut next_hash = hash; - let empty_layers = &self.empty_layers; - let layers_len = self.layers.len(); - for (layer_i, layer) in self.layers.iter_mut().enumerate() { - layer[idx] = next_hash; - if layer_i == layers_len - 1 { - // next_hash isn't needed - break; - } - let counterpart = layer - .get(idx ^ 1) - .cloned() - .unwrap_or_else(|| empty_layers[layer_i]); - if idx % 2 == 0 { - next_hash = hash_node(self.ty, next_hash, counterpart); - } else { - next_hash = hash_node(self.ty, counterpart, next_hash); - } - idx >>= 1; - } + locked_layers[0][idx] = hash; + self.dirty_indices.lock().unwrap().insert(idx >> 1); } /// Extends the leaves of the tree with the given hashes. @@ -226,17 +243,44 @@ impl Merkle { /// Returns the new number of leaves in the tree. /// Erorrs if the number of hashes plus the current leaves is greater than /// the capacity of the tree. - pub fn extend(&mut self, hashes: Vec) -> Result { - if hashes.len() > self.capacity() - self.layers[0].len() { + pub fn extend(&self, hashes: Vec) -> Result { + let mut layers = self.layers.lock().unwrap(); + if hashes.len() > capacity(layers.as_ref()) - layers[0].len() { return Err("Cannot extend with more leaves than the capicity of the tree.".to_owned()); } - let mut idx = self.layers[0].len(); - self.layers[0].resize(idx + hashes.len(), self.empty_layers[0]); + let mut idx = layers[0].len(); + layers[0].resize(idx + hashes.len(), self.empty_layers[0]); for hash in hashes { - self.set(idx, hash); + self.locked_set(&mut layers, idx, hash); idx += 1; } - return Ok(self.layers[0].len()); + return Ok(layers[0].len()); + } +} + +impl PartialEq for Merkle { + fn eq(&self, other: &Self) -> bool { + self.root() == other.root() + } +} + +impl Eq for Merkle {} + +pub mod arc_mutex_sedre { + pub fn serialize(data: &std::sync::Arc>, serializer: S) -> Result + where + S: serde::Serializer, + T: serde::Serialize, + { + data.lock().unwrap().serialize(serializer) + } + + pub fn deserialize<'de, D, T>(deserializer: D) -> Result>, D::Error> + where + D: serde::Deserializer<'de>, + T: serde::Deserialize<'de>, + { + Ok(std::sync::Arc::new(std::sync::Mutex::new(T::deserialize(deserializer)?))) } } @@ -258,7 +302,7 @@ fn extend_works() { MerkleType::Value, hash_node(MerkleType::Value, Bytes32::from([5; 32]), Bytes32::from([0; 32])), hash_node(MerkleType::Value, Bytes32::from([0; 32]), Bytes32::from([0; 32])))); - let mut merkle = Merkle::new(MerkleType::Value, hashes.clone()); + let merkle = Merkle::new(MerkleType::Value, hashes.clone()); assert_eq!(merkle.capacity(), 8); assert_eq!(merkle.root(), expected); @@ -276,7 +320,9 @@ fn extend_works() { MerkleType::Value, hash_node(MerkleType::Value, Bytes32::from([5; 32]), Bytes32::from([6; 32])), hash_node(MerkleType::Value, Bytes32::from([0; 32]), Bytes32::from([0; 32])))); + assert_eq!(merkle.capacity(), 8); assert_eq!(merkle.root(), expected); + merkle.prove(1).unwrap(); } #[test] @@ -288,9 +334,9 @@ fn correct_capacity() { } #[test] -#[should_panic] +#[should_panic(expected = "index out of bounds")] fn set_with_bad_index_panics() { - let mut merkle = Merkle::new(MerkleType::Value, vec![Bytes32::default(), Bytes32::default()]); + let merkle = Merkle::new(MerkleType::Value, vec![Bytes32::default(), Bytes32::default()]); assert_eq!(merkle.capacity(), 2); merkle.set(2, Bytes32::default()); } From cb1d10cde24374adbe2ca291397158c7ed7dc3ed Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Apr 2024 01:31:28 +0200 Subject: [PATCH 011/268] Fix the implementation of extend. Previously, it could hit an index out of bounds if the new leafs caused any parent layer to grow beyond its current size. --- arbitrator/prover/src/merkle.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 0a4fb42f08..36121f49d2 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -5,6 +5,7 @@ use arbutil::Bytes32; use digest::Digest; use serde::{Deserialize, Serialize}; use sha3::Keccak256; +use core::panic; use std::convert::{TryFrom, TryInto}; #[cfg(feature = "rayon")] @@ -203,7 +204,13 @@ impl Merkle { let empty_layers = &self.empty_layers; let layers_len = self.layers.len(); for (layer_i, layer) in self.layers.iter_mut().enumerate() { - layer[idx] = next_hash; + if idx < layer.len() { + layer[idx] = next_hash; + } else if idx == layer.len() { + layer.push(next_hash); + } else { + panic!("Index {} out of bounds {}", idx, layer.len()); + } if layer_i == layers_len - 1 { // next_hash isn't needed break; From e644b891e8b8314345497ccfb58b30caa5d7c8d1 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Apr 2024 01:33:10 +0200 Subject: [PATCH 012/268] Add criterion benchmark for a big merkle tree. Hopefully, this will allow us to compare this branch's implementation of a merkle tree to the one on merkle-perf-a. --- arbitrator/Cargo.lock | 180 ++++++++++++++++++++++ arbitrator/prover/Cargo.toml | 8 + arbitrator/prover/benches/merkle_bench.rs | 47 ++++++ arbitrator/prover/src/lib.rs | 2 +- 4 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 arbitrator/prover/benches/merkle_bench.rs diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 44ed6f0c01..b852174501 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -55,6 +55,12 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -334,6 +340,12 @@ dependencies = [ "wasmer", ] +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.90" @@ -356,6 +368,33 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "clap" version = "2.34.0" @@ -528,6 +567,42 @@ version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap 4.5.4", + "criterion-plot", + "is-terminal", + "itertools", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + [[package]] name = "crossbeam-deque" version = "0.8.5" @@ -872,6 +947,16 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if 1.0.0", + "crunchy", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -994,6 +1079,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "is-terminal" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "itertools" version = "0.10.5" @@ -1358,6 +1454,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "opaque-debug" version = "0.3.1" @@ -1399,6 +1501,34 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1455,6 +1585,7 @@ dependencies = [ "bincode", "brotli", "c-kzg", + "criterion", "derivative", "digest 0.9.0", "eyre", @@ -1470,6 +1601,7 @@ dependencies = [ "num-derive", "num-traits", "parking_lot", + "rand", "rayon", "rustc-demangle", "serde", @@ -1721,6 +1853,15 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -2056,6 +2197,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -2204,6 +2355,16 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2485,6 +2646,16 @@ dependencies = [ "wast", ] +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + [[package]] name = "wee_alloc" version = "0.4.5" @@ -2513,6 +2684,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/arbitrator/prover/Cargo.toml b/arbitrator/prover/Cargo.toml index 1fabc4d56c..f932d9459a 100644 --- a/arbitrator/prover/Cargo.toml +++ b/arbitrator/prover/Cargo.toml @@ -40,6 +40,14 @@ c-kzg = { version = "0.4.0", optional = true } # TODO: look into switching to ru sha2 = "0.9.9" lru = "0.12.3" +[dev-dependencies] +criterion = { version = "0.5.0", features = ["html_reports"] } +rand = "0.8.4" + +[[bench]] +name = "merkle_bench" +harness = false + [lib] name = "prover" crate-type = ["staticlib", "lib"] diff --git a/arbitrator/prover/benches/merkle_bench.rs b/arbitrator/prover/benches/merkle_bench.rs new file mode 100644 index 0000000000..b0ced75826 --- /dev/null +++ b/arbitrator/prover/benches/merkle_bench.rs @@ -0,0 +1,47 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +use prover::merkle::{Merkle, MerkleType}; +use arbutil::Bytes32; +use rand::Rng; + +fn extend_and_set_leavees(mut merkle: Merkle, rng: &mut rand::rngs::ThreadRng) { + let new_leaves = vec![ + Bytes32::from([6; 32]), + Bytes32::from([7; 32]), + Bytes32::from([8; 32]), + Bytes32::from([9; 32]), + Bytes32::from([10; 32]), + ]; + + for _ in 0..100 { + merkle.extend(new_leaves.clone()).expect("extend failed"); + for _ in 0..(merkle.len()/10) { + let random_index = rng.gen_range(0..merkle.len()); + merkle.set(random_index, Bytes32::from([rng.gen_range(0u8..9); 32])); + } + } + merkle.root(); +} + +fn merkle_benchmark(c: &mut Criterion) { + let mut rng = rand::thread_rng(); + let leaves = vec![ + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + Bytes32::from([5; 32]), + ]; + + let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 20); + assert_eq!(merkle.len(), 5); + + // Perform many calls to set leaves to new values + c.bench_function("extend_set_leaves_and_root", |b| { + b.iter(|| { + extend_and_set_leavees(merkle.clone(), &mut rng); + }) + }); +} + +criterion_group!(benches, merkle_benchmark); +criterion_main!(benches); \ No newline at end of file diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index fccd28ff0f..85c0ca2aa8 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -11,7 +11,7 @@ mod kzg; pub mod machine; /// cbindgen:ignore mod memory; -mod merkle; +pub mod merkle; mod print; pub mod programs; mod reinterpret; From b60438f8076d59519f58d9072c6d70fd0cf77dcb Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Apr 2024 01:50:33 +0200 Subject: [PATCH 013/268] Switch to a binary tree set. This gives us ordered traversal of the dirty indices. The performance benchmarks show that this severely regresses over the implmenetation on merkle-perf. --- arbitrator/prover/src/merkle.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 7f5a82667a..577eeb30a9 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -5,7 +5,7 @@ use arbutil::Bytes32; use digest::Digest; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use std::{collections::HashSet, convert::{TryFrom, TryInto}, sync::{Arc, Mutex, MutexGuard}}; +use std::{collections::BTreeSet, convert::{TryFrom, TryInto}, sync::{Arc, Mutex, MutexGuard}}; #[cfg(feature = "rayon")] use rayon::prelude::*; @@ -66,7 +66,7 @@ pub struct Merkle { empty_layers: Vec, min_depth: usize, #[serde(skip)] - dirty_indices: Arc>>, + dirty_indices: Arc>>, } fn hash_node(ty: MerkleType, a: Bytes32, b: Bytes32) -> Bytes32 { @@ -124,7 +124,7 @@ impl Merkle { layers: Arc::new(Mutex::new(layers)), empty_layers, min_depth, - dirty_indices: Arc::new(Mutex::new(HashSet::new())), + dirty_indices: Arc::new(Mutex::new(BTreeSet::new())), } } @@ -132,7 +132,7 @@ impl Merkle { if self.dirty_indices.lock().unwrap().is_empty() { return; } - let mut next_dirty: HashSet = HashSet::new(); + let mut next_dirty: BTreeSet = BTreeSet::new(); let mut dirty = self.dirty_indices.lock().unwrap(); let layers = &mut self.layers.lock().unwrap(); for layer_i in 1..layers.len() { From 28c90aee66803e30f22fcdf50d3bf83113a2e423 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Apr 2024 11:50:35 +0200 Subject: [PATCH 014/268] Use memory more efficiently. --- arbitrator/prover/src/merkle.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 577eeb30a9..df41b6cdbc 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -3,9 +3,10 @@ use arbutil::Bytes32; use digest::Digest; +use itertools::sorted; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use std::{collections::BTreeSet, convert::{TryFrom, TryInto}, sync::{Arc, Mutex, MutexGuard}}; +use std::{collections::HashSet, convert::{TryFrom, TryInto}, sync::{Arc, Mutex, MutexGuard}}; #[cfg(feature = "rayon")] use rayon::prelude::*; @@ -66,7 +67,7 @@ pub struct Merkle { empty_layers: Vec, min_depth: usize, #[serde(skip)] - dirty_indices: Arc>>, + dirty_indices: Arc>>, } fn hash_node(ty: MerkleType, a: Bytes32, b: Bytes32) -> Bytes32 { @@ -119,12 +120,13 @@ impl Merkle { empty_layers.push(hash_node(ty, empty_layer, empty_layer)); layers.push(new_layer); } + let dirty_indices = Arc::new(Mutex::new(HashSet::with_capacity(layers[0].len()))); Merkle { ty, layers: Arc::new(Mutex::new(layers)), empty_layers, min_depth, - dirty_indices: Arc::new(Mutex::new(BTreeSet::new())), + dirty_indices, } } @@ -132,11 +134,12 @@ impl Merkle { if self.dirty_indices.lock().unwrap().is_empty() { return; } - let mut next_dirty: BTreeSet = BTreeSet::new(); - let mut dirty = self.dirty_indices.lock().unwrap(); + println!("Rehashing with dirty indices: {:?} of {:?}", self.dirty_indices.lock().unwrap().len(), self.len()); let layers = &mut self.layers.lock().unwrap(); + let mut next_dirty: HashSet = HashSet::with_capacity(layers[2].len()); + let mut dirty = self.dirty_indices.lock().unwrap(); for layer_i in 1..layers.len() { - for idx in dirty.iter() { + for idx in sorted(dirty.iter()) { let left_child_idx = idx << 1; let right_child_idx = left_child_idx + 1; let left = layers[layer_i -1][left_child_idx]; @@ -156,7 +159,9 @@ impl Merkle { } } dirty.clone_from(&next_dirty); - next_dirty.clear(); + if layer_i < layers.len() - 1 { + next_dirty = HashSet::with_capacity(layers[layer_i + 1].len()); + } } } From e8868a87ce9994e7c0e275426fd96f7a28087765 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Apr 2024 11:52:26 +0200 Subject: [PATCH 015/268] Include the creation of a fresh tree for each iteration. The previous implementation was growing the same layers and dirty_indices arrays because the clone isn't deep (I guess.) --- arbitrator/prover/benches/merkle_bench.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arbitrator/prover/benches/merkle_bench.rs b/arbitrator/prover/benches/merkle_bench.rs index b0ced75826..922f6cb177 100644 --- a/arbitrator/prover/benches/merkle_bench.rs +++ b/arbitrator/prover/benches/merkle_bench.rs @@ -32,12 +32,10 @@ fn merkle_benchmark(c: &mut Criterion) { Bytes32::from([5; 32]), ]; - let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 20); - assert_eq!(merkle.len(), 5); - // Perform many calls to set leaves to new values c.bench_function("extend_set_leaves_and_root", |b| { b.iter(|| { + let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 20); extend_and_set_leavees(merkle.clone(), &mut rng); }) }); From 03d242016a1df513735d28cfb8e3c324909c2c86 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Apr 2024 11:58:24 +0200 Subject: [PATCH 016/268] Remove println This was just for troubleshooting. --- arbitrator/prover/src/merkle.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index df41b6cdbc..d74e742915 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -134,7 +134,6 @@ impl Merkle { if self.dirty_indices.lock().unwrap().is_empty() { return; } - println!("Rehashing with dirty indices: {:?} of {:?}", self.dirty_indices.lock().unwrap().len(), self.len()); let layers = &mut self.layers.lock().unwrap(); let mut next_dirty: HashSet = HashSet::with_capacity(layers[2].len()); let mut dirty = self.dirty_indices.lock().unwrap(); From b7e7cd338427fcfa697ea53a1baa9f4f6248958a Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Apr 2024 13:12:07 +0200 Subject: [PATCH 017/268] Further optimization. Specifically, this pre-allocates the dirty HashSets for each layer instead of having to allocate new ones each time rehash is called. --- arbitrator/prover/src/merkle.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index d74e742915..ca26a21e28 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -67,7 +67,7 @@ pub struct Merkle { empty_layers: Vec, min_depth: usize, #[serde(skip)] - dirty_indices: Arc>>, + dirty_layers: Arc>>>, } fn hash_node(ty: MerkleType, a: Bytes32, b: Bytes32) -> Bytes32 { @@ -105,6 +105,7 @@ impl Merkle { } let mut layers = vec![hashes]; let mut empty_layers = vec![empty_hash]; + let mut dirty_indices: Vec> = Vec::new(); while layers.last().unwrap().len() > 1 || layers.len() < min_depth { let empty_layer = *empty_layers.last().unwrap(); @@ -114,31 +115,33 @@ impl Merkle { #[cfg(not(feature = "rayon"))] let new_layer = layers.last().unwrap().chunks(2); - let new_layer = new_layer + let new_layer: Vec = new_layer .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_layer))) .collect(); empty_layers.push(hash_node(ty, empty_layer, empty_layer)); + dirty_indices.push(HashSet::with_capacity(new_layer.len())); layers.push(new_layer); } - let dirty_indices = Arc::new(Mutex::new(HashSet::with_capacity(layers[0].len()))); + let dirty_layers = Arc::new(Mutex::new(dirty_indices)); Merkle { ty, layers: Arc::new(Mutex::new(layers)), empty_layers, min_depth, - dirty_indices, + dirty_layers, } } fn rehash(&self) { - if self.dirty_indices.lock().unwrap().is_empty() { + let dirty_layers = &mut self.dirty_layers.lock().unwrap(); + if dirty_layers[0].is_empty() { return; } let layers = &mut self.layers.lock().unwrap(); - let mut next_dirty: HashSet = HashSet::with_capacity(layers[2].len()); - let mut dirty = self.dirty_indices.lock().unwrap(); for layer_i in 1..layers.len() { - for idx in sorted(dirty.iter()) { + let dirty_i = layer_i - 1; + let dirt = dirty_layers[dirty_i].clone(); + for idx in sorted(dirt.iter()) { let left_child_idx = idx << 1; let right_child_idx = left_child_idx + 1; let left = layers[layer_i -1][left_child_idx]; @@ -152,15 +155,11 @@ impl Merkle { } else { layers[layer_i].push(new_hash); } - layers[layer_i][*idx] = hash_node(self.ty, left, right); if layer_i < layers.len() - 1 { - next_dirty.insert(idx >> 1); + dirty_layers[dirty_i + 1].insert(idx >> 1); } } - dirty.clone_from(&next_dirty); - if layer_i < layers.len() - 1 { - next_dirty = HashSet::with_capacity(layers[layer_i + 1].len()); - } + dirty_layers[dirty_i].clear(); } } @@ -245,7 +244,7 @@ impl Merkle { return; } locked_layers[0][idx] = hash; - self.dirty_indices.lock().unwrap().insert(idx >> 1); + self.dirty_layers.lock().unwrap()[0].insert(idx >> 1); } /// Extends the leaves of the tree with the given hashes. From b354b09fe3a8a0116412099f38c052b1bb3b9bb7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Apr 2024 16:45:05 +0200 Subject: [PATCH 018/268] Fix the empty dirty indices bug. --- arbitrator/prover/src/merkle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index ca26a21e28..03ec6eb6ef 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -134,7 +134,7 @@ impl Merkle { fn rehash(&self) { let dirty_layers = &mut self.dirty_layers.lock().unwrap(); - if dirty_layers[0].is_empty() { + if dirty_layers.is_empty() || dirty_layers[0].is_empty() { return; } let layers = &mut self.layers.lock().unwrap(); From 1f528752e140a52e6ecaab7b2e51c17d93dc3e58 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 24 Apr 2024 16:44:56 +0200 Subject: [PATCH 019/268] Add some profiling and instrumentation code. There are a few different things going on in this commit. 1. I've added some counters for when methods get called on the Merkle tree. 2. I've added integration with gperftools for profiling specific areas of the code. --- arbitrator/Cargo.lock | 57 +++++++++++++++++-- arbitrator/bench/Cargo.toml | 3 +- arbitrator/bench/src/bin.rs | 15 ++++- arbitrator/prover/Cargo.toml | 3 +- arbitrator/prover/src/merkle.rs | 98 ++++++++++++++++++++++++++++++++- 5 files changed, 168 insertions(+), 8 deletions(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index b852174501..25dc258114 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -188,6 +188,7 @@ dependencies = [ "arbutil", "clap 4.5.4", "eyre", + "gperftools", "hex", "prover", ] @@ -816,7 +817,16 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6" dependencies = [ - "enum-iterator-derive", + "enum-iterator-derive 0.7.0", +] + +[[package]] +name = "enum-iterator" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e0b48d2b80ff6b002339547442496ea29d66a8c66ce8e1a6bd8c58b9cec7cf3" +dependencies = [ + "enum-iterator-derive 1.3.1", ] [[package]] @@ -830,6 +840,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "enum-iterator-derive" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19cbb53d33b57ac4df1f0af6b92c38c107cded663c4aea9fae1189dcfc17cf5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "enumset" version = "1.1.3" @@ -857,6 +878,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "backtrace", + "version_check", +] + [[package]] name = "eyre" version = "0.6.12" @@ -947,6 +978,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +[[package]] +name = "gperftools" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20a3fc5818b1223ec628fc6998c8900486208b577f78c07500d4b52f983ebc9d" +dependencies = [ + "error-chain", + "lazy_static", + "pkg-config", +] + [[package]] name = "half" version = "2.4.1" @@ -1501,6 +1543,12 @@ version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + [[package]] name = "plotters" version = "0.3.5" @@ -1588,6 +1636,7 @@ dependencies = [ "criterion", "derivative", "digest 0.9.0", + "enum-iterator 2.0.1", "eyre", "fnv", "hex", @@ -2491,7 +2540,7 @@ dependencies = [ "backtrace", "bytes", "cfg-if 1.0.0", - "enum-iterator", + "enum-iterator 0.7.0", "enumset", "lazy_static", "leb128", @@ -2580,7 +2629,7 @@ name = "wasmer-types" version = "4.2.3" dependencies = [ "bytecheck", - "enum-iterator", + "enum-iterator 0.7.0", "enumset", "indexmap 1.9.3", "more-asserts", @@ -2600,7 +2649,7 @@ dependencies = [ "crossbeam-queue", "dashmap", "derivative", - "enum-iterator", + "enum-iterator 0.7.0", "fnv", "indexmap 1.9.3", "lazy_static", diff --git a/arbitrator/bench/Cargo.toml b/arbitrator/bench/Cargo.toml index e0346d7fab..3a245f3d9c 100644 --- a/arbitrator/bench/Cargo.toml +++ b/arbitrator/bench/Cargo.toml @@ -17,6 +17,7 @@ eyre = "0.6.5" prover = { path = "../prover" } arbutil = { path = "../arbutil" } clap = { version = "4.4.8", features = ["derive"] } +gperftools = { version = "0.2.0", features = ["heap"] } [profile.release] -debug = true \ No newline at end of file +debug = true diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index b39e661925..d70b847196 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -3,8 +3,13 @@ use std::{path::PathBuf, time::Duration}; use bench::prepare::*; use clap::Parser; use eyre::bail; +use gperftools::profiler::PROFILER; +use gperftools::heap_profiler::HEAP_PROFILER; use prover::machine::MachineStatus; +#[cfg(feature = "counters")] +use prover::merkle; + #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { @@ -30,7 +35,6 @@ fn main() -> eyre::Result<()> { println!("Running benchmark with always merkleize feature off"); } for step_size in step_sizes { - let total = std::time::Instant::now(); let mut machine = prepare_machine( args.preimages_path.clone(), args.machine_path.clone(), @@ -40,6 +44,11 @@ fn main() -> eyre::Result<()> { let mut hash_times = vec![]; let mut step_times = vec![]; let mut num_iters = 0; + PROFILER.lock().unwrap().start(format!("./target/bench-{}.prof", step_size)).unwrap(); + HEAP_PROFILER.lock().unwrap().start(format!("./target/bench-{}.hprof", step_size)).unwrap(); + #[cfg(feature = "counters")] + merkle::resetCounters(); + let total = std::time::Instant::now(); loop { let start = std::time::Instant::now(); machine.step_n(step_size)?; @@ -66,6 +75,8 @@ fn main() -> eyre::Result<()> { break; } } + PROFILER.lock().unwrap().stop().unwrap(); + HEAP_PROFILER.lock().unwrap().stop().unwrap(); let total_end_time = total.elapsed(); println!( "avg hash time {:?}, avg step time {:?}, step size {}, num_iters {}, total time {:?}", @@ -75,6 +86,8 @@ fn main() -> eyre::Result<()> { num_iters, total_end_time, ); + #[cfg(feature = "counters")] + merkle::printCounters(); } Ok(()) } diff --git a/arbitrator/prover/Cargo.toml b/arbitrator/prover/Cargo.toml index f932d9459a..63158c9728 100644 --- a/arbitrator/prover/Cargo.toml +++ b/arbitrator/prover/Cargo.toml @@ -23,7 +23,7 @@ static_assertions = "1.1.0" structopt = "0.3.23" serde_with = "1.12.1" parking_lot = "0.12.1" -lazy_static.workspace = true +lazy_static = "1.4.0" itertools = "0.10.5" wat = "1.0.56" smallvec = { version = "1.10.0", features = ["serde"] } @@ -39,6 +39,7 @@ num-traits = "0.2.17" c-kzg = { version = "0.4.0", optional = true } # TODO: look into switching to rust-kzg (no crates.io release or hosted rustdoc yet) sha2 = "0.9.9" lru = "0.12.3" +enum-iterator = "2.0.1" [dev-dependencies] criterion = { version = "0.5.0", features = ["html_reports"] } diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 36121f49d2..2aec28ce5f 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -3,6 +3,26 @@ use arbutil::Bytes32; use digest::Digest; + +use enum_iterator::Sequence; + +#[cfg(feature = "counters")] +use enum_iterator::all; + + +#[cfg(feature = "counters")] +use std::sync::atomic::AtomicUsize; + +#[cfg(feature = "counters")] +use std::sync::atomic::Ordering; + +#[cfg(feature = "counters")] +use lazy_static::lazy_static; + + +#[cfg(feature = "counters")] +use std::collections::HashMap; + use serde::{Deserialize, Serialize}; use sha3::Keccak256; use core::panic; @@ -11,7 +31,54 @@ use std::convert::{TryFrom, TryInto}; #[cfg(feature = "rayon")] use rayon::prelude::*; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[cfg(feature = "counters")] +lazy_static! { + static ref NEW_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { + let mut map = HashMap::new(); + map.insert(&MerkleType::Empty, AtomicUsize::new(0)); + map.insert(&MerkleType::Value, AtomicUsize::new(0)); + map.insert(&MerkleType::Function, AtomicUsize::new(0)); + map.insert(&MerkleType::Instruction, AtomicUsize::new(0)); + map.insert(&MerkleType::Memory, AtomicUsize::new(0)); + map.insert(&MerkleType::Table, AtomicUsize::new(0)); + map.insert(&MerkleType::TableElement, AtomicUsize::new(0)); + map.insert(&MerkleType::Module, AtomicUsize::new(0)); + map + }; +} +#[cfg(feature = "counters")] +lazy_static! { + static ref ROOT_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { + let mut map = HashMap::new(); + map.insert(&MerkleType::Empty, AtomicUsize::new(0)); + map.insert(&MerkleType::Value, AtomicUsize::new(0)); + map.insert(&MerkleType::Function, AtomicUsize::new(0)); + map.insert(&MerkleType::Instruction, AtomicUsize::new(0)); + map.insert(&MerkleType::Memory, AtomicUsize::new(0)); + map.insert(&MerkleType::Table, AtomicUsize::new(0)); + map.insert(&MerkleType::TableElement, AtomicUsize::new(0)); + map.insert(&MerkleType::Module, AtomicUsize::new(0)); + map + }; +} +#[cfg(feature = "counters")] +lazy_static! { + static ref SET_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { + let mut map = HashMap::new(); + map.insert(&MerkleType::Empty, AtomicUsize::new(0)); + map.insert(&MerkleType::Value, AtomicUsize::new(0)); + map.insert(&MerkleType::Function, AtomicUsize::new(0)); + map.insert(&MerkleType::Instruction, AtomicUsize::new(0)); + map.insert(&MerkleType::Memory, AtomicUsize::new(0)); + map.insert(&MerkleType::Table, AtomicUsize::new(0)); + map.insert(&MerkleType::TableElement, AtomicUsize::new(0)); + map.insert(&MerkleType::Module, AtomicUsize::new(0)); + map + }; +} + + +#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Sequence)] pub enum MerkleType { Empty, Value, @@ -29,6 +96,29 @@ impl Default for MerkleType { } } +#[cfg(feature = "counters")] +pub fn printCounters() { + for ty in all::() { + if ty == MerkleType::Empty { + continue; + } + println!("{} New: {}, Root: {}, Set: {}", + ty.get_prefix(), NEW_COUNTERS[&ty].load(Ordering::Relaxed), ROOT_COUNTERS[&ty].load(Ordering::Relaxed), SET_COUNTERS[&ty].load(Ordering::Relaxed)); + } +} + +#[cfg(feature = "counters")] +pub fn resetCounters() { + for ty in all::() { + if ty == MerkleType::Empty { + continue; + } + NEW_COUNTERS[&ty].store(0, Ordering::Relaxed); + ROOT_COUNTERS[&ty].store(0, Ordering::Relaxed); + SET_COUNTERS[&ty].store(0, Ordering::Relaxed); + } +} + impl MerkleType { pub fn get_prefix(self) -> &'static str { match self { @@ -91,6 +181,8 @@ impl Merkle { empty_hash: Bytes32, min_depth: usize, ) -> Merkle { + #[cfg(feature = "counters")] + NEW_COUNTERS[&ty].fetch_add(1, Ordering::Relaxed); if hashes.is_empty() { return Merkle::default(); } @@ -120,6 +212,8 @@ impl Merkle { } pub fn root(&self) -> Bytes32 { + #[cfg(feature = "counters")] + ROOT_COUNTERS[&self.ty].fetch_add(1, Ordering::Relaxed); if let Some(layer) = self.layers.last() { assert_eq!(layer.len(), 1); layer[0] @@ -197,6 +291,8 @@ impl Merkle { // Sets the leaf at the given index to the given hash. // Panics if the index is out of bounds (since the structure doesn't grow). pub fn set(&mut self, mut idx: usize, hash: Bytes32) { + #[cfg(feature = "counters")] + SET_COUNTERS[&self.ty].fetch_add(1, Ordering::Relaxed); if self.layers[0][idx] == hash { return; } From 976cb36b14d8adab314c7389092aa21a661ac01d Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 25 Apr 2024 12:12:42 +0200 Subject: [PATCH 020/268] Make features work This allows me to profile CPU and Heap independently, and to enable and disable the call counters independently. --- arbitrator/bench/Cargo.toml | 7 ++++++- arbitrator/bench/src/bin.rs | 19 +++++++++++++++++-- arbitrator/prover/Cargo.toml | 3 ++- arbitrator/prover/src/merkle.rs | 4 ++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/arbitrator/bench/Cargo.toml b/arbitrator/bench/Cargo.toml index 3a245f3d9c..3441321877 100644 --- a/arbitrator/bench/Cargo.toml +++ b/arbitrator/bench/Cargo.toml @@ -17,7 +17,12 @@ eyre = "0.6.5" prover = { path = "../prover" } arbutil = { path = "../arbutil" } clap = { version = "4.4.8", features = ["derive"] } -gperftools = { version = "0.2.0", features = ["heap"] } +gperftools = { version = "0.2.0", optional = true } + +[features] +counters = [] +cpuprof = ["gperftools"] +heapprof = ["gperftools", "gperftools/heap"] [profile.release] debug = true diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index d70b847196..a2c94a6c7c 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -3,8 +3,13 @@ use std::{path::PathBuf, time::Duration}; use bench::prepare::*; use clap::Parser; use eyre::bail; + +#[cfg(feature = "cpuprof")] use gperftools::profiler::PROFILER; + +#[cfg(feature = "heapprof")] use gperftools::heap_profiler::HEAP_PROFILER; + use prover::machine::MachineStatus; #[cfg(feature = "counters")] @@ -44,10 +49,15 @@ fn main() -> eyre::Result<()> { let mut hash_times = vec![]; let mut step_times = vec![]; let mut num_iters = 0; + + #[cfg(feature = "cpuprof")] PROFILER.lock().unwrap().start(format!("./target/bench-{}.prof", step_size)).unwrap(); + + #[cfg(feature = "heapprof")] HEAP_PROFILER.lock().unwrap().start(format!("./target/bench-{}.hprof", step_size)).unwrap(); + #[cfg(feature = "counters")] - merkle::resetCounters(); + merkle::reset_counters(); let total = std::time::Instant::now(); loop { let start = std::time::Instant::now(); @@ -75,8 +85,13 @@ fn main() -> eyre::Result<()> { break; } } + + #[cfg(feature = "cpuprof")] PROFILER.lock().unwrap().stop().unwrap(); + + #[cfg(feature = "heapprof")] HEAP_PROFILER.lock().unwrap().stop().unwrap(); + let total_end_time = total.elapsed(); println!( "avg hash time {:?}, avg step time {:?}, step size {}, num_iters {}, total time {:?}", @@ -87,7 +102,7 @@ fn main() -> eyre::Result<()> { total_end_time, ); #[cfg(feature = "counters")] - merkle::printCounters(); + merkle::print_counters(); } Ok(()) } diff --git a/arbitrator/prover/Cargo.toml b/arbitrator/prover/Cargo.toml index 63158c9728..fe8b4b0f73 100644 --- a/arbitrator/prover/Cargo.toml +++ b/arbitrator/prover/Cargo.toml @@ -23,7 +23,7 @@ static_assertions = "1.1.0" structopt = "0.3.23" serde_with = "1.12.1" parking_lot = "0.12.1" -lazy_static = "1.4.0" +lazy_static.workspace = true itertools = "0.10.5" wat = "1.0.56" smallvec = { version = "1.10.0", features = ["serde"] } @@ -55,6 +55,7 @@ crate-type = ["staticlib", "lib"] [features] default = ["native", "rayon", "singlepass_rayon"] +counters = [] native = ["dep:wasmer", "dep:wasmer-compiler-singlepass", "brotli/wasmer_traits", "dep:c-kzg"] singlepass_rayon = ["wasmer-compiler-singlepass?/rayon"] rayon = ["dep:rayon"] diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 2aec28ce5f..3af5bd2ae8 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -97,7 +97,7 @@ impl Default for MerkleType { } #[cfg(feature = "counters")] -pub fn printCounters() { +pub fn print_counters() { for ty in all::() { if ty == MerkleType::Empty { continue; @@ -108,7 +108,7 @@ pub fn printCounters() { } #[cfg(feature = "counters")] -pub fn resetCounters() { +pub fn reset_counters() { for ty in all::() { if ty == MerkleType::Empty { continue; From d1a2f66ffe850b498948cac4e79e8d9c7dfa2861 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 26 Apr 2024 11:13:09 +0200 Subject: [PATCH 021/268] Add a benchmark for new_advanced. This part of the code is obviously slow. Let's see if we can improve it. --- arbitrator/prover/benches/merkle_bench.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arbitrator/prover/benches/merkle_bench.rs b/arbitrator/prover/benches/merkle_bench.rs index 922f6cb177..b472db0dc9 100644 --- a/arbitrator/prover/benches/merkle_bench.rs +++ b/arbitrator/prover/benches/merkle_bench.rs @@ -3,7 +3,7 @@ use prover::merkle::{Merkle, MerkleType}; use arbutil::Bytes32; use rand::Rng; -fn extend_and_set_leavees(mut merkle: Merkle, rng: &mut rand::rngs::ThreadRng) { +fn extend_and_set_leavees(merkle: Merkle, rng: &mut rand::rngs::ThreadRng) { let new_leaves = vec![ Bytes32::from([6; 32]), Bytes32::from([7; 32]), @@ -41,5 +41,20 @@ fn merkle_benchmark(c: &mut Criterion) { }); } -criterion_group!(benches, merkle_benchmark); +fn merkle_construction(c: &mut Criterion) { + let mut rng = rand::thread_rng(); + let mut leaves: Vec = Vec::with_capacity(1 >> 20); + for _ in 0..(1 >> 20) { + leaves.push(Bytes32::from([rng.gen_range(0u8..9); 32])); + } + + c.bench_function("merkle_construction", |b| { + b.iter(|| { + let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 21); + merkle.root(); + }) + }); +} + +criterion_group!(benches, merkle_benchmark, merkle_construction); criterion_main!(benches); \ No newline at end of file From b31a97b2859b035ee7cd4efc83c3899558ee37df Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 26 Apr 2024 16:38:42 +0200 Subject: [PATCH 022/268] Use capacity hints for all vector initialization. This nets a pretty variable 4%-7% savings in the micro bnechmark. --- arbitrator/prover/src/merkle.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 3d6e94fba9..48d9b65144 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -195,21 +195,27 @@ impl Merkle { if hashes.is_empty() { return Merkle::default(); } - let mut layers = vec![hashes]; - let mut empty_layers = vec![empty_hash]; - let mut dirty_indices: Vec> = Vec::new(); + let mut depth = (hashes.len() as f64).log2().ceil() as usize; + depth = depth.max(min_depth); + let mut layers: Vec> = Vec::with_capacity(depth); + layers.push(hashes); + let mut empty_layers: Vec = Vec::with_capacity(depth); + empty_layers.push(empty_hash); + let mut dirty_indices: Vec> = Vec::with_capacity(depth); while layers.last().unwrap().len() > 1 || layers.len() < min_depth { + let layer = layers.last().unwrap(); let empty_layer = *empty_layers.last().unwrap(); #[cfg(feature = "rayon")] - let new_layer = layers.last().unwrap().par_chunks(2); + let chunks = layer.par_chunks(2); #[cfg(not(feature = "rayon"))] - let new_layer = layers.last().unwrap().chunks(2); + let chunks = layer.chunks(2); - let new_layer: Vec = new_layer + let mut new_layer: Vec = Vec::with_capacity(layer.len() >> 1); + chunks .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_layer))) - .collect(); + .collect_into_vec(&mut new_layer); empty_layers.push(hash_node(ty, empty_layer, empty_layer)); dirty_indices.push(HashSet::with_capacity(new_layer.len())); layers.push(new_layer); From e5ec9c42ac71fc33f98249670462ca7a785ae941 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 26 Apr 2024 21:00:53 +0200 Subject: [PATCH 023/268] Add static vectors of empty hashes for 64 layers of each MerkleType. This saves every instance of a Merkle Tree from having to initialize its own vector of empty hashes. --- arbitrator/prover/src/merkle.rs | 27 +- arbitrator/prover/src/merkle/zerohashes.rs | 475 +++++++++++++++++++++ 2 files changed, 488 insertions(+), 14 deletions(-) create mode 100644 arbitrator/prover/src/merkle/zerohashes.rs diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 48d9b65144..95fa139186 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -10,7 +10,6 @@ use enum_iterator::Sequence; #[cfg(feature = "counters")] use enum_iterator::all; - #[cfg(feature = "counters")] use std::sync::atomic::AtomicUsize; @@ -20,7 +19,6 @@ use std::sync::atomic::Ordering; #[cfg(feature = "counters")] use lazy_static::lazy_static; - #[cfg(feature = "counters")] use std::collections::HashMap; @@ -31,6 +29,10 @@ use std::{collections::HashSet, convert::{TryFrom, TryInto}, sync::{Arc, Mutex, #[cfg(feature = "rayon")] use rayon::prelude::*; +mod zerohashes; + +use zerohashes::ZERO_HASHES; + #[cfg(feature = "counters")] lazy_static! { static ref NEW_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { @@ -154,7 +156,6 @@ pub struct Merkle { ty: MerkleType, #[serde(with = "arc_mutex_sedre")] layers: Arc>>>, - empty_layers: Vec, min_depth: usize, #[serde(skip)] dirty_layers: Arc>>>, @@ -199,12 +200,11 @@ impl Merkle { depth = depth.max(min_depth); let mut layers: Vec> = Vec::with_capacity(depth); layers.push(hashes); - let mut empty_layers: Vec = Vec::with_capacity(depth); - empty_layers.push(empty_hash); let mut dirty_indices: Vec> = Vec::with_capacity(depth); + let mut layer_i = 0usize; while layers.last().unwrap().len() > 1 || layers.len() < min_depth { let layer = layers.last().unwrap(); - let empty_layer = *empty_layers.last().unwrap(); + let empty_hash = ZERO_HASHES[&ty][layer_i]; #[cfg(feature = "rayon")] let chunks = layer.par_chunks(2); @@ -214,17 +214,16 @@ impl Merkle { let mut new_layer: Vec = Vec::with_capacity(layer.len() >> 1); chunks - .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_layer))) + .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_hash))) .collect_into_vec(&mut new_layer); - empty_layers.push(hash_node(ty, empty_layer, empty_layer)); dirty_indices.push(HashSet::with_capacity(new_layer.len())); layers.push(new_layer); + layer_i += 1; } let dirty_layers = Arc::new(Mutex::new(dirty_indices)); Merkle { ty, layers: Arc::new(Mutex::new(layers)), - empty_layers, min_depth, dirty_layers, } @@ -246,7 +245,7 @@ impl Merkle { let right = layers[layer_i-1] .get(right_child_idx) .cloned() - .unwrap_or_else(|| self.empty_layers[layer_i - 1]); + .unwrap_or_else(|| ZERO_HASHES[&self.ty][layer_i - 1]); let new_hash = hash_node(self.ty, left, right); if *idx < layers[layer_i].len() { layers[layer_i][*idx] = new_hash; @@ -307,7 +306,7 @@ impl Merkle { layer .get(counterpart) .cloned() - .unwrap_or_else(|| self.empty_layers[layer_i]), + .unwrap_or_else(|| ZERO_HASHES[&self.ty][layer_i]), ); idx >>= 1; } @@ -319,7 +318,7 @@ impl Merkle { pub fn push_leaf(&mut self, leaf: Bytes32) { let mut leaves = self.layers.lock().unwrap().swap_remove(0); leaves.push(leaf); - let empty = self.empty_layers[0]; + let empty = ZERO_HASHES[&self.ty][0]; *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); } @@ -328,7 +327,7 @@ impl Merkle { pub fn pop_leaf(&mut self) { let mut leaves = self.layers.lock().unwrap().swap_remove(0); leaves.pop(); - let empty = self.empty_layers[0]; + let empty = ZERO_HASHES[&self.ty][0]; *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); } @@ -360,7 +359,7 @@ impl Merkle { return Err("Cannot extend with more leaves than the capicity of the tree.".to_owned()); } let mut idx = layers[0].len(); - layers[0].resize(idx + hashes.len(), self.empty_layers[0]); + layers[0].resize(idx + hashes.len(), ZERO_HASHES[&self.ty][0]); for hash in hashes { self.locked_set(&mut layers, idx, hash); idx += 1; diff --git a/arbitrator/prover/src/merkle/zerohashes.rs b/arbitrator/prover/src/merkle/zerohashes.rs new file mode 100644 index 0000000000..97d5c59c10 --- /dev/null +++ b/arbitrator/prover/src/merkle/zerohashes.rs @@ -0,0 +1,475 @@ +use std::collections::HashMap; + +use arbutil::Bytes32; +use lazy_static::lazy_static; + +use crate::merkle::MerkleType; + +lazy_static! { + pub static ref ZERO_HASHES: HashMap> = { + let mut zero_hashes = HashMap::new(); + zero_hashes.insert(MerkleType::Value, vec![ + Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::from([119, 47, 167, 222, 218, 156, 26, 105, 57, 248, 170, 182, 183, 151, 18, 150, 142, 70, 138, 253, 54, 123, 132, 86, 170, 76, 157, 52, 113, 138, 253, 254]), + Bytes32::from([8, 117, 27, 211, 196, 42, 6, 98, 185, 88, 231, 145, 14, 3, 207, 145, 158, 255, 69, 52, 198, 196, 148, 154, 59, 94, 229, 157, 93, 51, 200, 69]), + Bytes32::from([247, 208, 196, 206, 204, 168, 129, 100, 238, 95, 52, 26, 132, 138, 233, 149, 196, 72, 179, 226, 60, 114, 27, 94, 173, 189, 197, 100, 163, 232, 180, 63]), + Bytes32::from([178, 100, 198, 112, 40, 33, 187, 175, 130, 245, 59, 210, 133, 234, 158, 158, 133, 64, 213, 72, 222, 157, 216, 42, 210, 134, 36, 13, 211, 156, 163, 211]), + Bytes32::from([203, 127, 32, 130, 225, 40, 219, 15, 35, 236, 47, 201, 161, 48, 53, 145, 134, 169, 109, 29, 26, 29, 178, 201, 118, 217, 57, 165, 116, 172, 232, 4]), + Bytes32::from([209, 109, 33, 102, 227, 251, 133, 224, 170, 130, 65, 90, 185, 209, 146, 77, 244, 145, 181, 206, 159, 70, 209, 64, 241, 19, 149, 223, 138, 31, 163, 61]), + Bytes32::from([145, 168, 124, 48, 254, 12, 34, 41, 4, 213, 245, 86, 61, 29, 177, 192, 67, 165, 237, 236, 87, 126, 193, 191, 15, 126, 104, 173, 165, 186, 1, 107]), + Bytes32::from([235, 161, 247, 143, 69, 95, 210, 40, 243, 76, 102, 29, 118, 86, 180, 54, 81, 144, 103, 54, 202, 164, 81, 83, 180, 90, 154, 184, 54, 28, 7, 220]), + Bytes32::from([203, 62, 12, 83, 35, 122, 214, 199, 125, 61, 236, 8, 253, 64, 145, 34, 127, 116, 217, 118, 245, 107, 15, 81, 9, 7, 31, 154, 89, 28, 123, 132]), + Bytes32::from([222, 94, 234, 109, 142, 74, 142, 176, 248, 3, 172, 30, 204, 138, 241, 195, 121, 232, 104, 219, 32, 54, 240, 77, 125, 247, 70, 137, 80, 46, 221, 247]), + Bytes32::from([162, 122, 237, 101, 178, 31, 12, 62, 50, 133, 242, 82, 111, 215, 166, 136, 138, 185, 72, 220, 163, 58, 58, 97, 6, 97, 167, 114, 179, 227, 19, 170]), + Bytes32::from([67, 251, 144, 11, 175, 194, 149, 65, 173, 179, 69, 140, 213, 191, 133, 59, 81, 175, 161, 115, 252, 125, 232, 150, 52, 241, 102, 164, 122, 32, 70, 229]), + Bytes32::from([249, 161, 115, 93, 215, 247, 145, 182, 75, 191, 48, 38, 123, 220, 232, 47, 246, 46, 81, 164, 98, 41, 141, 249, 137, 173, 93, 213, 96, 15, 151, 245]), + Bytes32::from([222, 93, 144, 194, 107, 42, 144, 4, 242, 153, 203, 176, 146, 242, 94, 72, 9, 222, 194, 2, 73, 200, 167, 147, 106, 9, 67, 73, 59, 127, 174, 178]), + Bytes32::from([56, 228, 248, 59, 153, 215, 120, 224, 111, 48, 159, 82, 171, 227, 93, 214, 208, 151, 78, 67, 112, 31, 218, 94, 219, 3, 79, 250, 227, 24, 222, 207]), + Bytes32::from([26, 171, 68, 22, 162, 195, 65, 97, 219, 55, 51, 46, 178, 6, 247, 65, 123, 219, 128, 86, 193, 3, 253, 0, 239, 228, 187, 94, 184, 240, 67, 11]), + Bytes32::from([250, 36, 5, 131, 94, 0, 99, 187, 112, 155, 252, 52, 68, 236, 185, 152, 93, 239, 0, 185, 101, 101, 182, 92, 112, 5, 67, 55, 121, 203, 100, 245]), + Bytes32::from([208, 57, 149, 71, 227, 213, 246, 213, 175, 88, 95, 238, 93, 122, 168, 223, 149, 84, 30, 89, 98, 228, 113, 72, 90, 48, 112, 171, 231, 67, 113, 216]), + Bytes32::from([125, 48, 157, 119, 154, 38, 14, 211, 223, 68, 87, 187, 159, 126, 234, 72, 84, 60, 236, 237, 227, 130, 87, 43, 217, 105, 81, 196, 159, 238, 240, 10]), + Bytes32::from([141, 217, 59, 213, 245, 231, 7, 85, 178, 197, 115, 188, 31, 49, 126, 237, 83, 199, 56, 196, 133, 169, 239, 218, 90, 131, 178, 70, 126, 132, 114, 186]), + Bytes32::from([18, 2, 140, 12, 121, 238, 8, 160, 7, 208, 89, 194, 105, 136, 211, 58, 179, 200, 226, 138, 186, 242, 4, 237, 18, 113, 131, 135, 31, 222, 28, 195]), + Bytes32::from([156, 222, 183, 39, 119, 110, 130, 60, 33, 221, 36, 39, 223, 155, 33, 2, 71, 32, 209, 25, 194, 172, 209, 1, 40, 105, 235, 140, 160, 18, 63, 168]), + Bytes32::from([211, 210, 123, 27, 217, 111, 97, 42, 167, 191, 112, 239, 66, 42, 199, 131, 124, 213, 89, 56, 92, 245, 166, 238, 185, 42, 48, 2, 113, 255, 156, 7]), + Bytes32::from([66, 255, 87, 69, 86, 6, 54, 162, 162, 5, 93, 138, 194, 194, 151, 195, 57, 155, 58, 17, 21, 149, 77, 2, 134, 107, 125, 54, 220, 247, 160, 209]), + Bytes32::from([169, 216, 13, 41, 251, 216, 191, 87, 91, 55, 236, 6, 242, 103, 98, 209, 46, 202, 29, 55, 2, 50, 233, 76, 107, 92, 82, 156, 113, 226, 78, 211]), + Bytes32::from([88, 189, 113, 129, 119, 11, 141, 60, 128, 134, 113, 107, 7, 186, 81, 200, 14, 76, 197, 14, 96, 19, 247, 220, 95, 62, 81, 153, 61, 231, 26, 86]), + Bytes32::from([41, 214, 41, 96, 151, 11, 231, 7, 203, 70, 242, 156, 247, 133, 49, 223, 254, 164, 202, 154, 188, 104, 124, 120, 225, 229, 148, 203, 141, 218, 228, 56]), + Bytes32::from([181, 157, 136, 110, 158, 152, 105, 61, 125, 220, 32, 180, 53, 115, 155, 189, 91, 152, 96, 172, 7, 121, 65, 143, 82, 180, 3, 69, 118, 219, 31, 244]), + Bytes32::from([29, 12, 159, 30, 12, 37, 126, 102, 218, 149, 67, 116, 182, 125, 134, 208, 184, 199, 181, 191, 87, 144, 48, 150, 87, 67, 222, 218, 254, 118, 12, 160]), + Bytes32::from([193, 249, 209, 245, 102, 95, 15, 55, 160, 156, 203, 160, 49, 198, 203, 30, 99, 172, 89, 92, 235, 89, 131, 205, 53, 254, 219, 168, 202, 195, 10, 242]), + Bytes32::from([131, 64, 102, 7, 226, 96, 60, 111, 221, 120, 41, 86, 239, 157, 121, 38, 57, 244, 221, 55, 32, 237, 13, 20, 244, 238, 133, 189, 89, 118, 204, 247]), + Bytes32::from([239, 211, 89, 185, 191, 211, 243, 207, 134, 159, 59, 19, 87, 254, 115, 27, 152, 156, 120, 226, 39, 63, 155, 51, 77, 130, 162, 63, 16, 43, 112, 121]), + Bytes32::from([10, 146, 190, 23, 235, 67, 23, 169, 33, 140, 54, 209, 129, 176, 29, 218, 40, 55, 13, 80, 57, 68, 92, 97, 44, 82, 209, 240, 207, 214, 22, 119]), + Bytes32::from([59, 161, 125, 95, 7, 155, 141, 55, 253, 106, 238, 72, 109, 158, 201, 200, 236, 157, 227, 178, 176, 47, 166, 84, 87, 111, 25, 133, 194, 55, 244, 254]), + Bytes32::from([8, 134, 213, 182, 108, 15, 225, 138, 152, 138, 132, 240, 27, 80, 231, 117, 194, 157, 205, 20, 110, 239, 166, 37, 50, 46, 213, 165, 216, 101, 245, 98]), + Bytes32::from([137, 57, 186, 173, 198, 113, 221, 42, 0, 211, 127, 200, 128, 7, 112, 97, 75, 155, 152, 224, 71, 220, 16, 124, 32, 50, 30, 48, 251, 132, 120, 147]), + Bytes32::from([201, 8, 226, 108, 147, 192, 3, 240, 168, 237, 131, 47, 150, 51, 251, 126, 23, 182, 223, 99, 162, 167, 248, 248, 233, 8, 121, 99, 71, 212, 120, 251]), + Bytes32::from([140, 30, 196, 244, 166, 80, 95, 116, 140, 218, 94, 20, 236, 233, 241, 129, 175, 187, 110, 88, 174, 173, 152, 203, 67, 75, 51, 232, 225, 6, 17, 134]), + Bytes32::from([92, 132, 115, 164, 66, 159, 201, 147, 233, 228, 16, 95, 81, 233, 129, 254, 155, 148, 38, 239, 186, 40, 118, 104, 144, 134, 17, 46, 99, 150, 211, 9]), + Bytes32::from([81, 73, 72, 117, 215, 159, 240, 86, 136, 196, 69, 201, 149, 208, 48, 245, 105, 153, 97, 107, 221, 85, 49, 121, 197, 129, 32, 140, 206, 231, 120, 123]), + Bytes32::from([0, 203, 34, 135, 242, 129, 113, 204, 198, 134, 219, 134, 187, 240, 235, 59, 44, 163, 180, 83, 174, 40, 66, 141, 95, 99, 71, 221, 186, 216, 37, 250]), + Bytes32::from([225, 181, 151, 12, 26, 209, 127, 99, 248, 177, 126, 113, 215, 220, 252, 89, 149, 123, 19, 65, 89, 122, 180, 169, 195, 87, 147, 9, 196, 31, 203, 178]), + Bytes32::from([125, 81, 154, 100, 204, 138, 194, 248, 156, 95, 119, 58, 60, 221, 150, 248, 216, 19, 123, 15, 198, 108, 228, 228, 224, 122, 16, 249, 223, 84, 117, 89]), + Bytes32::from([99, 153, 60, 217, 168, 254, 244, 149, 214, 115, 250, 90, 117, 112, 66, 163, 143, 207, 121, 70, 108, 92, 2, 47, 56, 109, 56, 207, 152, 27, 196, 141]), + Bytes32::from([99, 251, 124, 97, 158, 155, 101, 251, 98, 124, 239, 73, 50, 50, 173, 142, 39, 208, 167, 53, 5, 151, 85, 239, 25, 77, 36, 52, 141, 225, 66, 186]), + Bytes32::from([235, 44, 31, 180, 197, 243, 114, 60, 199, 242, 167, 21, 206, 27, 116, 165, 18, 76, 162, 163, 14, 91, 109, 104, 118, 51, 33, 172, 9, 165, 214, 38]), + Bytes32::from([188, 4, 5, 50, 169, 70, 231, 90, 220, 90, 226, 214, 89, 19, 159, 207, 201, 80, 241, 214, 32, 240, 63, 74, 6, 251, 177, 182, 236, 19, 156, 92]), + Bytes32::from([128, 150, 66, 27, 197, 229, 103, 137, 175, 252, 19, 131, 213, 63, 112, 172, 182, 255, 235, 246, 226, 37, 25, 180, 24, 38, 35, 138, 207, 149, 186, 175]), + Bytes32::from([5, 123, 231, 106, 12, 171, 157, 189, 58, 109, 144, 7, 38, 97, 4, 148, 1, 138, 124, 123, 2, 202, 108, 221, 194, 160, 53, 73, 115, 36, 231, 142]), + Bytes32::from([160, 157, 243, 224, 214, 120, 59, 206, 24, 30, 231, 209, 123, 227, 15, 221, 86, 30, 128, 117, 210, 109, 132, 117, 204, 87, 243, 213, 231, 224, 91, 75]), + Bytes32::from([74, 238, 110, 147, 63, 110, 246, 102, 252, 212, 120, 225, 124, 218, 145, 204, 129, 63, 13, 34, 1, 0, 15, 9, 27, 221, 39, 199, 24, 231, 9, 38]), + Bytes32::from([194, 20, 160, 161, 90, 2, 118, 75, 103, 228, 51, 42, 191, 220, 63, 150, 140, 32, 85, 172, 218, 29, 251, 31, 99, 96, 98, 46, 130, 157, 201, 61]), + Bytes32::from([88, 123, 95, 139, 94, 66, 69, 27, 223, 223, 216, 130, 99, 210, 130, 54, 248, 35, 226, 252, 151, 238, 7, 175, 12, 97, 188, 43, 233, 129, 82, 222]), + Bytes32::from([179, 248, 157, 243, 50, 157, 172, 17, 139, 10, 245, 208, 241, 210, 67, 199, 135, 233, 234, 39, 127, 38, 54, 39, 40, 159, 94, 122, 36, 221, 180, 195]), + Bytes32::from([190, 185, 147, 237, 82, 32, 165, 236, 252, 183, 173, 181, 68, 44, 216, 20, 110, 243, 158, 213, 88, 209, 218, 207, 244, 241, 121, 239, 136, 167, 245, 155]), + Bytes32::from([114, 131, 254, 248, 183, 0, 175, 217, 194, 58, 178, 238, 250, 119, 158, 205, 19, 74, 94, 35, 100, 175, 114, 55, 186, 192, 239, 126, 42, 86, 60, 119]), + Bytes32::from([1, 253, 107, 150, 25, 240, 27, 172, 252, 185, 151, 152, 107, 105, 164, 230, 221, 242, 7, 166, 142, 53, 237, 83, 19, 30, 81, 149, 150, 39, 123, 220]), + Bytes32::from([57, 240, 92, 232, 26, 238, 69, 252, 110, 171, 164, 109, 199, 73, 110, 49, 11, 253, 109, 69, 155, 26, 84, 52, 155, 204, 115, 99, 90, 38, 247, 167]), + Bytes32::from([46, 87, 146, 25, 215, 40, 208, 78, 73, 60, 35, 19, 194, 41, 34, 186, 215, 131, 205, 29, 107, 100, 95, 169, 45, 1, 242, 115, 30, 226, 93, 48]), + Bytes32::from([95, 183, 66, 0, 196, 173, 44, 27, 175, 151, 17, 0, 159, 168, 123, 236, 124, 198, 85, 181, 118, 89, 21, 52, 169, 104, 178, 111, 120, 173, 94, 109]), + Bytes32::from([13, 111, 162, 25, 133, 108, 250, 75, 197, 221, 19, 160, 147, 36, 130, 70, 224, 39, 134, 144, 149, 166, 187, 96, 155, 154, 123, 90, 241, 154, 44, 102]), + Bytes32::from([95, 171, 183, 135, 121, 205, 161, 160, 212, 226, 64, 232, 180, 166, 176, 95, 51, 96, 110, 20, 76, 143, 47, 96, 197, 132, 210, 109, 174, 132, 13, 95]), + Bytes32::from([66, 51, 176, 1, 106, 199, 192, 16, 106, 180, 212, 53, 72, 121, 218, 148, 77, 26, 15, 244, 124, 131, 88, 84, 147, 211, 254, 156, 187, 91, 193, 120]) + ]); + zero_hashes.insert(MerkleType::Function, vec![ + Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::from([239, 247, 49, 255, 201, 159, 228, 149, 22, 115, 41, 139, 56, 117, 149, 46, 67, 155, 98, 70, 216, 225, 85, 100, 113, 242, 144, 167, 97, 238, 117, 207]), + Bytes32::from([46, 87, 136, 101, 122, 12, 6, 120, 39, 121, 167, 193, 66, 146, 150, 1, 90, 240, 97, 225, 179, 150, 197, 127, 56, 214, 116, 24, 180, 109, 96, 51]), + Bytes32::from([54, 125, 90, 195, 243, 1, 115, 18, 251, 68, 203, 216, 48, 156, 216, 200, 215, 250, 80, 152, 203, 58, 245, 128, 70, 112, 221, 104, 34, 125, 234, 138]), + Bytes32::from([103, 99, 44, 86, 57, 0, 102, 201, 99, 214, 249, 24, 45, 112, 234, 183, 225, 196, 9, 162, 168, 33, 121, 118, 93, 184, 14, 70, 148, 135, 211, 214]), + Bytes32::from([69, 7, 89, 47, 41, 94, 148, 139, 67, 197, 99, 98, 100, 63, 25, 230, 100, 118, 213, 25, 28, 129, 5, 39, 69, 89, 71, 21, 102, 84, 101, 175]), + Bytes32::from([232, 195, 82, 123, 189, 200, 139, 61, 179, 141, 208, 69, 102, 58, 127, 66, 69, 127, 7, 179, 108, 128, 253, 154, 207, 254, 201, 18, 192, 241, 99, 208]), + Bytes32::from([138, 25, 185, 215, 159, 159, 214, 251, 161, 103, 180, 78, 209, 215, 131, 132, 134, 180, 177, 37, 79, 219, 19, 93, 45, 30, 53, 125, 142, 194, 114, 34]), + Bytes32::from([185, 24, 200, 28, 68, 7, 118, 226, 65, 240, 85, 120, 123, 174, 239, 85, 247, 210, 104, 247, 20, 229, 41, 91, 242, 5, 2, 121, 132, 69, 43, 33]), + Bytes32::from([78, 191, 92, 97, 205, 120, 114, 216, 112, 101, 44, 98, 148, 2, 112, 221, 168, 199, 254, 55, 160, 116, 116, 105, 109, 227, 130, 219, 194, 32, 209, 196]), + Bytes32::from([177, 203, 26, 1, 216, 115, 242, 158, 202, 107, 60, 221, 81, 167, 8, 233, 247, 235, 49, 54, 45, 133, 202, 193, 34, 158, 205, 29, 232, 245, 195, 194]), + Bytes32::from([193, 118, 182, 153, 10, 237, 67, 229, 136, 193, 253, 250, 46, 125, 141, 22, 107, 168, 74, 130, 60, 193, 194, 196, 249, 129, 153, 82, 162, 143, 188, 42]), + Bytes32::from([239, 57, 105, 90, 116, 61, 160, 214, 55, 191, 17, 228, 44, 149, 103, 180, 229, 4, 175, 240, 209, 231, 141, 95, 109, 195, 78, 142, 122, 177, 227, 20]), + Bytes32::from([153, 247, 105, 126, 178, 44, 190, 57, 12, 63, 169, 27, 206, 19, 151, 38, 33, 83, 35, 3, 177, 97, 36, 182, 37, 78, 150, 243, 222, 32, 180, 148]), + Bytes32::from([29, 109, 110, 167, 27, 136, 235, 226, 147, 175, 241, 236, 138, 135, 163, 200, 21, 94, 220, 238, 23, 84, 46, 14, 44, 100, 47, 131, 134, 43, 98, 173]), + Bytes32::from([73, 241, 108, 102, 184, 200, 64, 80, 58, 162, 29, 211, 173, 150, 6, 195, 2, 137, 246, 51, 155, 132, 41, 255, 21, 71, 74, 143, 197, 180, 217, 159]), + Bytes32::from([109, 189, 226, 33, 70, 157, 161, 166, 223, 31, 224, 221, 37, 112, 27, 215, 163, 250, 217, 155, 168, 121, 119, 232, 100, 177, 104, 210, 10, 118, 215, 0]), + Bytes32::from([175, 156, 32, 156, 238, 82, 62, 25, 96, 251, 146, 24, 13, 2, 115, 174, 163, 50, 14, 251, 196, 173, 5, 87, 171, 228, 191, 9, 90, 84, 156, 63]), + Bytes32::from([244, 161, 238, 217, 14, 60, 162, 139, 34, 84, 68, 121, 213, 11, 230, 95, 57, 221, 174, 107, 103, 105, 76, 137, 58, 247, 65, 209, 167, 63, 96, 212]), + Bytes32::from([31, 177, 221, 130, 152, 92, 190, 4, 59, 90, 122, 63, 128, 180, 140, 201, 75, 239, 200, 151, 94, 65, 36, 227, 21, 250, 10, 253, 26, 114, 238, 188]), + Bytes32::from([48, 216, 87, 30, 113, 214, 69, 1, 9, 112, 244, 232, 127, 55, 43, 162, 156, 83, 235, 199, 126, 132, 241, 106, 65, 209, 240, 32, 11, 179, 219, 135]), + Bytes32::from([20, 55, 225, 132, 0, 219, 175, 17, 235, 73, 236, 16, 24, 227, 250, 155, 32, 83, 234, 123, 191, 209, 157, 133, 215, 202, 3, 221, 135, 223, 221, 90]), + Bytes32::from([113, 185, 118, 164, 139, 219, 203, 140, 245, 123, 21, 186, 102, 22, 54, 14, 19, 230, 223, 120, 211, 114, 203, 77, 173, 214, 61, 80, 151, 10, 2, 205]), + Bytes32::from([50, 20, 214, 105, 232, 5, 9, 101, 16, 72, 46, 139, 177, 188, 25, 93, 14, 57, 60, 168, 49, 147, 134, 5, 62, 181, 120, 75, 193, 229, 107, 67]), + Bytes32::from([92, 167, 117, 18, 186, 193, 28, 56, 86, 25, 75, 64, 1, 8, 126, 212, 56, 163, 157, 242, 34, 73, 65, 58, 187, 2, 112, 58, 225, 229, 113, 58]), + Bytes32::from([173, 139, 156, 215, 250, 231, 15, 123, 8, 5, 98, 192, 164, 48, 106, 203, 152, 189, 118, 120, 245, 221, 214, 26, 79, 39, 148, 232, 217, 88, 34, 246]), + Bytes32::from([8, 207, 11, 196, 253, 51, 182, 90, 62, 110, 125, 142, 209, 154, 5, 203, 252, 62, 117, 215, 226, 136, 140, 201, 227, 210, 71, 34, 113, 160, 42, 68]), + Bytes32::from([108, 135, 226, 117, 179, 142, 93, 181, 20, 186, 189, 217, 49, 154, 66, 244, 180, 170, 122, 233, 153, 214, 104, 71, 44, 57, 103, 240, 97, 80, 170, 198]), + Bytes32::from([123, 168, 184, 254, 241, 78, 23, 91, 32, 77, 218, 176, 179, 189, 61, 162, 114, 158, 212, 7, 201, 15, 58, 4, 161, 211, 188, 156, 190, 2, 20, 183]), + Bytes32::from([60, 170, 86, 130, 38, 170, 202, 88, 97, 206, 67, 69, 140, 122, 201, 38, 70, 229, 144, 202, 146, 10, 146, 148, 21, 247, 119, 196, 150, 223, 110, 67]), + Bytes32::from([102, 154, 215, 132, 143, 248, 151, 101, 101, 253, 80, 211, 254, 64, 179, 73, 96, 132, 144, 216, 225, 130, 48, 56, 14, 39, 97, 223, 134, 10, 124, 138]), + Bytes32::from([197, 131, 194, 166, 168, 160, 24, 116, 47, 120, 89, 3, 44, 154, 83, 250, 142, 64, 77, 63, 15, 60, 97, 100, 150, 39, 227, 139, 42, 146, 146, 104]), + Bytes32::from([7, 160, 246, 93, 64, 79, 76, 208, 66, 80, 60, 123, 13, 51, 115, 251, 196, 209, 145, 106, 61, 105, 136, 58, 7, 129, 142, 203, 205, 69, 45, 203]), + Bytes32::from([64, 162, 48, 187, 213, 182, 41, 85, 62, 148, 26, 161, 227, 108, 173, 249, 195, 106, 203, 18, 28, 59, 184, 85, 249, 16, 224, 222, 114, 200, 99, 22]), + Bytes32::from([246, 194, 74, 122, 165, 216, 211, 144, 101, 143, 134, 9, 53, 229, 197, 227, 121, 248, 89, 169, 48, 220, 104, 216, 117, 118, 36, 234, 108, 135, 81, 162]), + Bytes32::from([232, 59, 196, 2, 103, 242, 44, 129, 41, 231, 226, 115, 238, 151, 166, 210, 158, 110, 43, 45, 86, 163, 127, 8, 162, 81, 131, 145, 165, 252, 170, 12]), + Bytes32::from([204, 88, 102, 180, 241, 148, 27, 183, 223, 71, 157, 119, 155, 31, 102, 239, 4, 83, 204, 246, 38, 228, 234, 20, 97, 233, 203, 149, 186, 67, 143, 51]), + Bytes32::from([246, 170, 233, 8, 202, 38, 67, 219, 175, 13, 250, 174, 98, 36, 84, 166, 6, 75, 27, 43, 62, 128, 106, 23, 163, 191, 86, 115, 164, 50, 127, 151]), + Bytes32::from([204, 72, 199, 57, 106, 136, 244, 66, 217, 155, 183, 211, 166, 71, 140, 211, 210, 181, 178, 218, 204, 91, 200, 204, 153, 60, 22, 32, 24, 153, 131, 31]), + Bytes32::from([204, 193, 13, 167, 214, 136, 121, 99, 198, 137, 11, 223, 85, 40, 167, 126, 153, 80, 187, 35, 226, 31, 226, 42, 9, 175, 31, 206, 119, 67, 153, 39]), + Bytes32::from([63, 82, 16, 182, 255, 45, 123, 220, 252, 52, 199, 222, 76, 172, 123, 232, 133, 182, 143, 202, 223, 161, 203, 91, 239, 225, 123, 184, 231, 53, 19, 253]), + Bytes32::from([5, 13, 255, 217, 70, 105, 205, 70, 41, 25, 44, 3, 245, 136, 16, 255, 101, 61, 189, 225, 142, 201, 210, 226, 9, 237, 171, 109, 63, 204, 204, 139]), + Bytes32::from([161, 218, 126, 252, 32, 196, 32, 105, 98, 13, 201, 117, 64, 37, 232, 32, 159, 106, 48, 121, 250, 139, 219, 137, 129, 3, 83, 194, 102, 251, 148, 71]), + Bytes32::from([72, 17, 9, 21, 142, 89, 135, 91, 81, 155, 72, 247, 56, 232, 136, 57, 251, 182, 211, 35, 207, 169, 87, 123, 31, 222, 72, 85, 212, 92, 159, 171]), + Bytes32::from([193, 253, 238, 224, 198, 216, 154, 52, 59, 87, 183, 80, 242, 162, 238, 7, 218, 195, 253, 210, 92, 116, 43, 181, 109, 40, 74, 38, 154, 211, 102, 173]), + Bytes32::from([193, 88, 249, 81, 11, 128, 242, 239, 220, 1, 237, 199, 235, 12, 153, 73, 145, 158, 15, 111, 108, 244, 19, 51, 159, 206, 66, 25, 147, 215, 157, 165]), + Bytes32::from([195, 90, 0, 163, 8, 199, 55, 59, 47, 117, 186, 204, 5, 42, 205, 164, 239, 233, 203, 210, 69, 205, 244, 152, 113, 184, 206, 110, 101, 197, 120, 101]), + Bytes32::from([114, 169, 222, 11, 169, 15, 123, 245, 42, 25, 120, 198, 66, 140, 125, 123, 201, 107, 3, 50, 245, 226, 52, 46, 162, 44, 134, 157, 226, 11, 115, 186]), + Bytes32::from([6, 47, 131, 89, 216, 138, 92, 250, 126, 232, 238, 50, 181, 78, 69, 115, 227, 25, 49, 50, 116, 138, 47, 61, 179, 75, 121, 124, 127, 106, 228, 178]), + Bytes32::from([152, 253, 228, 228, 120, 255, 82, 66, 24, 145, 159, 223, 39, 185, 81, 201, 81, 110, 47, 57, 105, 128, 8, 42, 130, 119, 92, 7, 14, 247, 137, 135]), + Bytes32::from([162, 28, 11, 245, 48, 21, 8, 137, 161, 131, 84, 18, 129, 70, 197, 122, 165, 39, 71, 213, 142, 115, 159, 52, 46, 213, 81, 10, 217, 212, 74, 20]), + Bytes32::from([129, 250, 71, 119, 46, 25, 220, 212, 143, 120, 0, 101, 85, 101, 109, 107, 142, 20, 107, 174, 39, 134, 128, 244, 237, 155, 190, 19, 110, 10, 240, 94]), + Bytes32::from([90, 70, 190, 48, 191, 45, 227, 17, 185, 162, 159, 12, 18, 94, 186, 251, 252, 238, 95, 174, 253, 99, 194, 204, 5, 178, 117, 139, 50, 154, 93, 170]), + Bytes32::from([201, 8, 48, 126, 70, 22, 83, 82, 229, 84, 168, 86, 100, 169, 227, 175, 196, 154, 217, 150, 2, 36, 1, 100, 48, 216, 141, 205, 113, 148, 109, 126]), + Bytes32::from([16, 182, 10, 119, 255, 70, 127, 242, 64, 68, 67, 44, 52, 195, 63, 185, 227, 97, 138, 244, 53, 246, 110, 99, 41, 176, 146, 206, 81, 168, 66, 140]), + Bytes32::from([95, 9, 211, 227, 219, 119, 221, 132, 248, 92, 236, 190, 110, 227, 153, 109, 103, 63, 121, 221, 165, 212, 20, 141, 33, 95, 52, 157, 69, 76, 2, 70]), + Bytes32::from([216, 138, 115, 198, 102, 135, 226, 247, 235, 185, 206, 147, 130, 9, 48, 166, 92, 22, 41, 158, 169, 52, 233, 1, 60, 229, 165, 208, 60, 161, 194, 166]), + Bytes32::from([129, 241, 87, 138, 103, 241, 79, 26, 52, 35, 125, 237, 54, 147, 253, 137, 101, 146, 235, 127, 124, 113, 60, 203, 181, 4, 250, 12, 72, 27, 24, 7]), + Bytes32::from([52, 120, 68, 97, 147, 229, 251, 178, 161, 233, 142, 136, 38, 40, 85, 46, 121, 156, 115, 186, 72, 95, 128, 43, 252, 176, 176, 51, 113, 83, 154, 232]), + Bytes32::from([227, 11, 188, 57, 98, 160, 248, 247, 112, 49, 247, 92, 94, 224, 135, 182, 211, 230, 69, 185, 138, 154, 141, 157, 18, 34, 138, 236, 67, 243, 26, 132]), + Bytes32::from([61, 246, 31, 52, 44, 146, 190, 215, 214, 105, 253, 86, 172, 174, 140, 112, 30, 154, 82, 173, 62, 199, 157, 180, 255, 104, 73, 136, 163, 79, 210, 252]), + Bytes32::from([200, 155, 200, 87, 142, 123, 62, 176, 250, 44, 18, 238, 229, 121, 125, 109, 102, 173, 60, 203, 88, 65, 33, 122, 22, 111, 157, 143, 164, 7, 214, 26]), + Bytes32::from([179, 76, 168, 179, 139, 86, 151, 173, 26, 70, 236, 116, 202, 123, 63, 80, 106, 208, 63, 138, 179, 225, 114, 64, 48, 34, 78, 124, 132, 210, 224, 190]), + Bytes32::from([138, 116, 89, 240, 28, 79, 42, 149, 199, 118, 149, 49, 146, 212, 104, 62, 17, 137, 138, 223, 225, 187, 152, 43, 134, 60, 95, 55, 175, 128, 95, 144]) + ]); + zero_hashes.insert(MerkleType::Instruction, vec![ + Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::from([248, 140, 83, 29, 241, 220, 66, 40, 126, 248, 5, 153, 77, 179, 26, 64, 221, 108, 205, 162, 173, 52, 179, 140, 202, 105, 0, 170, 166, 130, 120, 176]), + Bytes32::from([35, 74, 103, 235, 245, 71, 66, 212, 99, 147, 15, 200, 1, 237, 95, 163, 10, 146, 122, 251, 243, 239, 93, 186, 46, 74, 206, 130, 63, 17, 199, 80]), + Bytes32::from([113, 169, 40, 37, 169, 205, 28, 78, 37, 104, 52, 28, 29, 222, 39, 32, 208, 183, 215, 38, 255, 69, 87, 70, 174, 113, 221, 183, 206, 62, 192, 118]), + Bytes32::from([1, 148, 183, 39, 234, 23, 138, 182, 169, 58, 52, 158, 248, 212, 186, 127, 60, 42, 25, 210, 20, 170, 182, 139, 20, 185, 196, 85, 241, 214, 181, 64]), + Bytes32::from([241, 14, 59, 8, 168, 222, 232, 125, 149, 227, 125, 41, 223, 198, 88, 135, 54, 146, 140, 212, 164, 76, 239, 106, 10, 20, 67, 180, 24, 159, 174, 99]), + Bytes32::from([117, 111, 220, 19, 204, 227, 211, 18, 61, 239, 179, 46, 142, 75, 67, 98, 159, 221, 205, 158, 125, 42, 221, 227, 148, 162, 193, 229, 147, 70, 214, 127]), + Bytes32::from([20, 72, 211, 188, 38, 126, 166, 75, 54, 22, 225, 21, 113, 155, 167, 89, 161, 6, 37, 78, 227, 211, 219, 141, 161, 199, 151, 122, 81, 45, 159, 187]), + Bytes32::from([69, 198, 100, 170, 106, 174, 208, 152, 152, 121, 118, 66, 111, 89, 131, 14, 159, 115, 142, 200, 205, 173, 89, 77, 68, 234, 5, 171, 105, 248, 199, 83]), + Bytes32::from([17, 1, 220, 13, 154, 194, 88, 60, 253, 223, 149, 35, 44, 184, 107, 141, 205, 177, 185, 32, 22, 99, 212, 96, 194, 91, 255, 179, 121, 153, 254, 40]), + Bytes32::from([222, 247, 186, 138, 222, 183, 135, 183, 170, 79, 182, 23, 69, 89, 70, 68, 88, 87, 235, 22, 178, 134, 114, 220, 249, 153, 70, 71, 229, 139, 10, 190]), + Bytes32::from([183, 77, 65, 51, 207, 78, 55, 149, 222, 3, 100, 82, 232, 230, 21, 115, 249, 177, 36, 89, 12, 41, 70, 31, 199, 254, 213, 3, 184, 2, 85, 137]), + Bytes32::from([82, 15, 215, 135, 95, 18, 143, 49, 239, 237, 6, 15, 213, 113, 153, 49, 149, 54, 50, 139, 100, 192, 128, 226, 168, 9, 120, 167, 157, 42, 45, 19]), + Bytes32::from([70, 32, 130, 243, 186, 144, 224, 217, 130, 222, 175, 221, 218, 190, 179, 222, 217, 115, 70, 160, 141, 231, 221, 96, 2, 173, 27, 17, 158, 66, 180, 58]), + Bytes32::from([76, 243, 65, 235, 12, 31, 48, 195, 62, 176, 202, 57, 99, 80, 237, 222, 138, 199, 124, 251, 143, 243, 205, 226, 18, 164, 67, 64, 68, 238, 53, 71]), + Bytes32::from([70, 52, 254, 193, 211, 92, 63, 238, 92, 2, 160, 29, 154, 25, 221, 136, 2, 49, 96, 27, 15, 152, 238, 57, 241, 253, 32, 131, 73, 38, 229, 243]), + Bytes32::from([214, 162, 82, 44, 146, 145, 61, 77, 36, 3, 131, 81, 217, 39, 127, 81, 66, 82, 172, 230, 246, 3, 243, 217, 210, 38, 201, 109, 240, 143, 253, 79]), + Bytes32::from([127, 18, 198, 116, 112, 141, 16, 39, 115, 118, 37, 208, 118, 119, 147, 46, 196, 124, 19, 196, 34, 183, 172, 157, 18, 91, 4, 210, 77, 195, 220, 59]), + Bytes32::from([87, 54, 42, 60, 39, 223, 84, 148, 158, 230, 70, 53, 191, 1, 108, 103, 139, 111, 58, 220, 114, 46, 46, 110, 20, 211, 84, 1, 173, 104, 175, 191]), + Bytes32::from([182, 147, 66, 127, 229, 144, 125, 93, 84, 220, 116, 107, 51, 13, 24, 161, 68, 172, 165, 50, 12, 198, 229, 173, 49, 26, 114, 159, 84, 190, 6, 42]), + Bytes32::from([183, 20, 36, 145, 76, 36, 61, 136, 224, 139, 89, 23, 124, 29, 210, 137, 1, 160, 22, 128, 48, 242, 234, 85, 84, 24, 206, 49, 143, 185, 237, 110]), + Bytes32::from([38, 19, 77, 150, 92, 129, 177, 155, 139, 162, 90, 91, 231, 146, 216, 21, 54, 152, 18, 5, 98, 21, 67, 160, 154, 113, 175, 65, 214, 78, 19, 97]), + Bytes32::from([163, 236, 47, 120, 121, 17, 217, 4, 200, 247, 206, 178, 211, 212, 163, 48, 38, 172, 111, 123, 75, 221, 63, 117, 42, 3, 252, 233, 104, 13, 210, 203]), + Bytes32::from([127, 106, 132, 246, 28, 129, 245, 83, 159, 109, 196, 219, 68, 81, 230, 77, 254, 166, 55, 73, 169, 179, 93, 97, 117, 176, 53, 74, 121, 238, 184, 240]), + Bytes32::from([255, 23, 108, 186, 145, 182, 196, 67, 163, 95, 173, 17, 67, 239, 199, 189, 145, 153, 120, 152, 159, 126, 255, 39, 55, 178, 230, 173, 91, 165, 229, 106]), + Bytes32::from([184, 156, 20, 114, 222, 219, 89, 218, 102, 62, 130, 200, 179, 237, 32, 237, 127, 75, 251, 163, 160, 2, 221, 34, 166, 30, 172, 97, 115, 137, 179, 175]), + Bytes32::from([244, 165, 127, 27, 66, 22, 38, 243, 235, 107, 30, 181, 31, 193, 210, 174, 254, 129, 39, 71, 59, 117, 186, 37, 217, 129, 138, 23, 146, 114, 96, 78]), + Bytes32::from([27, 57, 244, 93, 208, 90, 64, 181, 161, 110, 161, 188, 62, 180, 46, 103, 136, 233, 63, 1, 243, 202, 236, 206, 173, 45, 45, 218, 238, 184, 83, 121]), + Bytes32::from([138, 185, 33, 206, 120, 214, 246, 27, 100, 91, 106, 213, 60, 177, 39, 182, 149, 204, 11, 225, 254, 5, 87, 9, 19, 186, 166, 210, 33, 67, 146, 37]), + Bytes32::from([243, 161, 7, 52, 35, 240, 227, 144, 29, 50, 232, 3, 101, 174, 192, 139, 89, 75, 204, 245, 173, 55, 139, 76, 126, 19, 142, 18, 230, 57, 219, 227]), + Bytes32::from([97, 73, 36, 70, 120, 55, 49, 114, 107, 193, 66, 219, 47, 122, 201, 194, 52, 142, 12, 163, 108, 2, 107, 58, 185, 251, 168, 146, 57, 189, 150, 134]), + Bytes32::from([11, 215, 29, 229, 151, 208, 62, 1, 172, 253, 253, 156, 177, 31, 117, 214, 161, 192, 68, 255, 140, 131, 66, 23, 247, 161, 107, 98, 199, 57, 123, 110]), + Bytes32::from([41, 166, 54, 134, 242, 64, 153, 167, 5, 230, 226, 128, 71, 10, 251, 160, 19, 187, 70, 4, 95, 98, 77, 233, 181, 24, 11, 239, 142, 152, 229, 215]), + Bytes32::from([221, 220, 68, 168, 143, 124, 235, 77, 241, 190, 214, 6, 102, 40, 32, 245, 131, 114, 170, 151, 134, 49, 79, 57, 242, 124, 85, 172, 83, 81, 68, 99]), + Bytes32::from([142, 200, 102, 97, 170, 43, 14, 11, 139, 207, 150, 163, 99, 103, 2, 46, 44, 63, 109, 61, 62, 64, 199, 104, 36, 194, 155, 232, 139, 250, 97, 224]), + Bytes32::from([162, 15, 26, 217, 96, 195, 70, 196, 253, 70, 127, 156, 39, 120, 120, 232, 197, 154, 192, 147, 104, 33, 104, 189, 120, 160, 36, 129, 208, 237, 128, 23]), + Bytes32::from([42, 228, 74, 47, 20, 55, 197, 252, 173, 70, 178, 8, 2, 43, 97, 238, 155, 124, 87, 225, 217, 6, 103, 134, 136, 235, 193, 175, 33, 228, 219, 217]), + Bytes32::from([219, 143, 25, 70, 78, 155, 119, 63, 126, 20, 158, 54, 27, 181, 104, 184, 74, 192, 75, 157, 42, 204, 45, 122, 25, 248, 247, 24, 225, 207, 51, 251]), + Bytes32::from([151, 253, 36, 33, 104, 222, 126, 234, 112, 74, 59, 94, 239, 58, 36, 114, 90, 195, 208, 46, 250, 138, 165, 200, 178, 54, 238, 154, 219, 238, 6, 183]), + Bytes32::from([205, 57, 187, 174, 221, 9, 164, 77, 76, 143, 54, 212, 115, 196, 67, 182, 200, 147, 78, 194, 245, 92, 173, 114, 180, 160, 168, 5, 200, 82, 217, 64]), + Bytes32::from([211, 104, 62, 114, 157, 56, 254, 26, 32, 168, 208, 248, 62, 195, 142, 68, 53, 13, 7, 36, 216, 5, 127, 153, 97, 88, 222, 206, 91, 42, 14, 114]), + Bytes32::from([203, 158, 225, 200, 62, 223, 202, 52, 207, 179, 250, 236, 29, 144, 181, 31, 87, 192, 203, 66, 56, 39, 123, 25, 123, 157, 196, 161, 34, 245, 22, 130]), + Bytes32::from([147, 247, 233, 96, 190, 104, 227, 251, 99, 2, 16, 8, 77, 119, 1, 97, 243, 78, 103, 46, 24, 228, 217, 65, 219, 238, 135, 18, 164, 219, 132, 39]), + Bytes32::from([239, 153, 72, 139, 52, 60, 171, 44, 72, 218, 138, 124, 45, 30, 143, 122, 147, 158, 12, 62, 213, 151, 217, 217, 212, 51, 110, 75, 122, 67, 134, 80]), + Bytes32::from([46, 47, 130, 237, 178, 232, 239, 217, 165, 114, 255, 202, 132, 214, 18, 8, 72, 8, 255, 0, 162, 82, 5, 228, 141, 201, 70, 135, 255, 21, 220, 3]), + Bytes32::from([21, 11, 196, 5, 215, 241, 194, 200, 198, 129, 133, 244, 204, 47, 131, 70, 138, 38, 107, 39, 211, 243, 72, 72, 34, 145, 35, 42, 14, 69, 218, 227]), + Bytes32::from([73, 103, 117, 195, 67, 126, 242, 57, 232, 74, 142, 64, 169, 248, 113, 69, 110, 103, 127, 185, 177, 51, 212, 178, 48, 183, 247, 44, 246, 69, 35, 208]), + Bytes32::from([125, 8, 83, 22, 215, 82, 179, 234, 169, 227, 213, 39, 170, 164, 195, 187, 63, 38, 59, 146, 144, 101, 38, 0, 110, 212, 202, 20, 245, 105, 187, 201]), + Bytes32::from([186, 231, 186, 148, 68, 208, 226, 170, 120, 80, 68, 79, 23, 41, 51, 205, 240, 201, 10, 16, 24, 38, 137, 151, 7, 102, 92, 244, 3, 194, 228, 229]), + Bytes32::from([46, 8, 51, 150, 63, 114, 126, 210, 30, 130, 76, 142, 13, 149, 14, 0, 205, 199, 48, 90, 86, 75, 151, 135, 164, 224, 129, 77, 174, 194, 212, 112]), + Bytes32::from([150, 239, 42, 111, 3, 112, 25, 168, 179, 36, 106, 73, 212, 188, 215, 79, 180, 142, 191, 29, 219, 12, 244, 74, 254, 205, 160, 54, 68, 144, 81, 207]), + Bytes32::from([23, 164, 189, 201, 250, 65, 212, 148, 132, 125, 94, 209, 115, 123, 29, 66, 3, 172, 57, 58, 46, 191, 96, 7, 212, 25, 226, 79, 120, 68, 202, 210]), + Bytes32::from([252, 13, 137, 225, 208, 6, 84, 75, 97, 32, 177, 156, 248, 191, 113, 97, 254, 122, 86, 194, 3, 103, 219, 74, 227, 160, 231, 202, 13, 126, 46, 255]), + Bytes32::from([70, 35, 27, 128, 17, 79, 226, 131, 144, 118, 248, 125, 188, 110, 20, 15, 255, 73, 205, 69, 0, 227, 26, 66, 39, 61, 191, 224, 239, 234, 83, 170]), + Bytes32::from([129, 52, 148, 121, 230, 84, 28, 112, 75, 68, 181, 197, 80, 227, 107, 22, 60, 118, 81, 209, 198, 125, 233, 190, 84, 189, 18, 25, 72, 143, 2, 190]), + Bytes32::from([244, 237, 81, 131, 251, 35, 56, 158, 229, 102, 150, 122, 213, 206, 119, 38, 54, 238, 158, 159, 1, 214, 31, 147, 245, 9, 172, 247, 156, 115, 209, 140]), + Bytes32::from([47, 5, 174, 62, 80, 172, 77, 111, 136, 114, 188, 85, 249, 157, 182, 175, 187, 207, 29, 43, 152, 88, 130, 156, 138, 30, 188, 51, 82, 105, 145, 161]), + Bytes32::from([102, 2, 197, 195, 206, 149, 53, 224, 61, 219, 163, 246, 208, 218, 140, 47, 16, 42, 196, 20, 145, 158, 101, 31, 225, 135, 49, 68, 95, 5, 228, 92]), + Bytes32::from([78, 136, 176, 216, 253, 15, 136, 48, 162, 5, 57, 120, 93, 222, 179, 174, 129, 40, 8, 63, 18, 102, 97, 41, 58, 214, 1, 52, 58, 126, 186, 146]), + Bytes32::from([145, 56, 231, 59, 247, 191, 104, 137, 240, 113, 32, 245, 235, 129, 255, 54, 99, 176, 109, 175, 107, 232, 201, 235, 95, 104, 54, 67, 252, 184, 200, 54]), + Bytes32::from([181, 3, 229, 152, 113, 182, 55, 93, 138, 137, 21, 67, 27, 204, 96, 69, 72, 247, 237, 216, 28, 36, 115, 185, 111, 149, 224, 69, 66, 121, 188, 228]), + Bytes32::from([212, 25, 201, 68, 187, 25, 10, 96, 40, 88, 100, 216, 145, 200, 26, 203, 220, 14, 14, 11, 190, 62, 143, 137, 53, 208, 233, 158, 37, 34, 8, 15]), + Bytes32::from([80, 101, 192, 136, 203, 90, 189, 204, 181, 36, 28, 107, 220, 69, 119, 99, 145, 227, 198, 55, 37, 237, 212, 114, 31, 27, 19, 90, 231, 143, 87, 149]), + Bytes32::from([248, 97, 168, 33, 15, 230, 128, 82, 157, 26, 186, 89, 200, 7, 101, 210, 117, 111, 75, 233, 244, 187, 1, 180, 30, 220, 15, 21, 203, 5, 243, 223]) + ]); + zero_hashes.insert(MerkleType::Memory, vec![ + Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::from([66, 208, 130, 169, 194, 116, 5, 27, 68, 75, 235, 175, 164, 169, 41, 91, 88, 134, 51, 194, 219, 201, 182, 199, 1, 52, 173, 215, 20, 37, 51, 0]), + Bytes32::from([90, 210, 50, 227, 58, 173, 147, 92, 139, 15, 127, 190, 196, 111, 142, 207, 31, 223, 70, 96, 17, 251, 164, 200, 133, 0, 76, 35, 200, 9, 51, 218]), + Bytes32::from([97, 5, 162, 226, 92, 108, 172, 8, 7, 65, 104, 176, 216, 3, 144, 47, 14, 88, 50, 101, 194, 94, 10, 132, 192, 76, 37, 152, 42, 73, 30, 2]), + Bytes32::from([68, 59, 208, 14, 89, 37, 33, 1, 177, 225, 235, 66, 129, 28, 103, 156, 46, 206, 94, 141, 33, 152, 141, 26, 209, 161, 53, 237, 198, 163, 115, 57]), + Bytes32::from([28, 94, 12, 53, 70, 163, 95, 44, 168, 42, 196, 126, 181, 231, 174, 247, 89, 100, 77, 238, 211, 74, 116, 144, 183, 111, 254, 75, 30, 187, 228, 222]), + Bytes32::from([238, 133, 50, 189, 14, 89, 244, 88, 239, 50, 172, 85, 172, 1, 131, 2, 24, 161, 70, 94, 0, 204, 50, 199, 48, 107, 30, 70, 6, 8, 18, 90]), + Bytes32::from([165, 239, 71, 173, 192, 165, 25, 35, 4, 130, 148, 158, 177, 193, 129, 45, 115, 209, 7, 233, 136, 108, 245, 126, 74, 200, 22, 204, 190, 137, 191, 105]), + Bytes32::from([173, 102, 127, 73, 167, 249, 117, 26, 190, 231, 26, 60, 201, 138, 160, 182, 180, 44, 34, 132, 171, 254, 91, 8, 167, 114, 188, 157, 181, 148, 169, 165]), + Bytes32::from([71, 62, 70, 89, 203, 1, 105, 187, 178, 167, 217, 118, 42, 217, 154, 234, 238, 109, 145, 231, 247, 199, 40, 110, 162, 11, 173, 144, 103, 110, 99, 101]), + Bytes32::from([121, 36, 94, 4, 25, 134, 16, 98, 198, 109, 123, 42, 56, 151, 224, 7, 232, 155, 231, 154, 229, 162, 250, 149, 231, 198, 0, 65, 17, 27, 181, 28]), + Bytes32::from([247, 158, 162, 102, 242, 117, 166, 252, 175, 158, 107, 157, 244, 44, 17, 99, 93, 52, 43, 136, 5, 211, 32, 152, 91, 148, 41, 32, 231, 18, 237, 208]), + Bytes32::from([147, 52, 155, 255, 81, 242, 75, 54, 54, 66, 166, 41, 131, 177, 183, 151, 229, 177, 232, 86, 146, 137, 106, 68, 226, 117, 20, 210, 224, 170, 249, 68]), + Bytes32::from([160, 89, 180, 156, 119, 172, 38, 10, 97, 101, 64, 56, 98, 133, 199, 228, 58, 66, 139, 128, 88, 140, 143, 85, 148, 167, 79, 75, 34, 45, 204, 68]), + Bytes32::from([165, 233, 117, 3, 27, 56, 166, 16, 56, 132, 198, 32, 11, 149, 212, 98, 64, 236, 180, 106, 174, 80, 122, 220, 102, 67, 67, 110, 67, 8, 48, 217]), + Bytes32::from([113, 74, 209, 139, 250, 181, 182, 127, 178, 77, 17, 63, 79, 109, 145, 74, 52, 102, 125, 154, 22, 241, 177, 177, 34, 189, 124, 22, 4, 200, 201, 76]), + Bytes32::from([67, 7, 240, 151, 128, 149, 238, 113, 130, 127, 174, 223, 142, 124, 230, 10, 91, 89, 113, 157, 230, 21, 213, 3, 146, 249, 26, 80, 239, 90, 4, 216]), + Bytes32::from([152, 20, 80, 244, 232, 182, 1, 145, 31, 191, 46, 207, 83, 199, 209, 104, 0, 75, 106, 230, 16, 98, 121, 127, 175, 78, 119, 154, 69, 55, 66, 169]), + Bytes32::from([123, 50, 162, 158, 51, 112, 129, 232, 242, 158, 150, 72, 244, 40, 191, 63, 205, 61, 144, 39, 65, 122, 28, 88, 253, 146, 29, 29, 15, 40, 122, 95]), + Bytes32::from([231, 253, 202, 45, 165, 158, 212, 29, 104, 165, 209, 179, 188, 154, 89, 18, 216, 23, 140, 66, 150, 49, 99, 200, 163, 155, 50, 9, 250, 22, 19, 203]), + Bytes32::from([127, 172, 110, 243, 156, 134, 199, 15, 248, 216, 12, 196, 221, 66, 202, 186, 105, 197, 43, 245, 46, 116, 251, 133, 111, 118, 56, 214, 157, 244, 187, 58]), + Bytes32::from([181, 181, 163, 95, 7, 188, 245, 128, 161, 210, 137, 217, 103, 101, 120, 255, 47, 83, 102, 68, 238, 195, 206, 105, 24, 150, 216, 50, 74, 6, 94, 95]), + Bytes32::from([171, 250, 198, 40, 153, 26, 240, 152, 96, 169, 15, 123, 33, 155, 57, 172, 89, 205, 9, 65, 45, 126, 155, 143, 224, 145, 25, 214, 19, 227, 213, 195]), + Bytes32::from([44, 177, 244, 220, 119, 33, 203, 59, 209, 72, 28, 4, 210, 54, 86, 20, 119, 41, 45, 231, 143, 104, 57, 206, 212, 222, 81, 62, 92, 221, 200, 32]), + Bytes32::from([37, 200, 165, 195, 67, 224, 131, 227, 97, 54, 21, 233, 76, 186, 6, 122, 178, 131, 252, 59, 97, 218, 239, 62, 124, 255, 201, 178, 241, 236, 4, 214]), + Bytes32::from([77, 171, 229, 183, 46, 112, 203, 177, 89, 90, 64, 114, 109, 220, 32, 120, 41, 223, 72, 86, 59, 211, 110, 17, 129, 112, 194, 186, 200, 92, 144, 49]), + Bytes32::from([2, 198, 61, 112, 181, 185, 194, 114, 149, 63, 65, 76, 55, 179, 170, 62, 91, 112, 189, 100, 13, 34, 98, 187, 85, 132, 202, 86, 47, 27, 236, 200]), + Bytes32::from([164, 238, 109, 209, 155, 118, 236, 237, 84, 43, 56, 99, 51, 60, 116, 235, 100, 39, 163, 105, 34, 93, 8, 187, 228, 213, 35, 200, 43, 8, 32, 68]), + Bytes32::from([32, 220, 39, 200, 214, 245, 102, 200, 167, 204, 3, 54, 140, 126, 129, 35, 139, 60, 112, 133, 52, 166, 162, 63, 119, 20, 2, 116, 132, 244, 246, 225]), + Bytes32::from([5, 54, 145, 188, 188, 251, 36, 4, 103, 140, 229, 143, 83, 11, 77, 207, 57, 125, 51, 127, 89, 130, 138, 193, 190, 17, 17, 23, 68, 168, 231, 106]), + Bytes32::from([239, 112, 72, 74, 116, 134, 210, 24, 226, 242, 91, 113, 99, 59, 19, 7, 226, 215, 254, 220, 14, 225, 75, 245, 11, 234, 138, 52, 195, 86, 79, 124]), + Bytes32::from([187, 35, 132, 188, 162, 128, 96, 71, 124, 213, 251, 229, 73, 52, 187, 22, 166, 35, 214, 14, 121, 189, 37, 5, 77, 54, 201, 51, 95, 179, 75, 229]), + Bytes32::from([5, 54, 88, 42, 68, 200, 45, 209, 121, 70, 128, 8, 178, 212, 197, 39, 101, 90, 101, 111, 77, 133, 13, 77, 19, 111, 113, 122, 222, 85, 180, 82]), + Bytes32::from([34, 182, 144, 13, 35, 35, 79, 14, 239, 80, 21, 255, 67, 48, 210, 174, 159, 182, 239, 236, 68, 46, 125, 105, 243, 202, 218, 64, 53, 94, 159, 253]), + Bytes32::from([224, 189, 145, 186, 43, 169, 131, 161, 223, 161, 72, 72, 229, 97, 113, 233, 2, 250, 109, 31, 19, 125, 57, 135, 144, 3, 187, 18, 102, 108, 232, 9]), + Bytes32::from([68, 94, 11, 104, 95, 110, 179, 226, 157, 245, 113, 68, 44, 122, 17, 22, 244, 35, 248, 126, 131, 192, 20, 169, 129, 236, 60, 54, 157, 30, 231, 36]), + Bytes32::from([101, 198, 107, 156, 226, 8, 67, 168, 197, 91, 189, 166, 187, 16, 121, 93, 114, 243, 137, 162, 125, 142, 50, 206, 160, 168, 165, 27, 207, 10, 22, 19]), + Bytes32::from([222, 29, 134, 137, 98, 73, 58, 143, 166, 134, 210, 47, 68, 23, 214, 237, 241, 207, 226, 83, 113, 222, 184, 139, 16, 1, 200, 56, 34, 208, 197, 152]), + Bytes32::from([107, 200, 189, 222, 185, 32, 192, 130, 237, 238, 168, 137, 14, 94, 3, 26, 41, 238, 19, 119, 207, 158, 25, 177, 116, 70, 170, 161, 141, 129, 16, 88]), + Bytes32::from([131, 243, 131, 161, 236, 101, 108, 81, 59, 123, 150, 6, 250, 124, 103, 101, 75, 234, 98, 223, 129, 87, 202, 59, 184, 173, 44, 191, 200, 30, 223, 66]), + Bytes32::from([17, 226, 72, 31, 180, 33, 229, 83, 154, 39, 104, 45, 93, 117, 153, 249, 216, 127, 120, 182, 4, 19, 169, 87, 127, 70, 7, 237, 80, 251, 220, 126]), + Bytes32::from([88, 122, 134, 181, 173, 175, 100, 74, 28, 141, 45, 215, 245, 170, 222, 54, 106, 118, 146, 59, 207, 251, 133, 155, 164, 75, 240, 208, 10, 185, 187, 163]), + Bytes32::from([214, 1, 209, 99, 53, 101, 233, 225, 55, 171, 69, 200, 44, 144, 169, 11, 65, 85, 84, 158, 233, 227, 37, 59, 42, 52, 153, 13, 0, 158, 122, 208]), + Bytes32::from([124, 146, 1, 221, 33, 138, 233, 130, 184, 163, 121, 110, 95, 242, 123, 251, 110, 46, 41, 197, 75, 145, 121, 95, 29, 1, 19, 19, 167, 220, 177, 153]), + Bytes32::from([77, 38, 54, 170, 19, 128, 180, 248, 208, 75, 27, 53, 228, 104, 7, 216, 188, 186, 40, 84, 87, 11, 121, 3, 175, 89, 49, 46, 191, 94, 80, 97]), + Bytes32::from([134, 127, 37, 206, 212, 70, 146, 143, 81, 104, 140, 28, 135, 233, 171, 88, 18, 2, 148, 143, 111, 208, 149, 138, 167, 84, 183, 100, 67, 181, 243, 135]), + Bytes32::from([218, 16, 220, 189, 192, 237, 252, 168, 45, 33, 177, 81, 53, 115, 141, 190, 99, 138, 113, 85, 60, 230, 244, 222, 205, 16, 152, 26, 185, 207, 114, 143]), + Bytes32::from([9, 85, 193, 163, 186, 152, 83, 149, 29, 71, 50, 13, 175, 149, 184, 51, 246, 97, 20, 22, 57, 201, 27, 72, 146, 19, 213, 102, 164, 148, 176, 45]), + Bytes32::from([140, 94, 218, 31, 232, 0, 167, 218, 122, 119, 62, 179, 181, 51, 100, 6, 150, 159, 212, 207, 160, 94, 212, 108, 225, 196, 190, 210, 145, 110, 120, 114]), + Bytes32::from([152, 169, 229, 240, 162, 212, 61, 59, 167, 135, 124, 147, 212, 248, 177, 85, 243, 72, 150, 127, 122, 60, 143, 125, 226, 186, 67, 219, 50, 112, 242, 212]), + Bytes32::from([47, 244, 81, 140, 243, 189, 116, 0, 2, 158, 242, 188, 215, 90, 177, 37, 175, 221, 80, 226, 209, 79, 2, 62, 112, 245, 1, 132, 7, 78, 0, 117]), + Bytes32::from([247, 236, 252, 118, 6, 245, 132, 187, 48, 36, 77, 0, 167, 150, 109, 72, 234, 9, 224, 162, 223, 191, 21, 19, 180, 201, 138, 56, 109, 97, 152, 170]), + Bytes32::from([77, 23, 112, 52, 78, 204, 135, 173, 2, 206, 148, 200, 60, 155, 60, 179, 201, 111, 73, 138, 76, 104, 79, 174, 190, 173, 42, 51, 38, 48, 237, 241]), + Bytes32::from([117, 234, 73, 183, 4, 144, 12, 196, 78, 228, 178, 218, 206, 147, 147, 94, 190, 22, 22, 233, 88, 118, 135, 55, 63, 29, 212, 38, 223, 160, 121, 230]), + Bytes32::from([74, 138, 173, 10, 77, 129, 10, 115, 18, 90, 57, 215, 221, 171, 109, 152, 31, 219, 235, 122, 189, 201, 210, 186, 52, 200, 81, 218, 112, 79, 80, 54]), + Bytes32::from([189, 150, 224, 30, 110, 73, 249, 62, 100, 244, 206, 110, 206, 239, 233, 213, 61, 213, 65, 139, 103, 19, 20, 123, 167, 65, 161, 165, 216, 217, 255, 248]), + Bytes32::from([119, 71, 56, 219, 155, 139, 253, 40, 100, 132, 185, 98, 24, 34, 156, 225, 120, 176, 76, 147, 31, 105, 245, 216, 165, 161, 89, 157, 246, 17, 251, 234]), + Bytes32::from([192, 39, 162, 126, 222, 211, 173, 195, 198, 124, 1, 124, 140, 2, 252, 191, 185, 85, 10, 125, 226, 7, 88, 221, 164, 13, 221, 74, 200, 7, 249, 177]), + Bytes32::from([251, 226, 24, 5, 54, 89, 9, 93, 217, 202, 148, 172, 208, 197, 65, 172, 98, 96, 58, 194, 61, 253, 157, 193, 135, 32, 206, 97, 133, 234, 199, 197]), + Bytes32::from([130, 3, 195, 156, 210, 123, 23, 44, 223, 25, 153, 169, 250, 88, 127, 239, 206, 196, 156, 143, 182, 185, 35, 77, 162, 48, 143, 64, 231, 129, 216, 185]), + Bytes32::from([123, 201, 97, 230, 121, 13, 207, 138, 137, 3, 122, 92, 105, 155, 214, 204, 142, 18, 119, 138, 135, 165, 249, 58, 184, 53, 27, 31, 109, 214, 176, 147]), + Bytes32::from([46, 71, 246, 155, 247, 109, 236, 225, 147, 51, 250, 72, 97, 116, 162, 36, 115, 164, 80, 28, 252, 238, 98, 92, 16, 66, 190, 208, 180, 39, 179, 211]), + Bytes32::from([38, 76, 13, 227, 149, 18, 84, 170, 83, 231, 122, 59, 237, 66, 32, 171, 158, 251, 78, 156, 186, 160, 29, 30, 207, 178, 16, 193, 221, 158, 49, 48]), + Bytes32::from([166, 13, 210, 208, 250, 131, 27, 163, 99, 204, 199, 134, 152, 131, 28, 164, 8, 222, 176, 200, 34, 40, 74, 188, 120, 46, 167, 44, 95, 199, 86, 225]) + ]); + zero_hashes.insert(MerkleType::Table, vec![ + Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::from([164, 47, 121, 69, 150, 44, 30, 204, 210, 181, 242, 154, 59, 111, 5, 10, 47, 121, 213, 80, 163, 196, 205, 188, 241, 64, 202, 26, 242, 47, 50, 205]), + Bytes32::from([166, 9, 224, 145, 14, 138, 194, 78, 202, 114, 110, 38, 244, 33, 189, 185, 170, 85, 144, 229, 123, 63, 229, 194, 59, 130, 156, 6, 184, 154, 187, 17]), + Bytes32::from([32, 51, 186, 232, 39, 244, 218, 98, 243, 254, 82, 247, 63, 120, 34, 123, 128, 240, 220, 145, 41, 114, 251, 208, 209, 244, 10, 9, 179, 5, 105, 181]), + Bytes32::from([73, 148, 74, 132, 241, 45, 129, 169, 83, 223, 101, 12, 184, 60, 10, 201, 169, 197, 75, 17, 198, 168, 79, 171, 207, 195, 123, 47, 249, 30, 176, 216]), + Bytes32::from([145, 224, 51, 196, 211, 137, 189, 133, 232, 210, 170, 157, 227, 160, 218, 143, 15, 82, 170, 226, 241, 83, 7, 112, 138, 227, 58, 59, 149, 168, 81, 94]), + Bytes32::from([241, 90, 42, 7, 231, 63, 36, 86, 238, 131, 19, 20, 38, 118, 65, 180, 109, 121, 147, 147, 213, 142, 203, 244, 239, 75, 5, 160, 16, 85, 221, 95]), + Bytes32::from([213, 113, 178, 221, 213, 107, 77, 153, 222, 48, 148, 140, 250, 1, 17, 59, 73, 19, 110, 106, 94, 195, 126, 49, 126, 109, 65, 55, 104, 111, 18, 171]), + Bytes32::from([43, 198, 12, 197, 95, 201, 76, 108, 96, 235, 76, 8, 117, 99, 42, 20, 177, 45, 112, 40, 2, 180, 68, 19, 25, 11, 210, 168, 170, 178, 99, 27]), + Bytes32::from([142, 205, 24, 125, 81, 234, 138, 161, 206, 121, 163, 225, 50, 9, 180, 102, 0, 25, 93, 180, 137, 164, 206, 249, 222, 20, 175, 177, 199, 14, 115, 207]), + Bytes32::from([213, 41, 249, 19, 173, 165, 236, 103, 42, 146, 223, 6, 190, 229, 161, 13, 96, 163, 110, 23, 203, 238, 24, 95, 130, 203, 35, 211, 63, 234, 32, 137]), + Bytes32::from([176, 82, 229, 48, 113, 46, 179, 38, 231, 83, 50, 136, 179, 190, 242, 126, 152, 210, 141, 102, 191, 21, 20, 96, 235, 245, 81, 254, 231, 117, 159, 146]), + Bytes32::from([216, 15, 120, 147, 70, 215, 12, 160, 223, 73, 246, 73, 195, 189, 200, 3, 19, 131, 102, 61, 173, 79, 50, 76, 39, 150, 151, 147, 35, 251, 200, 0]), + Bytes32::from([88, 215, 168, 30, 218, 72, 206, 159, 91, 121, 14, 133, 241, 220, 195, 46, 93, 244, 179, 53, 158, 75, 211, 161, 8, 120, 167, 141, 235, 16, 232, 42]), + Bytes32::from([114, 99, 218, 52, 203, 162, 199, 16, 225, 154, 182, 20, 59, 121, 250, 249, 166, 35, 118, 18, 142, 57, 122, 131, 32, 219, 83, 126, 147, 91, 116, 16]), + Bytes32::from([193, 157, 15, 251, 179, 155, 215, 190, 98, 93, 30, 167, 23, 175, 178, 172, 142, 143, 222, 20, 18, 157, 215, 42, 105, 107, 64, 16, 216, 143, 109, 45]), + Bytes32::from([178, 2, 203, 32, 83, 90, 114, 97, 124, 210, 81, 81, 179, 213, 71, 19, 181, 173, 227, 88, 226, 83, 48, 169, 134, 163, 62, 103, 222, 82, 128, 30]), + Bytes32::from([252, 17, 142, 50, 185, 19, 111, 148, 204, 30, 199, 138, 143, 207, 30, 212, 254, 7, 129, 43, 100, 167, 52, 115, 247, 143, 64, 106, 220, 5, 7, 89]), + Bytes32::from([117, 136, 111, 98, 95, 97, 253, 43, 82, 22, 43, 187, 65, 154, 132, 105, 55, 194, 240, 148, 170, 199, 185, 91, 157, 138, 43, 117, 218, 176, 110, 101]), + Bytes32::from([228, 56, 186, 202, 73, 47, 253, 151, 48, 173, 2, 101, 153, 197, 108, 145, 227, 170, 247, 86, 80, 70, 30, 93, 232, 148, 63, 211, 197, 135, 23, 97]), + Bytes32::from([162, 35, 93, 45, 208, 241, 87, 57, 138, 79, 231, 83, 75, 81, 102, 91, 115, 58, 1, 205, 193, 197, 62, 210, 144, 88, 59, 52, 149, 234, 121, 224]), + Bytes32::from([165, 67, 16, 239, 234, 92, 207, 81, 64, 93, 227, 154, 132, 33, 54, 53, 102, 198, 90, 134, 24, 29, 190, 158, 121, 23, 127, 30, 27, 239, 140, 88]), + Bytes32::from([61, 125, 183, 139, 186, 82, 193, 166, 2, 147, 231, 215, 179, 107, 163, 67, 122, 0, 90, 188, 142, 216, 72, 20, 63, 146, 85, 89, 231, 41, 153, 117]), + Bytes32::from([206, 31, 38, 182, 78, 170, 183, 207, 211, 114, 212, 4, 108, 84, 62, 99, 245, 196, 10, 1, 188, 63, 240, 199, 27, 85, 68, 101, 212, 222, 85, 12]), + Bytes32::from([106, 0, 225, 130, 195, 87, 113, 106, 101, 80, 56, 119, 93, 45, 74, 168, 240, 209, 155, 123, 8, 129, 73, 225, 204, 125, 42, 73, 102, 122, 228, 158]), + Bytes32::from([251, 63, 88, 92, 59, 176, 71, 194, 46, 19, 18, 27, 83, 57, 197, 231, 202, 242, 155, 63, 252, 240, 205, 216, 96, 130, 161, 197, 123, 110, 175, 220]), + Bytes32::from([239, 6, 249, 150, 189, 234, 197, 18, 79, 222, 80, 72, 205, 147, 251, 135, 226, 33, 46, 111, 186, 185, 4, 33, 219, 129, 30, 182, 57, 229, 34, 16]), + Bytes32::from([192, 35, 149, 149, 16, 111, 3, 119, 173, 215, 223, 247, 70, 25, 31, 107, 104, 5, 249, 243, 193, 66, 99, 48, 107, 158, 25, 147, 163, 151, 96, 149]), + Bytes32::from([197, 133, 241, 197, 67, 52, 255, 227, 180, 235, 137, 164, 174, 160, 183, 9, 159, 254, 210, 180, 231, 140, 176, 165, 113, 215, 182, 1, 177, 204, 219, 246]), + Bytes32::from([51, 32, 109, 173, 131, 6, 99, 63, 75, 191, 207, 187, 73, 26, 5, 139, 167, 216, 123, 26, 199, 176, 84, 215, 158, 243, 105, 0, 91, 254, 59, 146]), + Bytes32::from([229, 120, 15, 22, 225, 50, 131, 240, 190, 232, 83, 119, 169, 246, 172, 35, 99, 163, 58, 146, 234, 253, 252, 83, 5, 48, 54, 142, 172, 91, 145, 13]), + Bytes32::from([159, 9, 100, 20, 215, 92, 217, 43, 208, 254, 65, 234, 124, 167, 250, 53, 159, 151, 124, 70, 26, 0, 113, 28, 78, 44, 238, 8, 34, 255, 19, 36]), + Bytes32::from([193, 135, 44, 144, 13, 46, 76, 43, 127, 208, 79, 196, 229, 58, 125, 33, 71, 118, 215, 240, 80, 123, 44, 181, 174, 47, 102, 42, 137, 98, 190, 41]), + Bytes32::from([78, 19, 3, 217, 174, 154, 142, 109, 189, 14, 241, 12, 23, 185, 224, 152, 209, 108, 223, 202, 191, 11, 190, 149, 31, 236, 104, 234, 22, 38, 196, 3]), + Bytes32::from([60, 93, 237, 228, 186, 222, 179, 231, 151, 95, 147, 20, 188, 10, 191, 34, 126, 57, 253, 161, 154, 117, 182, 108, 143, 72, 48, 102, 191, 240, 81, 208]), + Bytes32::from([179, 114, 163, 89, 172, 211, 154, 204, 11, 125, 140, 186, 107, 90, 17, 116, 214, 31, 165, 94, 36, 187, 184, 151, 210, 208, 76, 215, 75, 166, 107, 91]), + Bytes32::from([125, 131, 52, 139, 120, 156, 163, 243, 206, 143, 204, 221, 123, 140, 1, 103, 235, 186, 64, 82, 194, 191, 205, 2, 32, 242, 38, 77, 184, 23, 236, 228]), + Bytes32::from([137, 224, 90, 1, 116, 95, 215, 47, 8, 3, 227, 132, 154, 232, 216, 63, 3, 80, 52, 18, 42, 29, 85, 38, 117, 255, 9, 99, 88, 233, 129, 92]), + Bytes32::from([54, 182, 145, 174, 54, 24, 168, 13, 71, 43, 178, 49, 153, 246, 94, 79, 228, 254, 134, 0, 21, 210, 176, 242, 82, 117, 76, 40, 221, 181, 30, 62]), + Bytes32::from([145, 171, 156, 87, 15, 174, 31, 111, 175, 161, 31, 116, 123, 123, 37, 216, 43, 147, 197, 79, 218, 49, 236, 111, 35, 49, 44, 188, 197, 79, 136, 45]), + Bytes32::from([169, 48, 186, 93, 10, 48, 80, 103, 68, 226, 103, 31, 176, 154, 146, 199, 166, 89, 48, 149, 116, 101, 157, 149, 149, 72, 123, 54, 153, 26, 210, 122]), + Bytes32::from([225, 45, 163, 167, 213, 84, 40, 87, 106, 253, 206, 80, 189, 71, 153, 5, 15, 107, 151, 150, 14, 22, 143, 207, 4, 192, 63, 250, 207, 207, 179, 26]), + Bytes32::from([110, 249, 172, 218, 206, 202, 107, 64, 48, 153, 226, 127, 165, 227, 50, 146, 140, 239, 220, 252, 188, 157, 77, 210, 92, 73, 38, 6, 16, 87, 244, 66]), + Bytes32::from([39, 217, 230, 91, 60, 231, 96, 137, 37, 58, 93, 51, 79, 222, 132, 171, 196, 109, 155, 4, 252, 213, 17, 33, 160, 24, 250, 118, 187, 62, 107, 113]), + Bytes32::from([120, 167, 145, 121, 184, 31, 185, 178, 241, 54, 20, 48, 132, 89, 132, 127, 235, 189, 197, 127, 249, 58, 255, 197, 40, 229, 130, 254, 213, 186, 114, 74]), + Bytes32::from([7, 40, 187, 172, 225, 196, 3, 77, 113, 16, 118, 148, 95, 65, 42, 234, 233, 29, 120, 223, 105, 77, 250, 119, 245, 20, 21, 155, 177, 13, 56, 151]), + Bytes32::from([22, 248, 25, 75, 36, 179, 251, 57, 101, 170, 213, 19, 216, 64, 164, 253, 151, 199, 88, 5, 92, 129, 138, 185, 9, 236, 231, 68, 112, 24, 218, 216]), + Bytes32::from([95, 141, 49, 39, 213, 214, 130, 49, 143, 124, 178, 114, 200, 136, 160, 90, 233, 73, 233, 185, 60, 250, 174, 74, 2, 123, 2, 62, 192, 174, 115, 158]), + Bytes32::from([142, 29, 212, 35, 71, 107, 91, 164, 226, 225, 180, 218, 99, 34, 200, 171, 33, 235, 113, 105, 191, 78, 105, 70, 221, 135, 167, 148, 24, 225, 6, 146]), + Bytes32::from([176, 194, 115, 243, 138, 104, 3, 247, 184, 74, 81, 60, 173, 45, 29, 189, 252, 202, 206, 66, 129, 65, 150, 25, 246, 145, 133, 4, 93, 201, 201, 240]), + Bytes32::from([18, 233, 186, 158, 43, 12, 206, 228, 80, 102, 187, 25, 78, 77, 180, 28, 82, 62, 168, 252, 14, 113, 126, 91, 243, 120, 213, 91, 189, 244, 247, 177]), + Bytes32::from([79, 126, 97, 23, 112, 98, 93, 86, 24, 103, 82, 33, 155, 188, 202, 61, 29, 146, 132, 169, 116, 207, 216, 35, 29, 229, 213, 120, 135, 240, 129, 205]), + Bytes32::from([146, 121, 255, 202, 145, 53, 46, 8, 102, 205, 56, 234, 49, 42, 85, 231, 217, 114, 235, 141, 233, 187, 29, 9, 122, 232, 61, 253, 42, 104, 4, 113]), + Bytes32::from([103, 174, 255, 6, 115, 155, 156, 65, 84, 251, 208, 55, 89, 124, 171, 167, 133, 227, 22, 134, 32, 71, 243, 181, 16, 100, 81, 63, 22, 207, 58, 190]), + Bytes32::from([69, 10, 247, 243, 56, 0, 64, 72, 218, 21, 211, 192, 62, 243, 66, 244, 230, 58, 107, 54, 180, 29, 216, 23, 86, 211, 173, 181, 118, 188, 238, 72]), + Bytes32::from([25, 179, 4, 93, 169, 76, 76, 69, 158, 3, 24, 146, 130, 9, 225, 198, 102, 238, 29, 73, 74, 179, 159, 74, 40, 111, 181, 110, 76, 173, 251, 255]), + Bytes32::from([236, 113, 37, 202, 149, 150, 90, 50, 233, 141, 125, 12, 212, 163, 137, 176, 15, 214, 194, 73, 138, 104, 4, 33, 235, 76, 185, 58, 125, 182, 56, 0]), + Bytes32::from([238, 54, 183, 94, 50, 33, 98, 31, 133, 181, 230, 98, 43, 154, 95, 111, 250, 71, 15, 197, 156, 60, 8, 90, 208, 50, 62, 127, 30, 18, 181, 176]), + Bytes32::from([246, 143, 72, 228, 143, 15, 15, 131, 178, 105, 113, 46, 85, 36, 165, 116, 63, 131, 61, 228, 98, 144, 232, 209, 228, 110, 168, 171, 252, 47, 79, 165]), + Bytes32::from([146, 70, 74, 79, 139, 107, 73, 28, 231, 88, 235, 214, 163, 185, 87, 195, 147, 186, 153, 222, 191, 214, 30, 231, 173, 166, 151, 169, 244, 15, 15, 227]), + Bytes32::from([137, 182, 175, 97, 212, 23, 62, 70, 50, 150, 67, 153, 253, 52, 179, 105, 147, 177, 217, 170, 125, 251, 1, 96, 4, 127, 196, 37, 254, 7, 217, 100]), + Bytes32::from([32, 253, 229, 209, 120, 43, 120, 189, 245, 227, 178, 79, 134, 175, 240, 107, 25, 124, 5, 67, 120, 213, 187, 200, 159, 9, 26, 119, 13, 1, 8, 120]), + Bytes32::from([115, 241, 26, 44, 83, 229, 130, 21, 249, 87, 72, 212, 75, 220, 95, 22, 151, 77, 182, 8, 196, 207, 95, 18, 9, 92, 89, 206, 114, 80, 36, 159]), + Bytes32::from([174, 151, 88, 171, 52, 40, 161, 16, 106, 45, 44, 9, 142, 95, 5, 205, 82, 24, 172, 103, 152, 202, 187, 34, 217, 173, 236, 129, 32, 203, 205, 38]) + ]); + zero_hashes.insert(MerkleType::TableElement, vec![ + Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::from([145, 218, 63, 74, 131, 182, 204, 163, 74, 206, 234, 50, 47, 3, 51, 74, 121, 225, 146, 237, 5, 128, 20, 230, 243, 89, 33, 248, 136, 154, 189, 5]), + Bytes32::from([36, 240, 95, 13, 214, 136, 92, 102, 96, 137, 39, 96, 108, 223, 147, 130, 220, 61, 147, 226, 52, 133, 67, 223, 211, 164, 6, 53, 45, 117, 120, 241]), + Bytes32::from([9, 2, 218, 34, 228, 8, 178, 127, 160, 30, 104, 198, 49, 37, 71, 115, 14, 35, 20, 15, 253, 160, 147, 143, 24, 186, 12, 90, 41, 169, 30, 8]), + Bytes32::from([137, 242, 105, 78, 161, 99, 76, 224, 226, 100, 216, 235, 156, 132, 214, 154, 107, 120, 197, 113, 45, 221, 170, 119, 92, 228, 76, 139, 170, 159, 111, 58]), + Bytes32::from([231, 165, 221, 185, 139, 22, 70, 40, 67, 162, 123, 94, 161, 156, 57, 53, 102, 217, 128, 227, 18, 132, 17, 170, 90, 31, 214, 181, 249, 220, 70, 37]), + Bytes32::from([171, 253, 174, 187, 9, 186, 87, 37, 22, 83, 13, 88, 75, 11, 177, 226, 237, 136, 132, 137, 101, 109, 135, 192, 224, 80, 87, 105, 95, 81, 255, 21]), + Bytes32::from([179, 50, 36, 230, 159, 162, 184, 132, 140, 121, 133, 155, 189, 44, 132, 93, 80, 79, 32, 244, 131, 57, 79, 222, 104, 63, 224, 182, 91, 162, 73, 122]), + Bytes32::from([17, 55, 206, 87, 127, 185, 135, 231, 41, 56, 166, 104, 229, 102, 222, 181, 236, 233, 230, 39, 43, 163, 16, 1, 225, 86, 211, 51, 145, 7, 169, 84]), + Bytes32::from([201, 174, 3, 154, 104, 190, 240, 99, 123, 201, 7, 118, 196, 85, 28, 247, 35, 232, 39, 25, 151, 52, 167, 136, 179, 13, 213, 60, 138, 158, 39, 131]), + Bytes32::from([35, 33, 109, 155, 171, 252, 195, 80, 10, 115, 40, 199, 250, 1, 241, 82, 146, 225, 118, 237, 11, 125, 198, 97, 57, 21, 171, 237, 94, 60, 49, 32]), + Bytes32::from([126, 95, 42, 157, 183, 168, 137, 120, 114, 64, 148, 170, 32, 156, 137, 96, 194, 91, 119, 11, 20, 3, 30, 62, 118, 12, 31, 48, 245, 144, 252, 29]), + Bytes32::from([48, 135, 201, 114, 103, 35, 8, 96, 5, 101, 125, 26, 87, 0, 98, 122, 239, 140, 230, 10, 102, 112, 155, 87, 249, 181, 152, 235, 28, 79, 176, 56]), + Bytes32::from([76, 70, 222, 210, 242, 159, 52, 123, 112, 106, 253, 140, 55, 160, 189, 255, 220, 64, 8, 168, 39, 196, 160, 8, 105, 154, 91, 184, 62, 63, 227, 156]), + Bytes32::from([138, 201, 8, 240, 218, 190, 210, 227, 236, 168, 45, 161, 209, 115, 126, 165, 235, 162, 6, 117, 76, 239, 3, 225, 163, 251, 111, 233, 233, 228, 14, 92]), + Bytes32::from([190, 166, 27, 117, 242, 0, 25, 148, 230, 125, 237, 22, 153, 158, 151, 56, 121, 194, 221, 198, 184, 147, 249, 149, 27, 29, 166, 243, 254, 181, 209, 102]), + Bytes32::from([235, 63, 149, 47, 164, 152, 80, 11, 178, 203, 99, 178, 176, 226, 164, 151, 39, 65, 83, 200, 102, 90, 12, 102, 178, 15, 232, 16, 222, 141, 78, 3]), + Bytes32::from([37, 179, 99, 114, 214, 120, 87, 53, 198, 229, 207, 47, 16, 112, 208, 33, 216, 152, 209, 228, 196, 14, 237, 250, 212, 90, 176, 185, 21, 248, 92, 109]), + Bytes32::from([237, 200, 122, 93, 145, 116, 138, 59, 86, 220, 58, 171, 160, 31, 142, 193, 231, 131, 106, 164, 166, 44, 120, 170, 62, 81, 73, 85, 0, 52, 219, 220]), + Bytes32::from([244, 173, 85, 141, 81, 198, 214, 0, 54, 21, 20, 169, 177, 235, 104, 206, 43, 218, 96, 68, 73, 37, 252, 77, 253, 18, 30, 97, 223, 122, 1, 12]), + Bytes32::from([104, 169, 247, 140, 131, 245, 193, 3, 36, 119, 249, 119, 108, 102, 115, 250, 173, 225, 33, 156, 116, 87, 180, 27, 84, 215, 126, 15, 187, 189, 32, 139]), + Bytes32::from([47, 156, 244, 88, 145, 227, 224, 87, 233, 138, 138, 9, 169, 96, 29, 204, 100, 170, 23, 105, 63, 4, 119, 90, 167, 161, 72, 109, 82, 254, 123, 48]), + Bytes32::from([196, 68, 107, 111, 141, 253, 138, 140, 162, 104, 247, 104, 87, 144, 123, 240, 105, 251, 246, 210, 172, 172, 241, 162, 155, 90, 83, 175, 131, 251, 107, 215]), + Bytes32::from([28, 100, 243, 226, 32, 234, 211, 106, 197, 179, 14, 192, 70, 11, 203, 125, 151, 53, 20, 77, 175, 99, 154, 100, 159, 249, 54, 39, 73, 168, 162, 66]), + Bytes32::from([83, 176, 7, 180, 201, 178, 172, 98, 47, 34, 80, 6, 62, 10, 4, 112, 43, 93, 10, 227, 74, 91, 11, 217, 83, 230, 104, 0, 167, 2, 114, 89]), + Bytes32::from([185, 162, 212, 82, 149, 182, 104, 215, 62, 244, 114, 124, 181, 74, 226, 119, 4, 42, 181, 238, 25, 212, 215, 219, 174, 231, 32, 170, 9, 234, 12, 212]), + Bytes32::from([173, 38, 241, 20, 137, 119, 33, 252, 174, 245, 252, 234, 165, 181, 128, 225, 14, 147, 182, 97, 145, 19, 40, 193, 90, 238, 140, 87, 0, 222, 70, 254]), + Bytes32::from([51, 218, 162, 213, 211, 23, 9, 158, 185, 156, 39, 145, 5, 146, 70, 144, 172, 10, 26, 212, 253, 37, 24, 32, 21, 65, 179, 140, 64, 237, 96, 157]), + Bytes32::from([221, 87, 57, 81, 246, 126, 53, 163, 190, 220, 109, 205, 114, 234, 85, 151, 75, 245, 254, 16, 140, 131, 239, 120, 9, 209, 54, 61, 177, 6, 188, 252]), + Bytes32::from([54, 161, 25, 198, 75, 151, 214, 76, 83, 74, 117, 229, 155, 237, 88, 95, 143, 119, 56, 12, 201, 164, 235, 20, 117, 49, 177, 88, 14, 248, 95, 198]), + Bytes32::from([60, 16, 183, 115, 241, 45, 253, 24, 105, 43, 79, 72, 212, 238, 24, 156, 132, 93, 78, 246, 1, 228, 222, 200, 254, 130, 170, 46, 91, 254, 205, 143]), + Bytes32::from([184, 30, 34, 235, 214, 40, 120, 64, 182, 15, 162, 189, 164, 202, 89, 146, 202, 177, 16, 105, 172, 158, 1, 95, 101, 146, 253, 115, 226, 233, 38, 171]), + Bytes32::from([70, 152, 3, 73, 249, 222, 93, 214, 74, 179, 140, 47, 34, 42, 149, 214, 152, 75, 34, 145, 68, 226, 151, 101, 121, 54, 252, 240, 206, 140, 81, 165]), + Bytes32::from([9, 88, 51, 124, 67, 108, 84, 244, 61, 241, 110, 246, 184, 105, 6, 116, 242, 58, 15, 144, 43, 76, 176, 107, 0, 138, 155, 235, 210, 138, 226, 215]), + Bytes32::from([98, 170, 168, 147, 158, 223, 186, 7, 58, 130, 89, 200, 153, 24, 158, 251, 69, 100, 7, 57, 96, 115, 136, 170, 57, 145, 143, 240, 102, 6, 248, 111]), + Bytes32::from([76, 75, 216, 216, 194, 146, 2, 59, 247, 64, 98, 160, 62, 105, 193, 186, 161, 191, 64, 154, 254, 196, 55, 214, 201, 103, 223, 131, 181, 192, 152, 176]), + Bytes32::from([188, 141, 114, 199, 33, 45, 183, 18, 123, 231, 92, 215, 51, 191, 11, 199, 253, 46, 28, 10, 156, 23, 92, 255, 219, 236, 176, 247, 52, 105, 210, 223]), + Bytes32::from([200, 67, 112, 29, 180, 70, 50, 18, 220, 122, 39, 122, 83, 186, 81, 77, 241, 44, 190, 3, 162, 217, 76, 61, 230, 237, 157, 230, 205, 172, 186, 247]), + Bytes32::from([131, 131, 129, 83, 251, 217, 83, 88, 93, 39, 66, 174, 51, 19, 190, 91, 16, 187, 95, 63, 35, 178, 94, 237, 194, 42, 231, 227, 138, 202, 216, 93]), + Bytes32::from([18, 177, 28, 41, 199, 59, 160, 244, 26, 162, 73, 48, 16, 74, 190, 195, 249, 216, 64, 229, 145, 65, 18, 131, 75, 57, 71, 74, 127, 239, 112, 13]), + Bytes32::from([41, 120, 53, 253, 151, 12, 143, 213, 212, 31, 245, 61, 168, 113, 30, 38, 112, 126, 156, 133, 241, 102, 110, 237, 4, 138, 50, 160, 79, 235, 52, 35]), + Bytes32::from([38, 74, 146, 27, 110, 86, 122, 250, 58, 243, 64, 185, 207, 174, 28, 124, 35, 183, 53, 88, 34, 234, 89, 58, 98, 223, 69, 13, 48, 15, 239, 230]), + Bytes32::from([221, 132, 1, 28, 157, 232, 235, 132, 32, 58, 26, 36, 60, 217, 197, 165, 141, 19, 64, 120, 197, 139, 190, 86, 153, 152, 235, 11, 99, 129, 222, 91]), + Bytes32::from([237, 76, 61, 239, 169, 108, 131, 62, 163, 67, 158, 210, 14, 45, 91, 105, 36, 182, 206, 182, 71, 11, 159, 169, 159, 248, 247, 176, 6, 176, 237, 123]), + Bytes32::from([232, 190, 198, 78, 12, 148, 86, 176, 221, 115, 1, 22, 122, 163, 223, 234, 74, 129, 125, 53, 211, 137, 115, 18, 241, 170, 69, 42, 34, 74, 180, 172]), + Bytes32::from([215, 199, 144, 158, 222, 153, 123, 125, 150, 97, 127, 151, 96, 43, 69, 155, 150, 119, 75, 82, 218, 48, 101, 70, 121, 18, 42, 146, 215, 183, 100, 158]), + Bytes32::from([121, 182, 45, 62, 255, 78, 32, 48, 107, 186, 208, 155, 158, 80, 231, 241, 90, 227, 219, 113, 52, 20, 66, 45, 124, 67, 209, 61, 167, 74, 60, 34]), + Bytes32::from([34, 136, 15, 103, 128, 220, 202, 103, 150, 123, 249, 145, 218, 227, 17, 64, 142, 129, 4, 42, 93, 7, 6, 147, 111, 117, 25, 185, 88, 104, 85, 115]), + Bytes32::from([144, 191, 235, 38, 205, 102, 127, 160, 139, 105, 75, 63, 86, 192, 194, 49, 240, 35, 65, 154, 4, 113, 51, 87, 40, 70, 32, 58, 243, 16, 136, 67]), + Bytes32::from([217, 150, 254, 250, 111, 69, 45, 227, 111, 59, 199, 149, 59, 216, 17, 117, 8, 226, 85, 250, 183, 187, 21, 129, 208, 0, 63, 158, 232, 106, 131, 16]), + Bytes32::from([148, 212, 84, 16, 204, 49, 69, 96, 137, 125, 102, 221, 111, 8, 41, 51, 221, 241, 87, 231, 88, 215, 211, 24, 254, 131, 111, 56, 160, 143, 230, 109]), + Bytes32::from([144, 48, 37, 157, 153, 7, 123, 206, 46, 224, 211, 249, 208, 217, 91, 243, 128, 62, 100, 126, 3, 253, 223, 161, 50, 108, 26, 151, 129, 242, 94, 132]), + Bytes32::from([97, 167, 177, 53, 183, 154, 164, 1, 129, 184, 234, 182, 190, 197, 244, 226, 150, 217, 57, 152, 243, 206, 60, 76, 114, 194, 51, 240, 58, 93, 219, 76]), + Bytes32::from([139, 70, 147, 227, 94, 147, 130, 53, 38, 112, 138, 176, 7, 148, 6, 21, 50, 199, 70, 33, 87, 180, 33, 167, 56, 89, 66, 95, 245, 247, 135, 24]), + Bytes32::from([175, 169, 204, 13, 145, 18, 40, 29, 84, 88, 206, 99, 208, 137, 249, 146, 0, 237, 188, 130, 135, 223, 121, 54, 126, 251, 247, 109, 141, 217, 62, 127]), + Bytes32::from([139, 188, 3, 234, 198, 124, 194, 238, 217, 237, 214, 250, 66, 220, 0, 51, 1, 203, 122, 125, 46, 213, 22, 253, 8, 218, 145, 253, 170, 156, 159, 96]), + Bytes32::from([107, 130, 208, 55, 16, 249, 46, 4, 98, 236, 130, 52, 190, 126, 232, 229, 108, 126, 239, 175, 25, 229, 84, 33, 249, 66, 128, 162, 47, 221, 110, 163]), + Bytes32::from([239, 176, 14, 134, 210, 125, 177, 40, 200, 42, 229, 32, 200, 58, 9, 73, 210, 161, 8, 105, 4, 70, 19, 134, 117, 132, 167, 18, 16, 108, 207, 113]), + Bytes32::from([237, 116, 250, 79, 151, 228, 171, 189, 89, 213, 122, 121, 55, 25, 52, 238, 79, 19, 31, 194, 73, 158, 43, 78, 86, 194, 36, 141, 105, 10, 87, 58]), + Bytes32::from([216, 125, 158, 123, 121, 158, 74, 152, 46, 18, 196, 115, 233, 149, 205, 189, 10, 232, 174, 21, 2, 52, 202, 111, 74, 160, 191, 196, 84, 93, 98, 46]), + Bytes32::from([201, 148, 124, 172, 62, 154, 127, 129, 205, 197, 134, 133, 144, 78, 47, 190, 197, 190, 103, 44, 129, 57, 155, 227, 152, 212, 130, 12, 192, 223, 244, 68]), + Bytes32::from([102, 147, 19, 104, 237, 188, 140, 66, 166, 77, 105, 55, 5, 165, 143, 107, 91, 247, 53, 203, 187, 163, 109, 66, 19, 164, 153, 170, 82, 251, 148, 10]), + Bytes32::from([33, 89, 246, 96, 201, 15, 77, 99, 252, 111, 250, 152, 124, 80, 50, 57, 197, 124, 254, 202, 246, 131, 11, 219, 249, 102, 35, 79, 100, 173, 146, 167]), + Bytes32::from([6, 27, 205, 165, 249, 112, 70, 105, 232, 156, 155, 204, 71, 5, 21, 239, 91, 69, 248, 111, 218, 154, 187, 85, 118, 72, 210, 99, 138, 40, 233, 75]) + ]); + zero_hashes.insert(MerkleType::Module, vec![ + Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::from([252, 178, 61, 5, 174, 66, 106, 30, 131, 163, 114, 90, 231, 83, 228, 153, 108, 255, 60, 37, 254, 139, 153, 129, 208, 156, 109, 74, 233, 129, 174, 182]), + Bytes32::from([128, 23, 154, 62, 181, 220, 154, 183, 222, 214, 79, 76, 162, 169, 179, 162, 185, 93, 179, 115, 161, 55, 19, 63, 227, 168, 140, 66, 182, 6, 60, 120]), + Bytes32::from([243, 119, 126, 55, 151, 128, 119, 12, 124, 84, 146, 243, 156, 68, 82, 174, 201, 162, 29, 73, 29, 77, 103, 205, 194, 250, 45, 133, 39, 71, 224, 177]), + Bytes32::from([209, 179, 222, 187, 184, 84, 131, 182, 172, 78, 20, 104, 236, 246, 114, 74, 55, 98, 29, 34, 117, 249, 89, 76, 85, 38, 248, 193, 75, 10, 243, 100]), + Bytes32::from([195, 14, 58, 139, 148, 140, 218, 174, 131, 204, 69, 84, 127, 8, 142, 88, 136, 83, 253, 241, 74, 247, 143, 204, 38, 15, 138, 98, 47, 188, 255, 245]), + Bytes32::from([167, 4, 177, 126, 159, 76, 19, 220, 160, 159, 81, 227, 110, 147, 179, 175, 253, 187, 46, 24, 15, 168, 153, 84, 4, 167, 247, 225, 121, 175, 134, 85]), + Bytes32::from([237, 144, 152, 155, 211, 100, 202, 187, 41, 181, 45, 224, 143, 139, 18, 77, 110, 34, 212, 207, 239, 180, 73, 84, 166, 194, 22, 149, 89, 215, 86, 21]), + Bytes32::from([226, 192, 91, 176, 242, 185, 212, 189, 178, 80, 238, 252, 183, 82, 220, 242, 22, 237, 84, 142, 132, 91, 95, 219, 252, 171, 51, 76, 28, 146, 86, 155]), + Bytes32::from([199, 200, 237, 66, 220, 14, 221, 121, 117, 150, 118, 36, 138, 142, 50, 173, 12, 195, 131, 90, 27, 189, 247, 221, 89, 151, 41, 27, 135, 207, 137, 172]), + Bytes32::from([160, 60, 124, 200, 56, 240, 67, 161, 121, 95, 247, 51, 153, 249, 125, 88, 231, 2, 85, 167, 251, 187, 21, 103, 49, 132, 213, 52, 219, 30, 146, 59]), + Bytes32::from([123, 52, 142, 254, 117, 160, 215, 99, 155, 130, 134, 183, 76, 99, 166, 246, 49, 51, 142, 67, 116, 234, 69, 199, 201, 19, 70, 3, 208, 247, 40, 82]), + Bytes32::from([165, 32, 183, 79, 246, 224, 220, 103, 11, 160, 233, 66, 129, 238, 194, 73, 17, 37, 128, 185, 175, 88, 144, 228, 231, 185, 22, 17, 149, 174, 72, 1]), + Bytes32::from([12, 24, 45, 128, 57, 246, 187, 176, 154, 247, 169, 18, 116, 176, 70, 246, 203, 141, 211, 104, 5, 147, 78, 214, 161, 71, 33, 97, 7, 21, 158, 61]), + Bytes32::from([215, 18, 110, 29, 36, 34, 133, 219, 15, 204, 206, 158, 186, 213, 181, 41, 184, 160, 71, 165, 163, 121, 88, 106, 228, 58, 34, 105, 112, 168, 84, 123]), + Bytes32::from([6, 169, 156, 220, 55, 53, 26, 229, 104, 60, 113, 111, 153, 18, 251, 234, 179, 159, 56, 14, 112, 7, 144, 199, 45, 180, 116, 239, 21, 207, 173, 205]), + Bytes32::from([24, 172, 76, 192, 21, 91, 250, 75, 196, 119, 231, 221, 13, 239, 113, 39, 62, 40, 165, 26, 245, 16, 61, 106, 39, 28, 78, 212, 249, 230, 84, 108]), + Bytes32::from([248, 34, 1, 62, 213, 235, 20, 21, 220, 78, 178, 126, 184, 102, 242, 50, 49, 174, 163, 122, 166, 96, 40, 110, 78, 199, 89, 158, 155, 251, 233, 49]), + Bytes32::from([103, 54, 133, 19, 189, 117, 46, 209, 17, 2, 64, 251, 77, 195, 197, 91, 38, 48, 214, 36, 96, 255, 133, 87, 244, 101, 166, 218, 167, 129, 225, 167]), + Bytes32::from([196, 159, 226, 85, 100, 246, 179, 251, 133, 33, 114, 51, 104, 245, 81, 54, 137, 126, 245, 76, 112, 146, 139, 185, 190, 19, 106, 132, 48, 203, 34, 237]), + Bytes32::from([41, 190, 7, 23, 227, 80, 13, 134, 244, 18, 215, 148, 1, 72, 1, 22, 91, 165, 182, 69, 160, 179, 241, 106, 254, 116, 245, 131, 136, 35, 190, 226]), + Bytes32::from([205, 132, 211, 121, 67, 210, 191, 102, 218, 92, 56, 204, 68, 160, 188, 100, 229, 80, 77, 27, 26, 86, 248, 86, 216, 39, 242, 211, 183, 139, 219, 83]), + Bytes32::from([13, 215, 68, 100, 180, 74, 23, 58, 157, 140, 76, 31, 114, 254, 85, 78, 234, 40, 251, 199, 35, 204, 111, 243, 163, 64, 221, 21, 96, 55, 127, 118]), + Bytes32::from([225, 14, 246, 105, 64, 96, 225, 200, 186, 66, 40, 253, 131, 80, 102, 178, 83, 22, 150, 32, 15, 139, 76, 172, 144, 3, 30, 43, 217, 213, 89, 43]), + Bytes32::from([200, 83, 93, 27, 98, 246, 87, 100, 53, 166, 89, 138, 157, 88, 148, 245, 61, 115, 246, 20, 142, 156, 54, 237, 179, 64, 148, 218, 67, 5, 142, 248]), + Bytes32::from([159, 25, 150, 25, 114, 252, 162, 57, 21, 125, 147, 111, 220, 117, 17, 107, 40, 21, 157, 183, 6, 63, 226, 37, 64, 179, 133, 58, 107, 245, 78, 14]), + Bytes32::from([58, 243, 16, 193, 174, 42, 255, 46, 40, 128, 26, 167, 173, 164, 71, 226, 155, 205, 26, 127, 154, 24, 74, 244, 106, 251, 25, 221, 197, 176, 194, 17]), + Bytes32::from([51, 47, 251, 206, 27, 9, 142, 27, 253, 132, 189, 62, 109, 150, 246, 2, 137, 90, 157, 185, 59, 96, 0, 154, 29, 17, 231, 3, 84, 95, 49, 51]), + Bytes32::from([250, 158, 158, 248, 206, 150, 95, 254, 53, 140, 80, 102, 67, 26, 76, 127, 236, 86, 182, 120, 72, 239, 190, 118, 60, 77, 28, 82, 152, 234, 73, 201]), + Bytes32::from([255, 137, 155, 144, 74, 231, 231, 43, 187, 202, 137, 66, 205, 37, 40, 225, 0, 33, 87, 137, 113, 163, 58, 64, 147, 74, 123, 128, 19, 156, 46, 83]), + Bytes32::from([207, 61, 79, 4, 202, 96, 238, 144, 154, 230, 145, 65, 230, 130, 246, 10, 140, 71, 66, 246, 53, 230, 148, 1, 248, 103, 145, 149, 157, 38, 169, 8]), + Bytes32::from([33, 168, 110, 82, 84, 151, 70, 98, 115, 2, 221, 116, 210, 10, 247, 189, 203, 245, 186, 86, 121, 142, 218, 95, 68, 241, 21, 219, 131, 241, 185, 203]), + Bytes32::from([125, 247, 7, 149, 181, 71, 68, 141, 123, 207, 144, 83, 170, 27, 244, 37, 210, 148, 0, 140, 144, 159, 237, 216, 227, 247, 85, 229, 80, 174, 40, 48]), + Bytes32::from([0, 205, 68, 89, 77, 97, 204, 140, 113, 244, 168, 76, 49, 137, 236, 21, 132, 99, 10, 206, 195, 206, 208, 120, 227, 77, 21, 223, 145, 227, 48, 139]), + Bytes32::from([10, 153, 106, 155, 149, 65, 211, 247, 246, 5, 129, 126, 74, 14, 113, 168, 152, 154, 205, 139, 49, 2, 182, 65, 163, 15, 62, 126, 62, 16, 26, 36]), + Bytes32::from([24, 251, 204, 187, 179, 146, 114, 66, 110, 182, 131, 248, 36, 170, 169, 128, 22, 221, 134, 193, 121, 189, 128, 94, 83, 255, 226, 37, 133, 83, 220, 181]), + Bytes32::from([25, 52, 245, 155, 53, 39, 73, 130, 12, 73, 106, 255, 44, 204, 208, 41, 32, 126, 159, 98, 197, 67, 58, 90, 6, 146, 25, 166, 195, 194, 215, 70]), + Bytes32::from([194, 167, 206, 222, 96, 6, 86, 241, 95, 105, 225, 147, 99, 93, 201, 220, 166, 145, 4, 25, 168, 188, 21, 168, 80, 163, 132, 216, 239, 19, 115, 36]), + Bytes32::from([243, 16, 4, 9, 140, 42, 62, 105, 97, 7, 4, 234, 200, 227, 42, 10, 51, 167, 38, 148, 69, 154, 143, 179, 94, 177, 248, 28, 33, 61, 166, 187]), + Bytes32::from([156, 201, 97, 197, 223, 83, 229, 186, 187, 33, 49, 210, 181, 222, 180, 234, 150, 33, 99, 168, 157, 26, 241, 1, 213, 220, 165, 8, 31, 76, 134, 243]), + Bytes32::from([34, 218, 29, 74, 212, 218, 95, 6, 53, 10, 63, 174, 119, 90, 90, 35, 92, 124, 169, 222, 75, 61, 199, 118, 132, 40, 193, 9, 250, 80, 12, 197]), + Bytes32::from([102, 137, 75, 155, 181, 222, 86, 192, 140, 167, 3, 178, 212, 165, 49, 163, 86, 8, 76, 240, 32, 202, 34, 159, 217, 173, 101, 125, 237, 34, 48, 179]), + Bytes32::from([136, 53, 156, 19, 107, 234, 210, 218, 180, 236, 9, 7, 80, 63, 146, 57, 77, 106, 135, 64, 23, 184, 9, 139, 61, 237, 225, 157, 183, 182, 137, 31]), + Bytes32::from([237, 226, 115, 218, 228, 122, 45, 46, 67, 21, 130, 204, 80, 2, 28, 47, 148, 191, 28, 33, 177, 47, 207, 14, 33, 117, 28, 46, 88, 254, 97, 227]), + Bytes32::from([38, 87, 252, 28, 105, 20, 117, 29, 234, 237, 60, 91, 48, 101, 219, 219, 24, 52, 169, 243, 71, 214, 117, 41, 207, 17, 148, 77, 218, 44, 122, 167]), + Bytes32::from([235, 31, 185, 222, 3, 22, 222, 174, 126, 128, 55, 67, 201, 229, 55, 28, 241, 144, 184, 85, 141, 153, 183, 211, 66, 80, 152, 248, 214, 130, 64, 205]), + Bytes32::from([52, 169, 226, 179, 195, 44, 245, 101, 35, 92, 145, 174, 152, 212, 192, 148, 241, 72, 248, 61, 239, 124, 98, 213, 181, 75, 84, 121, 57, 90, 172, 164]), + Bytes32::from([27, 19, 12, 74, 128, 193, 65, 63, 15, 6, 174, 167, 79, 56, 88, 13, 117, 6, 189, 14, 11, 13, 133, 136, 141, 64, 74, 17, 159, 192, 251, 242]), + Bytes32::from([101, 69, 132, 221, 127, 162, 162, 92, 248, 131, 39, 52, 169, 170, 231, 137, 123, 106, 161, 16, 202, 242, 216, 245, 211, 170, 74, 128, 108, 243, 166, 38]), + Bytes32::from([157, 82, 193, 234, 117, 199, 118, 245, 63, 31, 186, 32, 135, 233, 29, 213, 217, 119, 208, 64, 149, 116, 117, 129, 211, 225, 207, 22, 225, 99, 194, 222]), + Bytes32::from([112, 194, 64, 229, 154, 223, 109, 8, 191, 120, 32, 176, 154, 7, 174, 103, 2, 156, 230, 164, 245, 252, 0, 116, 213, 40, 20, 239, 135, 62, 198, 42]), + Bytes32::from([32, 91, 5, 170, 221, 134, 167, 144, 16, 130, 237, 114, 71, 184, 131, 223, 92, 149, 161, 68, 196, 56, 73, 148, 203, 187, 174, 178, 178, 53, 156, 177]), + Bytes32::from([234, 97, 64, 211, 81, 59, 14, 249, 38, 8, 247, 37, 243, 37, 88, 234, 19, 54, 146, 63, 88, 79, 127, 190, 144, 51, 240, 19, 15, 143, 18, 9]), + Bytes32::from([247, 102, 43, 28, 24, 201, 189, 198, 66, 58, 210, 51, 174, 234, 52, 239, 37, 83, 212, 184, 127, 170, 168, 127, 47, 11, 248, 213, 84, 3, 201, 181]), + Bytes32::from([126, 18, 116, 33, 129, 25, 247, 2, 162, 202, 103, 201, 237, 67, 28, 80, 46, 182, 163, 239, 90, 204, 47, 196, 137, 79, 19, 165, 209, 84, 140, 132]), + Bytes32::from([189, 160, 148, 101, 82, 248, 215, 206, 90, 91, 205, 148, 37, 38, 172, 82, 223, 228, 66, 173, 220, 246, 194, 73, 231, 17, 220, 47, 222, 175, 7, 24]), + Bytes32::from([237, 149, 54, 210, 99, 72, 182, 55, 69, 140, 161, 215, 104, 90, 104, 26, 216, 241, 232, 210, 37, 77, 56, 216, 6, 160, 199, 247, 164, 227, 142, 255]), + Bytes32::from([11, 57, 131, 77, 203, 89, 156, 126, 200, 215, 103, 209, 70, 235, 78, 247, 0, 126, 209, 248, 220, 135, 158, 244, 141, 74, 6, 158, 19, 37, 42, 39]), + Bytes32::from([107, 131, 231, 102, 64, 182, 78, 253, 77, 143, 94, 34, 199, 93, 44, 131, 169, 211, 71, 223, 53, 230, 59, 107, 146, 22, 188, 207, 210, 220, 168, 129]), + Bytes32::from([78, 71, 246, 216, 154, 188, 152, 6, 234, 254, 21, 1, 128, 148, 56, 91, 250, 95, 76, 103, 15, 250, 137, 186, 114, 254, 122, 69, 208, 242, 69, 111]), + Bytes32::from([82, 241, 242, 155, 248, 109, 84, 118, 225, 255, 122, 40, 3, 87, 20, 223, 212, 205, 141, 178, 32, 229, 234, 146, 101, 73, 79, 55, 28, 82, 81, 178]), + Bytes32::from([35, 169, 243, 198, 215, 220, 113, 91, 6, 79, 48, 201, 97, 143, 212, 34, 247, 46, 38, 93, 166, 213, 158, 218, 61, 86, 240, 149, 224, 174, 225, 73]), + Bytes32::from([25, 108, 21, 212, 193, 192, 96, 39, 57, 72, 193, 99, 239, 0, 231, 83, 183, 195, 105, 33, 220, 187, 18, 148, 43, 30, 42, 127, 192, 240, 13, 224]), + Bytes32::from([119, 117, 186, 31, 43, 128, 143, 25, 182, 135, 156, 58, 152, 81, 70, 116, 171, 137, 125, 157, 152, 163, 34, 65, 240, 178, 12, 24, 168, 111, 39, 35]) + ]); + zero_hashes + }; +} \ No newline at end of file From 5e14a2bfdb4aa37c5844d323bb978e410503c5d0 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 26 Apr 2024 11:13:09 +0200 Subject: [PATCH 024/268] Add a benchmark for new_advanced. This part of the code is obviously slow. Let's see if we can improve it. --- arbitrator/prover/benches/merkle_bench.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/arbitrator/prover/benches/merkle_bench.rs b/arbitrator/prover/benches/merkle_bench.rs index 922f6cb177..20b566e077 100644 --- a/arbitrator/prover/benches/merkle_bench.rs +++ b/arbitrator/prover/benches/merkle_bench.rs @@ -41,5 +41,20 @@ fn merkle_benchmark(c: &mut Criterion) { }); } -criterion_group!(benches, merkle_benchmark); +fn merkle_construction(c: &mut Criterion) { + let mut rng = rand::thread_rng(); + let mut leaves: Vec = Vec::with_capacity(1 >> 20); + for _ in 0..(1 >> 20) { + leaves.push(Bytes32::from([rng.gen_range(0u8..9); 32])); + } + + c.bench_function("merkle_construction", |b| { + b.iter(|| { + let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 21); + merkle.root(); + }) + }); +} + +criterion_group!(benches, merkle_benchmark, merkle_construction); criterion_main!(benches); \ No newline at end of file From c949b545cc02b9696cc27e0d0b5f55b2903581a7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 26 Apr 2024 23:21:15 +0200 Subject: [PATCH 025/268] Add constant arrays of empty hashes for each Merkle type. This allows the most efficient lookup possible for empty layer hashes. --- arbitrator/arbutil/src/types.rs | 6 + arbitrator/prover/src/merkle.rs | 27 +- arbitrator/prover/src/merkle/zerohashes.rs | 949 +++++++++++---------- 3 files changed, 503 insertions(+), 479 deletions(-) diff --git a/arbitrator/arbutil/src/types.rs b/arbitrator/arbutil/src/types.rs index 6cf1d6cdf7..532484cb5d 100644 --- a/arbitrator/arbutil/src/types.rs +++ b/arbitrator/arbutil/src/types.rs @@ -27,6 +27,12 @@ pub enum PreimageType { #[repr(C)] pub struct Bytes32(pub [u8; 32]); +impl Bytes32 { + pub const fn new(x: [u8; 32]) -> Self { + Self(x) + } +} + impl Deref for Bytes32 { type Target = [u8; 32]; diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 95fa139186..b1a3a6c03b 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -175,6 +175,19 @@ fn capacity(layers: &Vec>) -> usize { base.pow((layers.len() - 1).try_into().unwrap()) } +const fn empty_hash_at(ty: MerkleType, layer_i: usize) -> Bytes32 { + match ty { + MerkleType::Empty => Bytes32::new([0u8; 32]), + MerkleType::Value => ZERO_HASHES[0][layer_i], + MerkleType::Function => ZERO_HASHES[1][layer_i], + MerkleType::Instruction => ZERO_HASHES[2][layer_i], + MerkleType::Memory => ZERO_HASHES[3][layer_i], + MerkleType::Table => ZERO_HASHES[4][layer_i], + MerkleType::TableElement => ZERO_HASHES[5][layer_i], + MerkleType::Module => ZERO_HASHES[6][layer_i], + } +} + impl Merkle { /// Creates a new Merkle tree with the given type and leaf hashes. /// The tree is built up to the minimum depth necessary to hold all the @@ -188,7 +201,7 @@ impl Merkle { pub fn new_advanced( ty: MerkleType, hashes: Vec, - empty_hash: Bytes32, + _empty_hash: Bytes32, min_depth: usize, ) -> Merkle { #[cfg(feature = "counters")] @@ -204,7 +217,7 @@ impl Merkle { let mut layer_i = 0usize; while layers.last().unwrap().len() > 1 || layers.len() < min_depth { let layer = layers.last().unwrap(); - let empty_hash = ZERO_HASHES[&ty][layer_i]; + let empty_hash = empty_hash_at(ty, layer_i); #[cfg(feature = "rayon")] let chunks = layer.par_chunks(2); @@ -245,7 +258,7 @@ impl Merkle { let right = layers[layer_i-1] .get(right_child_idx) .cloned() - .unwrap_or_else(|| ZERO_HASHES[&self.ty][layer_i - 1]); + .unwrap_or_else(|| empty_hash_at(self.ty, layer_i - 1)); let new_hash = hash_node(self.ty, left, right); if *idx < layers[layer_i].len() { layers[layer_i][*idx] = new_hash; @@ -306,7 +319,7 @@ impl Merkle { layer .get(counterpart) .cloned() - .unwrap_or_else(|| ZERO_HASHES[&self.ty][layer_i]), + .unwrap_or_else(|| empty_hash_at(self.ty, layer_i)), ); idx >>= 1; } @@ -318,7 +331,7 @@ impl Merkle { pub fn push_leaf(&mut self, leaf: Bytes32) { let mut leaves = self.layers.lock().unwrap().swap_remove(0); leaves.push(leaf); - let empty = ZERO_HASHES[&self.ty][0]; + let empty = empty_hash_at(self.ty, 0); *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); } @@ -327,7 +340,7 @@ impl Merkle { pub fn pop_leaf(&mut self) { let mut leaves = self.layers.lock().unwrap().swap_remove(0); leaves.pop(); - let empty = ZERO_HASHES[&self.ty][0]; + let empty = empty_hash_at(self.ty,0); *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); } @@ -359,7 +372,7 @@ impl Merkle { return Err("Cannot extend with more leaves than the capicity of the tree.".to_owned()); } let mut idx = layers[0].len(); - layers[0].resize(idx + hashes.len(), ZERO_HASHES[&self.ty][0]); + layers[0].resize(idx + hashes.len(), empty_hash_at(self.ty, 0)); for hash in hashes { self.locked_set(&mut layers, idx, hash); idx += 1; diff --git a/arbitrator/prover/src/merkle/zerohashes.rs b/arbitrator/prover/src/merkle/zerohashes.rs index 97d5c59c10..5b72e010fe 100644 --- a/arbitrator/prover/src/merkle/zerohashes.rs +++ b/arbitrator/prover/src/merkle/zerohashes.rs @@ -1,475 +1,480 @@ -use std::collections::HashMap; - use arbutil::Bytes32; -use lazy_static::lazy_static; -use crate::merkle::MerkleType; +const VALUE_HASHES: &[Bytes32; 64] = &[ + Bytes32::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::new([119, 47, 167, 222, 218, 156, 26, 105, 57, 248, 170, 182, 183, 151, 18, 150, 142, 70, 138, 253, 54, 123, 132, 86, 170, 76, 157, 52, 113, 138, 253, 254]), + Bytes32::new([8, 117, 27, 211, 196, 42, 6, 98, 185, 88, 231, 145, 14, 3, 207, 145, 158, 255, 69, 52, 198, 196, 148, 154, 59, 94, 229, 157, 93, 51, 200, 69]), + Bytes32::new([247, 208, 196, 206, 204, 168, 129, 100, 238, 95, 52, 26, 132, 138, 233, 149, 196, 72, 179, 226, 60, 114, 27, 94, 173, 189, 197, 100, 163, 232, 180, 63]), + Bytes32::new([178, 100, 198, 112, 40, 33, 187, 175, 130, 245, 59, 210, 133, 234, 158, 158, 133, 64, 213, 72, 222, 157, 216, 42, 210, 134, 36, 13, 211, 156, 163, 211]), + Bytes32::new([203, 127, 32, 130, 225, 40, 219, 15, 35, 236, 47, 201, 161, 48, 53, 145, 134, 169, 109, 29, 26, 29, 178, 201, 118, 217, 57, 165, 116, 172, 232, 4]), + Bytes32::new([209, 109, 33, 102, 227, 251, 133, 224, 170, 130, 65, 90, 185, 209, 146, 77, 244, 145, 181, 206, 159, 70, 209, 64, 241, 19, 149, 223, 138, 31, 163, 61]), + Bytes32::new([145, 168, 124, 48, 254, 12, 34, 41, 4, 213, 245, 86, 61, 29, 177, 192, 67, 165, 237, 236, 87, 126, 193, 191, 15, 126, 104, 173, 165, 186, 1, 107]), + Bytes32::new([235, 161, 247, 143, 69, 95, 210, 40, 243, 76, 102, 29, 118, 86, 180, 54, 81, 144, 103, 54, 202, 164, 81, 83, 180, 90, 154, 184, 54, 28, 7, 220]), + Bytes32::new([203, 62, 12, 83, 35, 122, 214, 199, 125, 61, 236, 8, 253, 64, 145, 34, 127, 116, 217, 118, 245, 107, 15, 81, 9, 7, 31, 154, 89, 28, 123, 132]), + Bytes32::new([222, 94, 234, 109, 142, 74, 142, 176, 248, 3, 172, 30, 204, 138, 241, 195, 121, 232, 104, 219, 32, 54, 240, 77, 125, 247, 70, 137, 80, 46, 221, 247]), + Bytes32::new([162, 122, 237, 101, 178, 31, 12, 62, 50, 133, 242, 82, 111, 215, 166, 136, 138, 185, 72, 220, 163, 58, 58, 97, 6, 97, 167, 114, 179, 227, 19, 170]), + Bytes32::new([67, 251, 144, 11, 175, 194, 149, 65, 173, 179, 69, 140, 213, 191, 133, 59, 81, 175, 161, 115, 252, 125, 232, 150, 52, 241, 102, 164, 122, 32, 70, 229]), + Bytes32::new([249, 161, 115, 93, 215, 247, 145, 182, 75, 191, 48, 38, 123, 220, 232, 47, 246, 46, 81, 164, 98, 41, 141, 249, 137, 173, 93, 213, 96, 15, 151, 245]), + Bytes32::new([222, 93, 144, 194, 107, 42, 144, 4, 242, 153, 203, 176, 146, 242, 94, 72, 9, 222, 194, 2, 73, 200, 167, 147, 106, 9, 67, 73, 59, 127, 174, 178]), + Bytes32::new([56, 228, 248, 59, 153, 215, 120, 224, 111, 48, 159, 82, 171, 227, 93, 214, 208, 151, 78, 67, 112, 31, 218, 94, 219, 3, 79, 250, 227, 24, 222, 207]), + Bytes32::new([26, 171, 68, 22, 162, 195, 65, 97, 219, 55, 51, 46, 178, 6, 247, 65, 123, 219, 128, 86, 193, 3, 253, 0, 239, 228, 187, 94, 184, 240, 67, 11]), + Bytes32::new([250, 36, 5, 131, 94, 0, 99, 187, 112, 155, 252, 52, 68, 236, 185, 152, 93, 239, 0, 185, 101, 101, 182, 92, 112, 5, 67, 55, 121, 203, 100, 245]), + Bytes32::new([208, 57, 149, 71, 227, 213, 246, 213, 175, 88, 95, 238, 93, 122, 168, 223, 149, 84, 30, 89, 98, 228, 113, 72, 90, 48, 112, 171, 231, 67, 113, 216]), + Bytes32::new([125, 48, 157, 119, 154, 38, 14, 211, 223, 68, 87, 187, 159, 126, 234, 72, 84, 60, 236, 237, 227, 130, 87, 43, 217, 105, 81, 196, 159, 238, 240, 10]), + Bytes32::new([141, 217, 59, 213, 245, 231, 7, 85, 178, 197, 115, 188, 31, 49, 126, 237, 83, 199, 56, 196, 133, 169, 239, 218, 90, 131, 178, 70, 126, 132, 114, 186]), + Bytes32::new([18, 2, 140, 12, 121, 238, 8, 160, 7, 208, 89, 194, 105, 136, 211, 58, 179, 200, 226, 138, 186, 242, 4, 237, 18, 113, 131, 135, 31, 222, 28, 195]), + Bytes32::new([156, 222, 183, 39, 119, 110, 130, 60, 33, 221, 36, 39, 223, 155, 33, 2, 71, 32, 209, 25, 194, 172, 209, 1, 40, 105, 235, 140, 160, 18, 63, 168]), + Bytes32::new([211, 210, 123, 27, 217, 111, 97, 42, 167, 191, 112, 239, 66, 42, 199, 131, 124, 213, 89, 56, 92, 245, 166, 238, 185, 42, 48, 2, 113, 255, 156, 7]), + Bytes32::new([66, 255, 87, 69, 86, 6, 54, 162, 162, 5, 93, 138, 194, 194, 151, 195, 57, 155, 58, 17, 21, 149, 77, 2, 134, 107, 125, 54, 220, 247, 160, 209]), + Bytes32::new([169, 216, 13, 41, 251, 216, 191, 87, 91, 55, 236, 6, 242, 103, 98, 209, 46, 202, 29, 55, 2, 50, 233, 76, 107, 92, 82, 156, 113, 226, 78, 211]), + Bytes32::new([88, 189, 113, 129, 119, 11, 141, 60, 128, 134, 113, 107, 7, 186, 81, 200, 14, 76, 197, 14, 96, 19, 247, 220, 95, 62, 81, 153, 61, 231, 26, 86]), + Bytes32::new([41, 214, 41, 96, 151, 11, 231, 7, 203, 70, 242, 156, 247, 133, 49, 223, 254, 164, 202, 154, 188, 104, 124, 120, 225, 229, 148, 203, 141, 218, 228, 56]), + Bytes32::new([181, 157, 136, 110, 158, 152, 105, 61, 125, 220, 32, 180, 53, 115, 155, 189, 91, 152, 96, 172, 7, 121, 65, 143, 82, 180, 3, 69, 118, 219, 31, 244]), + Bytes32::new([29, 12, 159, 30, 12, 37, 126, 102, 218, 149, 67, 116, 182, 125, 134, 208, 184, 199, 181, 191, 87, 144, 48, 150, 87, 67, 222, 218, 254, 118, 12, 160]), + Bytes32::new([193, 249, 209, 245, 102, 95, 15, 55, 160, 156, 203, 160, 49, 198, 203, 30, 99, 172, 89, 92, 235, 89, 131, 205, 53, 254, 219, 168, 202, 195, 10, 242]), + Bytes32::new([131, 64, 102, 7, 226, 96, 60, 111, 221, 120, 41, 86, 239, 157, 121, 38, 57, 244, 221, 55, 32, 237, 13, 20, 244, 238, 133, 189, 89, 118, 204, 247]), + Bytes32::new([239, 211, 89, 185, 191, 211, 243, 207, 134, 159, 59, 19, 87, 254, 115, 27, 152, 156, 120, 226, 39, 63, 155, 51, 77, 130, 162, 63, 16, 43, 112, 121]), + Bytes32::new([10, 146, 190, 23, 235, 67, 23, 169, 33, 140, 54, 209, 129, 176, 29, 218, 40, 55, 13, 80, 57, 68, 92, 97, 44, 82, 209, 240, 207, 214, 22, 119]), + Bytes32::new([59, 161, 125, 95, 7, 155, 141, 55, 253, 106, 238, 72, 109, 158, 201, 200, 236, 157, 227, 178, 176, 47, 166, 84, 87, 111, 25, 133, 194, 55, 244, 254]), + Bytes32::new([8, 134, 213, 182, 108, 15, 225, 138, 152, 138, 132, 240, 27, 80, 231, 117, 194, 157, 205, 20, 110, 239, 166, 37, 50, 46, 213, 165, 216, 101, 245, 98]), + Bytes32::new([137, 57, 186, 173, 198, 113, 221, 42, 0, 211, 127, 200, 128, 7, 112, 97, 75, 155, 152, 224, 71, 220, 16, 124, 32, 50, 30, 48, 251, 132, 120, 147]), + Bytes32::new([201, 8, 226, 108, 147, 192, 3, 240, 168, 237, 131, 47, 150, 51, 251, 126, 23, 182, 223, 99, 162, 167, 248, 248, 233, 8, 121, 99, 71, 212, 120, 251]), + Bytes32::new([140, 30, 196, 244, 166, 80, 95, 116, 140, 218, 94, 20, 236, 233, 241, 129, 175, 187, 110, 88, 174, 173, 152, 203, 67, 75, 51, 232, 225, 6, 17, 134]), + Bytes32::new([92, 132, 115, 164, 66, 159, 201, 147, 233, 228, 16, 95, 81, 233, 129, 254, 155, 148, 38, 239, 186, 40, 118, 104, 144, 134, 17, 46, 99, 150, 211, 9]), + Bytes32::new([81, 73, 72, 117, 215, 159, 240, 86, 136, 196, 69, 201, 149, 208, 48, 245, 105, 153, 97, 107, 221, 85, 49, 121, 197, 129, 32, 140, 206, 231, 120, 123]), + Bytes32::new([0, 203, 34, 135, 242, 129, 113, 204, 198, 134, 219, 134, 187, 240, 235, 59, 44, 163, 180, 83, 174, 40, 66, 141, 95, 99, 71, 221, 186, 216, 37, 250]), + Bytes32::new([225, 181, 151, 12, 26, 209, 127, 99, 248, 177, 126, 113, 215, 220, 252, 89, 149, 123, 19, 65, 89, 122, 180, 169, 195, 87, 147, 9, 196, 31, 203, 178]), + Bytes32::new([125, 81, 154, 100, 204, 138, 194, 248, 156, 95, 119, 58, 60, 221, 150, 248, 216, 19, 123, 15, 198, 108, 228, 228, 224, 122, 16, 249, 223, 84, 117, 89]), + Bytes32::new([99, 153, 60, 217, 168, 254, 244, 149, 214, 115, 250, 90, 117, 112, 66, 163, 143, 207, 121, 70, 108, 92, 2, 47, 56, 109, 56, 207, 152, 27, 196, 141]), + Bytes32::new([99, 251, 124, 97, 158, 155, 101, 251, 98, 124, 239, 73, 50, 50, 173, 142, 39, 208, 167, 53, 5, 151, 85, 239, 25, 77, 36, 52, 141, 225, 66, 186]), + Bytes32::new([235, 44, 31, 180, 197, 243, 114, 60, 199, 242, 167, 21, 206, 27, 116, 165, 18, 76, 162, 163, 14, 91, 109, 104, 118, 51, 33, 172, 9, 165, 214, 38]), + Bytes32::new([188, 4, 5, 50, 169, 70, 231, 90, 220, 90, 226, 214, 89, 19, 159, 207, 201, 80, 241, 214, 32, 240, 63, 74, 6, 251, 177, 182, 236, 19, 156, 92]), + Bytes32::new([128, 150, 66, 27, 197, 229, 103, 137, 175, 252, 19, 131, 213, 63, 112, 172, 182, 255, 235, 246, 226, 37, 25, 180, 24, 38, 35, 138, 207, 149, 186, 175]), + Bytes32::new([5, 123, 231, 106, 12, 171, 157, 189, 58, 109, 144, 7, 38, 97, 4, 148, 1, 138, 124, 123, 2, 202, 108, 221, 194, 160, 53, 73, 115, 36, 231, 142]), + Bytes32::new([160, 157, 243, 224, 214, 120, 59, 206, 24, 30, 231, 209, 123, 227, 15, 221, 86, 30, 128, 117, 210, 109, 132, 117, 204, 87, 243, 213, 231, 224, 91, 75]), + Bytes32::new([74, 238, 110, 147, 63, 110, 246, 102, 252, 212, 120, 225, 124, 218, 145, 204, 129, 63, 13, 34, 1, 0, 15, 9, 27, 221, 39, 199, 24, 231, 9, 38]), + Bytes32::new([194, 20, 160, 161, 90, 2, 118, 75, 103, 228, 51, 42, 191, 220, 63, 150, 140, 32, 85, 172, 218, 29, 251, 31, 99, 96, 98, 46, 130, 157, 201, 61]), + Bytes32::new([88, 123, 95, 139, 94, 66, 69, 27, 223, 223, 216, 130, 99, 210, 130, 54, 248, 35, 226, 252, 151, 238, 7, 175, 12, 97, 188, 43, 233, 129, 82, 222]), + Bytes32::new([179, 248, 157, 243, 50, 157, 172, 17, 139, 10, 245, 208, 241, 210, 67, 199, 135, 233, 234, 39, 127, 38, 54, 39, 40, 159, 94, 122, 36, 221, 180, 195]), + Bytes32::new([190, 185, 147, 237, 82, 32, 165, 236, 252, 183, 173, 181, 68, 44, 216, 20, 110, 243, 158, 213, 88, 209, 218, 207, 244, 241, 121, 239, 136, 167, 245, 155]), + Bytes32::new([114, 131, 254, 248, 183, 0, 175, 217, 194, 58, 178, 238, 250, 119, 158, 205, 19, 74, 94, 35, 100, 175, 114, 55, 186, 192, 239, 126, 42, 86, 60, 119]), + Bytes32::new([1, 253, 107, 150, 25, 240, 27, 172, 252, 185, 151, 152, 107, 105, 164, 230, 221, 242, 7, 166, 142, 53, 237, 83, 19, 30, 81, 149, 150, 39, 123, 220]), + Bytes32::new([57, 240, 92, 232, 26, 238, 69, 252, 110, 171, 164, 109, 199, 73, 110, 49, 11, 253, 109, 69, 155, 26, 84, 52, 155, 204, 115, 99, 90, 38, 247, 167]), + Bytes32::new([46, 87, 146, 25, 215, 40, 208, 78, 73, 60, 35, 19, 194, 41, 34, 186, 215, 131, 205, 29, 107, 100, 95, 169, 45, 1, 242, 115, 30, 226, 93, 48]), + Bytes32::new([95, 183, 66, 0, 196, 173, 44, 27, 175, 151, 17, 0, 159, 168, 123, 236, 124, 198, 85, 181, 118, 89, 21, 52, 169, 104, 178, 111, 120, 173, 94, 109]), + Bytes32::new([13, 111, 162, 25, 133, 108, 250, 75, 197, 221, 19, 160, 147, 36, 130, 70, 224, 39, 134, 144, 149, 166, 187, 96, 155, 154, 123, 90, 241, 154, 44, 102]), + Bytes32::new([95, 171, 183, 135, 121, 205, 161, 160, 212, 226, 64, 232, 180, 166, 176, 95, 51, 96, 110, 20, 76, 143, 47, 96, 197, 132, 210, 109, 174, 132, 13, 95]), + Bytes32::new([66, 51, 176, 1, 106, 199, 192, 16, 106, 180, 212, 53, 72, 121, 218, 148, 77, 26, 15, 244, 124, 131, 88, 84, 147, 211, 254, 156, 187, 91, 193, 120]), +]; + +const FUNCTION_HASHES: &[Bytes32; 64] = &[ + Bytes32::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::new([239, 247, 49, 255, 201, 159, 228, 149, 22, 115, 41, 139, 56, 117, 149, 46, 67, 155, 98, 70, 216, 225, 85, 100, 113, 242, 144, 167, 97, 238, 117, 207]), + Bytes32::new([46, 87, 136, 101, 122, 12, 6, 120, 39, 121, 167, 193, 66, 146, 150, 1, 90, 240, 97, 225, 179, 150, 197, 127, 56, 214, 116, 24, 180, 109, 96, 51]), + Bytes32::new([54, 125, 90, 195, 243, 1, 115, 18, 251, 68, 203, 216, 48, 156, 216, 200, 215, 250, 80, 152, 203, 58, 245, 128, 70, 112, 221, 104, 34, 125, 234, 138]), + Bytes32::new([103, 99, 44, 86, 57, 0, 102, 201, 99, 214, 249, 24, 45, 112, 234, 183, 225, 196, 9, 162, 168, 33, 121, 118, 93, 184, 14, 70, 148, 135, 211, 214]), + Bytes32::new([69, 7, 89, 47, 41, 94, 148, 139, 67, 197, 99, 98, 100, 63, 25, 230, 100, 118, 213, 25, 28, 129, 5, 39, 69, 89, 71, 21, 102, 84, 101, 175]), + Bytes32::new([232, 195, 82, 123, 189, 200, 139, 61, 179, 141, 208, 69, 102, 58, 127, 66, 69, 127, 7, 179, 108, 128, 253, 154, 207, 254, 201, 18, 192, 241, 99, 208]), + Bytes32::new([138, 25, 185, 215, 159, 159, 214, 251, 161, 103, 180, 78, 209, 215, 131, 132, 134, 180, 177, 37, 79, 219, 19, 93, 45, 30, 53, 125, 142, 194, 114, 34]), + Bytes32::new([185, 24, 200, 28, 68, 7, 118, 226, 65, 240, 85, 120, 123, 174, 239, 85, 247, 210, 104, 247, 20, 229, 41, 91, 242, 5, 2, 121, 132, 69, 43, 33]), + Bytes32::new([78, 191, 92, 97, 205, 120, 114, 216, 112, 101, 44, 98, 148, 2, 112, 221, 168, 199, 254, 55, 160, 116, 116, 105, 109, 227, 130, 219, 194, 32, 209, 196]), + Bytes32::new([177, 203, 26, 1, 216, 115, 242, 158, 202, 107, 60, 221, 81, 167, 8, 233, 247, 235, 49, 54, 45, 133, 202, 193, 34, 158, 205, 29, 232, 245, 195, 194]), + Bytes32::new([193, 118, 182, 153, 10, 237, 67, 229, 136, 193, 253, 250, 46, 125, 141, 22, 107, 168, 74, 130, 60, 193, 194, 196, 249, 129, 153, 82, 162, 143, 188, 42]), + Bytes32::new([239, 57, 105, 90, 116, 61, 160, 214, 55, 191, 17, 228, 44, 149, 103, 180, 229, 4, 175, 240, 209, 231, 141, 95, 109, 195, 78, 142, 122, 177, 227, 20]), + Bytes32::new([153, 247, 105, 126, 178, 44, 190, 57, 12, 63, 169, 27, 206, 19, 151, 38, 33, 83, 35, 3, 177, 97, 36, 182, 37, 78, 150, 243, 222, 32, 180, 148]), + Bytes32::new([29, 109, 110, 167, 27, 136, 235, 226, 147, 175, 241, 236, 138, 135, 163, 200, 21, 94, 220, 238, 23, 84, 46, 14, 44, 100, 47, 131, 134, 43, 98, 173]), + Bytes32::new([73, 241, 108, 102, 184, 200, 64, 80, 58, 162, 29, 211, 173, 150, 6, 195, 2, 137, 246, 51, 155, 132, 41, 255, 21, 71, 74, 143, 197, 180, 217, 159]), + Bytes32::new([109, 189, 226, 33, 70, 157, 161, 166, 223, 31, 224, 221, 37, 112, 27, 215, 163, 250, 217, 155, 168, 121, 119, 232, 100, 177, 104, 210, 10, 118, 215, 0]), + Bytes32::new([175, 156, 32, 156, 238, 82, 62, 25, 96, 251, 146, 24, 13, 2, 115, 174, 163, 50, 14, 251, 196, 173, 5, 87, 171, 228, 191, 9, 90, 84, 156, 63]), + Bytes32::new([244, 161, 238, 217, 14, 60, 162, 139, 34, 84, 68, 121, 213, 11, 230, 95, 57, 221, 174, 107, 103, 105, 76, 137, 58, 247, 65, 209, 167, 63, 96, 212]), + Bytes32::new([31, 177, 221, 130, 152, 92, 190, 4, 59, 90, 122, 63, 128, 180, 140, 201, 75, 239, 200, 151, 94, 65, 36, 227, 21, 250, 10, 253, 26, 114, 238, 188]), + Bytes32::new([48, 216, 87, 30, 113, 214, 69, 1, 9, 112, 244, 232, 127, 55, 43, 162, 156, 83, 235, 199, 126, 132, 241, 106, 65, 209, 240, 32, 11, 179, 219, 135]), + Bytes32::new([20, 55, 225, 132, 0, 219, 175, 17, 235, 73, 236, 16, 24, 227, 250, 155, 32, 83, 234, 123, 191, 209, 157, 133, 215, 202, 3, 221, 135, 223, 221, 90]), + Bytes32::new([113, 185, 118, 164, 139, 219, 203, 140, 245, 123, 21, 186, 102, 22, 54, 14, 19, 230, 223, 120, 211, 114, 203, 77, 173, 214, 61, 80, 151, 10, 2, 205]), + Bytes32::new([50, 20, 214, 105, 232, 5, 9, 101, 16, 72, 46, 139, 177, 188, 25, 93, 14, 57, 60, 168, 49, 147, 134, 5, 62, 181, 120, 75, 193, 229, 107, 67]), + Bytes32::new([92, 167, 117, 18, 186, 193, 28, 56, 86, 25, 75, 64, 1, 8, 126, 212, 56, 163, 157, 242, 34, 73, 65, 58, 187, 2, 112, 58, 225, 229, 113, 58]), + Bytes32::new([173, 139, 156, 215, 250, 231, 15, 123, 8, 5, 98, 192, 164, 48, 106, 203, 152, 189, 118, 120, 245, 221, 214, 26, 79, 39, 148, 232, 217, 88, 34, 246]), + Bytes32::new([8, 207, 11, 196, 253, 51, 182, 90, 62, 110, 125, 142, 209, 154, 5, 203, 252, 62, 117, 215, 226, 136, 140, 201, 227, 210, 71, 34, 113, 160, 42, 68]), + Bytes32::new([108, 135, 226, 117, 179, 142, 93, 181, 20, 186, 189, 217, 49, 154, 66, 244, 180, 170, 122, 233, 153, 214, 104, 71, 44, 57, 103, 240, 97, 80, 170, 198]), + Bytes32::new([123, 168, 184, 254, 241, 78, 23, 91, 32, 77, 218, 176, 179, 189, 61, 162, 114, 158, 212, 7, 201, 15, 58, 4, 161, 211, 188, 156, 190, 2, 20, 183]), + Bytes32::new([60, 170, 86, 130, 38, 170, 202, 88, 97, 206, 67, 69, 140, 122, 201, 38, 70, 229, 144, 202, 146, 10, 146, 148, 21, 247, 119, 196, 150, 223, 110, 67]), + Bytes32::new([102, 154, 215, 132, 143, 248, 151, 101, 101, 253, 80, 211, 254, 64, 179, 73, 96, 132, 144, 216, 225, 130, 48, 56, 14, 39, 97, 223, 134, 10, 124, 138]), + Bytes32::new([197, 131, 194, 166, 168, 160, 24, 116, 47, 120, 89, 3, 44, 154, 83, 250, 142, 64, 77, 63, 15, 60, 97, 100, 150, 39, 227, 139, 42, 146, 146, 104]), + Bytes32::new([7, 160, 246, 93, 64, 79, 76, 208, 66, 80, 60, 123, 13, 51, 115, 251, 196, 209, 145, 106, 61, 105, 136, 58, 7, 129, 142, 203, 205, 69, 45, 203]), + Bytes32::new([64, 162, 48, 187, 213, 182, 41, 85, 62, 148, 26, 161, 227, 108, 173, 249, 195, 106, 203, 18, 28, 59, 184, 85, 249, 16, 224, 222, 114, 200, 99, 22]), + Bytes32::new([246, 194, 74, 122, 165, 216, 211, 144, 101, 143, 134, 9, 53, 229, 197, 227, 121, 248, 89, 169, 48, 220, 104, 216, 117, 118, 36, 234, 108, 135, 81, 162]), + Bytes32::new([232, 59, 196, 2, 103, 242, 44, 129, 41, 231, 226, 115, 238, 151, 166, 210, 158, 110, 43, 45, 86, 163, 127, 8, 162, 81, 131, 145, 165, 252, 170, 12]), + Bytes32::new([204, 88, 102, 180, 241, 148, 27, 183, 223, 71, 157, 119, 155, 31, 102, 239, 4, 83, 204, 246, 38, 228, 234, 20, 97, 233, 203, 149, 186, 67, 143, 51]), + Bytes32::new([246, 170, 233, 8, 202, 38, 67, 219, 175, 13, 250, 174, 98, 36, 84, 166, 6, 75, 27, 43, 62, 128, 106, 23, 163, 191, 86, 115, 164, 50, 127, 151]), + Bytes32::new([204, 72, 199, 57, 106, 136, 244, 66, 217, 155, 183, 211, 166, 71, 140, 211, 210, 181, 178, 218, 204, 91, 200, 204, 153, 60, 22, 32, 24, 153, 131, 31]), + Bytes32::new([204, 193, 13, 167, 214, 136, 121, 99, 198, 137, 11, 223, 85, 40, 167, 126, 153, 80, 187, 35, 226, 31, 226, 42, 9, 175, 31, 206, 119, 67, 153, 39]), + Bytes32::new([63, 82, 16, 182, 255, 45, 123, 220, 252, 52, 199, 222, 76, 172, 123, 232, 133, 182, 143, 202, 223, 161, 203, 91, 239, 225, 123, 184, 231, 53, 19, 253]), + Bytes32::new([5, 13, 255, 217, 70, 105, 205, 70, 41, 25, 44, 3, 245, 136, 16, 255, 101, 61, 189, 225, 142, 201, 210, 226, 9, 237, 171, 109, 63, 204, 204, 139]), + Bytes32::new([161, 218, 126, 252, 32, 196, 32, 105, 98, 13, 201, 117, 64, 37, 232, 32, 159, 106, 48, 121, 250, 139, 219, 137, 129, 3, 83, 194, 102, 251, 148, 71]), + Bytes32::new([72, 17, 9, 21, 142, 89, 135, 91, 81, 155, 72, 247, 56, 232, 136, 57, 251, 182, 211, 35, 207, 169, 87, 123, 31, 222, 72, 85, 212, 92, 159, 171]), + Bytes32::new([193, 253, 238, 224, 198, 216, 154, 52, 59, 87, 183, 80, 242, 162, 238, 7, 218, 195, 253, 210, 92, 116, 43, 181, 109, 40, 74, 38, 154, 211, 102, 173]), + Bytes32::new([193, 88, 249, 81, 11, 128, 242, 239, 220, 1, 237, 199, 235, 12, 153, 73, 145, 158, 15, 111, 108, 244, 19, 51, 159, 206, 66, 25, 147, 215, 157, 165]), + Bytes32::new([195, 90, 0, 163, 8, 199, 55, 59, 47, 117, 186, 204, 5, 42, 205, 164, 239, 233, 203, 210, 69, 205, 244, 152, 113, 184, 206, 110, 101, 197, 120, 101]), + Bytes32::new([114, 169, 222, 11, 169, 15, 123, 245, 42, 25, 120, 198, 66, 140, 125, 123, 201, 107, 3, 50, 245, 226, 52, 46, 162, 44, 134, 157, 226, 11, 115, 186]), + Bytes32::new([6, 47, 131, 89, 216, 138, 92, 250, 126, 232, 238, 50, 181, 78, 69, 115, 227, 25, 49, 50, 116, 138, 47, 61, 179, 75, 121, 124, 127, 106, 228, 178]), + Bytes32::new([152, 253, 228, 228, 120, 255, 82, 66, 24, 145, 159, 223, 39, 185, 81, 201, 81, 110, 47, 57, 105, 128, 8, 42, 130, 119, 92, 7, 14, 247, 137, 135]), + Bytes32::new([162, 28, 11, 245, 48, 21, 8, 137, 161, 131, 84, 18, 129, 70, 197, 122, 165, 39, 71, 213, 142, 115, 159, 52, 46, 213, 81, 10, 217, 212, 74, 20]), + Bytes32::new([129, 250, 71, 119, 46, 25, 220, 212, 143, 120, 0, 101, 85, 101, 109, 107, 142, 20, 107, 174, 39, 134, 128, 244, 237, 155, 190, 19, 110, 10, 240, 94]), + Bytes32::new([90, 70, 190, 48, 191, 45, 227, 17, 185, 162, 159, 12, 18, 94, 186, 251, 252, 238, 95, 174, 253, 99, 194, 204, 5, 178, 117, 139, 50, 154, 93, 170]), + Bytes32::new([201, 8, 48, 126, 70, 22, 83, 82, 229, 84, 168, 86, 100, 169, 227, 175, 196, 154, 217, 150, 2, 36, 1, 100, 48, 216, 141, 205, 113, 148, 109, 126]), + Bytes32::new([16, 182, 10, 119, 255, 70, 127, 242, 64, 68, 67, 44, 52, 195, 63, 185, 227, 97, 138, 244, 53, 246, 110, 99, 41, 176, 146, 206, 81, 168, 66, 140]), + Bytes32::new([95, 9, 211, 227, 219, 119, 221, 132, 248, 92, 236, 190, 110, 227, 153, 109, 103, 63, 121, 221, 165, 212, 20, 141, 33, 95, 52, 157, 69, 76, 2, 70]), + Bytes32::new([216, 138, 115, 198, 102, 135, 226, 247, 235, 185, 206, 147, 130, 9, 48, 166, 92, 22, 41, 158, 169, 52, 233, 1, 60, 229, 165, 208, 60, 161, 194, 166]), + Bytes32::new([129, 241, 87, 138, 103, 241, 79, 26, 52, 35, 125, 237, 54, 147, 253, 137, 101, 146, 235, 127, 124, 113, 60, 203, 181, 4, 250, 12, 72, 27, 24, 7]), + Bytes32::new([52, 120, 68, 97, 147, 229, 251, 178, 161, 233, 142, 136, 38, 40, 85, 46, 121, 156, 115, 186, 72, 95, 128, 43, 252, 176, 176, 51, 113, 83, 154, 232]), + Bytes32::new([227, 11, 188, 57, 98, 160, 248, 247, 112, 49, 247, 92, 94, 224, 135, 182, 211, 230, 69, 185, 138, 154, 141, 157, 18, 34, 138, 236, 67, 243, 26, 132]), + Bytes32::new([61, 246, 31, 52, 44, 146, 190, 215, 214, 105, 253, 86, 172, 174, 140, 112, 30, 154, 82, 173, 62, 199, 157, 180, 255, 104, 73, 136, 163, 79, 210, 252]), + Bytes32::new([200, 155, 200, 87, 142, 123, 62, 176, 250, 44, 18, 238, 229, 121, 125, 109, 102, 173, 60, 203, 88, 65, 33, 122, 22, 111, 157, 143, 164, 7, 214, 26]), + Bytes32::new([179, 76, 168, 179, 139, 86, 151, 173, 26, 70, 236, 116, 202, 123, 63, 80, 106, 208, 63, 138, 179, 225, 114, 64, 48, 34, 78, 124, 132, 210, 224, 190]), + Bytes32::new([138, 116, 89, 240, 28, 79, 42, 149, 199, 118, 149, 49, 146, 212, 104, 62, 17, 137, 138, 223, 225, 187, 152, 43, 134, 60, 95, 55, 175, 128, 95, 144]), +]; + +const INSTRUCTION_HASHES: &[Bytes32; 64] = &[ + Bytes32::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::new([248, 140, 83, 29, 241, 220, 66, 40, 126, 248, 5, 153, 77, 179, 26, 64, 221, 108, 205, 162, 173, 52, 179, 140, 202, 105, 0, 170, 166, 130, 120, 176]), + Bytes32::new([35, 74, 103, 235, 245, 71, 66, 212, 99, 147, 15, 200, 1, 237, 95, 163, 10, 146, 122, 251, 243, 239, 93, 186, 46, 74, 206, 130, 63, 17, 199, 80]), + Bytes32::new([113, 169, 40, 37, 169, 205, 28, 78, 37, 104, 52, 28, 29, 222, 39, 32, 208, 183, 215, 38, 255, 69, 87, 70, 174, 113, 221, 183, 206, 62, 192, 118]), + Bytes32::new([1, 148, 183, 39, 234, 23, 138, 182, 169, 58, 52, 158, 248, 212, 186, 127, 60, 42, 25, 210, 20, 170, 182, 139, 20, 185, 196, 85, 241, 214, 181, 64]), + Bytes32::new([241, 14, 59, 8, 168, 222, 232, 125, 149, 227, 125, 41, 223, 198, 88, 135, 54, 146, 140, 212, 164, 76, 239, 106, 10, 20, 67, 180, 24, 159, 174, 99]), + Bytes32::new([117, 111, 220, 19, 204, 227, 211, 18, 61, 239, 179, 46, 142, 75, 67, 98, 159, 221, 205, 158, 125, 42, 221, 227, 148, 162, 193, 229, 147, 70, 214, 127]), + Bytes32::new([20, 72, 211, 188, 38, 126, 166, 75, 54, 22, 225, 21, 113, 155, 167, 89, 161, 6, 37, 78, 227, 211, 219, 141, 161, 199, 151, 122, 81, 45, 159, 187]), + Bytes32::new([69, 198, 100, 170, 106, 174, 208, 152, 152, 121, 118, 66, 111, 89, 131, 14, 159, 115, 142, 200, 205, 173, 89, 77, 68, 234, 5, 171, 105, 248, 199, 83]), + Bytes32::new([17, 1, 220, 13, 154, 194, 88, 60, 253, 223, 149, 35, 44, 184, 107, 141, 205, 177, 185, 32, 22, 99, 212, 96, 194, 91, 255, 179, 121, 153, 254, 40]), + Bytes32::new([222, 247, 186, 138, 222, 183, 135, 183, 170, 79, 182, 23, 69, 89, 70, 68, 88, 87, 235, 22, 178, 134, 114, 220, 249, 153, 70, 71, 229, 139, 10, 190]), + Bytes32::new([183, 77, 65, 51, 207, 78, 55, 149, 222, 3, 100, 82, 232, 230, 21, 115, 249, 177, 36, 89, 12, 41, 70, 31, 199, 254, 213, 3, 184, 2, 85, 137]), + Bytes32::new([82, 15, 215, 135, 95, 18, 143, 49, 239, 237, 6, 15, 213, 113, 153, 49, 149, 54, 50, 139, 100, 192, 128, 226, 168, 9, 120, 167, 157, 42, 45, 19]), + Bytes32::new([70, 32, 130, 243, 186, 144, 224, 217, 130, 222, 175, 221, 218, 190, 179, 222, 217, 115, 70, 160, 141, 231, 221, 96, 2, 173, 27, 17, 158, 66, 180, 58]), + Bytes32::new([76, 243, 65, 235, 12, 31, 48, 195, 62, 176, 202, 57, 99, 80, 237, 222, 138, 199, 124, 251, 143, 243, 205, 226, 18, 164, 67, 64, 68, 238, 53, 71]), + Bytes32::new([70, 52, 254, 193, 211, 92, 63, 238, 92, 2, 160, 29, 154, 25, 221, 136, 2, 49, 96, 27, 15, 152, 238, 57, 241, 253, 32, 131, 73, 38, 229, 243]), + Bytes32::new([214, 162, 82, 44, 146, 145, 61, 77, 36, 3, 131, 81, 217, 39, 127, 81, 66, 82, 172, 230, 246, 3, 243, 217, 210, 38, 201, 109, 240, 143, 253, 79]), + Bytes32::new([127, 18, 198, 116, 112, 141, 16, 39, 115, 118, 37, 208, 118, 119, 147, 46, 196, 124, 19, 196, 34, 183, 172, 157, 18, 91, 4, 210, 77, 195, 220, 59]), + Bytes32::new([87, 54, 42, 60, 39, 223, 84, 148, 158, 230, 70, 53, 191, 1, 108, 103, 139, 111, 58, 220, 114, 46, 46, 110, 20, 211, 84, 1, 173, 104, 175, 191]), + Bytes32::new([182, 147, 66, 127, 229, 144, 125, 93, 84, 220, 116, 107, 51, 13, 24, 161, 68, 172, 165, 50, 12, 198, 229, 173, 49, 26, 114, 159, 84, 190, 6, 42]), + Bytes32::new([183, 20, 36, 145, 76, 36, 61, 136, 224, 139, 89, 23, 124, 29, 210, 137, 1, 160, 22, 128, 48, 242, 234, 85, 84, 24, 206, 49, 143, 185, 237, 110]), + Bytes32::new([38, 19, 77, 150, 92, 129, 177, 155, 139, 162, 90, 91, 231, 146, 216, 21, 54, 152, 18, 5, 98, 21, 67, 160, 154, 113, 175, 65, 214, 78, 19, 97]), + Bytes32::new([163, 236, 47, 120, 121, 17, 217, 4, 200, 247, 206, 178, 211, 212, 163, 48, 38, 172, 111, 123, 75, 221, 63, 117, 42, 3, 252, 233, 104, 13, 210, 203]), + Bytes32::new([127, 106, 132, 246, 28, 129, 245, 83, 159, 109, 196, 219, 68, 81, 230, 77, 254, 166, 55, 73, 169, 179, 93, 97, 117, 176, 53, 74, 121, 238, 184, 240]), + Bytes32::new([255, 23, 108, 186, 145, 182, 196, 67, 163, 95, 173, 17, 67, 239, 199, 189, 145, 153, 120, 152, 159, 126, 255, 39, 55, 178, 230, 173, 91, 165, 229, 106]), + Bytes32::new([184, 156, 20, 114, 222, 219, 89, 218, 102, 62, 130, 200, 179, 237, 32, 237, 127, 75, 251, 163, 160, 2, 221, 34, 166, 30, 172, 97, 115, 137, 179, 175]), + Bytes32::new([244, 165, 127, 27, 66, 22, 38, 243, 235, 107, 30, 181, 31, 193, 210, 174, 254, 129, 39, 71, 59, 117, 186, 37, 217, 129, 138, 23, 146, 114, 96, 78]), + Bytes32::new([27, 57, 244, 93, 208, 90, 64, 181, 161, 110, 161, 188, 62, 180, 46, 103, 136, 233, 63, 1, 243, 202, 236, 206, 173, 45, 45, 218, 238, 184, 83, 121]), + Bytes32::new([138, 185, 33, 206, 120, 214, 246, 27, 100, 91, 106, 213, 60, 177, 39, 182, 149, 204, 11, 225, 254, 5, 87, 9, 19, 186, 166, 210, 33, 67, 146, 37]), + Bytes32::new([243, 161, 7, 52, 35, 240, 227, 144, 29, 50, 232, 3, 101, 174, 192, 139, 89, 75, 204, 245, 173, 55, 139, 76, 126, 19, 142, 18, 230, 57, 219, 227]), + Bytes32::new([97, 73, 36, 70, 120, 55, 49, 114, 107, 193, 66, 219, 47, 122, 201, 194, 52, 142, 12, 163, 108, 2, 107, 58, 185, 251, 168, 146, 57, 189, 150, 134]), + Bytes32::new([11, 215, 29, 229, 151, 208, 62, 1, 172, 253, 253, 156, 177, 31, 117, 214, 161, 192, 68, 255, 140, 131, 66, 23, 247, 161, 107, 98, 199, 57, 123, 110]), + Bytes32::new([41, 166, 54, 134, 242, 64, 153, 167, 5, 230, 226, 128, 71, 10, 251, 160, 19, 187, 70, 4, 95, 98, 77, 233, 181, 24, 11, 239, 142, 152, 229, 215]), + Bytes32::new([221, 220, 68, 168, 143, 124, 235, 77, 241, 190, 214, 6, 102, 40, 32, 245, 131, 114, 170, 151, 134, 49, 79, 57, 242, 124, 85, 172, 83, 81, 68, 99]), + Bytes32::new([142, 200, 102, 97, 170, 43, 14, 11, 139, 207, 150, 163, 99, 103, 2, 46, 44, 63, 109, 61, 62, 64, 199, 104, 36, 194, 155, 232, 139, 250, 97, 224]), + Bytes32::new([162, 15, 26, 217, 96, 195, 70, 196, 253, 70, 127, 156, 39, 120, 120, 232, 197, 154, 192, 147, 104, 33, 104, 189, 120, 160, 36, 129, 208, 237, 128, 23]), + Bytes32::new([42, 228, 74, 47, 20, 55, 197, 252, 173, 70, 178, 8, 2, 43, 97, 238, 155, 124, 87, 225, 217, 6, 103, 134, 136, 235, 193, 175, 33, 228, 219, 217]), + Bytes32::new([219, 143, 25, 70, 78, 155, 119, 63, 126, 20, 158, 54, 27, 181, 104, 184, 74, 192, 75, 157, 42, 204, 45, 122, 25, 248, 247, 24, 225, 207, 51, 251]), + Bytes32::new([151, 253, 36, 33, 104, 222, 126, 234, 112, 74, 59, 94, 239, 58, 36, 114, 90, 195, 208, 46, 250, 138, 165, 200, 178, 54, 238, 154, 219, 238, 6, 183]), + Bytes32::new([205, 57, 187, 174, 221, 9, 164, 77, 76, 143, 54, 212, 115, 196, 67, 182, 200, 147, 78, 194, 245, 92, 173, 114, 180, 160, 168, 5, 200, 82, 217, 64]), + Bytes32::new([211, 104, 62, 114, 157, 56, 254, 26, 32, 168, 208, 248, 62, 195, 142, 68, 53, 13, 7, 36, 216, 5, 127, 153, 97, 88, 222, 206, 91, 42, 14, 114]), + Bytes32::new([203, 158, 225, 200, 62, 223, 202, 52, 207, 179, 250, 236, 29, 144, 181, 31, 87, 192, 203, 66, 56, 39, 123, 25, 123, 157, 196, 161, 34, 245, 22, 130]), + Bytes32::new([147, 247, 233, 96, 190, 104, 227, 251, 99, 2, 16, 8, 77, 119, 1, 97, 243, 78, 103, 46, 24, 228, 217, 65, 219, 238, 135, 18, 164, 219, 132, 39]), + Bytes32::new([239, 153, 72, 139, 52, 60, 171, 44, 72, 218, 138, 124, 45, 30, 143, 122, 147, 158, 12, 62, 213, 151, 217, 217, 212, 51, 110, 75, 122, 67, 134, 80]), + Bytes32::new([46, 47, 130, 237, 178, 232, 239, 217, 165, 114, 255, 202, 132, 214, 18, 8, 72, 8, 255, 0, 162, 82, 5, 228, 141, 201, 70, 135, 255, 21, 220, 3]), + Bytes32::new([21, 11, 196, 5, 215, 241, 194, 200, 198, 129, 133, 244, 204, 47, 131, 70, 138, 38, 107, 39, 211, 243, 72, 72, 34, 145, 35, 42, 14, 69, 218, 227]), + Bytes32::new([73, 103, 117, 195, 67, 126, 242, 57, 232, 74, 142, 64, 169, 248, 113, 69, 110, 103, 127, 185, 177, 51, 212, 178, 48, 183, 247, 44, 246, 69, 35, 208]), + Bytes32::new([125, 8, 83, 22, 215, 82, 179, 234, 169, 227, 213, 39, 170, 164, 195, 187, 63, 38, 59, 146, 144, 101, 38, 0, 110, 212, 202, 20, 245, 105, 187, 201]), + Bytes32::new([186, 231, 186, 148, 68, 208, 226, 170, 120, 80, 68, 79, 23, 41, 51, 205, 240, 201, 10, 16, 24, 38, 137, 151, 7, 102, 92, 244, 3, 194, 228, 229]), + Bytes32::new([46, 8, 51, 150, 63, 114, 126, 210, 30, 130, 76, 142, 13, 149, 14, 0, 205, 199, 48, 90, 86, 75, 151, 135, 164, 224, 129, 77, 174, 194, 212, 112]), + Bytes32::new([150, 239, 42, 111, 3, 112, 25, 168, 179, 36, 106, 73, 212, 188, 215, 79, 180, 142, 191, 29, 219, 12, 244, 74, 254, 205, 160, 54, 68, 144, 81, 207]), + Bytes32::new([23, 164, 189, 201, 250, 65, 212, 148, 132, 125, 94, 209, 115, 123, 29, 66, 3, 172, 57, 58, 46, 191, 96, 7, 212, 25, 226, 79, 120, 68, 202, 210]), + Bytes32::new([252, 13, 137, 225, 208, 6, 84, 75, 97, 32, 177, 156, 248, 191, 113, 97, 254, 122, 86, 194, 3, 103, 219, 74, 227, 160, 231, 202, 13, 126, 46, 255]), + Bytes32::new([70, 35, 27, 128, 17, 79, 226, 131, 144, 118, 248, 125, 188, 110, 20, 15, 255, 73, 205, 69, 0, 227, 26, 66, 39, 61, 191, 224, 239, 234, 83, 170]), + Bytes32::new([129, 52, 148, 121, 230, 84, 28, 112, 75, 68, 181, 197, 80, 227, 107, 22, 60, 118, 81, 209, 198, 125, 233, 190, 84, 189, 18, 25, 72, 143, 2, 190]), + Bytes32::new([244, 237, 81, 131, 251, 35, 56, 158, 229, 102, 150, 122, 213, 206, 119, 38, 54, 238, 158, 159, 1, 214, 31, 147, 245, 9, 172, 247, 156, 115, 209, 140]), + Bytes32::new([47, 5, 174, 62, 80, 172, 77, 111, 136, 114, 188, 85, 249, 157, 182, 175, 187, 207, 29, 43, 152, 88, 130, 156, 138, 30, 188, 51, 82, 105, 145, 161]), + Bytes32::new([102, 2, 197, 195, 206, 149, 53, 224, 61, 219, 163, 246, 208, 218, 140, 47, 16, 42, 196, 20, 145, 158, 101, 31, 225, 135, 49, 68, 95, 5, 228, 92]), + Bytes32::new([78, 136, 176, 216, 253, 15, 136, 48, 162, 5, 57, 120, 93, 222, 179, 174, 129, 40, 8, 63, 18, 102, 97, 41, 58, 214, 1, 52, 58, 126, 186, 146]), + Bytes32::new([145, 56, 231, 59, 247, 191, 104, 137, 240, 113, 32, 245, 235, 129, 255, 54, 99, 176, 109, 175, 107, 232, 201, 235, 95, 104, 54, 67, 252, 184, 200, 54]), + Bytes32::new([181, 3, 229, 152, 113, 182, 55, 93, 138, 137, 21, 67, 27, 204, 96, 69, 72, 247, 237, 216, 28, 36, 115, 185, 111, 149, 224, 69, 66, 121, 188, 228]), + Bytes32::new([212, 25, 201, 68, 187, 25, 10, 96, 40, 88, 100, 216, 145, 200, 26, 203, 220, 14, 14, 11, 190, 62, 143, 137, 53, 208, 233, 158, 37, 34, 8, 15]), + Bytes32::new([80, 101, 192, 136, 203, 90, 189, 204, 181, 36, 28, 107, 220, 69, 119, 99, 145, 227, 198, 55, 37, 237, 212, 114, 31, 27, 19, 90, 231, 143, 87, 149]), + Bytes32::new([248, 97, 168, 33, 15, 230, 128, 82, 157, 26, 186, 89, 200, 7, 101, 210, 117, 111, 75, 233, 244, 187, 1, 180, 30, 220, 15, 21, 203, 5, 243, 223]), +]; + +const MEMORY_HASHES: &[Bytes32; 64] = &[ + Bytes32::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::new([66, 208, 130, 169, 194, 116, 5, 27, 68, 75, 235, 175, 164, 169, 41, 91, 88, 134, 51, 194, 219, 201, 182, 199, 1, 52, 173, 215, 20, 37, 51, 0]), + Bytes32::new([90, 210, 50, 227, 58, 173, 147, 92, 139, 15, 127, 190, 196, 111, 142, 207, 31, 223, 70, 96, 17, 251, 164, 200, 133, 0, 76, 35, 200, 9, 51, 218]), + Bytes32::new([97, 5, 162, 226, 92, 108, 172, 8, 7, 65, 104, 176, 216, 3, 144, 47, 14, 88, 50, 101, 194, 94, 10, 132, 192, 76, 37, 152, 42, 73, 30, 2]), + Bytes32::new([68, 59, 208, 14, 89, 37, 33, 1, 177, 225, 235, 66, 129, 28, 103, 156, 46, 206, 94, 141, 33, 152, 141, 26, 209, 161, 53, 237, 198, 163, 115, 57]), + Bytes32::new([28, 94, 12, 53, 70, 163, 95, 44, 168, 42, 196, 126, 181, 231, 174, 247, 89, 100, 77, 238, 211, 74, 116, 144, 183, 111, 254, 75, 30, 187, 228, 222]), + Bytes32::new([238, 133, 50, 189, 14, 89, 244, 88, 239, 50, 172, 85, 172, 1, 131, 2, 24, 161, 70, 94, 0, 204, 50, 199, 48, 107, 30, 70, 6, 8, 18, 90]), + Bytes32::new([165, 239, 71, 173, 192, 165, 25, 35, 4, 130, 148, 158, 177, 193, 129, 45, 115, 209, 7, 233, 136, 108, 245, 126, 74, 200, 22, 204, 190, 137, 191, 105]), + Bytes32::new([173, 102, 127, 73, 167, 249, 117, 26, 190, 231, 26, 60, 201, 138, 160, 182, 180, 44, 34, 132, 171, 254, 91, 8, 167, 114, 188, 157, 181, 148, 169, 165]), + Bytes32::new([71, 62, 70, 89, 203, 1, 105, 187, 178, 167, 217, 118, 42, 217, 154, 234, 238, 109, 145, 231, 247, 199, 40, 110, 162, 11, 173, 144, 103, 110, 99, 101]), + Bytes32::new([121, 36, 94, 4, 25, 134, 16, 98, 198, 109, 123, 42, 56, 151, 224, 7, 232, 155, 231, 154, 229, 162, 250, 149, 231, 198, 0, 65, 17, 27, 181, 28]), + Bytes32::new([247, 158, 162, 102, 242, 117, 166, 252, 175, 158, 107, 157, 244, 44, 17, 99, 93, 52, 43, 136, 5, 211, 32, 152, 91, 148, 41, 32, 231, 18, 237, 208]), + Bytes32::new([147, 52, 155, 255, 81, 242, 75, 54, 54, 66, 166, 41, 131, 177, 183, 151, 229, 177, 232, 86, 146, 137, 106, 68, 226, 117, 20, 210, 224, 170, 249, 68]), + Bytes32::new([160, 89, 180, 156, 119, 172, 38, 10, 97, 101, 64, 56, 98, 133, 199, 228, 58, 66, 139, 128, 88, 140, 143, 85, 148, 167, 79, 75, 34, 45, 204, 68]), + Bytes32::new([165, 233, 117, 3, 27, 56, 166, 16, 56, 132, 198, 32, 11, 149, 212, 98, 64, 236, 180, 106, 174, 80, 122, 220, 102, 67, 67, 110, 67, 8, 48, 217]), + Bytes32::new([113, 74, 209, 139, 250, 181, 182, 127, 178, 77, 17, 63, 79, 109, 145, 74, 52, 102, 125, 154, 22, 241, 177, 177, 34, 189, 124, 22, 4, 200, 201, 76]), + Bytes32::new([67, 7, 240, 151, 128, 149, 238, 113, 130, 127, 174, 223, 142, 124, 230, 10, 91, 89, 113, 157, 230, 21, 213, 3, 146, 249, 26, 80, 239, 90, 4, 216]), + Bytes32::new([152, 20, 80, 244, 232, 182, 1, 145, 31, 191, 46, 207, 83, 199, 209, 104, 0, 75, 106, 230, 16, 98, 121, 127, 175, 78, 119, 154, 69, 55, 66, 169]), + Bytes32::new([123, 50, 162, 158, 51, 112, 129, 232, 242, 158, 150, 72, 244, 40, 191, 63, 205, 61, 144, 39, 65, 122, 28, 88, 253, 146, 29, 29, 15, 40, 122, 95]), + Bytes32::new([231, 253, 202, 45, 165, 158, 212, 29, 104, 165, 209, 179, 188, 154, 89, 18, 216, 23, 140, 66, 150, 49, 99, 200, 163, 155, 50, 9, 250, 22, 19, 203]), + Bytes32::new([127, 172, 110, 243, 156, 134, 199, 15, 248, 216, 12, 196, 221, 66, 202, 186, 105, 197, 43, 245, 46, 116, 251, 133, 111, 118, 56, 214, 157, 244, 187, 58]), + Bytes32::new([181, 181, 163, 95, 7, 188, 245, 128, 161, 210, 137, 217, 103, 101, 120, 255, 47, 83, 102, 68, 238, 195, 206, 105, 24, 150, 216, 50, 74, 6, 94, 95]), + Bytes32::new([171, 250, 198, 40, 153, 26, 240, 152, 96, 169, 15, 123, 33, 155, 57, 172, 89, 205, 9, 65, 45, 126, 155, 143, 224, 145, 25, 214, 19, 227, 213, 195]), + Bytes32::new([44, 177, 244, 220, 119, 33, 203, 59, 209, 72, 28, 4, 210, 54, 86, 20, 119, 41, 45, 231, 143, 104, 57, 206, 212, 222, 81, 62, 92, 221, 200, 32]), + Bytes32::new([37, 200, 165, 195, 67, 224, 131, 227, 97, 54, 21, 233, 76, 186, 6, 122, 178, 131, 252, 59, 97, 218, 239, 62, 124, 255, 201, 178, 241, 236, 4, 214]), + Bytes32::new([77, 171, 229, 183, 46, 112, 203, 177, 89, 90, 64, 114, 109, 220, 32, 120, 41, 223, 72, 86, 59, 211, 110, 17, 129, 112, 194, 186, 200, 92, 144, 49]), + Bytes32::new([2, 198, 61, 112, 181, 185, 194, 114, 149, 63, 65, 76, 55, 179, 170, 62, 91, 112, 189, 100, 13, 34, 98, 187, 85, 132, 202, 86, 47, 27, 236, 200]), + Bytes32::new([164, 238, 109, 209, 155, 118, 236, 237, 84, 43, 56, 99, 51, 60, 116, 235, 100, 39, 163, 105, 34, 93, 8, 187, 228, 213, 35, 200, 43, 8, 32, 68]), + Bytes32::new([32, 220, 39, 200, 214, 245, 102, 200, 167, 204, 3, 54, 140, 126, 129, 35, 139, 60, 112, 133, 52, 166, 162, 63, 119, 20, 2, 116, 132, 244, 246, 225]), + Bytes32::new([5, 54, 145, 188, 188, 251, 36, 4, 103, 140, 229, 143, 83, 11, 77, 207, 57, 125, 51, 127, 89, 130, 138, 193, 190, 17, 17, 23, 68, 168, 231, 106]), + Bytes32::new([239, 112, 72, 74, 116, 134, 210, 24, 226, 242, 91, 113, 99, 59, 19, 7, 226, 215, 254, 220, 14, 225, 75, 245, 11, 234, 138, 52, 195, 86, 79, 124]), + Bytes32::new([187, 35, 132, 188, 162, 128, 96, 71, 124, 213, 251, 229, 73, 52, 187, 22, 166, 35, 214, 14, 121, 189, 37, 5, 77, 54, 201, 51, 95, 179, 75, 229]), + Bytes32::new([5, 54, 88, 42, 68, 200, 45, 209, 121, 70, 128, 8, 178, 212, 197, 39, 101, 90, 101, 111, 77, 133, 13, 77, 19, 111, 113, 122, 222, 85, 180, 82]), + Bytes32::new([34, 182, 144, 13, 35, 35, 79, 14, 239, 80, 21, 255, 67, 48, 210, 174, 159, 182, 239, 236, 68, 46, 125, 105, 243, 202, 218, 64, 53, 94, 159, 253]), + Bytes32::new([224, 189, 145, 186, 43, 169, 131, 161, 223, 161, 72, 72, 229, 97, 113, 233, 2, 250, 109, 31, 19, 125, 57, 135, 144, 3, 187, 18, 102, 108, 232, 9]), + Bytes32::new([68, 94, 11, 104, 95, 110, 179, 226, 157, 245, 113, 68, 44, 122, 17, 22, 244, 35, 248, 126, 131, 192, 20, 169, 129, 236, 60, 54, 157, 30, 231, 36]), + Bytes32::new([101, 198, 107, 156, 226, 8, 67, 168, 197, 91, 189, 166, 187, 16, 121, 93, 114, 243, 137, 162, 125, 142, 50, 206, 160, 168, 165, 27, 207, 10, 22, 19]), + Bytes32::new([222, 29, 134, 137, 98, 73, 58, 143, 166, 134, 210, 47, 68, 23, 214, 237, 241, 207, 226, 83, 113, 222, 184, 139, 16, 1, 200, 56, 34, 208, 197, 152]), + Bytes32::new([107, 200, 189, 222, 185, 32, 192, 130, 237, 238, 168, 137, 14, 94, 3, 26, 41, 238, 19, 119, 207, 158, 25, 177, 116, 70, 170, 161, 141, 129, 16, 88]), + Bytes32::new([131, 243, 131, 161, 236, 101, 108, 81, 59, 123, 150, 6, 250, 124, 103, 101, 75, 234, 98, 223, 129, 87, 202, 59, 184, 173, 44, 191, 200, 30, 223, 66]), + Bytes32::new([17, 226, 72, 31, 180, 33, 229, 83, 154, 39, 104, 45, 93, 117, 153, 249, 216, 127, 120, 182, 4, 19, 169, 87, 127, 70, 7, 237, 80, 251, 220, 126]), + Bytes32::new([88, 122, 134, 181, 173, 175, 100, 74, 28, 141, 45, 215, 245, 170, 222, 54, 106, 118, 146, 59, 207, 251, 133, 155, 164, 75, 240, 208, 10, 185, 187, 163]), + Bytes32::new([214, 1, 209, 99, 53, 101, 233, 225, 55, 171, 69, 200, 44, 144, 169, 11, 65, 85, 84, 158, 233, 227, 37, 59, 42, 52, 153, 13, 0, 158, 122, 208]), + Bytes32::new([124, 146, 1, 221, 33, 138, 233, 130, 184, 163, 121, 110, 95, 242, 123, 251, 110, 46, 41, 197, 75, 145, 121, 95, 29, 1, 19, 19, 167, 220, 177, 153]), + Bytes32::new([77, 38, 54, 170, 19, 128, 180, 248, 208, 75, 27, 53, 228, 104, 7, 216, 188, 186, 40, 84, 87, 11, 121, 3, 175, 89, 49, 46, 191, 94, 80, 97]), + Bytes32::new([134, 127, 37, 206, 212, 70, 146, 143, 81, 104, 140, 28, 135, 233, 171, 88, 18, 2, 148, 143, 111, 208, 149, 138, 167, 84, 183, 100, 67, 181, 243, 135]), + Bytes32::new([218, 16, 220, 189, 192, 237, 252, 168, 45, 33, 177, 81, 53, 115, 141, 190, 99, 138, 113, 85, 60, 230, 244, 222, 205, 16, 152, 26, 185, 207, 114, 143]), + Bytes32::new([9, 85, 193, 163, 186, 152, 83, 149, 29, 71, 50, 13, 175, 149, 184, 51, 246, 97, 20, 22, 57, 201, 27, 72, 146, 19, 213, 102, 164, 148, 176, 45]), + Bytes32::new([140, 94, 218, 31, 232, 0, 167, 218, 122, 119, 62, 179, 181, 51, 100, 6, 150, 159, 212, 207, 160, 94, 212, 108, 225, 196, 190, 210, 145, 110, 120, 114]), + Bytes32::new([152, 169, 229, 240, 162, 212, 61, 59, 167, 135, 124, 147, 212, 248, 177, 85, 243, 72, 150, 127, 122, 60, 143, 125, 226, 186, 67, 219, 50, 112, 242, 212]), + Bytes32::new([47, 244, 81, 140, 243, 189, 116, 0, 2, 158, 242, 188, 215, 90, 177, 37, 175, 221, 80, 226, 209, 79, 2, 62, 112, 245, 1, 132, 7, 78, 0, 117]), + Bytes32::new([247, 236, 252, 118, 6, 245, 132, 187, 48, 36, 77, 0, 167, 150, 109, 72, 234, 9, 224, 162, 223, 191, 21, 19, 180, 201, 138, 56, 109, 97, 152, 170]), + Bytes32::new([77, 23, 112, 52, 78, 204, 135, 173, 2, 206, 148, 200, 60, 155, 60, 179, 201, 111, 73, 138, 76, 104, 79, 174, 190, 173, 42, 51, 38, 48, 237, 241]), + Bytes32::new([117, 234, 73, 183, 4, 144, 12, 196, 78, 228, 178, 218, 206, 147, 147, 94, 190, 22, 22, 233, 88, 118, 135, 55, 63, 29, 212, 38, 223, 160, 121, 230]), + Bytes32::new([74, 138, 173, 10, 77, 129, 10, 115, 18, 90, 57, 215, 221, 171, 109, 152, 31, 219, 235, 122, 189, 201, 210, 186, 52, 200, 81, 218, 112, 79, 80, 54]), + Bytes32::new([189, 150, 224, 30, 110, 73, 249, 62, 100, 244, 206, 110, 206, 239, 233, 213, 61, 213, 65, 139, 103, 19, 20, 123, 167, 65, 161, 165, 216, 217, 255, 248]), + Bytes32::new([119, 71, 56, 219, 155, 139, 253, 40, 100, 132, 185, 98, 24, 34, 156, 225, 120, 176, 76, 147, 31, 105, 245, 216, 165, 161, 89, 157, 246, 17, 251, 234]), + Bytes32::new([192, 39, 162, 126, 222, 211, 173, 195, 198, 124, 1, 124, 140, 2, 252, 191, 185, 85, 10, 125, 226, 7, 88, 221, 164, 13, 221, 74, 200, 7, 249, 177]), + Bytes32::new([251, 226, 24, 5, 54, 89, 9, 93, 217, 202, 148, 172, 208, 197, 65, 172, 98, 96, 58, 194, 61, 253, 157, 193, 135, 32, 206, 97, 133, 234, 199, 197]), + Bytes32::new([130, 3, 195, 156, 210, 123, 23, 44, 223, 25, 153, 169, 250, 88, 127, 239, 206, 196, 156, 143, 182, 185, 35, 77, 162, 48, 143, 64, 231, 129, 216, 185]), + Bytes32::new([123, 201, 97, 230, 121, 13, 207, 138, 137, 3, 122, 92, 105, 155, 214, 204, 142, 18, 119, 138, 135, 165, 249, 58, 184, 53, 27, 31, 109, 214, 176, 147]), + Bytes32::new([46, 71, 246, 155, 247, 109, 236, 225, 147, 51, 250, 72, 97, 116, 162, 36, 115, 164, 80, 28, 252, 238, 98, 92, 16, 66, 190, 208, 180, 39, 179, 211]), + Bytes32::new([38, 76, 13, 227, 149, 18, 84, 170, 83, 231, 122, 59, 237, 66, 32, 171, 158, 251, 78, 156, 186, 160, 29, 30, 207, 178, 16, 193, 221, 158, 49, 48]), + Bytes32::new([166, 13, 210, 208, 250, 131, 27, 163, 99, 204, 199, 134, 152, 131, 28, 164, 8, 222, 176, 200, 34, 40, 74, 188, 120, 46, 167, 44, 95, 199, 86, 225]), +]; + +const TABLE_HASHES: &[Bytes32; 64] = &[ + Bytes32::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::new([164, 47, 121, 69, 150, 44, 30, 204, 210, 181, 242, 154, 59, 111, 5, 10, 47, 121, 213, 80, 163, 196, 205, 188, 241, 64, 202, 26, 242, 47, 50, 205]), + Bytes32::new([166, 9, 224, 145, 14, 138, 194, 78, 202, 114, 110, 38, 244, 33, 189, 185, 170, 85, 144, 229, 123, 63, 229, 194, 59, 130, 156, 6, 184, 154, 187, 17]), + Bytes32::new([32, 51, 186, 232, 39, 244, 218, 98, 243, 254, 82, 247, 63, 120, 34, 123, 128, 240, 220, 145, 41, 114, 251, 208, 209, 244, 10, 9, 179, 5, 105, 181]), + Bytes32::new([73, 148, 74, 132, 241, 45, 129, 169, 83, 223, 101, 12, 184, 60, 10, 201, 169, 197, 75, 17, 198, 168, 79, 171, 207, 195, 123, 47, 249, 30, 176, 216]), + Bytes32::new([145, 224, 51, 196, 211, 137, 189, 133, 232, 210, 170, 157, 227, 160, 218, 143, 15, 82, 170, 226, 241, 83, 7, 112, 138, 227, 58, 59, 149, 168, 81, 94]), + Bytes32::new([241, 90, 42, 7, 231, 63, 36, 86, 238, 131, 19, 20, 38, 118, 65, 180, 109, 121, 147, 147, 213, 142, 203, 244, 239, 75, 5, 160, 16, 85, 221, 95]), + Bytes32::new([213, 113, 178, 221, 213, 107, 77, 153, 222, 48, 148, 140, 250, 1, 17, 59, 73, 19, 110, 106, 94, 195, 126, 49, 126, 109, 65, 55, 104, 111, 18, 171]), + Bytes32::new([43, 198, 12, 197, 95, 201, 76, 108, 96, 235, 76, 8, 117, 99, 42, 20, 177, 45, 112, 40, 2, 180, 68, 19, 25, 11, 210, 168, 170, 178, 99, 27]), + Bytes32::new([142, 205, 24, 125, 81, 234, 138, 161, 206, 121, 163, 225, 50, 9, 180, 102, 0, 25, 93, 180, 137, 164, 206, 249, 222, 20, 175, 177, 199, 14, 115, 207]), + Bytes32::new([213, 41, 249, 19, 173, 165, 236, 103, 42, 146, 223, 6, 190, 229, 161, 13, 96, 163, 110, 23, 203, 238, 24, 95, 130, 203, 35, 211, 63, 234, 32, 137]), + Bytes32::new([176, 82, 229, 48, 113, 46, 179, 38, 231, 83, 50, 136, 179, 190, 242, 126, 152, 210, 141, 102, 191, 21, 20, 96, 235, 245, 81, 254, 231, 117, 159, 146]), + Bytes32::new([216, 15, 120, 147, 70, 215, 12, 160, 223, 73, 246, 73, 195, 189, 200, 3, 19, 131, 102, 61, 173, 79, 50, 76, 39, 150, 151, 147, 35, 251, 200, 0]), + Bytes32::new([88, 215, 168, 30, 218, 72, 206, 159, 91, 121, 14, 133, 241, 220, 195, 46, 93, 244, 179, 53, 158, 75, 211, 161, 8, 120, 167, 141, 235, 16, 232, 42]), + Bytes32::new([114, 99, 218, 52, 203, 162, 199, 16, 225, 154, 182, 20, 59, 121, 250, 249, 166, 35, 118, 18, 142, 57, 122, 131, 32, 219, 83, 126, 147, 91, 116, 16]), + Bytes32::new([193, 157, 15, 251, 179, 155, 215, 190, 98, 93, 30, 167, 23, 175, 178, 172, 142, 143, 222, 20, 18, 157, 215, 42, 105, 107, 64, 16, 216, 143, 109, 45]), + Bytes32::new([178, 2, 203, 32, 83, 90, 114, 97, 124, 210, 81, 81, 179, 213, 71, 19, 181, 173, 227, 88, 226, 83, 48, 169, 134, 163, 62, 103, 222, 82, 128, 30]), + Bytes32::new([252, 17, 142, 50, 185, 19, 111, 148, 204, 30, 199, 138, 143, 207, 30, 212, 254, 7, 129, 43, 100, 167, 52, 115, 247, 143, 64, 106, 220, 5, 7, 89]), + Bytes32::new([117, 136, 111, 98, 95, 97, 253, 43, 82, 22, 43, 187, 65, 154, 132, 105, 55, 194, 240, 148, 170, 199, 185, 91, 157, 138, 43, 117, 218, 176, 110, 101]), + Bytes32::new([228, 56, 186, 202, 73, 47, 253, 151, 48, 173, 2, 101, 153, 197, 108, 145, 227, 170, 247, 86, 80, 70, 30, 93, 232, 148, 63, 211, 197, 135, 23, 97]), + Bytes32::new([162, 35, 93, 45, 208, 241, 87, 57, 138, 79, 231, 83, 75, 81, 102, 91, 115, 58, 1, 205, 193, 197, 62, 210, 144, 88, 59, 52, 149, 234, 121, 224]), + Bytes32::new([165, 67, 16, 239, 234, 92, 207, 81, 64, 93, 227, 154, 132, 33, 54, 53, 102, 198, 90, 134, 24, 29, 190, 158, 121, 23, 127, 30, 27, 239, 140, 88]), + Bytes32::new([61, 125, 183, 139, 186, 82, 193, 166, 2, 147, 231, 215, 179, 107, 163, 67, 122, 0, 90, 188, 142, 216, 72, 20, 63, 146, 85, 89, 231, 41, 153, 117]), + Bytes32::new([206, 31, 38, 182, 78, 170, 183, 207, 211, 114, 212, 4, 108, 84, 62, 99, 245, 196, 10, 1, 188, 63, 240, 199, 27, 85, 68, 101, 212, 222, 85, 12]), + Bytes32::new([106, 0, 225, 130, 195, 87, 113, 106, 101, 80, 56, 119, 93, 45, 74, 168, 240, 209, 155, 123, 8, 129, 73, 225, 204, 125, 42, 73, 102, 122, 228, 158]), + Bytes32::new([251, 63, 88, 92, 59, 176, 71, 194, 46, 19, 18, 27, 83, 57, 197, 231, 202, 242, 155, 63, 252, 240, 205, 216, 96, 130, 161, 197, 123, 110, 175, 220]), + Bytes32::new([239, 6, 249, 150, 189, 234, 197, 18, 79, 222, 80, 72, 205, 147, 251, 135, 226, 33, 46, 111, 186, 185, 4, 33, 219, 129, 30, 182, 57, 229, 34, 16]), + Bytes32::new([192, 35, 149, 149, 16, 111, 3, 119, 173, 215, 223, 247, 70, 25, 31, 107, 104, 5, 249, 243, 193, 66, 99, 48, 107, 158, 25, 147, 163, 151, 96, 149]), + Bytes32::new([197, 133, 241, 197, 67, 52, 255, 227, 180, 235, 137, 164, 174, 160, 183, 9, 159, 254, 210, 180, 231, 140, 176, 165, 113, 215, 182, 1, 177, 204, 219, 246]), + Bytes32::new([51, 32, 109, 173, 131, 6, 99, 63, 75, 191, 207, 187, 73, 26, 5, 139, 167, 216, 123, 26, 199, 176, 84, 215, 158, 243, 105, 0, 91, 254, 59, 146]), + Bytes32::new([229, 120, 15, 22, 225, 50, 131, 240, 190, 232, 83, 119, 169, 246, 172, 35, 99, 163, 58, 146, 234, 253, 252, 83, 5, 48, 54, 142, 172, 91, 145, 13]), + Bytes32::new([159, 9, 100, 20, 215, 92, 217, 43, 208, 254, 65, 234, 124, 167, 250, 53, 159, 151, 124, 70, 26, 0, 113, 28, 78, 44, 238, 8, 34, 255, 19, 36]), + Bytes32::new([193, 135, 44, 144, 13, 46, 76, 43, 127, 208, 79, 196, 229, 58, 125, 33, 71, 118, 215, 240, 80, 123, 44, 181, 174, 47, 102, 42, 137, 98, 190, 41]), + Bytes32::new([78, 19, 3, 217, 174, 154, 142, 109, 189, 14, 241, 12, 23, 185, 224, 152, 209, 108, 223, 202, 191, 11, 190, 149, 31, 236, 104, 234, 22, 38, 196, 3]), + Bytes32::new([60, 93, 237, 228, 186, 222, 179, 231, 151, 95, 147, 20, 188, 10, 191, 34, 126, 57, 253, 161, 154, 117, 182, 108, 143, 72, 48, 102, 191, 240, 81, 208]), + Bytes32::new([179, 114, 163, 89, 172, 211, 154, 204, 11, 125, 140, 186, 107, 90, 17, 116, 214, 31, 165, 94, 36, 187, 184, 151, 210, 208, 76, 215, 75, 166, 107, 91]), + Bytes32::new([125, 131, 52, 139, 120, 156, 163, 243, 206, 143, 204, 221, 123, 140, 1, 103, 235, 186, 64, 82, 194, 191, 205, 2, 32, 242, 38, 77, 184, 23, 236, 228]), + Bytes32::new([137, 224, 90, 1, 116, 95, 215, 47, 8, 3, 227, 132, 154, 232, 216, 63, 3, 80, 52, 18, 42, 29, 85, 38, 117, 255, 9, 99, 88, 233, 129, 92]), + Bytes32::new([54, 182, 145, 174, 54, 24, 168, 13, 71, 43, 178, 49, 153, 246, 94, 79, 228, 254, 134, 0, 21, 210, 176, 242, 82, 117, 76, 40, 221, 181, 30, 62]), + Bytes32::new([145, 171, 156, 87, 15, 174, 31, 111, 175, 161, 31, 116, 123, 123, 37, 216, 43, 147, 197, 79, 218, 49, 236, 111, 35, 49, 44, 188, 197, 79, 136, 45]), + Bytes32::new([169, 48, 186, 93, 10, 48, 80, 103, 68, 226, 103, 31, 176, 154, 146, 199, 166, 89, 48, 149, 116, 101, 157, 149, 149, 72, 123, 54, 153, 26, 210, 122]), + Bytes32::new([225, 45, 163, 167, 213, 84, 40, 87, 106, 253, 206, 80, 189, 71, 153, 5, 15, 107, 151, 150, 14, 22, 143, 207, 4, 192, 63, 250, 207, 207, 179, 26]), + Bytes32::new([110, 249, 172, 218, 206, 202, 107, 64, 48, 153, 226, 127, 165, 227, 50, 146, 140, 239, 220, 252, 188, 157, 77, 210, 92, 73, 38, 6, 16, 87, 244, 66]), + Bytes32::new([39, 217, 230, 91, 60, 231, 96, 137, 37, 58, 93, 51, 79, 222, 132, 171, 196, 109, 155, 4, 252, 213, 17, 33, 160, 24, 250, 118, 187, 62, 107, 113]), + Bytes32::new([120, 167, 145, 121, 184, 31, 185, 178, 241, 54, 20, 48, 132, 89, 132, 127, 235, 189, 197, 127, 249, 58, 255, 197, 40, 229, 130, 254, 213, 186, 114, 74]), + Bytes32::new([7, 40, 187, 172, 225, 196, 3, 77, 113, 16, 118, 148, 95, 65, 42, 234, 233, 29, 120, 223, 105, 77, 250, 119, 245, 20, 21, 155, 177, 13, 56, 151]), + Bytes32::new([22, 248, 25, 75, 36, 179, 251, 57, 101, 170, 213, 19, 216, 64, 164, 253, 151, 199, 88, 5, 92, 129, 138, 185, 9, 236, 231, 68, 112, 24, 218, 216]), + Bytes32::new([95, 141, 49, 39, 213, 214, 130, 49, 143, 124, 178, 114, 200, 136, 160, 90, 233, 73, 233, 185, 60, 250, 174, 74, 2, 123, 2, 62, 192, 174, 115, 158]), + Bytes32::new([142, 29, 212, 35, 71, 107, 91, 164, 226, 225, 180, 218, 99, 34, 200, 171, 33, 235, 113, 105, 191, 78, 105, 70, 221, 135, 167, 148, 24, 225, 6, 146]), + Bytes32::new([176, 194, 115, 243, 138, 104, 3, 247, 184, 74, 81, 60, 173, 45, 29, 189, 252, 202, 206, 66, 129, 65, 150, 25, 246, 145, 133, 4, 93, 201, 201, 240]), + Bytes32::new([18, 233, 186, 158, 43, 12, 206, 228, 80, 102, 187, 25, 78, 77, 180, 28, 82, 62, 168, 252, 14, 113, 126, 91, 243, 120, 213, 91, 189, 244, 247, 177]), + Bytes32::new([79, 126, 97, 23, 112, 98, 93, 86, 24, 103, 82, 33, 155, 188, 202, 61, 29, 146, 132, 169, 116, 207, 216, 35, 29, 229, 213, 120, 135, 240, 129, 205]), + Bytes32::new([146, 121, 255, 202, 145, 53, 46, 8, 102, 205, 56, 234, 49, 42, 85, 231, 217, 114, 235, 141, 233, 187, 29, 9, 122, 232, 61, 253, 42, 104, 4, 113]), + Bytes32::new([103, 174, 255, 6, 115, 155, 156, 65, 84, 251, 208, 55, 89, 124, 171, 167, 133, 227, 22, 134, 32, 71, 243, 181, 16, 100, 81, 63, 22, 207, 58, 190]), + Bytes32::new([69, 10, 247, 243, 56, 0, 64, 72, 218, 21, 211, 192, 62, 243, 66, 244, 230, 58, 107, 54, 180, 29, 216, 23, 86, 211, 173, 181, 118, 188, 238, 72]), + Bytes32::new([25, 179, 4, 93, 169, 76, 76, 69, 158, 3, 24, 146, 130, 9, 225, 198, 102, 238, 29, 73, 74, 179, 159, 74, 40, 111, 181, 110, 76, 173, 251, 255]), + Bytes32::new([236, 113, 37, 202, 149, 150, 90, 50, 233, 141, 125, 12, 212, 163, 137, 176, 15, 214, 194, 73, 138, 104, 4, 33, 235, 76, 185, 58, 125, 182, 56, 0]), + Bytes32::new([238, 54, 183, 94, 50, 33, 98, 31, 133, 181, 230, 98, 43, 154, 95, 111, 250, 71, 15, 197, 156, 60, 8, 90, 208, 50, 62, 127, 30, 18, 181, 176]), + Bytes32::new([246, 143, 72, 228, 143, 15, 15, 131, 178, 105, 113, 46, 85, 36, 165, 116, 63, 131, 61, 228, 98, 144, 232, 209, 228, 110, 168, 171, 252, 47, 79, 165]), + Bytes32::new([146, 70, 74, 79, 139, 107, 73, 28, 231, 88, 235, 214, 163, 185, 87, 195, 147, 186, 153, 222, 191, 214, 30, 231, 173, 166, 151, 169, 244, 15, 15, 227]), + Bytes32::new([137, 182, 175, 97, 212, 23, 62, 70, 50, 150, 67, 153, 253, 52, 179, 105, 147, 177, 217, 170, 125, 251, 1, 96, 4, 127, 196, 37, 254, 7, 217, 100]), + Bytes32::new([32, 253, 229, 209, 120, 43, 120, 189, 245, 227, 178, 79, 134, 175, 240, 107, 25, 124, 5, 67, 120, 213, 187, 200, 159, 9, 26, 119, 13, 1, 8, 120]), + Bytes32::new([115, 241, 26, 44, 83, 229, 130, 21, 249, 87, 72, 212, 75, 220, 95, 22, 151, 77, 182, 8, 196, 207, 95, 18, 9, 92, 89, 206, 114, 80, 36, 159]), + Bytes32::new([174, 151, 88, 171, 52, 40, 161, 16, 106, 45, 44, 9, 142, 95, 5, 205, 82, 24, 172, 103, 152, 202, 187, 34, 217, 173, 236, 129, 32, 203, 205, 38]), +]; + +const TABLE_ELEMENT_HASHES: &[Bytes32; 64] = &[ + Bytes32::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::new([145, 218, 63, 74, 131, 182, 204, 163, 74, 206, 234, 50, 47, 3, 51, 74, 121, 225, 146, 237, 5, 128, 20, 230, 243, 89, 33, 248, 136, 154, 189, 5]), + Bytes32::new([36, 240, 95, 13, 214, 136, 92, 102, 96, 137, 39, 96, 108, 223, 147, 130, 220, 61, 147, 226, 52, 133, 67, 223, 211, 164, 6, 53, 45, 117, 120, 241]), + Bytes32::new([9, 2, 218, 34, 228, 8, 178, 127, 160, 30, 104, 198, 49, 37, 71, 115, 14, 35, 20, 15, 253, 160, 147, 143, 24, 186, 12, 90, 41, 169, 30, 8]), + Bytes32::new([137, 242, 105, 78, 161, 99, 76, 224, 226, 100, 216, 235, 156, 132, 214, 154, 107, 120, 197, 113, 45, 221, 170, 119, 92, 228, 76, 139, 170, 159, 111, 58]), + Bytes32::new([231, 165, 221, 185, 139, 22, 70, 40, 67, 162, 123, 94, 161, 156, 57, 53, 102, 217, 128, 227, 18, 132, 17, 170, 90, 31, 214, 181, 249, 220, 70, 37]), + Bytes32::new([171, 253, 174, 187, 9, 186, 87, 37, 22, 83, 13, 88, 75, 11, 177, 226, 237, 136, 132, 137, 101, 109, 135, 192, 224, 80, 87, 105, 95, 81, 255, 21]), + Bytes32::new([179, 50, 36, 230, 159, 162, 184, 132, 140, 121, 133, 155, 189, 44, 132, 93, 80, 79, 32, 244, 131, 57, 79, 222, 104, 63, 224, 182, 91, 162, 73, 122]), + Bytes32::new([17, 55, 206, 87, 127, 185, 135, 231, 41, 56, 166, 104, 229, 102, 222, 181, 236, 233, 230, 39, 43, 163, 16, 1, 225, 86, 211, 51, 145, 7, 169, 84]), + Bytes32::new([201, 174, 3, 154, 104, 190, 240, 99, 123, 201, 7, 118, 196, 85, 28, 247, 35, 232, 39, 25, 151, 52, 167, 136, 179, 13, 213, 60, 138, 158, 39, 131]), + Bytes32::new([35, 33, 109, 155, 171, 252, 195, 80, 10, 115, 40, 199, 250, 1, 241, 82, 146, 225, 118, 237, 11, 125, 198, 97, 57, 21, 171, 237, 94, 60, 49, 32]), + Bytes32::new([126, 95, 42, 157, 183, 168, 137, 120, 114, 64, 148, 170, 32, 156, 137, 96, 194, 91, 119, 11, 20, 3, 30, 62, 118, 12, 31, 48, 245, 144, 252, 29]), + Bytes32::new([48, 135, 201, 114, 103, 35, 8, 96, 5, 101, 125, 26, 87, 0, 98, 122, 239, 140, 230, 10, 102, 112, 155, 87, 249, 181, 152, 235, 28, 79, 176, 56]), + Bytes32::new([76, 70, 222, 210, 242, 159, 52, 123, 112, 106, 253, 140, 55, 160, 189, 255, 220, 64, 8, 168, 39, 196, 160, 8, 105, 154, 91, 184, 62, 63, 227, 156]), + Bytes32::new([138, 201, 8, 240, 218, 190, 210, 227, 236, 168, 45, 161, 209, 115, 126, 165, 235, 162, 6, 117, 76, 239, 3, 225, 163, 251, 111, 233, 233, 228, 14, 92]), + Bytes32::new([190, 166, 27, 117, 242, 0, 25, 148, 230, 125, 237, 22, 153, 158, 151, 56, 121, 194, 221, 198, 184, 147, 249, 149, 27, 29, 166, 243, 254, 181, 209, 102]), + Bytes32::new([235, 63, 149, 47, 164, 152, 80, 11, 178, 203, 99, 178, 176, 226, 164, 151, 39, 65, 83, 200, 102, 90, 12, 102, 178, 15, 232, 16, 222, 141, 78, 3]), + Bytes32::new([37, 179, 99, 114, 214, 120, 87, 53, 198, 229, 207, 47, 16, 112, 208, 33, 216, 152, 209, 228, 196, 14, 237, 250, 212, 90, 176, 185, 21, 248, 92, 109]), + Bytes32::new([237, 200, 122, 93, 145, 116, 138, 59, 86, 220, 58, 171, 160, 31, 142, 193, 231, 131, 106, 164, 166, 44, 120, 170, 62, 81, 73, 85, 0, 52, 219, 220]), + Bytes32::new([244, 173, 85, 141, 81, 198, 214, 0, 54, 21, 20, 169, 177, 235, 104, 206, 43, 218, 96, 68, 73, 37, 252, 77, 253, 18, 30, 97, 223, 122, 1, 12]), + Bytes32::new([104, 169, 247, 140, 131, 245, 193, 3, 36, 119, 249, 119, 108, 102, 115, 250, 173, 225, 33, 156, 116, 87, 180, 27, 84, 215, 126, 15, 187, 189, 32, 139]), + Bytes32::new([47, 156, 244, 88, 145, 227, 224, 87, 233, 138, 138, 9, 169, 96, 29, 204, 100, 170, 23, 105, 63, 4, 119, 90, 167, 161, 72, 109, 82, 254, 123, 48]), + Bytes32::new([196, 68, 107, 111, 141, 253, 138, 140, 162, 104, 247, 104, 87, 144, 123, 240, 105, 251, 246, 210, 172, 172, 241, 162, 155, 90, 83, 175, 131, 251, 107, 215]), + Bytes32::new([28, 100, 243, 226, 32, 234, 211, 106, 197, 179, 14, 192, 70, 11, 203, 125, 151, 53, 20, 77, 175, 99, 154, 100, 159, 249, 54, 39, 73, 168, 162, 66]), + Bytes32::new([83, 176, 7, 180, 201, 178, 172, 98, 47, 34, 80, 6, 62, 10, 4, 112, 43, 93, 10, 227, 74, 91, 11, 217, 83, 230, 104, 0, 167, 2, 114, 89]), + Bytes32::new([185, 162, 212, 82, 149, 182, 104, 215, 62, 244, 114, 124, 181, 74, 226, 119, 4, 42, 181, 238, 25, 212, 215, 219, 174, 231, 32, 170, 9, 234, 12, 212]), + Bytes32::new([173, 38, 241, 20, 137, 119, 33, 252, 174, 245, 252, 234, 165, 181, 128, 225, 14, 147, 182, 97, 145, 19, 40, 193, 90, 238, 140, 87, 0, 222, 70, 254]), + Bytes32::new([51, 218, 162, 213, 211, 23, 9, 158, 185, 156, 39, 145, 5, 146, 70, 144, 172, 10, 26, 212, 253, 37, 24, 32, 21, 65, 179, 140, 64, 237, 96, 157]), + Bytes32::new([221, 87, 57, 81, 246, 126, 53, 163, 190, 220, 109, 205, 114, 234, 85, 151, 75, 245, 254, 16, 140, 131, 239, 120, 9, 209, 54, 61, 177, 6, 188, 252]), + Bytes32::new([54, 161, 25, 198, 75, 151, 214, 76, 83, 74, 117, 229, 155, 237, 88, 95, 143, 119, 56, 12, 201, 164, 235, 20, 117, 49, 177, 88, 14, 248, 95, 198]), + Bytes32::new([60, 16, 183, 115, 241, 45, 253, 24, 105, 43, 79, 72, 212, 238, 24, 156, 132, 93, 78, 246, 1, 228, 222, 200, 254, 130, 170, 46, 91, 254, 205, 143]), + Bytes32::new([184, 30, 34, 235, 214, 40, 120, 64, 182, 15, 162, 189, 164, 202, 89, 146, 202, 177, 16, 105, 172, 158, 1, 95, 101, 146, 253, 115, 226, 233, 38, 171]), + Bytes32::new([70, 152, 3, 73, 249, 222, 93, 214, 74, 179, 140, 47, 34, 42, 149, 214, 152, 75, 34, 145, 68, 226, 151, 101, 121, 54, 252, 240, 206, 140, 81, 165]), + Bytes32::new([9, 88, 51, 124, 67, 108, 84, 244, 61, 241, 110, 246, 184, 105, 6, 116, 242, 58, 15, 144, 43, 76, 176, 107, 0, 138, 155, 235, 210, 138, 226, 215]), + Bytes32::new([98, 170, 168, 147, 158, 223, 186, 7, 58, 130, 89, 200, 153, 24, 158, 251, 69, 100, 7, 57, 96, 115, 136, 170, 57, 145, 143, 240, 102, 6, 248, 111]), + Bytes32::new([76, 75, 216, 216, 194, 146, 2, 59, 247, 64, 98, 160, 62, 105, 193, 186, 161, 191, 64, 154, 254, 196, 55, 214, 201, 103, 223, 131, 181, 192, 152, 176]), + Bytes32::new([188, 141, 114, 199, 33, 45, 183, 18, 123, 231, 92, 215, 51, 191, 11, 199, 253, 46, 28, 10, 156, 23, 92, 255, 219, 236, 176, 247, 52, 105, 210, 223]), + Bytes32::new([200, 67, 112, 29, 180, 70, 50, 18, 220, 122, 39, 122, 83, 186, 81, 77, 241, 44, 190, 3, 162, 217, 76, 61, 230, 237, 157, 230, 205, 172, 186, 247]), + Bytes32::new([131, 131, 129, 83, 251, 217, 83, 88, 93, 39, 66, 174, 51, 19, 190, 91, 16, 187, 95, 63, 35, 178, 94, 237, 194, 42, 231, 227, 138, 202, 216, 93]), + Bytes32::new([18, 177, 28, 41, 199, 59, 160, 244, 26, 162, 73, 48, 16, 74, 190, 195, 249, 216, 64, 229, 145, 65, 18, 131, 75, 57, 71, 74, 127, 239, 112, 13]), + Bytes32::new([41, 120, 53, 253, 151, 12, 143, 213, 212, 31, 245, 61, 168, 113, 30, 38, 112, 126, 156, 133, 241, 102, 110, 237, 4, 138, 50, 160, 79, 235, 52, 35]), + Bytes32::new([38, 74, 146, 27, 110, 86, 122, 250, 58, 243, 64, 185, 207, 174, 28, 124, 35, 183, 53, 88, 34, 234, 89, 58, 98, 223, 69, 13, 48, 15, 239, 230]), + Bytes32::new([221, 132, 1, 28, 157, 232, 235, 132, 32, 58, 26, 36, 60, 217, 197, 165, 141, 19, 64, 120, 197, 139, 190, 86, 153, 152, 235, 11, 99, 129, 222, 91]), + Bytes32::new([237, 76, 61, 239, 169, 108, 131, 62, 163, 67, 158, 210, 14, 45, 91, 105, 36, 182, 206, 182, 71, 11, 159, 169, 159, 248, 247, 176, 6, 176, 237, 123]), + Bytes32::new([232, 190, 198, 78, 12, 148, 86, 176, 221, 115, 1, 22, 122, 163, 223, 234, 74, 129, 125, 53, 211, 137, 115, 18, 241, 170, 69, 42, 34, 74, 180, 172]), + Bytes32::new([215, 199, 144, 158, 222, 153, 123, 125, 150, 97, 127, 151, 96, 43, 69, 155, 150, 119, 75, 82, 218, 48, 101, 70, 121, 18, 42, 146, 215, 183, 100, 158]), + Bytes32::new([121, 182, 45, 62, 255, 78, 32, 48, 107, 186, 208, 155, 158, 80, 231, 241, 90, 227, 219, 113, 52, 20, 66, 45, 124, 67, 209, 61, 167, 74, 60, 34]), + Bytes32::new([34, 136, 15, 103, 128, 220, 202, 103, 150, 123, 249, 145, 218, 227, 17, 64, 142, 129, 4, 42, 93, 7, 6, 147, 111, 117, 25, 185, 88, 104, 85, 115]), + Bytes32::new([144, 191, 235, 38, 205, 102, 127, 160, 139, 105, 75, 63, 86, 192, 194, 49, 240, 35, 65, 154, 4, 113, 51, 87, 40, 70, 32, 58, 243, 16, 136, 67]), + Bytes32::new([217, 150, 254, 250, 111, 69, 45, 227, 111, 59, 199, 149, 59, 216, 17, 117, 8, 226, 85, 250, 183, 187, 21, 129, 208, 0, 63, 158, 232, 106, 131, 16]), + Bytes32::new([148, 212, 84, 16, 204, 49, 69, 96, 137, 125, 102, 221, 111, 8, 41, 51, 221, 241, 87, 231, 88, 215, 211, 24, 254, 131, 111, 56, 160, 143, 230, 109]), + Bytes32::new([144, 48, 37, 157, 153, 7, 123, 206, 46, 224, 211, 249, 208, 217, 91, 243, 128, 62, 100, 126, 3, 253, 223, 161, 50, 108, 26, 151, 129, 242, 94, 132]), + Bytes32::new([97, 167, 177, 53, 183, 154, 164, 1, 129, 184, 234, 182, 190, 197, 244, 226, 150, 217, 57, 152, 243, 206, 60, 76, 114, 194, 51, 240, 58, 93, 219, 76]), + Bytes32::new([139, 70, 147, 227, 94, 147, 130, 53, 38, 112, 138, 176, 7, 148, 6, 21, 50, 199, 70, 33, 87, 180, 33, 167, 56, 89, 66, 95, 245, 247, 135, 24]), + Bytes32::new([175, 169, 204, 13, 145, 18, 40, 29, 84, 88, 206, 99, 208, 137, 249, 146, 0, 237, 188, 130, 135, 223, 121, 54, 126, 251, 247, 109, 141, 217, 62, 127]), + Bytes32::new([139, 188, 3, 234, 198, 124, 194, 238, 217, 237, 214, 250, 66, 220, 0, 51, 1, 203, 122, 125, 46, 213, 22, 253, 8, 218, 145, 253, 170, 156, 159, 96]), + Bytes32::new([107, 130, 208, 55, 16, 249, 46, 4, 98, 236, 130, 52, 190, 126, 232, 229, 108, 126, 239, 175, 25, 229, 84, 33, 249, 66, 128, 162, 47, 221, 110, 163]), + Bytes32::new([239, 176, 14, 134, 210, 125, 177, 40, 200, 42, 229, 32, 200, 58, 9, 73, 210, 161, 8, 105, 4, 70, 19, 134, 117, 132, 167, 18, 16, 108, 207, 113]), + Bytes32::new([237, 116, 250, 79, 151, 228, 171, 189, 89, 213, 122, 121, 55, 25, 52, 238, 79, 19, 31, 194, 73, 158, 43, 78, 86, 194, 36, 141, 105, 10, 87, 58]), + Bytes32::new([216, 125, 158, 123, 121, 158, 74, 152, 46, 18, 196, 115, 233, 149, 205, 189, 10, 232, 174, 21, 2, 52, 202, 111, 74, 160, 191, 196, 84, 93, 98, 46]), + Bytes32::new([201, 148, 124, 172, 62, 154, 127, 129, 205, 197, 134, 133, 144, 78, 47, 190, 197, 190, 103, 44, 129, 57, 155, 227, 152, 212, 130, 12, 192, 223, 244, 68]), + Bytes32::new([102, 147, 19, 104, 237, 188, 140, 66, 166, 77, 105, 55, 5, 165, 143, 107, 91, 247, 53, 203, 187, 163, 109, 66, 19, 164, 153, 170, 82, 251, 148, 10]), + Bytes32::new([33, 89, 246, 96, 201, 15, 77, 99, 252, 111, 250, 152, 124, 80, 50, 57, 197, 124, 254, 202, 246, 131, 11, 219, 249, 102, 35, 79, 100, 173, 146, 167]), + Bytes32::new([6, 27, 205, 165, 249, 112, 70, 105, 232, 156, 155, 204, 71, 5, 21, 239, 91, 69, 248, 111, 218, 154, 187, 85, 118, 72, 210, 99, 138, 40, 233, 75]), +]; + +const MODULE_HASHES: &[Bytes32; 64] = &[ + Bytes32::new([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), + Bytes32::new([252, 178, 61, 5, 174, 66, 106, 30, 131, 163, 114, 90, 231, 83, 228, 153, 108, 255, 60, 37, 254, 139, 153, 129, 208, 156, 109, 74, 233, 129, 174, 182]), + Bytes32::new([128, 23, 154, 62, 181, 220, 154, 183, 222, 214, 79, 76, 162, 169, 179, 162, 185, 93, 179, 115, 161, 55, 19, 63, 227, 168, 140, 66, 182, 6, 60, 120]), + Bytes32::new([243, 119, 126, 55, 151, 128, 119, 12, 124, 84, 146, 243, 156, 68, 82, 174, 201, 162, 29, 73, 29, 77, 103, 205, 194, 250, 45, 133, 39, 71, 224, 177]), + Bytes32::new([209, 179, 222, 187, 184, 84, 131, 182, 172, 78, 20, 104, 236, 246, 114, 74, 55, 98, 29, 34, 117, 249, 89, 76, 85, 38, 248, 193, 75, 10, 243, 100]), + Bytes32::new([195, 14, 58, 139, 148, 140, 218, 174, 131, 204, 69, 84, 127, 8, 142, 88, 136, 83, 253, 241, 74, 247, 143, 204, 38, 15, 138, 98, 47, 188, 255, 245]), + Bytes32::new([167, 4, 177, 126, 159, 76, 19, 220, 160, 159, 81, 227, 110, 147, 179, 175, 253, 187, 46, 24, 15, 168, 153, 84, 4, 167, 247, 225, 121, 175, 134, 85]), + Bytes32::new([237, 144, 152, 155, 211, 100, 202, 187, 41, 181, 45, 224, 143, 139, 18, 77, 110, 34, 212, 207, 239, 180, 73, 84, 166, 194, 22, 149, 89, 215, 86, 21]), + Bytes32::new([226, 192, 91, 176, 242, 185, 212, 189, 178, 80, 238, 252, 183, 82, 220, 242, 22, 237, 84, 142, 132, 91, 95, 219, 252, 171, 51, 76, 28, 146, 86, 155]), + Bytes32::new([199, 200, 237, 66, 220, 14, 221, 121, 117, 150, 118, 36, 138, 142, 50, 173, 12, 195, 131, 90, 27, 189, 247, 221, 89, 151, 41, 27, 135, 207, 137, 172]), + Bytes32::new([160, 60, 124, 200, 56, 240, 67, 161, 121, 95, 247, 51, 153, 249, 125, 88, 231, 2, 85, 167, 251, 187, 21, 103, 49, 132, 213, 52, 219, 30, 146, 59]), + Bytes32::new([123, 52, 142, 254, 117, 160, 215, 99, 155, 130, 134, 183, 76, 99, 166, 246, 49, 51, 142, 67, 116, 234, 69, 199, 201, 19, 70, 3, 208, 247, 40, 82]), + Bytes32::new([165, 32, 183, 79, 246, 224, 220, 103, 11, 160, 233, 66, 129, 238, 194, 73, 17, 37, 128, 185, 175, 88, 144, 228, 231, 185, 22, 17, 149, 174, 72, 1]), + Bytes32::new([12, 24, 45, 128, 57, 246, 187, 176, 154, 247, 169, 18, 116, 176, 70, 246, 203, 141, 211, 104, 5, 147, 78, 214, 161, 71, 33, 97, 7, 21, 158, 61]), + Bytes32::new([215, 18, 110, 29, 36, 34, 133, 219, 15, 204, 206, 158, 186, 213, 181, 41, 184, 160, 71, 165, 163, 121, 88, 106, 228, 58, 34, 105, 112, 168, 84, 123]), + Bytes32::new([6, 169, 156, 220, 55, 53, 26, 229, 104, 60, 113, 111, 153, 18, 251, 234, 179, 159, 56, 14, 112, 7, 144, 199, 45, 180, 116, 239, 21, 207, 173, 205]), + Bytes32::new([24, 172, 76, 192, 21, 91, 250, 75, 196, 119, 231, 221, 13, 239, 113, 39, 62, 40, 165, 26, 245, 16, 61, 106, 39, 28, 78, 212, 249, 230, 84, 108]), + Bytes32::new([248, 34, 1, 62, 213, 235, 20, 21, 220, 78, 178, 126, 184, 102, 242, 50, 49, 174, 163, 122, 166, 96, 40, 110, 78, 199, 89, 158, 155, 251, 233, 49]), + Bytes32::new([103, 54, 133, 19, 189, 117, 46, 209, 17, 2, 64, 251, 77, 195, 197, 91, 38, 48, 214, 36, 96, 255, 133, 87, 244, 101, 166, 218, 167, 129, 225, 167]), + Bytes32::new([196, 159, 226, 85, 100, 246, 179, 251, 133, 33, 114, 51, 104, 245, 81, 54, 137, 126, 245, 76, 112, 146, 139, 185, 190, 19, 106, 132, 48, 203, 34, 237]), + Bytes32::new([41, 190, 7, 23, 227, 80, 13, 134, 244, 18, 215, 148, 1, 72, 1, 22, 91, 165, 182, 69, 160, 179, 241, 106, 254, 116, 245, 131, 136, 35, 190, 226]), + Bytes32::new([205, 132, 211, 121, 67, 210, 191, 102, 218, 92, 56, 204, 68, 160, 188, 100, 229, 80, 77, 27, 26, 86, 248, 86, 216, 39, 242, 211, 183, 139, 219, 83]), + Bytes32::new([13, 215, 68, 100, 180, 74, 23, 58, 157, 140, 76, 31, 114, 254, 85, 78, 234, 40, 251, 199, 35, 204, 111, 243, 163, 64, 221, 21, 96, 55, 127, 118]), + Bytes32::new([225, 14, 246, 105, 64, 96, 225, 200, 186, 66, 40, 253, 131, 80, 102, 178, 83, 22, 150, 32, 15, 139, 76, 172, 144, 3, 30, 43, 217, 213, 89, 43]), + Bytes32::new([200, 83, 93, 27, 98, 246, 87, 100, 53, 166, 89, 138, 157, 88, 148, 245, 61, 115, 246, 20, 142, 156, 54, 237, 179, 64, 148, 218, 67, 5, 142, 248]), + Bytes32::new([159, 25, 150, 25, 114, 252, 162, 57, 21, 125, 147, 111, 220, 117, 17, 107, 40, 21, 157, 183, 6, 63, 226, 37, 64, 179, 133, 58, 107, 245, 78, 14]), + Bytes32::new([58, 243, 16, 193, 174, 42, 255, 46, 40, 128, 26, 167, 173, 164, 71, 226, 155, 205, 26, 127, 154, 24, 74, 244, 106, 251, 25, 221, 197, 176, 194, 17]), + Bytes32::new([51, 47, 251, 206, 27, 9, 142, 27, 253, 132, 189, 62, 109, 150, 246, 2, 137, 90, 157, 185, 59, 96, 0, 154, 29, 17, 231, 3, 84, 95, 49, 51]), + Bytes32::new([250, 158, 158, 248, 206, 150, 95, 254, 53, 140, 80, 102, 67, 26, 76, 127, 236, 86, 182, 120, 72, 239, 190, 118, 60, 77, 28, 82, 152, 234, 73, 201]), + Bytes32::new([255, 137, 155, 144, 74, 231, 231, 43, 187, 202, 137, 66, 205, 37, 40, 225, 0, 33, 87, 137, 113, 163, 58, 64, 147, 74, 123, 128, 19, 156, 46, 83]), + Bytes32::new([207, 61, 79, 4, 202, 96, 238, 144, 154, 230, 145, 65, 230, 130, 246, 10, 140, 71, 66, 246, 53, 230, 148, 1, 248, 103, 145, 149, 157, 38, 169, 8]), + Bytes32::new([33, 168, 110, 82, 84, 151, 70, 98, 115, 2, 221, 116, 210, 10, 247, 189, 203, 245, 186, 86, 121, 142, 218, 95, 68, 241, 21, 219, 131, 241, 185, 203]), + Bytes32::new([125, 247, 7, 149, 181, 71, 68, 141, 123, 207, 144, 83, 170, 27, 244, 37, 210, 148, 0, 140, 144, 159, 237, 216, 227, 247, 85, 229, 80, 174, 40, 48]), + Bytes32::new([0, 205, 68, 89, 77, 97, 204, 140, 113, 244, 168, 76, 49, 137, 236, 21, 132, 99, 10, 206, 195, 206, 208, 120, 227, 77, 21, 223, 145, 227, 48, 139]), + Bytes32::new([10, 153, 106, 155, 149, 65, 211, 247, 246, 5, 129, 126, 74, 14, 113, 168, 152, 154, 205, 139, 49, 2, 182, 65, 163, 15, 62, 126, 62, 16, 26, 36]), + Bytes32::new([24, 251, 204, 187, 179, 146, 114, 66, 110, 182, 131, 248, 36, 170, 169, 128, 22, 221, 134, 193, 121, 189, 128, 94, 83, 255, 226, 37, 133, 83, 220, 181]), + Bytes32::new([25, 52, 245, 155, 53, 39, 73, 130, 12, 73, 106, 255, 44, 204, 208, 41, 32, 126, 159, 98, 197, 67, 58, 90, 6, 146, 25, 166, 195, 194, 215, 70]), + Bytes32::new([194, 167, 206, 222, 96, 6, 86, 241, 95, 105, 225, 147, 99, 93, 201, 220, 166, 145, 4, 25, 168, 188, 21, 168, 80, 163, 132, 216, 239, 19, 115, 36]), + Bytes32::new([243, 16, 4, 9, 140, 42, 62, 105, 97, 7, 4, 234, 200, 227, 42, 10, 51, 167, 38, 148, 69, 154, 143, 179, 94, 177, 248, 28, 33, 61, 166, 187]), + Bytes32::new([156, 201, 97, 197, 223, 83, 229, 186, 187, 33, 49, 210, 181, 222, 180, 234, 150, 33, 99, 168, 157, 26, 241, 1, 213, 220, 165, 8, 31, 76, 134, 243]), + Bytes32::new([34, 218, 29, 74, 212, 218, 95, 6, 53, 10, 63, 174, 119, 90, 90, 35, 92, 124, 169, 222, 75, 61, 199, 118, 132, 40, 193, 9, 250, 80, 12, 197]), + Bytes32::new([102, 137, 75, 155, 181, 222, 86, 192, 140, 167, 3, 178, 212, 165, 49, 163, 86, 8, 76, 240, 32, 202, 34, 159, 217, 173, 101, 125, 237, 34, 48, 179]), + Bytes32::new([136, 53, 156, 19, 107, 234, 210, 218, 180, 236, 9, 7, 80, 63, 146, 57, 77, 106, 135, 64, 23, 184, 9, 139, 61, 237, 225, 157, 183, 182, 137, 31]), + Bytes32::new([237, 226, 115, 218, 228, 122, 45, 46, 67, 21, 130, 204, 80, 2, 28, 47, 148, 191, 28, 33, 177, 47, 207, 14, 33, 117, 28, 46, 88, 254, 97, 227]), + Bytes32::new([38, 87, 252, 28, 105, 20, 117, 29, 234, 237, 60, 91, 48, 101, 219, 219, 24, 52, 169, 243, 71, 214, 117, 41, 207, 17, 148, 77, 218, 44, 122, 167]), + Bytes32::new([235, 31, 185, 222, 3, 22, 222, 174, 126, 128, 55, 67, 201, 229, 55, 28, 241, 144, 184, 85, 141, 153, 183, 211, 66, 80, 152, 248, 214, 130, 64, 205]), + Bytes32::new([52, 169, 226, 179, 195, 44, 245, 101, 35, 92, 145, 174, 152, 212, 192, 148, 241, 72, 248, 61, 239, 124, 98, 213, 181, 75, 84, 121, 57, 90, 172, 164]), + Bytes32::new([27, 19, 12, 74, 128, 193, 65, 63, 15, 6, 174, 167, 79, 56, 88, 13, 117, 6, 189, 14, 11, 13, 133, 136, 141, 64, 74, 17, 159, 192, 251, 242]), + Bytes32::new([101, 69, 132, 221, 127, 162, 162, 92, 248, 131, 39, 52, 169, 170, 231, 137, 123, 106, 161, 16, 202, 242, 216, 245, 211, 170, 74, 128, 108, 243, 166, 38]), + Bytes32::new([157, 82, 193, 234, 117, 199, 118, 245, 63, 31, 186, 32, 135, 233, 29, 213, 217, 119, 208, 64, 149, 116, 117, 129, 211, 225, 207, 22, 225, 99, 194, 222]), + Bytes32::new([112, 194, 64, 229, 154, 223, 109, 8, 191, 120, 32, 176, 154, 7, 174, 103, 2, 156, 230, 164, 245, 252, 0, 116, 213, 40, 20, 239, 135, 62, 198, 42]), + Bytes32::new([32, 91, 5, 170, 221, 134, 167, 144, 16, 130, 237, 114, 71, 184, 131, 223, 92, 149, 161, 68, 196, 56, 73, 148, 203, 187, 174, 178, 178, 53, 156, 177]), + Bytes32::new([234, 97, 64, 211, 81, 59, 14, 249, 38, 8, 247, 37, 243, 37, 88, 234, 19, 54, 146, 63, 88, 79, 127, 190, 144, 51, 240, 19, 15, 143, 18, 9]), + Bytes32::new([247, 102, 43, 28, 24, 201, 189, 198, 66, 58, 210, 51, 174, 234, 52, 239, 37, 83, 212, 184, 127, 170, 168, 127, 47, 11, 248, 213, 84, 3, 201, 181]), + Bytes32::new([126, 18, 116, 33, 129, 25, 247, 2, 162, 202, 103, 201, 237, 67, 28, 80, 46, 182, 163, 239, 90, 204, 47, 196, 137, 79, 19, 165, 209, 84, 140, 132]), + Bytes32::new([189, 160, 148, 101, 82, 248, 215, 206, 90, 91, 205, 148, 37, 38, 172, 82, 223, 228, 66, 173, 220, 246, 194, 73, 231, 17, 220, 47, 222, 175, 7, 24]), + Bytes32::new([237, 149, 54, 210, 99, 72, 182, 55, 69, 140, 161, 215, 104, 90, 104, 26, 216, 241, 232, 210, 37, 77, 56, 216, 6, 160, 199, 247, 164, 227, 142, 255]), + Bytes32::new([11, 57, 131, 77, 203, 89, 156, 126, 200, 215, 103, 209, 70, 235, 78, 247, 0, 126, 209, 248, 220, 135, 158, 244, 141, 74, 6, 158, 19, 37, 42, 39]), + Bytes32::new([107, 131, 231, 102, 64, 182, 78, 253, 77, 143, 94, 34, 199, 93, 44, 131, 169, 211, 71, 223, 53, 230, 59, 107, 146, 22, 188, 207, 210, 220, 168, 129]), + Bytes32::new([78, 71, 246, 216, 154, 188, 152, 6, 234, 254, 21, 1, 128, 148, 56, 91, 250, 95, 76, 103, 15, 250, 137, 186, 114, 254, 122, 69, 208, 242, 69, 111]), + Bytes32::new([82, 241, 242, 155, 248, 109, 84, 118, 225, 255, 122, 40, 3, 87, 20, 223, 212, 205, 141, 178, 32, 229, 234, 146, 101, 73, 79, 55, 28, 82, 81, 178]), + Bytes32::new([35, 169, 243, 198, 215, 220, 113, 91, 6, 79, 48, 201, 97, 143, 212, 34, 247, 46, 38, 93, 166, 213, 158, 218, 61, 86, 240, 149, 224, 174, 225, 73]), + Bytes32::new([25, 108, 21, 212, 193, 192, 96, 39, 57, 72, 193, 99, 239, 0, 231, 83, 183, 195, 105, 33, 220, 187, 18, 148, 43, 30, 42, 127, 192, 240, 13, 224]), + Bytes32::new([119, 117, 186, 31, 43, 128, 143, 25, 182, 135, 156, 58, 152, 81, 70, 116, 171, 137, 125, 157, 152, 163, 34, 65, 240, 178, 12, 24, 168, 111, 39, 35]), +]; -lazy_static! { - pub static ref ZERO_HASHES: HashMap> = { - let mut zero_hashes = HashMap::new(); - zero_hashes.insert(MerkleType::Value, vec![ - Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::from([119, 47, 167, 222, 218, 156, 26, 105, 57, 248, 170, 182, 183, 151, 18, 150, 142, 70, 138, 253, 54, 123, 132, 86, 170, 76, 157, 52, 113, 138, 253, 254]), - Bytes32::from([8, 117, 27, 211, 196, 42, 6, 98, 185, 88, 231, 145, 14, 3, 207, 145, 158, 255, 69, 52, 198, 196, 148, 154, 59, 94, 229, 157, 93, 51, 200, 69]), - Bytes32::from([247, 208, 196, 206, 204, 168, 129, 100, 238, 95, 52, 26, 132, 138, 233, 149, 196, 72, 179, 226, 60, 114, 27, 94, 173, 189, 197, 100, 163, 232, 180, 63]), - Bytes32::from([178, 100, 198, 112, 40, 33, 187, 175, 130, 245, 59, 210, 133, 234, 158, 158, 133, 64, 213, 72, 222, 157, 216, 42, 210, 134, 36, 13, 211, 156, 163, 211]), - Bytes32::from([203, 127, 32, 130, 225, 40, 219, 15, 35, 236, 47, 201, 161, 48, 53, 145, 134, 169, 109, 29, 26, 29, 178, 201, 118, 217, 57, 165, 116, 172, 232, 4]), - Bytes32::from([209, 109, 33, 102, 227, 251, 133, 224, 170, 130, 65, 90, 185, 209, 146, 77, 244, 145, 181, 206, 159, 70, 209, 64, 241, 19, 149, 223, 138, 31, 163, 61]), - Bytes32::from([145, 168, 124, 48, 254, 12, 34, 41, 4, 213, 245, 86, 61, 29, 177, 192, 67, 165, 237, 236, 87, 126, 193, 191, 15, 126, 104, 173, 165, 186, 1, 107]), - Bytes32::from([235, 161, 247, 143, 69, 95, 210, 40, 243, 76, 102, 29, 118, 86, 180, 54, 81, 144, 103, 54, 202, 164, 81, 83, 180, 90, 154, 184, 54, 28, 7, 220]), - Bytes32::from([203, 62, 12, 83, 35, 122, 214, 199, 125, 61, 236, 8, 253, 64, 145, 34, 127, 116, 217, 118, 245, 107, 15, 81, 9, 7, 31, 154, 89, 28, 123, 132]), - Bytes32::from([222, 94, 234, 109, 142, 74, 142, 176, 248, 3, 172, 30, 204, 138, 241, 195, 121, 232, 104, 219, 32, 54, 240, 77, 125, 247, 70, 137, 80, 46, 221, 247]), - Bytes32::from([162, 122, 237, 101, 178, 31, 12, 62, 50, 133, 242, 82, 111, 215, 166, 136, 138, 185, 72, 220, 163, 58, 58, 97, 6, 97, 167, 114, 179, 227, 19, 170]), - Bytes32::from([67, 251, 144, 11, 175, 194, 149, 65, 173, 179, 69, 140, 213, 191, 133, 59, 81, 175, 161, 115, 252, 125, 232, 150, 52, 241, 102, 164, 122, 32, 70, 229]), - Bytes32::from([249, 161, 115, 93, 215, 247, 145, 182, 75, 191, 48, 38, 123, 220, 232, 47, 246, 46, 81, 164, 98, 41, 141, 249, 137, 173, 93, 213, 96, 15, 151, 245]), - Bytes32::from([222, 93, 144, 194, 107, 42, 144, 4, 242, 153, 203, 176, 146, 242, 94, 72, 9, 222, 194, 2, 73, 200, 167, 147, 106, 9, 67, 73, 59, 127, 174, 178]), - Bytes32::from([56, 228, 248, 59, 153, 215, 120, 224, 111, 48, 159, 82, 171, 227, 93, 214, 208, 151, 78, 67, 112, 31, 218, 94, 219, 3, 79, 250, 227, 24, 222, 207]), - Bytes32::from([26, 171, 68, 22, 162, 195, 65, 97, 219, 55, 51, 46, 178, 6, 247, 65, 123, 219, 128, 86, 193, 3, 253, 0, 239, 228, 187, 94, 184, 240, 67, 11]), - Bytes32::from([250, 36, 5, 131, 94, 0, 99, 187, 112, 155, 252, 52, 68, 236, 185, 152, 93, 239, 0, 185, 101, 101, 182, 92, 112, 5, 67, 55, 121, 203, 100, 245]), - Bytes32::from([208, 57, 149, 71, 227, 213, 246, 213, 175, 88, 95, 238, 93, 122, 168, 223, 149, 84, 30, 89, 98, 228, 113, 72, 90, 48, 112, 171, 231, 67, 113, 216]), - Bytes32::from([125, 48, 157, 119, 154, 38, 14, 211, 223, 68, 87, 187, 159, 126, 234, 72, 84, 60, 236, 237, 227, 130, 87, 43, 217, 105, 81, 196, 159, 238, 240, 10]), - Bytes32::from([141, 217, 59, 213, 245, 231, 7, 85, 178, 197, 115, 188, 31, 49, 126, 237, 83, 199, 56, 196, 133, 169, 239, 218, 90, 131, 178, 70, 126, 132, 114, 186]), - Bytes32::from([18, 2, 140, 12, 121, 238, 8, 160, 7, 208, 89, 194, 105, 136, 211, 58, 179, 200, 226, 138, 186, 242, 4, 237, 18, 113, 131, 135, 31, 222, 28, 195]), - Bytes32::from([156, 222, 183, 39, 119, 110, 130, 60, 33, 221, 36, 39, 223, 155, 33, 2, 71, 32, 209, 25, 194, 172, 209, 1, 40, 105, 235, 140, 160, 18, 63, 168]), - Bytes32::from([211, 210, 123, 27, 217, 111, 97, 42, 167, 191, 112, 239, 66, 42, 199, 131, 124, 213, 89, 56, 92, 245, 166, 238, 185, 42, 48, 2, 113, 255, 156, 7]), - Bytes32::from([66, 255, 87, 69, 86, 6, 54, 162, 162, 5, 93, 138, 194, 194, 151, 195, 57, 155, 58, 17, 21, 149, 77, 2, 134, 107, 125, 54, 220, 247, 160, 209]), - Bytes32::from([169, 216, 13, 41, 251, 216, 191, 87, 91, 55, 236, 6, 242, 103, 98, 209, 46, 202, 29, 55, 2, 50, 233, 76, 107, 92, 82, 156, 113, 226, 78, 211]), - Bytes32::from([88, 189, 113, 129, 119, 11, 141, 60, 128, 134, 113, 107, 7, 186, 81, 200, 14, 76, 197, 14, 96, 19, 247, 220, 95, 62, 81, 153, 61, 231, 26, 86]), - Bytes32::from([41, 214, 41, 96, 151, 11, 231, 7, 203, 70, 242, 156, 247, 133, 49, 223, 254, 164, 202, 154, 188, 104, 124, 120, 225, 229, 148, 203, 141, 218, 228, 56]), - Bytes32::from([181, 157, 136, 110, 158, 152, 105, 61, 125, 220, 32, 180, 53, 115, 155, 189, 91, 152, 96, 172, 7, 121, 65, 143, 82, 180, 3, 69, 118, 219, 31, 244]), - Bytes32::from([29, 12, 159, 30, 12, 37, 126, 102, 218, 149, 67, 116, 182, 125, 134, 208, 184, 199, 181, 191, 87, 144, 48, 150, 87, 67, 222, 218, 254, 118, 12, 160]), - Bytes32::from([193, 249, 209, 245, 102, 95, 15, 55, 160, 156, 203, 160, 49, 198, 203, 30, 99, 172, 89, 92, 235, 89, 131, 205, 53, 254, 219, 168, 202, 195, 10, 242]), - Bytes32::from([131, 64, 102, 7, 226, 96, 60, 111, 221, 120, 41, 86, 239, 157, 121, 38, 57, 244, 221, 55, 32, 237, 13, 20, 244, 238, 133, 189, 89, 118, 204, 247]), - Bytes32::from([239, 211, 89, 185, 191, 211, 243, 207, 134, 159, 59, 19, 87, 254, 115, 27, 152, 156, 120, 226, 39, 63, 155, 51, 77, 130, 162, 63, 16, 43, 112, 121]), - Bytes32::from([10, 146, 190, 23, 235, 67, 23, 169, 33, 140, 54, 209, 129, 176, 29, 218, 40, 55, 13, 80, 57, 68, 92, 97, 44, 82, 209, 240, 207, 214, 22, 119]), - Bytes32::from([59, 161, 125, 95, 7, 155, 141, 55, 253, 106, 238, 72, 109, 158, 201, 200, 236, 157, 227, 178, 176, 47, 166, 84, 87, 111, 25, 133, 194, 55, 244, 254]), - Bytes32::from([8, 134, 213, 182, 108, 15, 225, 138, 152, 138, 132, 240, 27, 80, 231, 117, 194, 157, 205, 20, 110, 239, 166, 37, 50, 46, 213, 165, 216, 101, 245, 98]), - Bytes32::from([137, 57, 186, 173, 198, 113, 221, 42, 0, 211, 127, 200, 128, 7, 112, 97, 75, 155, 152, 224, 71, 220, 16, 124, 32, 50, 30, 48, 251, 132, 120, 147]), - Bytes32::from([201, 8, 226, 108, 147, 192, 3, 240, 168, 237, 131, 47, 150, 51, 251, 126, 23, 182, 223, 99, 162, 167, 248, 248, 233, 8, 121, 99, 71, 212, 120, 251]), - Bytes32::from([140, 30, 196, 244, 166, 80, 95, 116, 140, 218, 94, 20, 236, 233, 241, 129, 175, 187, 110, 88, 174, 173, 152, 203, 67, 75, 51, 232, 225, 6, 17, 134]), - Bytes32::from([92, 132, 115, 164, 66, 159, 201, 147, 233, 228, 16, 95, 81, 233, 129, 254, 155, 148, 38, 239, 186, 40, 118, 104, 144, 134, 17, 46, 99, 150, 211, 9]), - Bytes32::from([81, 73, 72, 117, 215, 159, 240, 86, 136, 196, 69, 201, 149, 208, 48, 245, 105, 153, 97, 107, 221, 85, 49, 121, 197, 129, 32, 140, 206, 231, 120, 123]), - Bytes32::from([0, 203, 34, 135, 242, 129, 113, 204, 198, 134, 219, 134, 187, 240, 235, 59, 44, 163, 180, 83, 174, 40, 66, 141, 95, 99, 71, 221, 186, 216, 37, 250]), - Bytes32::from([225, 181, 151, 12, 26, 209, 127, 99, 248, 177, 126, 113, 215, 220, 252, 89, 149, 123, 19, 65, 89, 122, 180, 169, 195, 87, 147, 9, 196, 31, 203, 178]), - Bytes32::from([125, 81, 154, 100, 204, 138, 194, 248, 156, 95, 119, 58, 60, 221, 150, 248, 216, 19, 123, 15, 198, 108, 228, 228, 224, 122, 16, 249, 223, 84, 117, 89]), - Bytes32::from([99, 153, 60, 217, 168, 254, 244, 149, 214, 115, 250, 90, 117, 112, 66, 163, 143, 207, 121, 70, 108, 92, 2, 47, 56, 109, 56, 207, 152, 27, 196, 141]), - Bytes32::from([99, 251, 124, 97, 158, 155, 101, 251, 98, 124, 239, 73, 50, 50, 173, 142, 39, 208, 167, 53, 5, 151, 85, 239, 25, 77, 36, 52, 141, 225, 66, 186]), - Bytes32::from([235, 44, 31, 180, 197, 243, 114, 60, 199, 242, 167, 21, 206, 27, 116, 165, 18, 76, 162, 163, 14, 91, 109, 104, 118, 51, 33, 172, 9, 165, 214, 38]), - Bytes32::from([188, 4, 5, 50, 169, 70, 231, 90, 220, 90, 226, 214, 89, 19, 159, 207, 201, 80, 241, 214, 32, 240, 63, 74, 6, 251, 177, 182, 236, 19, 156, 92]), - Bytes32::from([128, 150, 66, 27, 197, 229, 103, 137, 175, 252, 19, 131, 213, 63, 112, 172, 182, 255, 235, 246, 226, 37, 25, 180, 24, 38, 35, 138, 207, 149, 186, 175]), - Bytes32::from([5, 123, 231, 106, 12, 171, 157, 189, 58, 109, 144, 7, 38, 97, 4, 148, 1, 138, 124, 123, 2, 202, 108, 221, 194, 160, 53, 73, 115, 36, 231, 142]), - Bytes32::from([160, 157, 243, 224, 214, 120, 59, 206, 24, 30, 231, 209, 123, 227, 15, 221, 86, 30, 128, 117, 210, 109, 132, 117, 204, 87, 243, 213, 231, 224, 91, 75]), - Bytes32::from([74, 238, 110, 147, 63, 110, 246, 102, 252, 212, 120, 225, 124, 218, 145, 204, 129, 63, 13, 34, 1, 0, 15, 9, 27, 221, 39, 199, 24, 231, 9, 38]), - Bytes32::from([194, 20, 160, 161, 90, 2, 118, 75, 103, 228, 51, 42, 191, 220, 63, 150, 140, 32, 85, 172, 218, 29, 251, 31, 99, 96, 98, 46, 130, 157, 201, 61]), - Bytes32::from([88, 123, 95, 139, 94, 66, 69, 27, 223, 223, 216, 130, 99, 210, 130, 54, 248, 35, 226, 252, 151, 238, 7, 175, 12, 97, 188, 43, 233, 129, 82, 222]), - Bytes32::from([179, 248, 157, 243, 50, 157, 172, 17, 139, 10, 245, 208, 241, 210, 67, 199, 135, 233, 234, 39, 127, 38, 54, 39, 40, 159, 94, 122, 36, 221, 180, 195]), - Bytes32::from([190, 185, 147, 237, 82, 32, 165, 236, 252, 183, 173, 181, 68, 44, 216, 20, 110, 243, 158, 213, 88, 209, 218, 207, 244, 241, 121, 239, 136, 167, 245, 155]), - Bytes32::from([114, 131, 254, 248, 183, 0, 175, 217, 194, 58, 178, 238, 250, 119, 158, 205, 19, 74, 94, 35, 100, 175, 114, 55, 186, 192, 239, 126, 42, 86, 60, 119]), - Bytes32::from([1, 253, 107, 150, 25, 240, 27, 172, 252, 185, 151, 152, 107, 105, 164, 230, 221, 242, 7, 166, 142, 53, 237, 83, 19, 30, 81, 149, 150, 39, 123, 220]), - Bytes32::from([57, 240, 92, 232, 26, 238, 69, 252, 110, 171, 164, 109, 199, 73, 110, 49, 11, 253, 109, 69, 155, 26, 84, 52, 155, 204, 115, 99, 90, 38, 247, 167]), - Bytes32::from([46, 87, 146, 25, 215, 40, 208, 78, 73, 60, 35, 19, 194, 41, 34, 186, 215, 131, 205, 29, 107, 100, 95, 169, 45, 1, 242, 115, 30, 226, 93, 48]), - Bytes32::from([95, 183, 66, 0, 196, 173, 44, 27, 175, 151, 17, 0, 159, 168, 123, 236, 124, 198, 85, 181, 118, 89, 21, 52, 169, 104, 178, 111, 120, 173, 94, 109]), - Bytes32::from([13, 111, 162, 25, 133, 108, 250, 75, 197, 221, 19, 160, 147, 36, 130, 70, 224, 39, 134, 144, 149, 166, 187, 96, 155, 154, 123, 90, 241, 154, 44, 102]), - Bytes32::from([95, 171, 183, 135, 121, 205, 161, 160, 212, 226, 64, 232, 180, 166, 176, 95, 51, 96, 110, 20, 76, 143, 47, 96, 197, 132, 210, 109, 174, 132, 13, 95]), - Bytes32::from([66, 51, 176, 1, 106, 199, 192, 16, 106, 180, 212, 53, 72, 121, 218, 148, 77, 26, 15, 244, 124, 131, 88, 84, 147, 211, 254, 156, 187, 91, 193, 120]) - ]); - zero_hashes.insert(MerkleType::Function, vec![ - Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::from([239, 247, 49, 255, 201, 159, 228, 149, 22, 115, 41, 139, 56, 117, 149, 46, 67, 155, 98, 70, 216, 225, 85, 100, 113, 242, 144, 167, 97, 238, 117, 207]), - Bytes32::from([46, 87, 136, 101, 122, 12, 6, 120, 39, 121, 167, 193, 66, 146, 150, 1, 90, 240, 97, 225, 179, 150, 197, 127, 56, 214, 116, 24, 180, 109, 96, 51]), - Bytes32::from([54, 125, 90, 195, 243, 1, 115, 18, 251, 68, 203, 216, 48, 156, 216, 200, 215, 250, 80, 152, 203, 58, 245, 128, 70, 112, 221, 104, 34, 125, 234, 138]), - Bytes32::from([103, 99, 44, 86, 57, 0, 102, 201, 99, 214, 249, 24, 45, 112, 234, 183, 225, 196, 9, 162, 168, 33, 121, 118, 93, 184, 14, 70, 148, 135, 211, 214]), - Bytes32::from([69, 7, 89, 47, 41, 94, 148, 139, 67, 197, 99, 98, 100, 63, 25, 230, 100, 118, 213, 25, 28, 129, 5, 39, 69, 89, 71, 21, 102, 84, 101, 175]), - Bytes32::from([232, 195, 82, 123, 189, 200, 139, 61, 179, 141, 208, 69, 102, 58, 127, 66, 69, 127, 7, 179, 108, 128, 253, 154, 207, 254, 201, 18, 192, 241, 99, 208]), - Bytes32::from([138, 25, 185, 215, 159, 159, 214, 251, 161, 103, 180, 78, 209, 215, 131, 132, 134, 180, 177, 37, 79, 219, 19, 93, 45, 30, 53, 125, 142, 194, 114, 34]), - Bytes32::from([185, 24, 200, 28, 68, 7, 118, 226, 65, 240, 85, 120, 123, 174, 239, 85, 247, 210, 104, 247, 20, 229, 41, 91, 242, 5, 2, 121, 132, 69, 43, 33]), - Bytes32::from([78, 191, 92, 97, 205, 120, 114, 216, 112, 101, 44, 98, 148, 2, 112, 221, 168, 199, 254, 55, 160, 116, 116, 105, 109, 227, 130, 219, 194, 32, 209, 196]), - Bytes32::from([177, 203, 26, 1, 216, 115, 242, 158, 202, 107, 60, 221, 81, 167, 8, 233, 247, 235, 49, 54, 45, 133, 202, 193, 34, 158, 205, 29, 232, 245, 195, 194]), - Bytes32::from([193, 118, 182, 153, 10, 237, 67, 229, 136, 193, 253, 250, 46, 125, 141, 22, 107, 168, 74, 130, 60, 193, 194, 196, 249, 129, 153, 82, 162, 143, 188, 42]), - Bytes32::from([239, 57, 105, 90, 116, 61, 160, 214, 55, 191, 17, 228, 44, 149, 103, 180, 229, 4, 175, 240, 209, 231, 141, 95, 109, 195, 78, 142, 122, 177, 227, 20]), - Bytes32::from([153, 247, 105, 126, 178, 44, 190, 57, 12, 63, 169, 27, 206, 19, 151, 38, 33, 83, 35, 3, 177, 97, 36, 182, 37, 78, 150, 243, 222, 32, 180, 148]), - Bytes32::from([29, 109, 110, 167, 27, 136, 235, 226, 147, 175, 241, 236, 138, 135, 163, 200, 21, 94, 220, 238, 23, 84, 46, 14, 44, 100, 47, 131, 134, 43, 98, 173]), - Bytes32::from([73, 241, 108, 102, 184, 200, 64, 80, 58, 162, 29, 211, 173, 150, 6, 195, 2, 137, 246, 51, 155, 132, 41, 255, 21, 71, 74, 143, 197, 180, 217, 159]), - Bytes32::from([109, 189, 226, 33, 70, 157, 161, 166, 223, 31, 224, 221, 37, 112, 27, 215, 163, 250, 217, 155, 168, 121, 119, 232, 100, 177, 104, 210, 10, 118, 215, 0]), - Bytes32::from([175, 156, 32, 156, 238, 82, 62, 25, 96, 251, 146, 24, 13, 2, 115, 174, 163, 50, 14, 251, 196, 173, 5, 87, 171, 228, 191, 9, 90, 84, 156, 63]), - Bytes32::from([244, 161, 238, 217, 14, 60, 162, 139, 34, 84, 68, 121, 213, 11, 230, 95, 57, 221, 174, 107, 103, 105, 76, 137, 58, 247, 65, 209, 167, 63, 96, 212]), - Bytes32::from([31, 177, 221, 130, 152, 92, 190, 4, 59, 90, 122, 63, 128, 180, 140, 201, 75, 239, 200, 151, 94, 65, 36, 227, 21, 250, 10, 253, 26, 114, 238, 188]), - Bytes32::from([48, 216, 87, 30, 113, 214, 69, 1, 9, 112, 244, 232, 127, 55, 43, 162, 156, 83, 235, 199, 126, 132, 241, 106, 65, 209, 240, 32, 11, 179, 219, 135]), - Bytes32::from([20, 55, 225, 132, 0, 219, 175, 17, 235, 73, 236, 16, 24, 227, 250, 155, 32, 83, 234, 123, 191, 209, 157, 133, 215, 202, 3, 221, 135, 223, 221, 90]), - Bytes32::from([113, 185, 118, 164, 139, 219, 203, 140, 245, 123, 21, 186, 102, 22, 54, 14, 19, 230, 223, 120, 211, 114, 203, 77, 173, 214, 61, 80, 151, 10, 2, 205]), - Bytes32::from([50, 20, 214, 105, 232, 5, 9, 101, 16, 72, 46, 139, 177, 188, 25, 93, 14, 57, 60, 168, 49, 147, 134, 5, 62, 181, 120, 75, 193, 229, 107, 67]), - Bytes32::from([92, 167, 117, 18, 186, 193, 28, 56, 86, 25, 75, 64, 1, 8, 126, 212, 56, 163, 157, 242, 34, 73, 65, 58, 187, 2, 112, 58, 225, 229, 113, 58]), - Bytes32::from([173, 139, 156, 215, 250, 231, 15, 123, 8, 5, 98, 192, 164, 48, 106, 203, 152, 189, 118, 120, 245, 221, 214, 26, 79, 39, 148, 232, 217, 88, 34, 246]), - Bytes32::from([8, 207, 11, 196, 253, 51, 182, 90, 62, 110, 125, 142, 209, 154, 5, 203, 252, 62, 117, 215, 226, 136, 140, 201, 227, 210, 71, 34, 113, 160, 42, 68]), - Bytes32::from([108, 135, 226, 117, 179, 142, 93, 181, 20, 186, 189, 217, 49, 154, 66, 244, 180, 170, 122, 233, 153, 214, 104, 71, 44, 57, 103, 240, 97, 80, 170, 198]), - Bytes32::from([123, 168, 184, 254, 241, 78, 23, 91, 32, 77, 218, 176, 179, 189, 61, 162, 114, 158, 212, 7, 201, 15, 58, 4, 161, 211, 188, 156, 190, 2, 20, 183]), - Bytes32::from([60, 170, 86, 130, 38, 170, 202, 88, 97, 206, 67, 69, 140, 122, 201, 38, 70, 229, 144, 202, 146, 10, 146, 148, 21, 247, 119, 196, 150, 223, 110, 67]), - Bytes32::from([102, 154, 215, 132, 143, 248, 151, 101, 101, 253, 80, 211, 254, 64, 179, 73, 96, 132, 144, 216, 225, 130, 48, 56, 14, 39, 97, 223, 134, 10, 124, 138]), - Bytes32::from([197, 131, 194, 166, 168, 160, 24, 116, 47, 120, 89, 3, 44, 154, 83, 250, 142, 64, 77, 63, 15, 60, 97, 100, 150, 39, 227, 139, 42, 146, 146, 104]), - Bytes32::from([7, 160, 246, 93, 64, 79, 76, 208, 66, 80, 60, 123, 13, 51, 115, 251, 196, 209, 145, 106, 61, 105, 136, 58, 7, 129, 142, 203, 205, 69, 45, 203]), - Bytes32::from([64, 162, 48, 187, 213, 182, 41, 85, 62, 148, 26, 161, 227, 108, 173, 249, 195, 106, 203, 18, 28, 59, 184, 85, 249, 16, 224, 222, 114, 200, 99, 22]), - Bytes32::from([246, 194, 74, 122, 165, 216, 211, 144, 101, 143, 134, 9, 53, 229, 197, 227, 121, 248, 89, 169, 48, 220, 104, 216, 117, 118, 36, 234, 108, 135, 81, 162]), - Bytes32::from([232, 59, 196, 2, 103, 242, 44, 129, 41, 231, 226, 115, 238, 151, 166, 210, 158, 110, 43, 45, 86, 163, 127, 8, 162, 81, 131, 145, 165, 252, 170, 12]), - Bytes32::from([204, 88, 102, 180, 241, 148, 27, 183, 223, 71, 157, 119, 155, 31, 102, 239, 4, 83, 204, 246, 38, 228, 234, 20, 97, 233, 203, 149, 186, 67, 143, 51]), - Bytes32::from([246, 170, 233, 8, 202, 38, 67, 219, 175, 13, 250, 174, 98, 36, 84, 166, 6, 75, 27, 43, 62, 128, 106, 23, 163, 191, 86, 115, 164, 50, 127, 151]), - Bytes32::from([204, 72, 199, 57, 106, 136, 244, 66, 217, 155, 183, 211, 166, 71, 140, 211, 210, 181, 178, 218, 204, 91, 200, 204, 153, 60, 22, 32, 24, 153, 131, 31]), - Bytes32::from([204, 193, 13, 167, 214, 136, 121, 99, 198, 137, 11, 223, 85, 40, 167, 126, 153, 80, 187, 35, 226, 31, 226, 42, 9, 175, 31, 206, 119, 67, 153, 39]), - Bytes32::from([63, 82, 16, 182, 255, 45, 123, 220, 252, 52, 199, 222, 76, 172, 123, 232, 133, 182, 143, 202, 223, 161, 203, 91, 239, 225, 123, 184, 231, 53, 19, 253]), - Bytes32::from([5, 13, 255, 217, 70, 105, 205, 70, 41, 25, 44, 3, 245, 136, 16, 255, 101, 61, 189, 225, 142, 201, 210, 226, 9, 237, 171, 109, 63, 204, 204, 139]), - Bytes32::from([161, 218, 126, 252, 32, 196, 32, 105, 98, 13, 201, 117, 64, 37, 232, 32, 159, 106, 48, 121, 250, 139, 219, 137, 129, 3, 83, 194, 102, 251, 148, 71]), - Bytes32::from([72, 17, 9, 21, 142, 89, 135, 91, 81, 155, 72, 247, 56, 232, 136, 57, 251, 182, 211, 35, 207, 169, 87, 123, 31, 222, 72, 85, 212, 92, 159, 171]), - Bytes32::from([193, 253, 238, 224, 198, 216, 154, 52, 59, 87, 183, 80, 242, 162, 238, 7, 218, 195, 253, 210, 92, 116, 43, 181, 109, 40, 74, 38, 154, 211, 102, 173]), - Bytes32::from([193, 88, 249, 81, 11, 128, 242, 239, 220, 1, 237, 199, 235, 12, 153, 73, 145, 158, 15, 111, 108, 244, 19, 51, 159, 206, 66, 25, 147, 215, 157, 165]), - Bytes32::from([195, 90, 0, 163, 8, 199, 55, 59, 47, 117, 186, 204, 5, 42, 205, 164, 239, 233, 203, 210, 69, 205, 244, 152, 113, 184, 206, 110, 101, 197, 120, 101]), - Bytes32::from([114, 169, 222, 11, 169, 15, 123, 245, 42, 25, 120, 198, 66, 140, 125, 123, 201, 107, 3, 50, 245, 226, 52, 46, 162, 44, 134, 157, 226, 11, 115, 186]), - Bytes32::from([6, 47, 131, 89, 216, 138, 92, 250, 126, 232, 238, 50, 181, 78, 69, 115, 227, 25, 49, 50, 116, 138, 47, 61, 179, 75, 121, 124, 127, 106, 228, 178]), - Bytes32::from([152, 253, 228, 228, 120, 255, 82, 66, 24, 145, 159, 223, 39, 185, 81, 201, 81, 110, 47, 57, 105, 128, 8, 42, 130, 119, 92, 7, 14, 247, 137, 135]), - Bytes32::from([162, 28, 11, 245, 48, 21, 8, 137, 161, 131, 84, 18, 129, 70, 197, 122, 165, 39, 71, 213, 142, 115, 159, 52, 46, 213, 81, 10, 217, 212, 74, 20]), - Bytes32::from([129, 250, 71, 119, 46, 25, 220, 212, 143, 120, 0, 101, 85, 101, 109, 107, 142, 20, 107, 174, 39, 134, 128, 244, 237, 155, 190, 19, 110, 10, 240, 94]), - Bytes32::from([90, 70, 190, 48, 191, 45, 227, 17, 185, 162, 159, 12, 18, 94, 186, 251, 252, 238, 95, 174, 253, 99, 194, 204, 5, 178, 117, 139, 50, 154, 93, 170]), - Bytes32::from([201, 8, 48, 126, 70, 22, 83, 82, 229, 84, 168, 86, 100, 169, 227, 175, 196, 154, 217, 150, 2, 36, 1, 100, 48, 216, 141, 205, 113, 148, 109, 126]), - Bytes32::from([16, 182, 10, 119, 255, 70, 127, 242, 64, 68, 67, 44, 52, 195, 63, 185, 227, 97, 138, 244, 53, 246, 110, 99, 41, 176, 146, 206, 81, 168, 66, 140]), - Bytes32::from([95, 9, 211, 227, 219, 119, 221, 132, 248, 92, 236, 190, 110, 227, 153, 109, 103, 63, 121, 221, 165, 212, 20, 141, 33, 95, 52, 157, 69, 76, 2, 70]), - Bytes32::from([216, 138, 115, 198, 102, 135, 226, 247, 235, 185, 206, 147, 130, 9, 48, 166, 92, 22, 41, 158, 169, 52, 233, 1, 60, 229, 165, 208, 60, 161, 194, 166]), - Bytes32::from([129, 241, 87, 138, 103, 241, 79, 26, 52, 35, 125, 237, 54, 147, 253, 137, 101, 146, 235, 127, 124, 113, 60, 203, 181, 4, 250, 12, 72, 27, 24, 7]), - Bytes32::from([52, 120, 68, 97, 147, 229, 251, 178, 161, 233, 142, 136, 38, 40, 85, 46, 121, 156, 115, 186, 72, 95, 128, 43, 252, 176, 176, 51, 113, 83, 154, 232]), - Bytes32::from([227, 11, 188, 57, 98, 160, 248, 247, 112, 49, 247, 92, 94, 224, 135, 182, 211, 230, 69, 185, 138, 154, 141, 157, 18, 34, 138, 236, 67, 243, 26, 132]), - Bytes32::from([61, 246, 31, 52, 44, 146, 190, 215, 214, 105, 253, 86, 172, 174, 140, 112, 30, 154, 82, 173, 62, 199, 157, 180, 255, 104, 73, 136, 163, 79, 210, 252]), - Bytes32::from([200, 155, 200, 87, 142, 123, 62, 176, 250, 44, 18, 238, 229, 121, 125, 109, 102, 173, 60, 203, 88, 65, 33, 122, 22, 111, 157, 143, 164, 7, 214, 26]), - Bytes32::from([179, 76, 168, 179, 139, 86, 151, 173, 26, 70, 236, 116, 202, 123, 63, 80, 106, 208, 63, 138, 179, 225, 114, 64, 48, 34, 78, 124, 132, 210, 224, 190]), - Bytes32::from([138, 116, 89, 240, 28, 79, 42, 149, 199, 118, 149, 49, 146, 212, 104, 62, 17, 137, 138, 223, 225, 187, 152, 43, 134, 60, 95, 55, 175, 128, 95, 144]) - ]); - zero_hashes.insert(MerkleType::Instruction, vec![ - Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::from([248, 140, 83, 29, 241, 220, 66, 40, 126, 248, 5, 153, 77, 179, 26, 64, 221, 108, 205, 162, 173, 52, 179, 140, 202, 105, 0, 170, 166, 130, 120, 176]), - Bytes32::from([35, 74, 103, 235, 245, 71, 66, 212, 99, 147, 15, 200, 1, 237, 95, 163, 10, 146, 122, 251, 243, 239, 93, 186, 46, 74, 206, 130, 63, 17, 199, 80]), - Bytes32::from([113, 169, 40, 37, 169, 205, 28, 78, 37, 104, 52, 28, 29, 222, 39, 32, 208, 183, 215, 38, 255, 69, 87, 70, 174, 113, 221, 183, 206, 62, 192, 118]), - Bytes32::from([1, 148, 183, 39, 234, 23, 138, 182, 169, 58, 52, 158, 248, 212, 186, 127, 60, 42, 25, 210, 20, 170, 182, 139, 20, 185, 196, 85, 241, 214, 181, 64]), - Bytes32::from([241, 14, 59, 8, 168, 222, 232, 125, 149, 227, 125, 41, 223, 198, 88, 135, 54, 146, 140, 212, 164, 76, 239, 106, 10, 20, 67, 180, 24, 159, 174, 99]), - Bytes32::from([117, 111, 220, 19, 204, 227, 211, 18, 61, 239, 179, 46, 142, 75, 67, 98, 159, 221, 205, 158, 125, 42, 221, 227, 148, 162, 193, 229, 147, 70, 214, 127]), - Bytes32::from([20, 72, 211, 188, 38, 126, 166, 75, 54, 22, 225, 21, 113, 155, 167, 89, 161, 6, 37, 78, 227, 211, 219, 141, 161, 199, 151, 122, 81, 45, 159, 187]), - Bytes32::from([69, 198, 100, 170, 106, 174, 208, 152, 152, 121, 118, 66, 111, 89, 131, 14, 159, 115, 142, 200, 205, 173, 89, 77, 68, 234, 5, 171, 105, 248, 199, 83]), - Bytes32::from([17, 1, 220, 13, 154, 194, 88, 60, 253, 223, 149, 35, 44, 184, 107, 141, 205, 177, 185, 32, 22, 99, 212, 96, 194, 91, 255, 179, 121, 153, 254, 40]), - Bytes32::from([222, 247, 186, 138, 222, 183, 135, 183, 170, 79, 182, 23, 69, 89, 70, 68, 88, 87, 235, 22, 178, 134, 114, 220, 249, 153, 70, 71, 229, 139, 10, 190]), - Bytes32::from([183, 77, 65, 51, 207, 78, 55, 149, 222, 3, 100, 82, 232, 230, 21, 115, 249, 177, 36, 89, 12, 41, 70, 31, 199, 254, 213, 3, 184, 2, 85, 137]), - Bytes32::from([82, 15, 215, 135, 95, 18, 143, 49, 239, 237, 6, 15, 213, 113, 153, 49, 149, 54, 50, 139, 100, 192, 128, 226, 168, 9, 120, 167, 157, 42, 45, 19]), - Bytes32::from([70, 32, 130, 243, 186, 144, 224, 217, 130, 222, 175, 221, 218, 190, 179, 222, 217, 115, 70, 160, 141, 231, 221, 96, 2, 173, 27, 17, 158, 66, 180, 58]), - Bytes32::from([76, 243, 65, 235, 12, 31, 48, 195, 62, 176, 202, 57, 99, 80, 237, 222, 138, 199, 124, 251, 143, 243, 205, 226, 18, 164, 67, 64, 68, 238, 53, 71]), - Bytes32::from([70, 52, 254, 193, 211, 92, 63, 238, 92, 2, 160, 29, 154, 25, 221, 136, 2, 49, 96, 27, 15, 152, 238, 57, 241, 253, 32, 131, 73, 38, 229, 243]), - Bytes32::from([214, 162, 82, 44, 146, 145, 61, 77, 36, 3, 131, 81, 217, 39, 127, 81, 66, 82, 172, 230, 246, 3, 243, 217, 210, 38, 201, 109, 240, 143, 253, 79]), - Bytes32::from([127, 18, 198, 116, 112, 141, 16, 39, 115, 118, 37, 208, 118, 119, 147, 46, 196, 124, 19, 196, 34, 183, 172, 157, 18, 91, 4, 210, 77, 195, 220, 59]), - Bytes32::from([87, 54, 42, 60, 39, 223, 84, 148, 158, 230, 70, 53, 191, 1, 108, 103, 139, 111, 58, 220, 114, 46, 46, 110, 20, 211, 84, 1, 173, 104, 175, 191]), - Bytes32::from([182, 147, 66, 127, 229, 144, 125, 93, 84, 220, 116, 107, 51, 13, 24, 161, 68, 172, 165, 50, 12, 198, 229, 173, 49, 26, 114, 159, 84, 190, 6, 42]), - Bytes32::from([183, 20, 36, 145, 76, 36, 61, 136, 224, 139, 89, 23, 124, 29, 210, 137, 1, 160, 22, 128, 48, 242, 234, 85, 84, 24, 206, 49, 143, 185, 237, 110]), - Bytes32::from([38, 19, 77, 150, 92, 129, 177, 155, 139, 162, 90, 91, 231, 146, 216, 21, 54, 152, 18, 5, 98, 21, 67, 160, 154, 113, 175, 65, 214, 78, 19, 97]), - Bytes32::from([163, 236, 47, 120, 121, 17, 217, 4, 200, 247, 206, 178, 211, 212, 163, 48, 38, 172, 111, 123, 75, 221, 63, 117, 42, 3, 252, 233, 104, 13, 210, 203]), - Bytes32::from([127, 106, 132, 246, 28, 129, 245, 83, 159, 109, 196, 219, 68, 81, 230, 77, 254, 166, 55, 73, 169, 179, 93, 97, 117, 176, 53, 74, 121, 238, 184, 240]), - Bytes32::from([255, 23, 108, 186, 145, 182, 196, 67, 163, 95, 173, 17, 67, 239, 199, 189, 145, 153, 120, 152, 159, 126, 255, 39, 55, 178, 230, 173, 91, 165, 229, 106]), - Bytes32::from([184, 156, 20, 114, 222, 219, 89, 218, 102, 62, 130, 200, 179, 237, 32, 237, 127, 75, 251, 163, 160, 2, 221, 34, 166, 30, 172, 97, 115, 137, 179, 175]), - Bytes32::from([244, 165, 127, 27, 66, 22, 38, 243, 235, 107, 30, 181, 31, 193, 210, 174, 254, 129, 39, 71, 59, 117, 186, 37, 217, 129, 138, 23, 146, 114, 96, 78]), - Bytes32::from([27, 57, 244, 93, 208, 90, 64, 181, 161, 110, 161, 188, 62, 180, 46, 103, 136, 233, 63, 1, 243, 202, 236, 206, 173, 45, 45, 218, 238, 184, 83, 121]), - Bytes32::from([138, 185, 33, 206, 120, 214, 246, 27, 100, 91, 106, 213, 60, 177, 39, 182, 149, 204, 11, 225, 254, 5, 87, 9, 19, 186, 166, 210, 33, 67, 146, 37]), - Bytes32::from([243, 161, 7, 52, 35, 240, 227, 144, 29, 50, 232, 3, 101, 174, 192, 139, 89, 75, 204, 245, 173, 55, 139, 76, 126, 19, 142, 18, 230, 57, 219, 227]), - Bytes32::from([97, 73, 36, 70, 120, 55, 49, 114, 107, 193, 66, 219, 47, 122, 201, 194, 52, 142, 12, 163, 108, 2, 107, 58, 185, 251, 168, 146, 57, 189, 150, 134]), - Bytes32::from([11, 215, 29, 229, 151, 208, 62, 1, 172, 253, 253, 156, 177, 31, 117, 214, 161, 192, 68, 255, 140, 131, 66, 23, 247, 161, 107, 98, 199, 57, 123, 110]), - Bytes32::from([41, 166, 54, 134, 242, 64, 153, 167, 5, 230, 226, 128, 71, 10, 251, 160, 19, 187, 70, 4, 95, 98, 77, 233, 181, 24, 11, 239, 142, 152, 229, 215]), - Bytes32::from([221, 220, 68, 168, 143, 124, 235, 77, 241, 190, 214, 6, 102, 40, 32, 245, 131, 114, 170, 151, 134, 49, 79, 57, 242, 124, 85, 172, 83, 81, 68, 99]), - Bytes32::from([142, 200, 102, 97, 170, 43, 14, 11, 139, 207, 150, 163, 99, 103, 2, 46, 44, 63, 109, 61, 62, 64, 199, 104, 36, 194, 155, 232, 139, 250, 97, 224]), - Bytes32::from([162, 15, 26, 217, 96, 195, 70, 196, 253, 70, 127, 156, 39, 120, 120, 232, 197, 154, 192, 147, 104, 33, 104, 189, 120, 160, 36, 129, 208, 237, 128, 23]), - Bytes32::from([42, 228, 74, 47, 20, 55, 197, 252, 173, 70, 178, 8, 2, 43, 97, 238, 155, 124, 87, 225, 217, 6, 103, 134, 136, 235, 193, 175, 33, 228, 219, 217]), - Bytes32::from([219, 143, 25, 70, 78, 155, 119, 63, 126, 20, 158, 54, 27, 181, 104, 184, 74, 192, 75, 157, 42, 204, 45, 122, 25, 248, 247, 24, 225, 207, 51, 251]), - Bytes32::from([151, 253, 36, 33, 104, 222, 126, 234, 112, 74, 59, 94, 239, 58, 36, 114, 90, 195, 208, 46, 250, 138, 165, 200, 178, 54, 238, 154, 219, 238, 6, 183]), - Bytes32::from([205, 57, 187, 174, 221, 9, 164, 77, 76, 143, 54, 212, 115, 196, 67, 182, 200, 147, 78, 194, 245, 92, 173, 114, 180, 160, 168, 5, 200, 82, 217, 64]), - Bytes32::from([211, 104, 62, 114, 157, 56, 254, 26, 32, 168, 208, 248, 62, 195, 142, 68, 53, 13, 7, 36, 216, 5, 127, 153, 97, 88, 222, 206, 91, 42, 14, 114]), - Bytes32::from([203, 158, 225, 200, 62, 223, 202, 52, 207, 179, 250, 236, 29, 144, 181, 31, 87, 192, 203, 66, 56, 39, 123, 25, 123, 157, 196, 161, 34, 245, 22, 130]), - Bytes32::from([147, 247, 233, 96, 190, 104, 227, 251, 99, 2, 16, 8, 77, 119, 1, 97, 243, 78, 103, 46, 24, 228, 217, 65, 219, 238, 135, 18, 164, 219, 132, 39]), - Bytes32::from([239, 153, 72, 139, 52, 60, 171, 44, 72, 218, 138, 124, 45, 30, 143, 122, 147, 158, 12, 62, 213, 151, 217, 217, 212, 51, 110, 75, 122, 67, 134, 80]), - Bytes32::from([46, 47, 130, 237, 178, 232, 239, 217, 165, 114, 255, 202, 132, 214, 18, 8, 72, 8, 255, 0, 162, 82, 5, 228, 141, 201, 70, 135, 255, 21, 220, 3]), - Bytes32::from([21, 11, 196, 5, 215, 241, 194, 200, 198, 129, 133, 244, 204, 47, 131, 70, 138, 38, 107, 39, 211, 243, 72, 72, 34, 145, 35, 42, 14, 69, 218, 227]), - Bytes32::from([73, 103, 117, 195, 67, 126, 242, 57, 232, 74, 142, 64, 169, 248, 113, 69, 110, 103, 127, 185, 177, 51, 212, 178, 48, 183, 247, 44, 246, 69, 35, 208]), - Bytes32::from([125, 8, 83, 22, 215, 82, 179, 234, 169, 227, 213, 39, 170, 164, 195, 187, 63, 38, 59, 146, 144, 101, 38, 0, 110, 212, 202, 20, 245, 105, 187, 201]), - Bytes32::from([186, 231, 186, 148, 68, 208, 226, 170, 120, 80, 68, 79, 23, 41, 51, 205, 240, 201, 10, 16, 24, 38, 137, 151, 7, 102, 92, 244, 3, 194, 228, 229]), - Bytes32::from([46, 8, 51, 150, 63, 114, 126, 210, 30, 130, 76, 142, 13, 149, 14, 0, 205, 199, 48, 90, 86, 75, 151, 135, 164, 224, 129, 77, 174, 194, 212, 112]), - Bytes32::from([150, 239, 42, 111, 3, 112, 25, 168, 179, 36, 106, 73, 212, 188, 215, 79, 180, 142, 191, 29, 219, 12, 244, 74, 254, 205, 160, 54, 68, 144, 81, 207]), - Bytes32::from([23, 164, 189, 201, 250, 65, 212, 148, 132, 125, 94, 209, 115, 123, 29, 66, 3, 172, 57, 58, 46, 191, 96, 7, 212, 25, 226, 79, 120, 68, 202, 210]), - Bytes32::from([252, 13, 137, 225, 208, 6, 84, 75, 97, 32, 177, 156, 248, 191, 113, 97, 254, 122, 86, 194, 3, 103, 219, 74, 227, 160, 231, 202, 13, 126, 46, 255]), - Bytes32::from([70, 35, 27, 128, 17, 79, 226, 131, 144, 118, 248, 125, 188, 110, 20, 15, 255, 73, 205, 69, 0, 227, 26, 66, 39, 61, 191, 224, 239, 234, 83, 170]), - Bytes32::from([129, 52, 148, 121, 230, 84, 28, 112, 75, 68, 181, 197, 80, 227, 107, 22, 60, 118, 81, 209, 198, 125, 233, 190, 84, 189, 18, 25, 72, 143, 2, 190]), - Bytes32::from([244, 237, 81, 131, 251, 35, 56, 158, 229, 102, 150, 122, 213, 206, 119, 38, 54, 238, 158, 159, 1, 214, 31, 147, 245, 9, 172, 247, 156, 115, 209, 140]), - Bytes32::from([47, 5, 174, 62, 80, 172, 77, 111, 136, 114, 188, 85, 249, 157, 182, 175, 187, 207, 29, 43, 152, 88, 130, 156, 138, 30, 188, 51, 82, 105, 145, 161]), - Bytes32::from([102, 2, 197, 195, 206, 149, 53, 224, 61, 219, 163, 246, 208, 218, 140, 47, 16, 42, 196, 20, 145, 158, 101, 31, 225, 135, 49, 68, 95, 5, 228, 92]), - Bytes32::from([78, 136, 176, 216, 253, 15, 136, 48, 162, 5, 57, 120, 93, 222, 179, 174, 129, 40, 8, 63, 18, 102, 97, 41, 58, 214, 1, 52, 58, 126, 186, 146]), - Bytes32::from([145, 56, 231, 59, 247, 191, 104, 137, 240, 113, 32, 245, 235, 129, 255, 54, 99, 176, 109, 175, 107, 232, 201, 235, 95, 104, 54, 67, 252, 184, 200, 54]), - Bytes32::from([181, 3, 229, 152, 113, 182, 55, 93, 138, 137, 21, 67, 27, 204, 96, 69, 72, 247, 237, 216, 28, 36, 115, 185, 111, 149, 224, 69, 66, 121, 188, 228]), - Bytes32::from([212, 25, 201, 68, 187, 25, 10, 96, 40, 88, 100, 216, 145, 200, 26, 203, 220, 14, 14, 11, 190, 62, 143, 137, 53, 208, 233, 158, 37, 34, 8, 15]), - Bytes32::from([80, 101, 192, 136, 203, 90, 189, 204, 181, 36, 28, 107, 220, 69, 119, 99, 145, 227, 198, 55, 37, 237, 212, 114, 31, 27, 19, 90, 231, 143, 87, 149]), - Bytes32::from([248, 97, 168, 33, 15, 230, 128, 82, 157, 26, 186, 89, 200, 7, 101, 210, 117, 111, 75, 233, 244, 187, 1, 180, 30, 220, 15, 21, 203, 5, 243, 223]) - ]); - zero_hashes.insert(MerkleType::Memory, vec![ - Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::from([66, 208, 130, 169, 194, 116, 5, 27, 68, 75, 235, 175, 164, 169, 41, 91, 88, 134, 51, 194, 219, 201, 182, 199, 1, 52, 173, 215, 20, 37, 51, 0]), - Bytes32::from([90, 210, 50, 227, 58, 173, 147, 92, 139, 15, 127, 190, 196, 111, 142, 207, 31, 223, 70, 96, 17, 251, 164, 200, 133, 0, 76, 35, 200, 9, 51, 218]), - Bytes32::from([97, 5, 162, 226, 92, 108, 172, 8, 7, 65, 104, 176, 216, 3, 144, 47, 14, 88, 50, 101, 194, 94, 10, 132, 192, 76, 37, 152, 42, 73, 30, 2]), - Bytes32::from([68, 59, 208, 14, 89, 37, 33, 1, 177, 225, 235, 66, 129, 28, 103, 156, 46, 206, 94, 141, 33, 152, 141, 26, 209, 161, 53, 237, 198, 163, 115, 57]), - Bytes32::from([28, 94, 12, 53, 70, 163, 95, 44, 168, 42, 196, 126, 181, 231, 174, 247, 89, 100, 77, 238, 211, 74, 116, 144, 183, 111, 254, 75, 30, 187, 228, 222]), - Bytes32::from([238, 133, 50, 189, 14, 89, 244, 88, 239, 50, 172, 85, 172, 1, 131, 2, 24, 161, 70, 94, 0, 204, 50, 199, 48, 107, 30, 70, 6, 8, 18, 90]), - Bytes32::from([165, 239, 71, 173, 192, 165, 25, 35, 4, 130, 148, 158, 177, 193, 129, 45, 115, 209, 7, 233, 136, 108, 245, 126, 74, 200, 22, 204, 190, 137, 191, 105]), - Bytes32::from([173, 102, 127, 73, 167, 249, 117, 26, 190, 231, 26, 60, 201, 138, 160, 182, 180, 44, 34, 132, 171, 254, 91, 8, 167, 114, 188, 157, 181, 148, 169, 165]), - Bytes32::from([71, 62, 70, 89, 203, 1, 105, 187, 178, 167, 217, 118, 42, 217, 154, 234, 238, 109, 145, 231, 247, 199, 40, 110, 162, 11, 173, 144, 103, 110, 99, 101]), - Bytes32::from([121, 36, 94, 4, 25, 134, 16, 98, 198, 109, 123, 42, 56, 151, 224, 7, 232, 155, 231, 154, 229, 162, 250, 149, 231, 198, 0, 65, 17, 27, 181, 28]), - Bytes32::from([247, 158, 162, 102, 242, 117, 166, 252, 175, 158, 107, 157, 244, 44, 17, 99, 93, 52, 43, 136, 5, 211, 32, 152, 91, 148, 41, 32, 231, 18, 237, 208]), - Bytes32::from([147, 52, 155, 255, 81, 242, 75, 54, 54, 66, 166, 41, 131, 177, 183, 151, 229, 177, 232, 86, 146, 137, 106, 68, 226, 117, 20, 210, 224, 170, 249, 68]), - Bytes32::from([160, 89, 180, 156, 119, 172, 38, 10, 97, 101, 64, 56, 98, 133, 199, 228, 58, 66, 139, 128, 88, 140, 143, 85, 148, 167, 79, 75, 34, 45, 204, 68]), - Bytes32::from([165, 233, 117, 3, 27, 56, 166, 16, 56, 132, 198, 32, 11, 149, 212, 98, 64, 236, 180, 106, 174, 80, 122, 220, 102, 67, 67, 110, 67, 8, 48, 217]), - Bytes32::from([113, 74, 209, 139, 250, 181, 182, 127, 178, 77, 17, 63, 79, 109, 145, 74, 52, 102, 125, 154, 22, 241, 177, 177, 34, 189, 124, 22, 4, 200, 201, 76]), - Bytes32::from([67, 7, 240, 151, 128, 149, 238, 113, 130, 127, 174, 223, 142, 124, 230, 10, 91, 89, 113, 157, 230, 21, 213, 3, 146, 249, 26, 80, 239, 90, 4, 216]), - Bytes32::from([152, 20, 80, 244, 232, 182, 1, 145, 31, 191, 46, 207, 83, 199, 209, 104, 0, 75, 106, 230, 16, 98, 121, 127, 175, 78, 119, 154, 69, 55, 66, 169]), - Bytes32::from([123, 50, 162, 158, 51, 112, 129, 232, 242, 158, 150, 72, 244, 40, 191, 63, 205, 61, 144, 39, 65, 122, 28, 88, 253, 146, 29, 29, 15, 40, 122, 95]), - Bytes32::from([231, 253, 202, 45, 165, 158, 212, 29, 104, 165, 209, 179, 188, 154, 89, 18, 216, 23, 140, 66, 150, 49, 99, 200, 163, 155, 50, 9, 250, 22, 19, 203]), - Bytes32::from([127, 172, 110, 243, 156, 134, 199, 15, 248, 216, 12, 196, 221, 66, 202, 186, 105, 197, 43, 245, 46, 116, 251, 133, 111, 118, 56, 214, 157, 244, 187, 58]), - Bytes32::from([181, 181, 163, 95, 7, 188, 245, 128, 161, 210, 137, 217, 103, 101, 120, 255, 47, 83, 102, 68, 238, 195, 206, 105, 24, 150, 216, 50, 74, 6, 94, 95]), - Bytes32::from([171, 250, 198, 40, 153, 26, 240, 152, 96, 169, 15, 123, 33, 155, 57, 172, 89, 205, 9, 65, 45, 126, 155, 143, 224, 145, 25, 214, 19, 227, 213, 195]), - Bytes32::from([44, 177, 244, 220, 119, 33, 203, 59, 209, 72, 28, 4, 210, 54, 86, 20, 119, 41, 45, 231, 143, 104, 57, 206, 212, 222, 81, 62, 92, 221, 200, 32]), - Bytes32::from([37, 200, 165, 195, 67, 224, 131, 227, 97, 54, 21, 233, 76, 186, 6, 122, 178, 131, 252, 59, 97, 218, 239, 62, 124, 255, 201, 178, 241, 236, 4, 214]), - Bytes32::from([77, 171, 229, 183, 46, 112, 203, 177, 89, 90, 64, 114, 109, 220, 32, 120, 41, 223, 72, 86, 59, 211, 110, 17, 129, 112, 194, 186, 200, 92, 144, 49]), - Bytes32::from([2, 198, 61, 112, 181, 185, 194, 114, 149, 63, 65, 76, 55, 179, 170, 62, 91, 112, 189, 100, 13, 34, 98, 187, 85, 132, 202, 86, 47, 27, 236, 200]), - Bytes32::from([164, 238, 109, 209, 155, 118, 236, 237, 84, 43, 56, 99, 51, 60, 116, 235, 100, 39, 163, 105, 34, 93, 8, 187, 228, 213, 35, 200, 43, 8, 32, 68]), - Bytes32::from([32, 220, 39, 200, 214, 245, 102, 200, 167, 204, 3, 54, 140, 126, 129, 35, 139, 60, 112, 133, 52, 166, 162, 63, 119, 20, 2, 116, 132, 244, 246, 225]), - Bytes32::from([5, 54, 145, 188, 188, 251, 36, 4, 103, 140, 229, 143, 83, 11, 77, 207, 57, 125, 51, 127, 89, 130, 138, 193, 190, 17, 17, 23, 68, 168, 231, 106]), - Bytes32::from([239, 112, 72, 74, 116, 134, 210, 24, 226, 242, 91, 113, 99, 59, 19, 7, 226, 215, 254, 220, 14, 225, 75, 245, 11, 234, 138, 52, 195, 86, 79, 124]), - Bytes32::from([187, 35, 132, 188, 162, 128, 96, 71, 124, 213, 251, 229, 73, 52, 187, 22, 166, 35, 214, 14, 121, 189, 37, 5, 77, 54, 201, 51, 95, 179, 75, 229]), - Bytes32::from([5, 54, 88, 42, 68, 200, 45, 209, 121, 70, 128, 8, 178, 212, 197, 39, 101, 90, 101, 111, 77, 133, 13, 77, 19, 111, 113, 122, 222, 85, 180, 82]), - Bytes32::from([34, 182, 144, 13, 35, 35, 79, 14, 239, 80, 21, 255, 67, 48, 210, 174, 159, 182, 239, 236, 68, 46, 125, 105, 243, 202, 218, 64, 53, 94, 159, 253]), - Bytes32::from([224, 189, 145, 186, 43, 169, 131, 161, 223, 161, 72, 72, 229, 97, 113, 233, 2, 250, 109, 31, 19, 125, 57, 135, 144, 3, 187, 18, 102, 108, 232, 9]), - Bytes32::from([68, 94, 11, 104, 95, 110, 179, 226, 157, 245, 113, 68, 44, 122, 17, 22, 244, 35, 248, 126, 131, 192, 20, 169, 129, 236, 60, 54, 157, 30, 231, 36]), - Bytes32::from([101, 198, 107, 156, 226, 8, 67, 168, 197, 91, 189, 166, 187, 16, 121, 93, 114, 243, 137, 162, 125, 142, 50, 206, 160, 168, 165, 27, 207, 10, 22, 19]), - Bytes32::from([222, 29, 134, 137, 98, 73, 58, 143, 166, 134, 210, 47, 68, 23, 214, 237, 241, 207, 226, 83, 113, 222, 184, 139, 16, 1, 200, 56, 34, 208, 197, 152]), - Bytes32::from([107, 200, 189, 222, 185, 32, 192, 130, 237, 238, 168, 137, 14, 94, 3, 26, 41, 238, 19, 119, 207, 158, 25, 177, 116, 70, 170, 161, 141, 129, 16, 88]), - Bytes32::from([131, 243, 131, 161, 236, 101, 108, 81, 59, 123, 150, 6, 250, 124, 103, 101, 75, 234, 98, 223, 129, 87, 202, 59, 184, 173, 44, 191, 200, 30, 223, 66]), - Bytes32::from([17, 226, 72, 31, 180, 33, 229, 83, 154, 39, 104, 45, 93, 117, 153, 249, 216, 127, 120, 182, 4, 19, 169, 87, 127, 70, 7, 237, 80, 251, 220, 126]), - Bytes32::from([88, 122, 134, 181, 173, 175, 100, 74, 28, 141, 45, 215, 245, 170, 222, 54, 106, 118, 146, 59, 207, 251, 133, 155, 164, 75, 240, 208, 10, 185, 187, 163]), - Bytes32::from([214, 1, 209, 99, 53, 101, 233, 225, 55, 171, 69, 200, 44, 144, 169, 11, 65, 85, 84, 158, 233, 227, 37, 59, 42, 52, 153, 13, 0, 158, 122, 208]), - Bytes32::from([124, 146, 1, 221, 33, 138, 233, 130, 184, 163, 121, 110, 95, 242, 123, 251, 110, 46, 41, 197, 75, 145, 121, 95, 29, 1, 19, 19, 167, 220, 177, 153]), - Bytes32::from([77, 38, 54, 170, 19, 128, 180, 248, 208, 75, 27, 53, 228, 104, 7, 216, 188, 186, 40, 84, 87, 11, 121, 3, 175, 89, 49, 46, 191, 94, 80, 97]), - Bytes32::from([134, 127, 37, 206, 212, 70, 146, 143, 81, 104, 140, 28, 135, 233, 171, 88, 18, 2, 148, 143, 111, 208, 149, 138, 167, 84, 183, 100, 67, 181, 243, 135]), - Bytes32::from([218, 16, 220, 189, 192, 237, 252, 168, 45, 33, 177, 81, 53, 115, 141, 190, 99, 138, 113, 85, 60, 230, 244, 222, 205, 16, 152, 26, 185, 207, 114, 143]), - Bytes32::from([9, 85, 193, 163, 186, 152, 83, 149, 29, 71, 50, 13, 175, 149, 184, 51, 246, 97, 20, 22, 57, 201, 27, 72, 146, 19, 213, 102, 164, 148, 176, 45]), - Bytes32::from([140, 94, 218, 31, 232, 0, 167, 218, 122, 119, 62, 179, 181, 51, 100, 6, 150, 159, 212, 207, 160, 94, 212, 108, 225, 196, 190, 210, 145, 110, 120, 114]), - Bytes32::from([152, 169, 229, 240, 162, 212, 61, 59, 167, 135, 124, 147, 212, 248, 177, 85, 243, 72, 150, 127, 122, 60, 143, 125, 226, 186, 67, 219, 50, 112, 242, 212]), - Bytes32::from([47, 244, 81, 140, 243, 189, 116, 0, 2, 158, 242, 188, 215, 90, 177, 37, 175, 221, 80, 226, 209, 79, 2, 62, 112, 245, 1, 132, 7, 78, 0, 117]), - Bytes32::from([247, 236, 252, 118, 6, 245, 132, 187, 48, 36, 77, 0, 167, 150, 109, 72, 234, 9, 224, 162, 223, 191, 21, 19, 180, 201, 138, 56, 109, 97, 152, 170]), - Bytes32::from([77, 23, 112, 52, 78, 204, 135, 173, 2, 206, 148, 200, 60, 155, 60, 179, 201, 111, 73, 138, 76, 104, 79, 174, 190, 173, 42, 51, 38, 48, 237, 241]), - Bytes32::from([117, 234, 73, 183, 4, 144, 12, 196, 78, 228, 178, 218, 206, 147, 147, 94, 190, 22, 22, 233, 88, 118, 135, 55, 63, 29, 212, 38, 223, 160, 121, 230]), - Bytes32::from([74, 138, 173, 10, 77, 129, 10, 115, 18, 90, 57, 215, 221, 171, 109, 152, 31, 219, 235, 122, 189, 201, 210, 186, 52, 200, 81, 218, 112, 79, 80, 54]), - Bytes32::from([189, 150, 224, 30, 110, 73, 249, 62, 100, 244, 206, 110, 206, 239, 233, 213, 61, 213, 65, 139, 103, 19, 20, 123, 167, 65, 161, 165, 216, 217, 255, 248]), - Bytes32::from([119, 71, 56, 219, 155, 139, 253, 40, 100, 132, 185, 98, 24, 34, 156, 225, 120, 176, 76, 147, 31, 105, 245, 216, 165, 161, 89, 157, 246, 17, 251, 234]), - Bytes32::from([192, 39, 162, 126, 222, 211, 173, 195, 198, 124, 1, 124, 140, 2, 252, 191, 185, 85, 10, 125, 226, 7, 88, 221, 164, 13, 221, 74, 200, 7, 249, 177]), - Bytes32::from([251, 226, 24, 5, 54, 89, 9, 93, 217, 202, 148, 172, 208, 197, 65, 172, 98, 96, 58, 194, 61, 253, 157, 193, 135, 32, 206, 97, 133, 234, 199, 197]), - Bytes32::from([130, 3, 195, 156, 210, 123, 23, 44, 223, 25, 153, 169, 250, 88, 127, 239, 206, 196, 156, 143, 182, 185, 35, 77, 162, 48, 143, 64, 231, 129, 216, 185]), - Bytes32::from([123, 201, 97, 230, 121, 13, 207, 138, 137, 3, 122, 92, 105, 155, 214, 204, 142, 18, 119, 138, 135, 165, 249, 58, 184, 53, 27, 31, 109, 214, 176, 147]), - Bytes32::from([46, 71, 246, 155, 247, 109, 236, 225, 147, 51, 250, 72, 97, 116, 162, 36, 115, 164, 80, 28, 252, 238, 98, 92, 16, 66, 190, 208, 180, 39, 179, 211]), - Bytes32::from([38, 76, 13, 227, 149, 18, 84, 170, 83, 231, 122, 59, 237, 66, 32, 171, 158, 251, 78, 156, 186, 160, 29, 30, 207, 178, 16, 193, 221, 158, 49, 48]), - Bytes32::from([166, 13, 210, 208, 250, 131, 27, 163, 99, 204, 199, 134, 152, 131, 28, 164, 8, 222, 176, 200, 34, 40, 74, 188, 120, 46, 167, 44, 95, 199, 86, 225]) - ]); - zero_hashes.insert(MerkleType::Table, vec![ - Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::from([164, 47, 121, 69, 150, 44, 30, 204, 210, 181, 242, 154, 59, 111, 5, 10, 47, 121, 213, 80, 163, 196, 205, 188, 241, 64, 202, 26, 242, 47, 50, 205]), - Bytes32::from([166, 9, 224, 145, 14, 138, 194, 78, 202, 114, 110, 38, 244, 33, 189, 185, 170, 85, 144, 229, 123, 63, 229, 194, 59, 130, 156, 6, 184, 154, 187, 17]), - Bytes32::from([32, 51, 186, 232, 39, 244, 218, 98, 243, 254, 82, 247, 63, 120, 34, 123, 128, 240, 220, 145, 41, 114, 251, 208, 209, 244, 10, 9, 179, 5, 105, 181]), - Bytes32::from([73, 148, 74, 132, 241, 45, 129, 169, 83, 223, 101, 12, 184, 60, 10, 201, 169, 197, 75, 17, 198, 168, 79, 171, 207, 195, 123, 47, 249, 30, 176, 216]), - Bytes32::from([145, 224, 51, 196, 211, 137, 189, 133, 232, 210, 170, 157, 227, 160, 218, 143, 15, 82, 170, 226, 241, 83, 7, 112, 138, 227, 58, 59, 149, 168, 81, 94]), - Bytes32::from([241, 90, 42, 7, 231, 63, 36, 86, 238, 131, 19, 20, 38, 118, 65, 180, 109, 121, 147, 147, 213, 142, 203, 244, 239, 75, 5, 160, 16, 85, 221, 95]), - Bytes32::from([213, 113, 178, 221, 213, 107, 77, 153, 222, 48, 148, 140, 250, 1, 17, 59, 73, 19, 110, 106, 94, 195, 126, 49, 126, 109, 65, 55, 104, 111, 18, 171]), - Bytes32::from([43, 198, 12, 197, 95, 201, 76, 108, 96, 235, 76, 8, 117, 99, 42, 20, 177, 45, 112, 40, 2, 180, 68, 19, 25, 11, 210, 168, 170, 178, 99, 27]), - Bytes32::from([142, 205, 24, 125, 81, 234, 138, 161, 206, 121, 163, 225, 50, 9, 180, 102, 0, 25, 93, 180, 137, 164, 206, 249, 222, 20, 175, 177, 199, 14, 115, 207]), - Bytes32::from([213, 41, 249, 19, 173, 165, 236, 103, 42, 146, 223, 6, 190, 229, 161, 13, 96, 163, 110, 23, 203, 238, 24, 95, 130, 203, 35, 211, 63, 234, 32, 137]), - Bytes32::from([176, 82, 229, 48, 113, 46, 179, 38, 231, 83, 50, 136, 179, 190, 242, 126, 152, 210, 141, 102, 191, 21, 20, 96, 235, 245, 81, 254, 231, 117, 159, 146]), - Bytes32::from([216, 15, 120, 147, 70, 215, 12, 160, 223, 73, 246, 73, 195, 189, 200, 3, 19, 131, 102, 61, 173, 79, 50, 76, 39, 150, 151, 147, 35, 251, 200, 0]), - Bytes32::from([88, 215, 168, 30, 218, 72, 206, 159, 91, 121, 14, 133, 241, 220, 195, 46, 93, 244, 179, 53, 158, 75, 211, 161, 8, 120, 167, 141, 235, 16, 232, 42]), - Bytes32::from([114, 99, 218, 52, 203, 162, 199, 16, 225, 154, 182, 20, 59, 121, 250, 249, 166, 35, 118, 18, 142, 57, 122, 131, 32, 219, 83, 126, 147, 91, 116, 16]), - Bytes32::from([193, 157, 15, 251, 179, 155, 215, 190, 98, 93, 30, 167, 23, 175, 178, 172, 142, 143, 222, 20, 18, 157, 215, 42, 105, 107, 64, 16, 216, 143, 109, 45]), - Bytes32::from([178, 2, 203, 32, 83, 90, 114, 97, 124, 210, 81, 81, 179, 213, 71, 19, 181, 173, 227, 88, 226, 83, 48, 169, 134, 163, 62, 103, 222, 82, 128, 30]), - Bytes32::from([252, 17, 142, 50, 185, 19, 111, 148, 204, 30, 199, 138, 143, 207, 30, 212, 254, 7, 129, 43, 100, 167, 52, 115, 247, 143, 64, 106, 220, 5, 7, 89]), - Bytes32::from([117, 136, 111, 98, 95, 97, 253, 43, 82, 22, 43, 187, 65, 154, 132, 105, 55, 194, 240, 148, 170, 199, 185, 91, 157, 138, 43, 117, 218, 176, 110, 101]), - Bytes32::from([228, 56, 186, 202, 73, 47, 253, 151, 48, 173, 2, 101, 153, 197, 108, 145, 227, 170, 247, 86, 80, 70, 30, 93, 232, 148, 63, 211, 197, 135, 23, 97]), - Bytes32::from([162, 35, 93, 45, 208, 241, 87, 57, 138, 79, 231, 83, 75, 81, 102, 91, 115, 58, 1, 205, 193, 197, 62, 210, 144, 88, 59, 52, 149, 234, 121, 224]), - Bytes32::from([165, 67, 16, 239, 234, 92, 207, 81, 64, 93, 227, 154, 132, 33, 54, 53, 102, 198, 90, 134, 24, 29, 190, 158, 121, 23, 127, 30, 27, 239, 140, 88]), - Bytes32::from([61, 125, 183, 139, 186, 82, 193, 166, 2, 147, 231, 215, 179, 107, 163, 67, 122, 0, 90, 188, 142, 216, 72, 20, 63, 146, 85, 89, 231, 41, 153, 117]), - Bytes32::from([206, 31, 38, 182, 78, 170, 183, 207, 211, 114, 212, 4, 108, 84, 62, 99, 245, 196, 10, 1, 188, 63, 240, 199, 27, 85, 68, 101, 212, 222, 85, 12]), - Bytes32::from([106, 0, 225, 130, 195, 87, 113, 106, 101, 80, 56, 119, 93, 45, 74, 168, 240, 209, 155, 123, 8, 129, 73, 225, 204, 125, 42, 73, 102, 122, 228, 158]), - Bytes32::from([251, 63, 88, 92, 59, 176, 71, 194, 46, 19, 18, 27, 83, 57, 197, 231, 202, 242, 155, 63, 252, 240, 205, 216, 96, 130, 161, 197, 123, 110, 175, 220]), - Bytes32::from([239, 6, 249, 150, 189, 234, 197, 18, 79, 222, 80, 72, 205, 147, 251, 135, 226, 33, 46, 111, 186, 185, 4, 33, 219, 129, 30, 182, 57, 229, 34, 16]), - Bytes32::from([192, 35, 149, 149, 16, 111, 3, 119, 173, 215, 223, 247, 70, 25, 31, 107, 104, 5, 249, 243, 193, 66, 99, 48, 107, 158, 25, 147, 163, 151, 96, 149]), - Bytes32::from([197, 133, 241, 197, 67, 52, 255, 227, 180, 235, 137, 164, 174, 160, 183, 9, 159, 254, 210, 180, 231, 140, 176, 165, 113, 215, 182, 1, 177, 204, 219, 246]), - Bytes32::from([51, 32, 109, 173, 131, 6, 99, 63, 75, 191, 207, 187, 73, 26, 5, 139, 167, 216, 123, 26, 199, 176, 84, 215, 158, 243, 105, 0, 91, 254, 59, 146]), - Bytes32::from([229, 120, 15, 22, 225, 50, 131, 240, 190, 232, 83, 119, 169, 246, 172, 35, 99, 163, 58, 146, 234, 253, 252, 83, 5, 48, 54, 142, 172, 91, 145, 13]), - Bytes32::from([159, 9, 100, 20, 215, 92, 217, 43, 208, 254, 65, 234, 124, 167, 250, 53, 159, 151, 124, 70, 26, 0, 113, 28, 78, 44, 238, 8, 34, 255, 19, 36]), - Bytes32::from([193, 135, 44, 144, 13, 46, 76, 43, 127, 208, 79, 196, 229, 58, 125, 33, 71, 118, 215, 240, 80, 123, 44, 181, 174, 47, 102, 42, 137, 98, 190, 41]), - Bytes32::from([78, 19, 3, 217, 174, 154, 142, 109, 189, 14, 241, 12, 23, 185, 224, 152, 209, 108, 223, 202, 191, 11, 190, 149, 31, 236, 104, 234, 22, 38, 196, 3]), - Bytes32::from([60, 93, 237, 228, 186, 222, 179, 231, 151, 95, 147, 20, 188, 10, 191, 34, 126, 57, 253, 161, 154, 117, 182, 108, 143, 72, 48, 102, 191, 240, 81, 208]), - Bytes32::from([179, 114, 163, 89, 172, 211, 154, 204, 11, 125, 140, 186, 107, 90, 17, 116, 214, 31, 165, 94, 36, 187, 184, 151, 210, 208, 76, 215, 75, 166, 107, 91]), - Bytes32::from([125, 131, 52, 139, 120, 156, 163, 243, 206, 143, 204, 221, 123, 140, 1, 103, 235, 186, 64, 82, 194, 191, 205, 2, 32, 242, 38, 77, 184, 23, 236, 228]), - Bytes32::from([137, 224, 90, 1, 116, 95, 215, 47, 8, 3, 227, 132, 154, 232, 216, 63, 3, 80, 52, 18, 42, 29, 85, 38, 117, 255, 9, 99, 88, 233, 129, 92]), - Bytes32::from([54, 182, 145, 174, 54, 24, 168, 13, 71, 43, 178, 49, 153, 246, 94, 79, 228, 254, 134, 0, 21, 210, 176, 242, 82, 117, 76, 40, 221, 181, 30, 62]), - Bytes32::from([145, 171, 156, 87, 15, 174, 31, 111, 175, 161, 31, 116, 123, 123, 37, 216, 43, 147, 197, 79, 218, 49, 236, 111, 35, 49, 44, 188, 197, 79, 136, 45]), - Bytes32::from([169, 48, 186, 93, 10, 48, 80, 103, 68, 226, 103, 31, 176, 154, 146, 199, 166, 89, 48, 149, 116, 101, 157, 149, 149, 72, 123, 54, 153, 26, 210, 122]), - Bytes32::from([225, 45, 163, 167, 213, 84, 40, 87, 106, 253, 206, 80, 189, 71, 153, 5, 15, 107, 151, 150, 14, 22, 143, 207, 4, 192, 63, 250, 207, 207, 179, 26]), - Bytes32::from([110, 249, 172, 218, 206, 202, 107, 64, 48, 153, 226, 127, 165, 227, 50, 146, 140, 239, 220, 252, 188, 157, 77, 210, 92, 73, 38, 6, 16, 87, 244, 66]), - Bytes32::from([39, 217, 230, 91, 60, 231, 96, 137, 37, 58, 93, 51, 79, 222, 132, 171, 196, 109, 155, 4, 252, 213, 17, 33, 160, 24, 250, 118, 187, 62, 107, 113]), - Bytes32::from([120, 167, 145, 121, 184, 31, 185, 178, 241, 54, 20, 48, 132, 89, 132, 127, 235, 189, 197, 127, 249, 58, 255, 197, 40, 229, 130, 254, 213, 186, 114, 74]), - Bytes32::from([7, 40, 187, 172, 225, 196, 3, 77, 113, 16, 118, 148, 95, 65, 42, 234, 233, 29, 120, 223, 105, 77, 250, 119, 245, 20, 21, 155, 177, 13, 56, 151]), - Bytes32::from([22, 248, 25, 75, 36, 179, 251, 57, 101, 170, 213, 19, 216, 64, 164, 253, 151, 199, 88, 5, 92, 129, 138, 185, 9, 236, 231, 68, 112, 24, 218, 216]), - Bytes32::from([95, 141, 49, 39, 213, 214, 130, 49, 143, 124, 178, 114, 200, 136, 160, 90, 233, 73, 233, 185, 60, 250, 174, 74, 2, 123, 2, 62, 192, 174, 115, 158]), - Bytes32::from([142, 29, 212, 35, 71, 107, 91, 164, 226, 225, 180, 218, 99, 34, 200, 171, 33, 235, 113, 105, 191, 78, 105, 70, 221, 135, 167, 148, 24, 225, 6, 146]), - Bytes32::from([176, 194, 115, 243, 138, 104, 3, 247, 184, 74, 81, 60, 173, 45, 29, 189, 252, 202, 206, 66, 129, 65, 150, 25, 246, 145, 133, 4, 93, 201, 201, 240]), - Bytes32::from([18, 233, 186, 158, 43, 12, 206, 228, 80, 102, 187, 25, 78, 77, 180, 28, 82, 62, 168, 252, 14, 113, 126, 91, 243, 120, 213, 91, 189, 244, 247, 177]), - Bytes32::from([79, 126, 97, 23, 112, 98, 93, 86, 24, 103, 82, 33, 155, 188, 202, 61, 29, 146, 132, 169, 116, 207, 216, 35, 29, 229, 213, 120, 135, 240, 129, 205]), - Bytes32::from([146, 121, 255, 202, 145, 53, 46, 8, 102, 205, 56, 234, 49, 42, 85, 231, 217, 114, 235, 141, 233, 187, 29, 9, 122, 232, 61, 253, 42, 104, 4, 113]), - Bytes32::from([103, 174, 255, 6, 115, 155, 156, 65, 84, 251, 208, 55, 89, 124, 171, 167, 133, 227, 22, 134, 32, 71, 243, 181, 16, 100, 81, 63, 22, 207, 58, 190]), - Bytes32::from([69, 10, 247, 243, 56, 0, 64, 72, 218, 21, 211, 192, 62, 243, 66, 244, 230, 58, 107, 54, 180, 29, 216, 23, 86, 211, 173, 181, 118, 188, 238, 72]), - Bytes32::from([25, 179, 4, 93, 169, 76, 76, 69, 158, 3, 24, 146, 130, 9, 225, 198, 102, 238, 29, 73, 74, 179, 159, 74, 40, 111, 181, 110, 76, 173, 251, 255]), - Bytes32::from([236, 113, 37, 202, 149, 150, 90, 50, 233, 141, 125, 12, 212, 163, 137, 176, 15, 214, 194, 73, 138, 104, 4, 33, 235, 76, 185, 58, 125, 182, 56, 0]), - Bytes32::from([238, 54, 183, 94, 50, 33, 98, 31, 133, 181, 230, 98, 43, 154, 95, 111, 250, 71, 15, 197, 156, 60, 8, 90, 208, 50, 62, 127, 30, 18, 181, 176]), - Bytes32::from([246, 143, 72, 228, 143, 15, 15, 131, 178, 105, 113, 46, 85, 36, 165, 116, 63, 131, 61, 228, 98, 144, 232, 209, 228, 110, 168, 171, 252, 47, 79, 165]), - Bytes32::from([146, 70, 74, 79, 139, 107, 73, 28, 231, 88, 235, 214, 163, 185, 87, 195, 147, 186, 153, 222, 191, 214, 30, 231, 173, 166, 151, 169, 244, 15, 15, 227]), - Bytes32::from([137, 182, 175, 97, 212, 23, 62, 70, 50, 150, 67, 153, 253, 52, 179, 105, 147, 177, 217, 170, 125, 251, 1, 96, 4, 127, 196, 37, 254, 7, 217, 100]), - Bytes32::from([32, 253, 229, 209, 120, 43, 120, 189, 245, 227, 178, 79, 134, 175, 240, 107, 25, 124, 5, 67, 120, 213, 187, 200, 159, 9, 26, 119, 13, 1, 8, 120]), - Bytes32::from([115, 241, 26, 44, 83, 229, 130, 21, 249, 87, 72, 212, 75, 220, 95, 22, 151, 77, 182, 8, 196, 207, 95, 18, 9, 92, 89, 206, 114, 80, 36, 159]), - Bytes32::from([174, 151, 88, 171, 52, 40, 161, 16, 106, 45, 44, 9, 142, 95, 5, 205, 82, 24, 172, 103, 152, 202, 187, 34, 217, 173, 236, 129, 32, 203, 205, 38]) - ]); - zero_hashes.insert(MerkleType::TableElement, vec![ - Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::from([145, 218, 63, 74, 131, 182, 204, 163, 74, 206, 234, 50, 47, 3, 51, 74, 121, 225, 146, 237, 5, 128, 20, 230, 243, 89, 33, 248, 136, 154, 189, 5]), - Bytes32::from([36, 240, 95, 13, 214, 136, 92, 102, 96, 137, 39, 96, 108, 223, 147, 130, 220, 61, 147, 226, 52, 133, 67, 223, 211, 164, 6, 53, 45, 117, 120, 241]), - Bytes32::from([9, 2, 218, 34, 228, 8, 178, 127, 160, 30, 104, 198, 49, 37, 71, 115, 14, 35, 20, 15, 253, 160, 147, 143, 24, 186, 12, 90, 41, 169, 30, 8]), - Bytes32::from([137, 242, 105, 78, 161, 99, 76, 224, 226, 100, 216, 235, 156, 132, 214, 154, 107, 120, 197, 113, 45, 221, 170, 119, 92, 228, 76, 139, 170, 159, 111, 58]), - Bytes32::from([231, 165, 221, 185, 139, 22, 70, 40, 67, 162, 123, 94, 161, 156, 57, 53, 102, 217, 128, 227, 18, 132, 17, 170, 90, 31, 214, 181, 249, 220, 70, 37]), - Bytes32::from([171, 253, 174, 187, 9, 186, 87, 37, 22, 83, 13, 88, 75, 11, 177, 226, 237, 136, 132, 137, 101, 109, 135, 192, 224, 80, 87, 105, 95, 81, 255, 21]), - Bytes32::from([179, 50, 36, 230, 159, 162, 184, 132, 140, 121, 133, 155, 189, 44, 132, 93, 80, 79, 32, 244, 131, 57, 79, 222, 104, 63, 224, 182, 91, 162, 73, 122]), - Bytes32::from([17, 55, 206, 87, 127, 185, 135, 231, 41, 56, 166, 104, 229, 102, 222, 181, 236, 233, 230, 39, 43, 163, 16, 1, 225, 86, 211, 51, 145, 7, 169, 84]), - Bytes32::from([201, 174, 3, 154, 104, 190, 240, 99, 123, 201, 7, 118, 196, 85, 28, 247, 35, 232, 39, 25, 151, 52, 167, 136, 179, 13, 213, 60, 138, 158, 39, 131]), - Bytes32::from([35, 33, 109, 155, 171, 252, 195, 80, 10, 115, 40, 199, 250, 1, 241, 82, 146, 225, 118, 237, 11, 125, 198, 97, 57, 21, 171, 237, 94, 60, 49, 32]), - Bytes32::from([126, 95, 42, 157, 183, 168, 137, 120, 114, 64, 148, 170, 32, 156, 137, 96, 194, 91, 119, 11, 20, 3, 30, 62, 118, 12, 31, 48, 245, 144, 252, 29]), - Bytes32::from([48, 135, 201, 114, 103, 35, 8, 96, 5, 101, 125, 26, 87, 0, 98, 122, 239, 140, 230, 10, 102, 112, 155, 87, 249, 181, 152, 235, 28, 79, 176, 56]), - Bytes32::from([76, 70, 222, 210, 242, 159, 52, 123, 112, 106, 253, 140, 55, 160, 189, 255, 220, 64, 8, 168, 39, 196, 160, 8, 105, 154, 91, 184, 62, 63, 227, 156]), - Bytes32::from([138, 201, 8, 240, 218, 190, 210, 227, 236, 168, 45, 161, 209, 115, 126, 165, 235, 162, 6, 117, 76, 239, 3, 225, 163, 251, 111, 233, 233, 228, 14, 92]), - Bytes32::from([190, 166, 27, 117, 242, 0, 25, 148, 230, 125, 237, 22, 153, 158, 151, 56, 121, 194, 221, 198, 184, 147, 249, 149, 27, 29, 166, 243, 254, 181, 209, 102]), - Bytes32::from([235, 63, 149, 47, 164, 152, 80, 11, 178, 203, 99, 178, 176, 226, 164, 151, 39, 65, 83, 200, 102, 90, 12, 102, 178, 15, 232, 16, 222, 141, 78, 3]), - Bytes32::from([37, 179, 99, 114, 214, 120, 87, 53, 198, 229, 207, 47, 16, 112, 208, 33, 216, 152, 209, 228, 196, 14, 237, 250, 212, 90, 176, 185, 21, 248, 92, 109]), - Bytes32::from([237, 200, 122, 93, 145, 116, 138, 59, 86, 220, 58, 171, 160, 31, 142, 193, 231, 131, 106, 164, 166, 44, 120, 170, 62, 81, 73, 85, 0, 52, 219, 220]), - Bytes32::from([244, 173, 85, 141, 81, 198, 214, 0, 54, 21, 20, 169, 177, 235, 104, 206, 43, 218, 96, 68, 73, 37, 252, 77, 253, 18, 30, 97, 223, 122, 1, 12]), - Bytes32::from([104, 169, 247, 140, 131, 245, 193, 3, 36, 119, 249, 119, 108, 102, 115, 250, 173, 225, 33, 156, 116, 87, 180, 27, 84, 215, 126, 15, 187, 189, 32, 139]), - Bytes32::from([47, 156, 244, 88, 145, 227, 224, 87, 233, 138, 138, 9, 169, 96, 29, 204, 100, 170, 23, 105, 63, 4, 119, 90, 167, 161, 72, 109, 82, 254, 123, 48]), - Bytes32::from([196, 68, 107, 111, 141, 253, 138, 140, 162, 104, 247, 104, 87, 144, 123, 240, 105, 251, 246, 210, 172, 172, 241, 162, 155, 90, 83, 175, 131, 251, 107, 215]), - Bytes32::from([28, 100, 243, 226, 32, 234, 211, 106, 197, 179, 14, 192, 70, 11, 203, 125, 151, 53, 20, 77, 175, 99, 154, 100, 159, 249, 54, 39, 73, 168, 162, 66]), - Bytes32::from([83, 176, 7, 180, 201, 178, 172, 98, 47, 34, 80, 6, 62, 10, 4, 112, 43, 93, 10, 227, 74, 91, 11, 217, 83, 230, 104, 0, 167, 2, 114, 89]), - Bytes32::from([185, 162, 212, 82, 149, 182, 104, 215, 62, 244, 114, 124, 181, 74, 226, 119, 4, 42, 181, 238, 25, 212, 215, 219, 174, 231, 32, 170, 9, 234, 12, 212]), - Bytes32::from([173, 38, 241, 20, 137, 119, 33, 252, 174, 245, 252, 234, 165, 181, 128, 225, 14, 147, 182, 97, 145, 19, 40, 193, 90, 238, 140, 87, 0, 222, 70, 254]), - Bytes32::from([51, 218, 162, 213, 211, 23, 9, 158, 185, 156, 39, 145, 5, 146, 70, 144, 172, 10, 26, 212, 253, 37, 24, 32, 21, 65, 179, 140, 64, 237, 96, 157]), - Bytes32::from([221, 87, 57, 81, 246, 126, 53, 163, 190, 220, 109, 205, 114, 234, 85, 151, 75, 245, 254, 16, 140, 131, 239, 120, 9, 209, 54, 61, 177, 6, 188, 252]), - Bytes32::from([54, 161, 25, 198, 75, 151, 214, 76, 83, 74, 117, 229, 155, 237, 88, 95, 143, 119, 56, 12, 201, 164, 235, 20, 117, 49, 177, 88, 14, 248, 95, 198]), - Bytes32::from([60, 16, 183, 115, 241, 45, 253, 24, 105, 43, 79, 72, 212, 238, 24, 156, 132, 93, 78, 246, 1, 228, 222, 200, 254, 130, 170, 46, 91, 254, 205, 143]), - Bytes32::from([184, 30, 34, 235, 214, 40, 120, 64, 182, 15, 162, 189, 164, 202, 89, 146, 202, 177, 16, 105, 172, 158, 1, 95, 101, 146, 253, 115, 226, 233, 38, 171]), - Bytes32::from([70, 152, 3, 73, 249, 222, 93, 214, 74, 179, 140, 47, 34, 42, 149, 214, 152, 75, 34, 145, 68, 226, 151, 101, 121, 54, 252, 240, 206, 140, 81, 165]), - Bytes32::from([9, 88, 51, 124, 67, 108, 84, 244, 61, 241, 110, 246, 184, 105, 6, 116, 242, 58, 15, 144, 43, 76, 176, 107, 0, 138, 155, 235, 210, 138, 226, 215]), - Bytes32::from([98, 170, 168, 147, 158, 223, 186, 7, 58, 130, 89, 200, 153, 24, 158, 251, 69, 100, 7, 57, 96, 115, 136, 170, 57, 145, 143, 240, 102, 6, 248, 111]), - Bytes32::from([76, 75, 216, 216, 194, 146, 2, 59, 247, 64, 98, 160, 62, 105, 193, 186, 161, 191, 64, 154, 254, 196, 55, 214, 201, 103, 223, 131, 181, 192, 152, 176]), - Bytes32::from([188, 141, 114, 199, 33, 45, 183, 18, 123, 231, 92, 215, 51, 191, 11, 199, 253, 46, 28, 10, 156, 23, 92, 255, 219, 236, 176, 247, 52, 105, 210, 223]), - Bytes32::from([200, 67, 112, 29, 180, 70, 50, 18, 220, 122, 39, 122, 83, 186, 81, 77, 241, 44, 190, 3, 162, 217, 76, 61, 230, 237, 157, 230, 205, 172, 186, 247]), - Bytes32::from([131, 131, 129, 83, 251, 217, 83, 88, 93, 39, 66, 174, 51, 19, 190, 91, 16, 187, 95, 63, 35, 178, 94, 237, 194, 42, 231, 227, 138, 202, 216, 93]), - Bytes32::from([18, 177, 28, 41, 199, 59, 160, 244, 26, 162, 73, 48, 16, 74, 190, 195, 249, 216, 64, 229, 145, 65, 18, 131, 75, 57, 71, 74, 127, 239, 112, 13]), - Bytes32::from([41, 120, 53, 253, 151, 12, 143, 213, 212, 31, 245, 61, 168, 113, 30, 38, 112, 126, 156, 133, 241, 102, 110, 237, 4, 138, 50, 160, 79, 235, 52, 35]), - Bytes32::from([38, 74, 146, 27, 110, 86, 122, 250, 58, 243, 64, 185, 207, 174, 28, 124, 35, 183, 53, 88, 34, 234, 89, 58, 98, 223, 69, 13, 48, 15, 239, 230]), - Bytes32::from([221, 132, 1, 28, 157, 232, 235, 132, 32, 58, 26, 36, 60, 217, 197, 165, 141, 19, 64, 120, 197, 139, 190, 86, 153, 152, 235, 11, 99, 129, 222, 91]), - Bytes32::from([237, 76, 61, 239, 169, 108, 131, 62, 163, 67, 158, 210, 14, 45, 91, 105, 36, 182, 206, 182, 71, 11, 159, 169, 159, 248, 247, 176, 6, 176, 237, 123]), - Bytes32::from([232, 190, 198, 78, 12, 148, 86, 176, 221, 115, 1, 22, 122, 163, 223, 234, 74, 129, 125, 53, 211, 137, 115, 18, 241, 170, 69, 42, 34, 74, 180, 172]), - Bytes32::from([215, 199, 144, 158, 222, 153, 123, 125, 150, 97, 127, 151, 96, 43, 69, 155, 150, 119, 75, 82, 218, 48, 101, 70, 121, 18, 42, 146, 215, 183, 100, 158]), - Bytes32::from([121, 182, 45, 62, 255, 78, 32, 48, 107, 186, 208, 155, 158, 80, 231, 241, 90, 227, 219, 113, 52, 20, 66, 45, 124, 67, 209, 61, 167, 74, 60, 34]), - Bytes32::from([34, 136, 15, 103, 128, 220, 202, 103, 150, 123, 249, 145, 218, 227, 17, 64, 142, 129, 4, 42, 93, 7, 6, 147, 111, 117, 25, 185, 88, 104, 85, 115]), - Bytes32::from([144, 191, 235, 38, 205, 102, 127, 160, 139, 105, 75, 63, 86, 192, 194, 49, 240, 35, 65, 154, 4, 113, 51, 87, 40, 70, 32, 58, 243, 16, 136, 67]), - Bytes32::from([217, 150, 254, 250, 111, 69, 45, 227, 111, 59, 199, 149, 59, 216, 17, 117, 8, 226, 85, 250, 183, 187, 21, 129, 208, 0, 63, 158, 232, 106, 131, 16]), - Bytes32::from([148, 212, 84, 16, 204, 49, 69, 96, 137, 125, 102, 221, 111, 8, 41, 51, 221, 241, 87, 231, 88, 215, 211, 24, 254, 131, 111, 56, 160, 143, 230, 109]), - Bytes32::from([144, 48, 37, 157, 153, 7, 123, 206, 46, 224, 211, 249, 208, 217, 91, 243, 128, 62, 100, 126, 3, 253, 223, 161, 50, 108, 26, 151, 129, 242, 94, 132]), - Bytes32::from([97, 167, 177, 53, 183, 154, 164, 1, 129, 184, 234, 182, 190, 197, 244, 226, 150, 217, 57, 152, 243, 206, 60, 76, 114, 194, 51, 240, 58, 93, 219, 76]), - Bytes32::from([139, 70, 147, 227, 94, 147, 130, 53, 38, 112, 138, 176, 7, 148, 6, 21, 50, 199, 70, 33, 87, 180, 33, 167, 56, 89, 66, 95, 245, 247, 135, 24]), - Bytes32::from([175, 169, 204, 13, 145, 18, 40, 29, 84, 88, 206, 99, 208, 137, 249, 146, 0, 237, 188, 130, 135, 223, 121, 54, 126, 251, 247, 109, 141, 217, 62, 127]), - Bytes32::from([139, 188, 3, 234, 198, 124, 194, 238, 217, 237, 214, 250, 66, 220, 0, 51, 1, 203, 122, 125, 46, 213, 22, 253, 8, 218, 145, 253, 170, 156, 159, 96]), - Bytes32::from([107, 130, 208, 55, 16, 249, 46, 4, 98, 236, 130, 52, 190, 126, 232, 229, 108, 126, 239, 175, 25, 229, 84, 33, 249, 66, 128, 162, 47, 221, 110, 163]), - Bytes32::from([239, 176, 14, 134, 210, 125, 177, 40, 200, 42, 229, 32, 200, 58, 9, 73, 210, 161, 8, 105, 4, 70, 19, 134, 117, 132, 167, 18, 16, 108, 207, 113]), - Bytes32::from([237, 116, 250, 79, 151, 228, 171, 189, 89, 213, 122, 121, 55, 25, 52, 238, 79, 19, 31, 194, 73, 158, 43, 78, 86, 194, 36, 141, 105, 10, 87, 58]), - Bytes32::from([216, 125, 158, 123, 121, 158, 74, 152, 46, 18, 196, 115, 233, 149, 205, 189, 10, 232, 174, 21, 2, 52, 202, 111, 74, 160, 191, 196, 84, 93, 98, 46]), - Bytes32::from([201, 148, 124, 172, 62, 154, 127, 129, 205, 197, 134, 133, 144, 78, 47, 190, 197, 190, 103, 44, 129, 57, 155, 227, 152, 212, 130, 12, 192, 223, 244, 68]), - Bytes32::from([102, 147, 19, 104, 237, 188, 140, 66, 166, 77, 105, 55, 5, 165, 143, 107, 91, 247, 53, 203, 187, 163, 109, 66, 19, 164, 153, 170, 82, 251, 148, 10]), - Bytes32::from([33, 89, 246, 96, 201, 15, 77, 99, 252, 111, 250, 152, 124, 80, 50, 57, 197, 124, 254, 202, 246, 131, 11, 219, 249, 102, 35, 79, 100, 173, 146, 167]), - Bytes32::from([6, 27, 205, 165, 249, 112, 70, 105, 232, 156, 155, 204, 71, 5, 21, 239, 91, 69, 248, 111, 218, 154, 187, 85, 118, 72, 210, 99, 138, 40, 233, 75]) - ]); - zero_hashes.insert(MerkleType::Module, vec![ - Bytes32::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::from([252, 178, 61, 5, 174, 66, 106, 30, 131, 163, 114, 90, 231, 83, 228, 153, 108, 255, 60, 37, 254, 139, 153, 129, 208, 156, 109, 74, 233, 129, 174, 182]), - Bytes32::from([128, 23, 154, 62, 181, 220, 154, 183, 222, 214, 79, 76, 162, 169, 179, 162, 185, 93, 179, 115, 161, 55, 19, 63, 227, 168, 140, 66, 182, 6, 60, 120]), - Bytes32::from([243, 119, 126, 55, 151, 128, 119, 12, 124, 84, 146, 243, 156, 68, 82, 174, 201, 162, 29, 73, 29, 77, 103, 205, 194, 250, 45, 133, 39, 71, 224, 177]), - Bytes32::from([209, 179, 222, 187, 184, 84, 131, 182, 172, 78, 20, 104, 236, 246, 114, 74, 55, 98, 29, 34, 117, 249, 89, 76, 85, 38, 248, 193, 75, 10, 243, 100]), - Bytes32::from([195, 14, 58, 139, 148, 140, 218, 174, 131, 204, 69, 84, 127, 8, 142, 88, 136, 83, 253, 241, 74, 247, 143, 204, 38, 15, 138, 98, 47, 188, 255, 245]), - Bytes32::from([167, 4, 177, 126, 159, 76, 19, 220, 160, 159, 81, 227, 110, 147, 179, 175, 253, 187, 46, 24, 15, 168, 153, 84, 4, 167, 247, 225, 121, 175, 134, 85]), - Bytes32::from([237, 144, 152, 155, 211, 100, 202, 187, 41, 181, 45, 224, 143, 139, 18, 77, 110, 34, 212, 207, 239, 180, 73, 84, 166, 194, 22, 149, 89, 215, 86, 21]), - Bytes32::from([226, 192, 91, 176, 242, 185, 212, 189, 178, 80, 238, 252, 183, 82, 220, 242, 22, 237, 84, 142, 132, 91, 95, 219, 252, 171, 51, 76, 28, 146, 86, 155]), - Bytes32::from([199, 200, 237, 66, 220, 14, 221, 121, 117, 150, 118, 36, 138, 142, 50, 173, 12, 195, 131, 90, 27, 189, 247, 221, 89, 151, 41, 27, 135, 207, 137, 172]), - Bytes32::from([160, 60, 124, 200, 56, 240, 67, 161, 121, 95, 247, 51, 153, 249, 125, 88, 231, 2, 85, 167, 251, 187, 21, 103, 49, 132, 213, 52, 219, 30, 146, 59]), - Bytes32::from([123, 52, 142, 254, 117, 160, 215, 99, 155, 130, 134, 183, 76, 99, 166, 246, 49, 51, 142, 67, 116, 234, 69, 199, 201, 19, 70, 3, 208, 247, 40, 82]), - Bytes32::from([165, 32, 183, 79, 246, 224, 220, 103, 11, 160, 233, 66, 129, 238, 194, 73, 17, 37, 128, 185, 175, 88, 144, 228, 231, 185, 22, 17, 149, 174, 72, 1]), - Bytes32::from([12, 24, 45, 128, 57, 246, 187, 176, 154, 247, 169, 18, 116, 176, 70, 246, 203, 141, 211, 104, 5, 147, 78, 214, 161, 71, 33, 97, 7, 21, 158, 61]), - Bytes32::from([215, 18, 110, 29, 36, 34, 133, 219, 15, 204, 206, 158, 186, 213, 181, 41, 184, 160, 71, 165, 163, 121, 88, 106, 228, 58, 34, 105, 112, 168, 84, 123]), - Bytes32::from([6, 169, 156, 220, 55, 53, 26, 229, 104, 60, 113, 111, 153, 18, 251, 234, 179, 159, 56, 14, 112, 7, 144, 199, 45, 180, 116, 239, 21, 207, 173, 205]), - Bytes32::from([24, 172, 76, 192, 21, 91, 250, 75, 196, 119, 231, 221, 13, 239, 113, 39, 62, 40, 165, 26, 245, 16, 61, 106, 39, 28, 78, 212, 249, 230, 84, 108]), - Bytes32::from([248, 34, 1, 62, 213, 235, 20, 21, 220, 78, 178, 126, 184, 102, 242, 50, 49, 174, 163, 122, 166, 96, 40, 110, 78, 199, 89, 158, 155, 251, 233, 49]), - Bytes32::from([103, 54, 133, 19, 189, 117, 46, 209, 17, 2, 64, 251, 77, 195, 197, 91, 38, 48, 214, 36, 96, 255, 133, 87, 244, 101, 166, 218, 167, 129, 225, 167]), - Bytes32::from([196, 159, 226, 85, 100, 246, 179, 251, 133, 33, 114, 51, 104, 245, 81, 54, 137, 126, 245, 76, 112, 146, 139, 185, 190, 19, 106, 132, 48, 203, 34, 237]), - Bytes32::from([41, 190, 7, 23, 227, 80, 13, 134, 244, 18, 215, 148, 1, 72, 1, 22, 91, 165, 182, 69, 160, 179, 241, 106, 254, 116, 245, 131, 136, 35, 190, 226]), - Bytes32::from([205, 132, 211, 121, 67, 210, 191, 102, 218, 92, 56, 204, 68, 160, 188, 100, 229, 80, 77, 27, 26, 86, 248, 86, 216, 39, 242, 211, 183, 139, 219, 83]), - Bytes32::from([13, 215, 68, 100, 180, 74, 23, 58, 157, 140, 76, 31, 114, 254, 85, 78, 234, 40, 251, 199, 35, 204, 111, 243, 163, 64, 221, 21, 96, 55, 127, 118]), - Bytes32::from([225, 14, 246, 105, 64, 96, 225, 200, 186, 66, 40, 253, 131, 80, 102, 178, 83, 22, 150, 32, 15, 139, 76, 172, 144, 3, 30, 43, 217, 213, 89, 43]), - Bytes32::from([200, 83, 93, 27, 98, 246, 87, 100, 53, 166, 89, 138, 157, 88, 148, 245, 61, 115, 246, 20, 142, 156, 54, 237, 179, 64, 148, 218, 67, 5, 142, 248]), - Bytes32::from([159, 25, 150, 25, 114, 252, 162, 57, 21, 125, 147, 111, 220, 117, 17, 107, 40, 21, 157, 183, 6, 63, 226, 37, 64, 179, 133, 58, 107, 245, 78, 14]), - Bytes32::from([58, 243, 16, 193, 174, 42, 255, 46, 40, 128, 26, 167, 173, 164, 71, 226, 155, 205, 26, 127, 154, 24, 74, 244, 106, 251, 25, 221, 197, 176, 194, 17]), - Bytes32::from([51, 47, 251, 206, 27, 9, 142, 27, 253, 132, 189, 62, 109, 150, 246, 2, 137, 90, 157, 185, 59, 96, 0, 154, 29, 17, 231, 3, 84, 95, 49, 51]), - Bytes32::from([250, 158, 158, 248, 206, 150, 95, 254, 53, 140, 80, 102, 67, 26, 76, 127, 236, 86, 182, 120, 72, 239, 190, 118, 60, 77, 28, 82, 152, 234, 73, 201]), - Bytes32::from([255, 137, 155, 144, 74, 231, 231, 43, 187, 202, 137, 66, 205, 37, 40, 225, 0, 33, 87, 137, 113, 163, 58, 64, 147, 74, 123, 128, 19, 156, 46, 83]), - Bytes32::from([207, 61, 79, 4, 202, 96, 238, 144, 154, 230, 145, 65, 230, 130, 246, 10, 140, 71, 66, 246, 53, 230, 148, 1, 248, 103, 145, 149, 157, 38, 169, 8]), - Bytes32::from([33, 168, 110, 82, 84, 151, 70, 98, 115, 2, 221, 116, 210, 10, 247, 189, 203, 245, 186, 86, 121, 142, 218, 95, 68, 241, 21, 219, 131, 241, 185, 203]), - Bytes32::from([125, 247, 7, 149, 181, 71, 68, 141, 123, 207, 144, 83, 170, 27, 244, 37, 210, 148, 0, 140, 144, 159, 237, 216, 227, 247, 85, 229, 80, 174, 40, 48]), - Bytes32::from([0, 205, 68, 89, 77, 97, 204, 140, 113, 244, 168, 76, 49, 137, 236, 21, 132, 99, 10, 206, 195, 206, 208, 120, 227, 77, 21, 223, 145, 227, 48, 139]), - Bytes32::from([10, 153, 106, 155, 149, 65, 211, 247, 246, 5, 129, 126, 74, 14, 113, 168, 152, 154, 205, 139, 49, 2, 182, 65, 163, 15, 62, 126, 62, 16, 26, 36]), - Bytes32::from([24, 251, 204, 187, 179, 146, 114, 66, 110, 182, 131, 248, 36, 170, 169, 128, 22, 221, 134, 193, 121, 189, 128, 94, 83, 255, 226, 37, 133, 83, 220, 181]), - Bytes32::from([25, 52, 245, 155, 53, 39, 73, 130, 12, 73, 106, 255, 44, 204, 208, 41, 32, 126, 159, 98, 197, 67, 58, 90, 6, 146, 25, 166, 195, 194, 215, 70]), - Bytes32::from([194, 167, 206, 222, 96, 6, 86, 241, 95, 105, 225, 147, 99, 93, 201, 220, 166, 145, 4, 25, 168, 188, 21, 168, 80, 163, 132, 216, 239, 19, 115, 36]), - Bytes32::from([243, 16, 4, 9, 140, 42, 62, 105, 97, 7, 4, 234, 200, 227, 42, 10, 51, 167, 38, 148, 69, 154, 143, 179, 94, 177, 248, 28, 33, 61, 166, 187]), - Bytes32::from([156, 201, 97, 197, 223, 83, 229, 186, 187, 33, 49, 210, 181, 222, 180, 234, 150, 33, 99, 168, 157, 26, 241, 1, 213, 220, 165, 8, 31, 76, 134, 243]), - Bytes32::from([34, 218, 29, 74, 212, 218, 95, 6, 53, 10, 63, 174, 119, 90, 90, 35, 92, 124, 169, 222, 75, 61, 199, 118, 132, 40, 193, 9, 250, 80, 12, 197]), - Bytes32::from([102, 137, 75, 155, 181, 222, 86, 192, 140, 167, 3, 178, 212, 165, 49, 163, 86, 8, 76, 240, 32, 202, 34, 159, 217, 173, 101, 125, 237, 34, 48, 179]), - Bytes32::from([136, 53, 156, 19, 107, 234, 210, 218, 180, 236, 9, 7, 80, 63, 146, 57, 77, 106, 135, 64, 23, 184, 9, 139, 61, 237, 225, 157, 183, 182, 137, 31]), - Bytes32::from([237, 226, 115, 218, 228, 122, 45, 46, 67, 21, 130, 204, 80, 2, 28, 47, 148, 191, 28, 33, 177, 47, 207, 14, 33, 117, 28, 46, 88, 254, 97, 227]), - Bytes32::from([38, 87, 252, 28, 105, 20, 117, 29, 234, 237, 60, 91, 48, 101, 219, 219, 24, 52, 169, 243, 71, 214, 117, 41, 207, 17, 148, 77, 218, 44, 122, 167]), - Bytes32::from([235, 31, 185, 222, 3, 22, 222, 174, 126, 128, 55, 67, 201, 229, 55, 28, 241, 144, 184, 85, 141, 153, 183, 211, 66, 80, 152, 248, 214, 130, 64, 205]), - Bytes32::from([52, 169, 226, 179, 195, 44, 245, 101, 35, 92, 145, 174, 152, 212, 192, 148, 241, 72, 248, 61, 239, 124, 98, 213, 181, 75, 84, 121, 57, 90, 172, 164]), - Bytes32::from([27, 19, 12, 74, 128, 193, 65, 63, 15, 6, 174, 167, 79, 56, 88, 13, 117, 6, 189, 14, 11, 13, 133, 136, 141, 64, 74, 17, 159, 192, 251, 242]), - Bytes32::from([101, 69, 132, 221, 127, 162, 162, 92, 248, 131, 39, 52, 169, 170, 231, 137, 123, 106, 161, 16, 202, 242, 216, 245, 211, 170, 74, 128, 108, 243, 166, 38]), - Bytes32::from([157, 82, 193, 234, 117, 199, 118, 245, 63, 31, 186, 32, 135, 233, 29, 213, 217, 119, 208, 64, 149, 116, 117, 129, 211, 225, 207, 22, 225, 99, 194, 222]), - Bytes32::from([112, 194, 64, 229, 154, 223, 109, 8, 191, 120, 32, 176, 154, 7, 174, 103, 2, 156, 230, 164, 245, 252, 0, 116, 213, 40, 20, 239, 135, 62, 198, 42]), - Bytes32::from([32, 91, 5, 170, 221, 134, 167, 144, 16, 130, 237, 114, 71, 184, 131, 223, 92, 149, 161, 68, 196, 56, 73, 148, 203, 187, 174, 178, 178, 53, 156, 177]), - Bytes32::from([234, 97, 64, 211, 81, 59, 14, 249, 38, 8, 247, 37, 243, 37, 88, 234, 19, 54, 146, 63, 88, 79, 127, 190, 144, 51, 240, 19, 15, 143, 18, 9]), - Bytes32::from([247, 102, 43, 28, 24, 201, 189, 198, 66, 58, 210, 51, 174, 234, 52, 239, 37, 83, 212, 184, 127, 170, 168, 127, 47, 11, 248, 213, 84, 3, 201, 181]), - Bytes32::from([126, 18, 116, 33, 129, 25, 247, 2, 162, 202, 103, 201, 237, 67, 28, 80, 46, 182, 163, 239, 90, 204, 47, 196, 137, 79, 19, 165, 209, 84, 140, 132]), - Bytes32::from([189, 160, 148, 101, 82, 248, 215, 206, 90, 91, 205, 148, 37, 38, 172, 82, 223, 228, 66, 173, 220, 246, 194, 73, 231, 17, 220, 47, 222, 175, 7, 24]), - Bytes32::from([237, 149, 54, 210, 99, 72, 182, 55, 69, 140, 161, 215, 104, 90, 104, 26, 216, 241, 232, 210, 37, 77, 56, 216, 6, 160, 199, 247, 164, 227, 142, 255]), - Bytes32::from([11, 57, 131, 77, 203, 89, 156, 126, 200, 215, 103, 209, 70, 235, 78, 247, 0, 126, 209, 248, 220, 135, 158, 244, 141, 74, 6, 158, 19, 37, 42, 39]), - Bytes32::from([107, 131, 231, 102, 64, 182, 78, 253, 77, 143, 94, 34, 199, 93, 44, 131, 169, 211, 71, 223, 53, 230, 59, 107, 146, 22, 188, 207, 210, 220, 168, 129]), - Bytes32::from([78, 71, 246, 216, 154, 188, 152, 6, 234, 254, 21, 1, 128, 148, 56, 91, 250, 95, 76, 103, 15, 250, 137, 186, 114, 254, 122, 69, 208, 242, 69, 111]), - Bytes32::from([82, 241, 242, 155, 248, 109, 84, 118, 225, 255, 122, 40, 3, 87, 20, 223, 212, 205, 141, 178, 32, 229, 234, 146, 101, 73, 79, 55, 28, 82, 81, 178]), - Bytes32::from([35, 169, 243, 198, 215, 220, 113, 91, 6, 79, 48, 201, 97, 143, 212, 34, 247, 46, 38, 93, 166, 213, 158, 218, 61, 86, 240, 149, 224, 174, 225, 73]), - Bytes32::from([25, 108, 21, 212, 193, 192, 96, 39, 57, 72, 193, 99, 239, 0, 231, 83, 183, 195, 105, 33, 220, 187, 18, 148, 43, 30, 42, 127, 192, 240, 13, 224]), - Bytes32::from([119, 117, 186, 31, 43, 128, 143, 25, 182, 135, 156, 58, 152, 81, 70, 116, 171, 137, 125, 157, 152, 163, 34, 65, 240, 178, 12, 24, 168, 111, 39, 35]) - ]); - zero_hashes - }; -} \ No newline at end of file +pub const ZERO_HASHES: &[&[Bytes32; 64]; 7] = &[ + FUNCTION_HASHES, + VALUE_HASHES, + INSTRUCTION_HASHES, + MEMORY_HASHES, + TABLE_HASHES, + TABLE_ELEMENT_HASHES, + MODULE_HASHES, +]; \ No newline at end of file From c5d29939fdd6c271da1c3addeb9376b9755e5cf0 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 26 Apr 2024 23:30:50 +0200 Subject: [PATCH 026/268] Fix order of VALUES and FUNCTIONS. Yay! Tests caught typos. --- arbitrator/prover/src/merkle/zerohashes.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle/zerohashes.rs b/arbitrator/prover/src/merkle/zerohashes.rs index 5b72e010fe..e0db5fbee2 100644 --- a/arbitrator/prover/src/merkle/zerohashes.rs +++ b/arbitrator/prover/src/merkle/zerohashes.rs @@ -470,8 +470,8 @@ const MODULE_HASHES: &[Bytes32; 64] = &[ ]; pub const ZERO_HASHES: &[&[Bytes32; 64]; 7] = &[ - FUNCTION_HASHES, VALUE_HASHES, + FUNCTION_HASHES, INSTRUCTION_HASHES, MEMORY_HASHES, TABLE_HASHES, From 0cce10c41f76f68233f28c12544bca4b3d29cbc7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Sat, 27 Apr 2024 00:05:05 +0200 Subject: [PATCH 027/268] Make merkle.rs compile with non-rayon. Previously, this wouldn't work because the collect_into_iter() method is not supported on the non-rayon map. --- arbitrator/prover/src/merkle.rs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index b1a3a6c03b..628b6c64eb 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -188,6 +188,26 @@ const fn empty_hash_at(ty: MerkleType, layer_i: usize) -> Bytes32 { } } +#[inline] +#[cfg(feature = "rayon")] +fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: Bytes32) -> Vec { + let mut new_layer: Vec = Vec::with_capacity(layer.len() >> 1); + let chunks = layer.par_chunks(2); + chunks + .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_hash))) + .collect_into_vec(&mut new_layer); + new_layer +} + +#[inline] +#[cfg(not(feature = "rayon"))] +fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: Bytes32) -> Vec { + let new_layer = layer.chunks(2) + .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_hash))) + .collect(); + new_layer +} + impl Merkle { /// Creates a new Merkle tree with the given type and leaf hashes. /// The tree is built up to the minimum depth necessary to hold all the @@ -219,16 +239,7 @@ impl Merkle { let layer = layers.last().unwrap(); let empty_hash = empty_hash_at(ty, layer_i); - #[cfg(feature = "rayon")] - let chunks = layer.par_chunks(2); - - #[cfg(not(feature = "rayon"))] - let chunks = layer.chunks(2); - - let mut new_layer: Vec = Vec::with_capacity(layer.len() >> 1); - chunks - .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_hash))) - .collect_into_vec(&mut new_layer); + let new_layer = new_layer(ty, layer, empty_hash); dirty_indices.push(HashSet::with_capacity(new_layer.len())); layers.push(new_layer); layer_i += 1; From 2f2e1731ec828bd153bdc532a2075da010565f3e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Sat, 27 Apr 2024 00:06:20 +0200 Subject: [PATCH 028/268] Actually set the cached merkle back on the instance. This is why there were all those unexpected "new_advanced" calls on the memory merkle. The resizes were actually setting self.merkle back to None. --- arbitrator/prover/src/memory.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index d8cb9cec15..98e4cc4195 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -312,8 +312,10 @@ impl Memory { self.buffer.resize(new_size, 0); if let Some(mut merkle) = self.merkle.take() { let extra = new_size - merkle.len(); - merkle.extend(vec![hash_leaf([0u8; 32]); extra]) - .expect("Couldn't extend merkle tree"); + merkle + .extend(vec![hash_leaf([0u8; 32]); extra]) + .expect("Couldn't extend merkle tree"); + self.merkle = Some(merkle); } } } From fc16ec383d87a756c810324b32add30699afc94b Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Sat, 27 Apr 2024 01:02:21 +0200 Subject: [PATCH 029/268] Update the version of the enum-iterator-derive crate. --- arbitrator/wasm-libraries/Cargo.lock | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/arbitrator/wasm-libraries/Cargo.lock b/arbitrator/wasm-libraries/Cargo.lock index c5e3855259..650484a631 100644 --- a/arbitrator/wasm-libraries/Cargo.lock +++ b/arbitrator/wasm-libraries/Cargo.lock @@ -378,7 +378,16 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6" dependencies = [ - "enum-iterator-derive", + "enum-iterator-derive 0.7.0", +] + +[[package]] +name = "enum-iterator" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e0b48d2b80ff6b002339547442496ea29d66a8c66ce8e1a6bd8c58b9cec7cf3" +dependencies = [ + "enum-iterator-derive 1.3.1", ] [[package]] @@ -392,6 +401,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "enum-iterator-derive" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19cbb53d33b57ac4df1f0af6b92c38c107cded663c4aea9fae1189dcfc17cf5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "enumset" version = "1.1.3" @@ -887,6 +907,7 @@ dependencies = [ "brotli", "derivative", "digest 0.9.0", + "enum-iterator 2.0.1", "eyre", "fnv", "hex", @@ -1481,7 +1502,7 @@ name = "wasmer-types" version = "4.2.3" dependencies = [ "bytecheck", - "enum-iterator", + "enum-iterator 0.7.0", "enumset", "indexmap 1.9.3", "more-asserts", From 1a52847b58d6773b6bf011ccd37736c8521279fa Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 29 Apr 2024 13:56:39 +0200 Subject: [PATCH 030/268] Update the logic for expand to include upper layers. There was a bug where expanding the lowest layer and calling set on all of the new elements was not sufficient to grow the upper layers. This commit also fixes a warning about the package-level profile override being ineffective. --- arbitrator/bench/Cargo.toml | 3 --- arbitrator/bench/src/bin.rs | 4 ++-- arbitrator/prover/src/merkle.rs | 8 ++++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arbitrator/bench/Cargo.toml b/arbitrator/bench/Cargo.toml index 3441321877..396988ed83 100644 --- a/arbitrator/bench/Cargo.toml +++ b/arbitrator/bench/Cargo.toml @@ -23,6 +23,3 @@ gperftools = { version = "0.2.0", optional = true } counters = [] cpuprof = ["gperftools"] heapprof = ["gperftools", "gperftools/heap"] - -[profile.release] -debug = true diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index a2c94a6c7c..723a1a92d1 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -33,7 +33,7 @@ struct Args { fn main() -> eyre::Result<()> { let args = Args::parse(); - let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20]; + let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24]; if args.always_merkleize { println!("Running benchmark with always merkleize feature on"); } else { @@ -94,7 +94,7 @@ fn main() -> eyre::Result<()> { let total_end_time = total.elapsed(); println!( - "avg hash time {:?}, avg step time {:?}, step size {}, num_iters {}, total time {:?}", + "avg hash time {:>12?}, avg step time {:>12?}, step size {:>8}, num_iters {}, total time {:>12?}", average(&hash_times), average(&step_times), step_size, diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 3af5bd2ae8..29606d42de 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -305,7 +305,7 @@ impl Merkle { } else if idx == layer.len() { layer.push(next_hash); } else { - panic!("Index {} out of bounds {}", idx, layer.len()); + panic!("Index {} out of bounds {} in layer {}", idx, layer.len(), layer_i); } if layer_i == layers_len - 1 { // next_hash isn't needed @@ -334,7 +334,11 @@ impl Merkle { return Err("Cannot extend with more leaves than the capicity of the tree.".to_owned()); } let mut idx = self.layers[0].len(); - self.layers[0].resize(idx + hashes.len(), self.empty_layers[0]); + let mut new_size = idx + hashes.len(); + for (layer_i, layer) in self.layers.iter_mut().enumerate() { + layer.resize(new_size, self.empty_layers[layer_i]); + new_size >>= 1; + } for hash in hashes { self.set(idx, hash); idx += 1; From bcf845504b87a973169c6a087d769e6d65216471 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 29 Apr 2024 15:40:31 +0200 Subject: [PATCH 031/268] Fix the merge issue for index out of bounds. --- arbitrator/prover/src/merkle.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 34d489ef0c..ed23db0fc5 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -33,6 +33,8 @@ mod zerohashes; use zerohashes::ZERO_HASHES; +use crate::print; + #[cfg(feature = "counters")] lazy_static! { static ref NEW_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { @@ -382,7 +384,7 @@ impl Merkle { if hashes.len() > capacity(layers.as_ref()) - layers[0].len() { return Err("Cannot extend with more leaves than the capicity of the tree.".to_owned()); } - let mut idx = layers.len(); + let mut idx = layers[0].len(); let mut new_size = idx + hashes.len(); for (layer_i, layer) in layers.iter_mut().enumerate() { layer.resize(new_size, empty_hash_at(self.ty, layer_i)); From 72bc92fb64ffd8816e8c3847ae7e7f852941403f Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 30 Apr 2024 10:25:50 +0200 Subject: [PATCH 032/268] Remove the bold submodule. I don't think it's being used. --- bold | 1 - 1 file changed, 1 deletion(-) delete mode 160000 bold diff --git a/bold b/bold deleted file mode 160000 index f456e2fbfa..0000000000 --- a/bold +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f456e2fbfa8560e52ada5fcc5ce927577d07483d From 6f7cafa341a032c81ce0230d0c2647d6f20135e5 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 30 Apr 2024 14:44:59 +0200 Subject: [PATCH 033/268] Enable always_merkelize for all uses of the merkle tree. --- arbitrator/prover/src/lib.rs | 4 ++-- arbitrator/prover/src/machine.rs | 4 ++-- arbitrator/stylus/src/test/mod.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index 85c0ca2aa8..f3169e8ef8 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -101,7 +101,7 @@ unsafe fn arbitrator_load_machine_impl( &libraries, binary_path, true, - false, + true, false, debug_chain, debug_chain, @@ -117,7 +117,7 @@ unsafe fn arbitrator_load_machine_impl( pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char) -> *mut Machine { let binary_path = cstr_to_string(binary_path); let binary_path = Path::new(&binary_path); - match Machine::new_from_wavm(binary_path, false) { + match Machine::new_from_wavm(binary_path, true) { Ok(mach) => Box::into_raw(Box::new(mach)), Err(err) => { eprintln!("Error loading binary: {err}"); diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index 77fcdca883..e836bed5f1 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1245,11 +1245,11 @@ impl Machine { let soft_float = std::fs::read("../../target/machines/latest/soft-float.wasm")?; let soft_float = parse(&soft_float, Path::new("soft-float"))?; - let mut machine = Self::from_binaries( + let mut machine: Machine = Self::from_binaries( &[soft_float, wasi_stub, user_test], bin, false, - false, + true, false, compile.debug.debug_funcs, true, diff --git a/arbitrator/stylus/src/test/mod.rs b/arbitrator/stylus/src/test/mod.rs index 0f1cfd7618..a6259d82bf 100644 --- a/arbitrator/stylus/src/test/mod.rs +++ b/arbitrator/stylus/src/test/mod.rs @@ -150,7 +150,7 @@ fn new_test_machine(path: &str, compile: &CompileConfig) -> Result { &[lib], bin, false, - false, + true, true, compile.debug.debug_funcs, true, From 36578d7d415df6a99fc4346cf643cf36227526f4 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 30 Apr 2024 15:04:18 +0200 Subject: [PATCH 034/268] Make clippy happy. --- arbitrator/prover/src/flat_merkle.rs | 2 +- arbitrator/prover/src/merkle.rs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arbitrator/prover/src/flat_merkle.rs b/arbitrator/prover/src/flat_merkle.rs index 4c46c0b2b6..87ce55d14b 100644 --- a/arbitrator/prover/src/flat_merkle.rs +++ b/arbitrator/prover/src/flat_merkle.rs @@ -58,7 +58,7 @@ impl Merkle { Self::new_advanced(ty, hashes, Bytes32::default(), 0) } pub fn new_advanced( - ty: MerkleType, + _ty: MerkleType, hashes: Vec, empty_hash: Bytes32, min_depth: usize, diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 29606d42de..75f27d38e6 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -10,6 +10,7 @@ use enum_iterator::Sequence; use enum_iterator::all; +use std::cmp::Ordering; #[cfg(feature = "counters")] use std::sync::atomic::AtomicUsize; @@ -242,6 +243,10 @@ impl Merkle { self.layers[0].len() } + pub fn is_empty(&self) -> bool { + self.layers.is_empty() || self.layers[0].is_empty() + } + #[must_use] pub fn prove(&self, idx: usize) -> Option> { if idx >= self.leaves().len() { @@ -300,12 +305,10 @@ impl Merkle { let empty_layers = &self.empty_layers; let layers_len = self.layers.len(); for (layer_i, layer) in self.layers.iter_mut().enumerate() { - if idx < layer.len() { - layer[idx] = next_hash; - } else if idx == layer.len() { - layer.push(next_hash); - } else { - panic!("Index {} out of bounds {} in layer {}", idx, layer.len(), layer_i); + match idx.cmp(&layer.len()) { + Ordering::Less => layer[idx] = next_hash, + Ordering::Equal => layer.push(next_hash), + Ordering::Greater => panic!("Index {} out of bounds {} in layer {}", idx, layer.len(), layer_i), } if layer_i == layers_len - 1 { // next_hash isn't needed @@ -343,7 +346,7 @@ impl Merkle { self.set(idx, hash); idx += 1; } - return Ok(self.layers[0].len()); + Ok(self.layers[0].len()) } } From 97d93d5b08e2e9a28ea72803c007ecf2393f79a7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 30 Apr 2024 15:57:58 +0200 Subject: [PATCH 035/268] Add the fake stuff for the benchmarks to the Dockerfile. I have no idea why this is needed. But, it makes `make docker` successful again. --- Dockerfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6e26a16226..2eba3ca25c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,6 +99,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ COPY arbitrator/Cargo.* arbitrator/ COPY ./Makefile ./ COPY arbitrator/arbutil arbitrator/arbutil +COPY arbitrator/bench arbitrator/bench COPY arbitrator/brotli arbitrator/brotli COPY arbitrator/caller-env arbitrator/caller-env COPY arbitrator/prover arbitrator/prover @@ -127,9 +128,12 @@ RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ COPY --from=brotli-library-export / target/ COPY arbitrator/Cargo.* arbitrator/ COPY arbitrator/arbutil arbitrator/arbutil +COPY arbitrator/bench arbitrator/bench COPY arbitrator/brotli arbitrator/brotli COPY arbitrator/caller-env arbitrator/caller-env COPY arbitrator/prover/Cargo.toml arbitrator/prover/ +COPY arbitrator/prover/benches arbitrator/prover/benches +COPY arbitrator/bench/Cargo.toml arbitrator/bench/ COPY arbitrator/jit/Cargo.toml arbitrator/jit/ COPY arbitrator/stylus/Cargo.toml arbitrator/stylus/ COPY arbitrator/tools/wasmer arbitrator/tools/wasmer @@ -137,11 +141,15 @@ COPY arbitrator/wasm-libraries/user-host-trait/Cargo.toml arbitrator/wasm-librar RUN bash -c 'mkdir arbitrator/{prover,jit,stylus}/src arbitrator/wasm-libraries/user-host-trait/src' RUN echo "fn test() {}" > arbitrator/jit/src/lib.rs && \ echo "fn test() {}" > arbitrator/prover/src/lib.rs && \ + echo "fn test() {}" > arbitrator/bench/src/lib.rs && \ + echo "fn test() {}" > arbitrator/prover/benches/merkle_bench.rs && \ echo "fn test() {}" > arbitrator/stylus/src/lib.rs && \ echo "fn test() {}" > arbitrator/wasm-libraries/user-host-trait/src/lib.rs && \ cargo build --manifest-path arbitrator/Cargo.toml --release --lib && \ rm arbitrator/prover/src/lib.rs arbitrator/jit/src/lib.rs arbitrator/stylus/src/lib.rs && \ - rm arbitrator/wasm-libraries/user-host-trait/src/lib.rs + rm arbitrator/wasm-libraries/user-host-trait/src/lib.rs && \ + rm arbitrator/prover/benches/merkle_bench.rs && \ + rm arbitrator/bench/src/lib.rs COPY ./Makefile ./ COPY arbitrator/prover arbitrator/prover COPY arbitrator/wasm-libraries arbitrator/wasm-libraries From e3d7cf4626b4cfc8e8f2821fd377dc4777045c23 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 30 Apr 2024 16:29:57 +0200 Subject: [PATCH 036/268] Make clippy even happier. --- arbitrator/bench/src/parse_input.rs | 32 ++++++++++++++--------------- arbitrator/bench/src/prepare.rs | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/arbitrator/bench/src/parse_input.rs b/arbitrator/bench/src/parse_input.rs index 9b645850f7..32f1c15ed3 100644 --- a/arbitrator/bench/src/parse_input.rs +++ b/arbitrator/bench/src/parse_input.rs @@ -58,21 +58,21 @@ impl FileData { let mut line = String::new(); while reader.read_line(&mut line)? > 0 { if line.starts_with("Id:") { - id = line.split(":").nth(1).unwrap().trim().parse().unwrap(); + id = line.split(':').nth(1).unwrap().trim().parse().unwrap(); } else if line.starts_with("HasDelayedMsg:") { - has_delayed_msg = line.split(":").nth(1).unwrap().trim().parse().unwrap(); + has_delayed_msg = line.split(':').nth(1).unwrap().trim().parse().unwrap(); } else if line.starts_with("DelayedMsgNr:") { - delayed_msg_nr = line.split(":").nth(1).unwrap().trim().parse().unwrap(); + delayed_msg_nr = line.split(':').nth(1).unwrap().trim().parse().unwrap(); } else if line.starts_with("Preimages:") { items.push(Item::from_reader(&mut reader, &mut line)?); } else if line.starts_with("BatchInfo:") { - let parts: Vec<_> = line.split(",").collect(); - batch_info.number = parts[0].split(":").nth(2).unwrap().trim().parse().unwrap(); - batch_info.data = hex::decode(parts[1].split(":").nth(1).unwrap().trim()).unwrap(); + let parts: Vec<_> = line.split(',').collect(); + batch_info.number = parts[0].split(':').nth(2).unwrap().trim().parse().unwrap(); + batch_info.data = hex::decode(parts[1].split(':').nth(1).unwrap().trim()).unwrap(); } else if line.starts_with("DelayedMsg:") { - delayed_msg = hex::decode(line.split(":").nth(1).unwrap().trim()).unwrap(); + delayed_msg = hex::decode(line.split(':').nth(1).unwrap().trim()).unwrap(); } else if line.starts_with("StartState:") { - let parts: Vec<_> = line.split(",").collect(); + let parts: Vec<_> = line.split(',').collect(); // Parsing block_hash let block_hash_str = parts[0].split("BlockHash:").nth(1).unwrap().trim(); @@ -80,13 +80,13 @@ impl FileData { hex::decode(block_hash_str.strip_prefix("0x").unwrap()).unwrap(); // Parsing send_root - let send_root_str = parts[1].split(":").nth(1).unwrap().trim(); + let send_root_str = parts[1].split(':').nth(1).unwrap().trim(); start_state.send_root = hex::decode(send_root_str.strip_prefix("0x").unwrap()).unwrap(); // Parsing batch start_state.batch = parts[2] - .split(":") + .split(':') .nth(1) .unwrap() .trim() @@ -95,7 +95,7 @@ impl FileData { // Parsing pos_in_batch start_state.pos_in_batch = parts[3] - .split(":") + .split(':') .nth(1) .unwrap() .trim() @@ -131,12 +131,12 @@ impl Item { } if line.starts_with("Preimages:") { line.clear(); - while reader.read_line(line)? > 0 && line.starts_with("\t") { - let parts: Vec<_> = line.trim().split(",").collect(); - let type_ = parts[0].split(":").nth(1).unwrap().trim().parse().unwrap(); + while reader.read_line(line)? > 0 && line.starts_with('\t') { + let parts: Vec<_> = line.trim().split(',').collect(); + let type_ = parts[0].split(':').nth(1).unwrap().trim().parse().unwrap(); let hash = hex::decode( parts[1] - .split(":") + .split(':') .nth(1) .unwrap() .trim() @@ -144,7 +144,7 @@ impl Item { .unwrap(), ) .unwrap(); - let data = hex::decode(parts[2].split(":").nth(1).unwrap().trim()).unwrap(); + let data = hex::decode(parts[2].split(':').nth(1).unwrap().trim()).unwrap(); preimages.push(Preimage { type_, hash, data }); line.clear(); } diff --git a/arbitrator/bench/src/prepare.rs b/arbitrator/bench/src/prepare.rs index 4004e467a9..daf0f48f8f 100644 --- a/arbitrator/bench/src/prepare.rs +++ b/arbitrator/bench/src/prepare.rs @@ -14,11 +14,11 @@ pub fn prepare_machine( machines: PathBuf, always_merkleize: bool, ) -> eyre::Result { - let file = File::open(&preimages)?; + let file = File::open(preimages)?; let reader = BufReader::new(file); let data = FileData::from_reader(reader)?; - let item = data.items.get(0).unwrap().clone(); + let item = data.items.first().unwrap().clone(); let preimages = item.preimages; let preimages = preimages .into_iter() From 521a7d830f49718bb73842b3b03a27483dd9a3e7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 30 Apr 2024 18:24:59 +0200 Subject: [PATCH 037/268] Cargo fmt changes only. --- arbitrator/bench/src/bin.rs | 12 ++- arbitrator/prover/benches/merkle_bench.rs | 12 ++- arbitrator/prover/src/merkle.rs | 109 ++++++++++++++++------ 3 files changed, 99 insertions(+), 34 deletions(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 723a1a92d1..23930652c2 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -51,10 +51,18 @@ fn main() -> eyre::Result<()> { let mut num_iters = 0; #[cfg(feature = "cpuprof")] - PROFILER.lock().unwrap().start(format!("./target/bench-{}.prof", step_size)).unwrap(); + PROFILER + .lock() + .unwrap() + .start(format!("./target/bench-{}.prof", step_size)) + .unwrap(); #[cfg(feature = "heapprof")] - HEAP_PROFILER.lock().unwrap().start(format!("./target/bench-{}.hprof", step_size)).unwrap(); + HEAP_PROFILER + .lock() + .unwrap() + .start(format!("./target/bench-{}.hprof", step_size)) + .unwrap(); #[cfg(feature = "counters")] merkle::reset_counters(); diff --git a/arbitrator/prover/benches/merkle_bench.rs b/arbitrator/prover/benches/merkle_bench.rs index 20b566e077..ee8905964f 100644 --- a/arbitrator/prover/benches/merkle_bench.rs +++ b/arbitrator/prover/benches/merkle_bench.rs @@ -1,6 +1,6 @@ +use arbutil::Bytes32; use criterion::{criterion_group, criterion_main, Criterion}; use prover::merkle::{Merkle, MerkleType}; -use arbutil::Bytes32; use rand::Rng; fn extend_and_set_leavees(mut merkle: Merkle, rng: &mut rand::rngs::ThreadRng) { @@ -14,7 +14,7 @@ fn extend_and_set_leavees(mut merkle: Merkle, rng: &mut rand::rngs::ThreadRng) { for _ in 0..100 { merkle.extend(new_leaves.clone()).expect("extend failed"); - for _ in 0..(merkle.len()/10) { + for _ in 0..(merkle.len() / 10) { let random_index = rng.gen_range(0..merkle.len()); merkle.set(random_index, Bytes32::from([rng.gen_range(0u8..9); 32])); } @@ -35,7 +35,8 @@ fn merkle_benchmark(c: &mut Criterion) { // Perform many calls to set leaves to new values c.bench_function("extend_set_leaves_and_root", |b| { b.iter(|| { - let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 20); + let merkle = + Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 20); extend_and_set_leavees(merkle.clone(), &mut rng); }) }); @@ -50,11 +51,12 @@ fn merkle_construction(c: &mut Criterion) { c.bench_function("merkle_construction", |b| { b.iter(|| { - let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 21); + let merkle = + Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 21); merkle.root(); }) }); } criterion_group!(benches, merkle_benchmark, merkle_construction); -criterion_main!(benches); \ No newline at end of file +criterion_main!(benches); diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 75f27d38e6..52afd587dd 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -9,7 +9,6 @@ use enum_iterator::Sequence; #[cfg(feature = "counters")] use enum_iterator::all; - use std::cmp::Ordering; #[cfg(feature = "counters")] use std::sync::atomic::AtomicUsize; @@ -20,13 +19,12 @@ use std::sync::atomic::Ordering; #[cfg(feature = "counters")] use lazy_static::lazy_static; - #[cfg(feature = "counters")] use std::collections::HashMap; +use core::panic; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use core::panic; use std::convert::{TryFrom, TryInto}; #[cfg(feature = "rayon")] @@ -78,7 +76,6 @@ lazy_static! { }; } - #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Sequence)] pub enum MerkleType { Empty, @@ -103,8 +100,13 @@ pub fn print_counters() { if ty == MerkleType::Empty { continue; } - println!("{} New: {}, Root: {}, Set: {}", - ty.get_prefix(), NEW_COUNTERS[&ty].load(Ordering::Relaxed), ROOT_COUNTERS[&ty].load(Ordering::Relaxed), SET_COUNTERS[&ty].load(Ordering::Relaxed)); + println!( + "{} New: {}, Root: {}, Set: {}", + ty.get_prefix(), + NEW_COUNTERS[&ty].load(Ordering::Relaxed), + ROOT_COUNTERS[&ty].load(Ordering::Relaxed), + SET_COUNTERS[&ty].load(Ordering::Relaxed) + ); } } @@ -136,19 +138,19 @@ impl MerkleType { } /// A Merkle tree with a fixed number of layers -/// +/// /// https://en.wikipedia.org/wiki/Merkle_tree -/// +/// /// Each instance's leaves contain the hashes of a specific [MerkleType]. /// The tree does not grow in height, but it can be initialized with fewer /// leaves than the number that could be contained in its layers. -/// +/// /// When initialized with [Merkle::new], the tree has the minimum depth /// necessary to hold all the leaves. (e.g. 5 leaves -> 4 layers.) -/// +/// /// It can be over-provisioned using the [Merkle::new_advanced] method /// and passing a minimum depth. -/// +/// /// This structure does not contain the data itself, only the hashes. #[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)] pub struct Merkle { @@ -235,7 +237,7 @@ impl Merkle { #[inline] fn capacity(&self) -> usize { let base: usize = 2; - base.pow((self.layers.len() -1).try_into().unwrap()) + base.pow((self.layers.len() - 1).try_into().unwrap()) } // Returns the number of leaves in the tree. @@ -308,7 +310,12 @@ impl Merkle { match idx.cmp(&layer.len()) { Ordering::Less => layer[idx] = next_hash, Ordering::Equal => layer.push(next_hash), - Ordering::Greater => panic!("Index {} out of bounds {} in layer {}", idx, layer.len(), layer_i), + Ordering::Greater => panic!( + "Index {} out of bounds {} in layer {}", + idx, + layer.len(), + layer_i + ), } if layer_i == layers_len - 1 { // next_hash isn't needed @@ -328,7 +335,7 @@ impl Merkle { } /// Extends the leaves of the tree with the given hashes. - /// + /// /// Returns the new number of leaves in the tree. /// Erorrs if the number of hashes plus the current leaves is greater than /// the capacity of the tree. @@ -359,33 +366,73 @@ fn extend_works() { Bytes32::from([4; 32]), Bytes32::from([5; 32]), ]; - let mut expected = hash_node(MerkleType::Value, + let mut expected = hash_node( + MerkleType::Value, hash_node( MerkleType::Value, - hash_node(MerkleType::Value, Bytes32::from([1; 32]), Bytes32::from([2; 32])), - hash_node(MerkleType::Value, Bytes32::from([3; 32]), Bytes32::from([4; 32]))), + hash_node( + MerkleType::Value, + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + ), + ), hash_node( MerkleType::Value, - hash_node(MerkleType::Value, Bytes32::from([5; 32]), Bytes32::from([0; 32])), - hash_node(MerkleType::Value, Bytes32::from([0; 32]), Bytes32::from([0; 32])))); + hash_node( + MerkleType::Value, + Bytes32::from([5; 32]), + Bytes32::from([0; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([0; 32]), + Bytes32::from([0; 32]), + ), + ), + ); let mut merkle = Merkle::new(MerkleType::Value, hashes.clone()); assert_eq!(merkle.capacity(), 8); assert_eq!(merkle.root(), expected); let new_size = match merkle.extend(vec![Bytes32::from([6; 32])]) { Ok(size) => size, - Err(e) => panic!("{}", e) + Err(e) => panic!("{}", e), }; assert_eq!(new_size, 6); - expected = hash_node(MerkleType::Value, + expected = hash_node( + MerkleType::Value, hash_node( MerkleType::Value, - hash_node(MerkleType::Value, Bytes32::from([1; 32]), Bytes32::from([2; 32])), - hash_node(MerkleType::Value, Bytes32::from([3; 32]), Bytes32::from([4; 32]))), + hash_node( + MerkleType::Value, + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + ), + ), hash_node( MerkleType::Value, - hash_node(MerkleType::Value, Bytes32::from([5; 32]), Bytes32::from([6; 32])), - hash_node(MerkleType::Value, Bytes32::from([0; 32]), Bytes32::from([0; 32])))); + hash_node( + MerkleType::Value, + Bytes32::from([5; 32]), + Bytes32::from([6; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([0; 32]), + Bytes32::from([0; 32]), + ), + ), + ); assert_eq!(merkle.root(), expected); } @@ -393,14 +440,22 @@ fn extend_works() { fn correct_capacity() { let merkle = Merkle::new(MerkleType::Value, vec![Bytes32::from([1; 32])]); assert_eq!(merkle.capacity(), 1); - let merkle = Merkle::new_advanced(MerkleType::Memory, vec![Bytes32::from([1; 32])], Bytes32::default(), 11); + let merkle = Merkle::new_advanced( + MerkleType::Memory, + vec![Bytes32::from([1; 32])], + Bytes32::default(), + 11, + ); assert_eq!(merkle.capacity(), 1024); } #[test] #[should_panic] fn set_with_bad_index_panics() { - let mut merkle = Merkle::new(MerkleType::Value, vec![Bytes32::default(), Bytes32::default()]); + let mut merkle = Merkle::new( + MerkleType::Value, + vec![Bytes32::default(), Bytes32::default()], + ); assert_eq!(merkle.capacity(), 2); merkle.set(2, Bytes32::default()); } From cf50743843659560bd079c6f651b345003df6642 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 1 May 2024 23:32:58 +0200 Subject: [PATCH 038/268] Fix right-shifting to zero. --- arbitrator/prover/src/merkle.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 52afd587dd..adf4c1ea80 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -9,6 +9,7 @@ use enum_iterator::Sequence; #[cfg(feature = "counters")] use enum_iterator::all; +use std::cmp::max; use std::cmp::Ordering; #[cfg(feature = "counters")] use std::sync::atomic::AtomicUsize; @@ -347,7 +348,7 @@ impl Merkle { let mut new_size = idx + hashes.len(); for (layer_i, layer) in self.layers.iter_mut().enumerate() { layer.resize(new_size, self.empty_layers[layer_i]); - new_size >>= 1; + new_size = max(new_size >> 1, 1); } for hash in hashes { self.set(idx, hash); From cc71b3275112bf81af511900439aea864a0f5c67 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 2 May 2024 00:55:06 +0200 Subject: [PATCH 039/268] Turn off always_merkelize for now. The system tests are timing out because the implementation is still too slow for large steps with lots of store and resize memory calls. --- arbitrator/prover/src/lib.rs | 4 ++-- arbitrator/prover/src/machine.rs | 4 ++-- arbitrator/stylus/src/test/mod.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index f3169e8ef8..85c0ca2aa8 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -101,7 +101,7 @@ unsafe fn arbitrator_load_machine_impl( &libraries, binary_path, true, - true, + false, false, debug_chain, debug_chain, @@ -117,7 +117,7 @@ unsafe fn arbitrator_load_machine_impl( pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char) -> *mut Machine { let binary_path = cstr_to_string(binary_path); let binary_path = Path::new(&binary_path); - match Machine::new_from_wavm(binary_path, true) { + match Machine::new_from_wavm(binary_path, false) { Ok(mach) => Box::into_raw(Box::new(mach)), Err(err) => { eprintln!("Error loading binary: {err}"); diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index 22da90bb80..6f99cd905e 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1243,11 +1243,11 @@ impl Machine { let soft_float = std::fs::read("../../target/machines/latest/soft-float.wasm")?; let soft_float = parse(&soft_float, Path::new("soft-float"))?; - let mut machine: Machine = Self::from_binaries( + let mut machine = Self::from_binaries( &[soft_float, wasi_stub, user_test], bin, false, - true, + false, false, compile.debug.debug_funcs, true, diff --git a/arbitrator/stylus/src/test/mod.rs b/arbitrator/stylus/src/test/mod.rs index a6259d82bf..0f1cfd7618 100644 --- a/arbitrator/stylus/src/test/mod.rs +++ b/arbitrator/stylus/src/test/mod.rs @@ -150,7 +150,7 @@ fn new_test_machine(path: &str, compile: &CompileConfig) -> Result { &[lib], bin, false, - true, + false, true, compile.debug.debug_funcs, true, From d8069c837f03927a573b34b6224f5aca11cf84cd Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 2 May 2024 14:22:33 +0200 Subject: [PATCH 040/268] Fix up the branch after merges. --- arbitrator/prover/benches/merkle_bench.rs | 6 +- arbitrator/prover/src/memory.rs | 1 - arbitrator/prover/src/merkle.rs | 99 +- arbitrator/prover/src/merkle/zerohashes.rs | 2244 ++++++++++++++++---- 4 files changed, 1827 insertions(+), 523 deletions(-) diff --git a/arbitrator/prover/benches/merkle_bench.rs b/arbitrator/prover/benches/merkle_bench.rs index d1b37b93f7..f64bfa780a 100644 --- a/arbitrator/prover/benches/merkle_bench.rs +++ b/arbitrator/prover/benches/merkle_bench.rs @@ -35,8 +35,7 @@ fn merkle_benchmark(c: &mut Criterion) { // Perform many calls to set leaves to new values c.bench_function("extend_set_leaves_and_root", |b| { b.iter(|| { - let merkle = - Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 20); + let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), 20); extend_and_set_leavees(merkle.clone(), &mut rng); }) }); @@ -51,8 +50,7 @@ fn merkle_construction(c: &mut Criterion) { c.bench_function("merkle_construction", |b| { b.iter(|| { - let merkle = - Merkle::new_advanced(MerkleType::Memory, leaves.clone(), Bytes32::default(), 21); + let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), 21); merkle.root(); }) }); diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 91deaba28d..72407b15c7 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -125,7 +125,6 @@ impl Memory { Cow::Owned(Merkle::new_advanced( MerkleType::Memory, leaf_hashes, - hash_leaf([0u8; 32]), Self::MEMORY_LAYERS, )) } diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 008a5c4528..90671bde17 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -11,7 +11,7 @@ use enum_iterator::Sequence; use enum_iterator::all; use std::cmp::max; -use std::cmp::Ordering; + #[cfg(feature = "counters")] use std::sync::atomic::AtomicUsize; @@ -40,7 +40,7 @@ mod zerohashes; use zerohashes::ZERO_HASHES; -use crate::print; +use self::zerohashes::EMPTY_HASH; #[cfg(feature = "counters")] lazy_static! { @@ -174,7 +174,7 @@ pub struct Merkle { dirty_layers: Arc>>>, } -fn hash_node(ty: MerkleType, a: Bytes32, b: Bytes32) -> Bytes32 { +fn hash_node(ty: MerkleType, a: impl AsRef<[u8]>, b: impl AsRef<[u8]>) -> Bytes32 { let mut h = Keccak256::new(); h.update(ty.get_prefix()); h.update(a); @@ -188,36 +188,36 @@ fn capacity(layers: &Vec>) -> usize { base.pow((layers.len() - 1).try_into().unwrap()) } -const fn empty_hash_at(ty: MerkleType, layer_i: usize) -> Bytes32 { +const fn empty_hash_at(ty: MerkleType, layer_i: usize) -> &'static Bytes32 { match ty { - MerkleType::Empty => Bytes32::new_direct([0u8; 32]), - MerkleType::Value => ZERO_HASHES[0][layer_i], - MerkleType::Function => ZERO_HASHES[1][layer_i], - MerkleType::Instruction => ZERO_HASHES[2][layer_i], - MerkleType::Memory => ZERO_HASHES[3][layer_i], - MerkleType::Table => ZERO_HASHES[4][layer_i], - MerkleType::TableElement => ZERO_HASHES[5][layer_i], - MerkleType::Module => ZERO_HASHES[6][layer_i], + MerkleType::Empty => EMPTY_HASH, + MerkleType::Value => &ZERO_HASHES[0][layer_i], + MerkleType::Function => &ZERO_HASHES[1][layer_i], + MerkleType::Instruction => &ZERO_HASHES[2][layer_i], + MerkleType::Memory => &ZERO_HASHES[3][layer_i], + MerkleType::Table => &ZERO_HASHES[4][layer_i], + MerkleType::TableElement => &ZERO_HASHES[5][layer_i], + MerkleType::Module => &ZERO_HASHES[6][layer_i], } } #[inline] #[cfg(feature = "rayon")] -fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: Bytes32) -> Vec { +fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: &'static Bytes32) -> Vec { let mut new_layer: Vec = Vec::with_capacity(layer.len() >> 1); let chunks = layer.par_chunks(2); chunks - .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_hash))) + .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).unwrap_or(empty_hash))) .collect_into_vec(&mut new_layer); new_layer } #[inline] #[cfg(not(feature = "rayon"))] -fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: Bytes32) -> Vec { +fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: &'static Bytes32) -> Vec { let new_layer = layer .chunks(2) - .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).cloned().unwrap_or(empty_hash))) + .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).unwrap_or(empty_hash))) .collect(); new_layer } @@ -227,17 +227,12 @@ impl Merkle { /// The tree is built up to the minimum depth necessary to hold all the /// leaves. pub fn new(ty: MerkleType, hashes: Vec) -> Merkle { - Self::new_advanced(ty, hashes, Bytes32::default(), 0) + Self::new_advanced(ty, hashes, 0) } /// Creates a new Merkle tree with the given type, leaf hashes, a hash to /// use for representing empty leaves, and a minimum depth. - pub fn new_advanced( - ty: MerkleType, - hashes: Vec, - _empty_hash: Bytes32, - min_depth: usize, - ) -> Merkle { + pub fn new_advanced(ty: MerkleType, hashes: Vec, min_depth: usize) -> Merkle { #[cfg(feature = "counters")] NEW_COUNTERS[&ty].fetch_add(1, Ordering::Relaxed); if hashes.is_empty() { @@ -282,8 +277,7 @@ impl Merkle { let left = layers[layer_i - 1][left_child_idx]; let right = layers[layer_i - 1] .get(right_child_idx) - .cloned() - .unwrap_or_else(|| empty_hash_at(self.ty, layer_i - 1)); + .unwrap_or(empty_hash_at(self.ty, layer_i - 1)); let new_hash = hash_node(self.ty, left, right); if *idx < layers[layer_i].len() { layers[layer_i][*idx] = new_hash; @@ -323,7 +317,8 @@ impl Merkle { } pub fn is_empty(&self) -> bool { - self.layers.is_empty() || self.layers[0].is_empty() + let layers = self.layers.lock().unwrap(); + layers.is_empty() || layers[0].is_empty() } #[must_use] @@ -348,7 +343,7 @@ impl Merkle { layer .get(counterpart) .cloned() - .unwrap_or_else(|| empty_hash_at(self.ty, layer_i)), + .unwrap_or_else(|| *empty_hash_at(self.ty, layer_i)), ); idx >>= 1; } @@ -360,8 +355,7 @@ impl Merkle { pub fn push_leaf(&mut self, leaf: Bytes32) { let mut leaves = self.layers.lock().unwrap().swap_remove(0); leaves.push(leaf); - let empty = empty_hash_at(self.ty, 0); - *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); + *self = Self::new_advanced(self.ty, leaves, self.min_depth); } /// Removes the rightmost leaf from the merkle @@ -369,8 +363,7 @@ impl Merkle { pub fn pop_leaf(&mut self) { let mut leaves = self.layers.lock().unwrap().swap_remove(0); leaves.pop(); - let empty = empty_hash_at(self.ty, 0); - *self = Self::new_advanced(self.ty, leaves, empty, self.min_depth); + *self = Self::new_advanced(self.ty, leaves, self.min_depth); } // Sets the leaf at the given index to the given hash. @@ -391,35 +384,8 @@ impl Merkle { if locked_layers[0][idx] == hash { return; } - let mut next_hash = hash; - let empty_layers = &self.empty_layers; - let layers_len = self.layers.len(); - for (layer_i, layer) in self.layers.iter_mut().enumerate() { - match idx.cmp(&layer.len()) { - Ordering::Less => layer[idx] = next_hash, - Ordering::Equal => layer.push(next_hash), - Ordering::Greater => panic!( - "Index {} out of bounds {} in layer {}", - idx, - layer.len(), - layer_i - ), - } - if layer_i == layers_len - 1 { - // next_hash isn't needed - break; - } - let counterpart = layer - .get(idx ^ 1) - .cloned() - .unwrap_or_else(|| empty_layers[layer_i]); - if idx % 2 == 0 { - next_hash = hash_node(self.ty, next_hash, counterpart); - } else { - next_hash = hash_node(self.ty, counterpart, next_hash); - } - idx >>= 1; - } + locked_layers[0][idx] = hash; + self.dirty_layers.lock().unwrap()[0].insert(idx >> 1); } /// Extends the leaves of the tree with the given hashes. @@ -435,14 +401,14 @@ impl Merkle { let mut idx = layers[0].len(); let mut new_size = idx + hashes.len(); for (layer_i, layer) in layers.iter_mut().enumerate() { - layer.resize(new_size, empty_hash_at(self.ty, layer_i)); + layer.resize(new_size, *empty_hash_at(self.ty, layer_i)); new_size = max(new_size >> 1, 1); } for hash in hashes { self.locked_set(&mut layers, idx, hash); idx += 1; } - Ok(self.layers[0].len()) + Ok(layers[0].len()) } } @@ -517,7 +483,7 @@ fn extend_works() { ), ), ); - let mut merkle = Merkle::new(MerkleType::Value, hashes.clone()); + let merkle = Merkle::new(MerkleType::Value, hashes.clone()); assert_eq!(merkle.capacity(), 8); assert_eq!(merkle.root(), expected); @@ -563,12 +529,7 @@ fn extend_works() { fn correct_capacity() { let merkle = Merkle::new(MerkleType::Value, vec![Bytes32::from([1; 32])]); assert_eq!(merkle.capacity(), 1); - let merkle = Merkle::new_advanced( - MerkleType::Memory, - vec![Bytes32::from([1; 32])], - Bytes32::default(), - 11, - ); + let merkle = Merkle::new_advanced(MerkleType::Memory, vec![Bytes32::from([1; 32])], 11); assert_eq!(merkle.capacity(), 1024); } diff --git a/arbitrator/prover/src/merkle/zerohashes.rs b/arbitrator/prover/src/merkle/zerohashes.rs index c0971f17e6..acb5757d61 100644 --- a/arbitrator/prover/src/merkle/zerohashes.rs +++ b/arbitrator/prover/src/merkle/zerohashes.rs @@ -1,474 +1,1820 @@ use arbutil::Bytes32; const VALUE_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::new_direct([119, 47, 167, 222, 218, 156, 26, 105, 57, 248, 170, 182, 183, 151, 18, 150, 142, 70, 138, 253, 54, 123, 132, 86, 170, 76, 157, 52, 113, 138, 253, 254]), - Bytes32::new_direct([8, 117, 27, 211, 196, 42, 6, 98, 185, 88, 231, 145, 14, 3, 207, 145, 158, 255, 69, 52, 198, 196, 148, 154, 59, 94, 229, 157, 93, 51, 200, 69]), - Bytes32::new_direct([247, 208, 196, 206, 204, 168, 129, 100, 238, 95, 52, 26, 132, 138, 233, 149, 196, 72, 179, 226, 60, 114, 27, 94, 173, 189, 197, 100, 163, 232, 180, 63]), - Bytes32::new_direct([178, 100, 198, 112, 40, 33, 187, 175, 130, 245, 59, 210, 133, 234, 158, 158, 133, 64, 213, 72, 222, 157, 216, 42, 210, 134, 36, 13, 211, 156, 163, 211]), - Bytes32::new_direct([203, 127, 32, 130, 225, 40, 219, 15, 35, 236, 47, 201, 161, 48, 53, 145, 134, 169, 109, 29, 26, 29, 178, 201, 118, 217, 57, 165, 116, 172, 232, 4]), - Bytes32::new_direct([209, 109, 33, 102, 227, 251, 133, 224, 170, 130, 65, 90, 185, 209, 146, 77, 244, 145, 181, 206, 159, 70, 209, 64, 241, 19, 149, 223, 138, 31, 163, 61]), - Bytes32::new_direct([145, 168, 124, 48, 254, 12, 34, 41, 4, 213, 245, 86, 61, 29, 177, 192, 67, 165, 237, 236, 87, 126, 193, 191, 15, 126, 104, 173, 165, 186, 1, 107]), - Bytes32::new_direct([235, 161, 247, 143, 69, 95, 210, 40, 243, 76, 102, 29, 118, 86, 180, 54, 81, 144, 103, 54, 202, 164, 81, 83, 180, 90, 154, 184, 54, 28, 7, 220]), - Bytes32::new_direct([203, 62, 12, 83, 35, 122, 214, 199, 125, 61, 236, 8, 253, 64, 145, 34, 127, 116, 217, 118, 245, 107, 15, 81, 9, 7, 31, 154, 89, 28, 123, 132]), - Bytes32::new_direct([222, 94, 234, 109, 142, 74, 142, 176, 248, 3, 172, 30, 204, 138, 241, 195, 121, 232, 104, 219, 32, 54, 240, 77, 125, 247, 70, 137, 80, 46, 221, 247]), - Bytes32::new_direct([162, 122, 237, 101, 178, 31, 12, 62, 50, 133, 242, 82, 111, 215, 166, 136, 138, 185, 72, 220, 163, 58, 58, 97, 6, 97, 167, 114, 179, 227, 19, 170]), - Bytes32::new_direct([67, 251, 144, 11, 175, 194, 149, 65, 173, 179, 69, 140, 213, 191, 133, 59, 81, 175, 161, 115, 252, 125, 232, 150, 52, 241, 102, 164, 122, 32, 70, 229]), - Bytes32::new_direct([249, 161, 115, 93, 215, 247, 145, 182, 75, 191, 48, 38, 123, 220, 232, 47, 246, 46, 81, 164, 98, 41, 141, 249, 137, 173, 93, 213, 96, 15, 151, 245]), - Bytes32::new_direct([222, 93, 144, 194, 107, 42, 144, 4, 242, 153, 203, 176, 146, 242, 94, 72, 9, 222, 194, 2, 73, 200, 167, 147, 106, 9, 67, 73, 59, 127, 174, 178]), - Bytes32::new_direct([56, 228, 248, 59, 153, 215, 120, 224, 111, 48, 159, 82, 171, 227, 93, 214, 208, 151, 78, 67, 112, 31, 218, 94, 219, 3, 79, 250, 227, 24, 222, 207]), - Bytes32::new_direct([26, 171, 68, 22, 162, 195, 65, 97, 219, 55, 51, 46, 178, 6, 247, 65, 123, 219, 128, 86, 193, 3, 253, 0, 239, 228, 187, 94, 184, 240, 67, 11]), - Bytes32::new_direct([250, 36, 5, 131, 94, 0, 99, 187, 112, 155, 252, 52, 68, 236, 185, 152, 93, 239, 0, 185, 101, 101, 182, 92, 112, 5, 67, 55, 121, 203, 100, 245]), - Bytes32::new_direct([208, 57, 149, 71, 227, 213, 246, 213, 175, 88, 95, 238, 93, 122, 168, 223, 149, 84, 30, 89, 98, 228, 113, 72, 90, 48, 112, 171, 231, 67, 113, 216]), - Bytes32::new_direct([125, 48, 157, 119, 154, 38, 14, 211, 223, 68, 87, 187, 159, 126, 234, 72, 84, 60, 236, 237, 227, 130, 87, 43, 217, 105, 81, 196, 159, 238, 240, 10]), - Bytes32::new_direct([141, 217, 59, 213, 245, 231, 7, 85, 178, 197, 115, 188, 31, 49, 126, 237, 83, 199, 56, 196, 133, 169, 239, 218, 90, 131, 178, 70, 126, 132, 114, 186]), - Bytes32::new_direct([18, 2, 140, 12, 121, 238, 8, 160, 7, 208, 89, 194, 105, 136, 211, 58, 179, 200, 226, 138, 186, 242, 4, 237, 18, 113, 131, 135, 31, 222, 28, 195]), - Bytes32::new_direct([156, 222, 183, 39, 119, 110, 130, 60, 33, 221, 36, 39, 223, 155, 33, 2, 71, 32, 209, 25, 194, 172, 209, 1, 40, 105, 235, 140, 160, 18, 63, 168]), - Bytes32::new_direct([211, 210, 123, 27, 217, 111, 97, 42, 167, 191, 112, 239, 66, 42, 199, 131, 124, 213, 89, 56, 92, 245, 166, 238, 185, 42, 48, 2, 113, 255, 156, 7]), - Bytes32::new_direct([66, 255, 87, 69, 86, 6, 54, 162, 162, 5, 93, 138, 194, 194, 151, 195, 57, 155, 58, 17, 21, 149, 77, 2, 134, 107, 125, 54, 220, 247, 160, 209]), - Bytes32::new_direct([169, 216, 13, 41, 251, 216, 191, 87, 91, 55, 236, 6, 242, 103, 98, 209, 46, 202, 29, 55, 2, 50, 233, 76, 107, 92, 82, 156, 113, 226, 78, 211]), - Bytes32::new_direct([88, 189, 113, 129, 119, 11, 141, 60, 128, 134, 113, 107, 7, 186, 81, 200, 14, 76, 197, 14, 96, 19, 247, 220, 95, 62, 81, 153, 61, 231, 26, 86]), - Bytes32::new_direct([41, 214, 41, 96, 151, 11, 231, 7, 203, 70, 242, 156, 247, 133, 49, 223, 254, 164, 202, 154, 188, 104, 124, 120, 225, 229, 148, 203, 141, 218, 228, 56]), - Bytes32::new_direct([181, 157, 136, 110, 158, 152, 105, 61, 125, 220, 32, 180, 53, 115, 155, 189, 91, 152, 96, 172, 7, 121, 65, 143, 82, 180, 3, 69, 118, 219, 31, 244]), - Bytes32::new_direct([29, 12, 159, 30, 12, 37, 126, 102, 218, 149, 67, 116, 182, 125, 134, 208, 184, 199, 181, 191, 87, 144, 48, 150, 87, 67, 222, 218, 254, 118, 12, 160]), - Bytes32::new_direct([193, 249, 209, 245, 102, 95, 15, 55, 160, 156, 203, 160, 49, 198, 203, 30, 99, 172, 89, 92, 235, 89, 131, 205, 53, 254, 219, 168, 202, 195, 10, 242]), - Bytes32::new_direct([131, 64, 102, 7, 226, 96, 60, 111, 221, 120, 41, 86, 239, 157, 121, 38, 57, 244, 221, 55, 32, 237, 13, 20, 244, 238, 133, 189, 89, 118, 204, 247]), - Bytes32::new_direct([239, 211, 89, 185, 191, 211, 243, 207, 134, 159, 59, 19, 87, 254, 115, 27, 152, 156, 120, 226, 39, 63, 155, 51, 77, 130, 162, 63, 16, 43, 112, 121]), - Bytes32::new_direct([10, 146, 190, 23, 235, 67, 23, 169, 33, 140, 54, 209, 129, 176, 29, 218, 40, 55, 13, 80, 57, 68, 92, 97, 44, 82, 209, 240, 207, 214, 22, 119]), - Bytes32::new_direct([59, 161, 125, 95, 7, 155, 141, 55, 253, 106, 238, 72, 109, 158, 201, 200, 236, 157, 227, 178, 176, 47, 166, 84, 87, 111, 25, 133, 194, 55, 244, 254]), - Bytes32::new_direct([8, 134, 213, 182, 108, 15, 225, 138, 152, 138, 132, 240, 27, 80, 231, 117, 194, 157, 205, 20, 110, 239, 166, 37, 50, 46, 213, 165, 216, 101, 245, 98]), - Bytes32::new_direct([137, 57, 186, 173, 198, 113, 221, 42, 0, 211, 127, 200, 128, 7, 112, 97, 75, 155, 152, 224, 71, 220, 16, 124, 32, 50, 30, 48, 251, 132, 120, 147]), - Bytes32::new_direct([201, 8, 226, 108, 147, 192, 3, 240, 168, 237, 131, 47, 150, 51, 251, 126, 23, 182, 223, 99, 162, 167, 248, 248, 233, 8, 121, 99, 71, 212, 120, 251]), - Bytes32::new_direct([140, 30, 196, 244, 166, 80, 95, 116, 140, 218, 94, 20, 236, 233, 241, 129, 175, 187, 110, 88, 174, 173, 152, 203, 67, 75, 51, 232, 225, 6, 17, 134]), - Bytes32::new_direct([92, 132, 115, 164, 66, 159, 201, 147, 233, 228, 16, 95, 81, 233, 129, 254, 155, 148, 38, 239, 186, 40, 118, 104, 144, 134, 17, 46, 99, 150, 211, 9]), - Bytes32::new_direct([81, 73, 72, 117, 215, 159, 240, 86, 136, 196, 69, 201, 149, 208, 48, 245, 105, 153, 97, 107, 221, 85, 49, 121, 197, 129, 32, 140, 206, 231, 120, 123]), - Bytes32::new_direct([0, 203, 34, 135, 242, 129, 113, 204, 198, 134, 219, 134, 187, 240, 235, 59, 44, 163, 180, 83, 174, 40, 66, 141, 95, 99, 71, 221, 186, 216, 37, 250]), - Bytes32::new_direct([225, 181, 151, 12, 26, 209, 127, 99, 248, 177, 126, 113, 215, 220, 252, 89, 149, 123, 19, 65, 89, 122, 180, 169, 195, 87, 147, 9, 196, 31, 203, 178]), - Bytes32::new_direct([125, 81, 154, 100, 204, 138, 194, 248, 156, 95, 119, 58, 60, 221, 150, 248, 216, 19, 123, 15, 198, 108, 228, 228, 224, 122, 16, 249, 223, 84, 117, 89]), - Bytes32::new_direct([99, 153, 60, 217, 168, 254, 244, 149, 214, 115, 250, 90, 117, 112, 66, 163, 143, 207, 121, 70, 108, 92, 2, 47, 56, 109, 56, 207, 152, 27, 196, 141]), - Bytes32::new_direct([99, 251, 124, 97, 158, 155, 101, 251, 98, 124, 239, 73, 50, 50, 173, 142, 39, 208, 167, 53, 5, 151, 85, 239, 25, 77, 36, 52, 141, 225, 66, 186]), - Bytes32::new_direct([235, 44, 31, 180, 197, 243, 114, 60, 199, 242, 167, 21, 206, 27, 116, 165, 18, 76, 162, 163, 14, 91, 109, 104, 118, 51, 33, 172, 9, 165, 214, 38]), - Bytes32::new_direct([188, 4, 5, 50, 169, 70, 231, 90, 220, 90, 226, 214, 89, 19, 159, 207, 201, 80, 241, 214, 32, 240, 63, 74, 6, 251, 177, 182, 236, 19, 156, 92]), - Bytes32::new_direct([128, 150, 66, 27, 197, 229, 103, 137, 175, 252, 19, 131, 213, 63, 112, 172, 182, 255, 235, 246, 226, 37, 25, 180, 24, 38, 35, 138, 207, 149, 186, 175]), - Bytes32::new_direct([5, 123, 231, 106, 12, 171, 157, 189, 58, 109, 144, 7, 38, 97, 4, 148, 1, 138, 124, 123, 2, 202, 108, 221, 194, 160, 53, 73, 115, 36, 231, 142]), - Bytes32::new_direct([160, 157, 243, 224, 214, 120, 59, 206, 24, 30, 231, 209, 123, 227, 15, 221, 86, 30, 128, 117, 210, 109, 132, 117, 204, 87, 243, 213, 231, 224, 91, 75]), - Bytes32::new_direct([74, 238, 110, 147, 63, 110, 246, 102, 252, 212, 120, 225, 124, 218, 145, 204, 129, 63, 13, 34, 1, 0, 15, 9, 27, 221, 39, 199, 24, 231, 9, 38]), - Bytes32::new_direct([194, 20, 160, 161, 90, 2, 118, 75, 103, 228, 51, 42, 191, 220, 63, 150, 140, 32, 85, 172, 218, 29, 251, 31, 99, 96, 98, 46, 130, 157, 201, 61]), - Bytes32::new_direct([88, 123, 95, 139, 94, 66, 69, 27, 223, 223, 216, 130, 99, 210, 130, 54, 248, 35, 226, 252, 151, 238, 7, 175, 12, 97, 188, 43, 233, 129, 82, 222]), - Bytes32::new_direct([179, 248, 157, 243, 50, 157, 172, 17, 139, 10, 245, 208, 241, 210, 67, 199, 135, 233, 234, 39, 127, 38, 54, 39, 40, 159, 94, 122, 36, 221, 180, 195]), - Bytes32::new_direct([190, 185, 147, 237, 82, 32, 165, 236, 252, 183, 173, 181, 68, 44, 216, 20, 110, 243, 158, 213, 88, 209, 218, 207, 244, 241, 121, 239, 136, 167, 245, 155]), - Bytes32::new_direct([114, 131, 254, 248, 183, 0, 175, 217, 194, 58, 178, 238, 250, 119, 158, 205, 19, 74, 94, 35, 100, 175, 114, 55, 186, 192, 239, 126, 42, 86, 60, 119]), - Bytes32::new_direct([1, 253, 107, 150, 25, 240, 27, 172, 252, 185, 151, 152, 107, 105, 164, 230, 221, 242, 7, 166, 142, 53, 237, 83, 19, 30, 81, 149, 150, 39, 123, 220]), - Bytes32::new_direct([57, 240, 92, 232, 26, 238, 69, 252, 110, 171, 164, 109, 199, 73, 110, 49, 11, 253, 109, 69, 155, 26, 84, 52, 155, 204, 115, 99, 90, 38, 247, 167]), - Bytes32::new_direct([46, 87, 146, 25, 215, 40, 208, 78, 73, 60, 35, 19, 194, 41, 34, 186, 215, 131, 205, 29, 107, 100, 95, 169, 45, 1, 242, 115, 30, 226, 93, 48]), - Bytes32::new_direct([95, 183, 66, 0, 196, 173, 44, 27, 175, 151, 17, 0, 159, 168, 123, 236, 124, 198, 85, 181, 118, 89, 21, 52, 169, 104, 178, 111, 120, 173, 94, 109]), - Bytes32::new_direct([13, 111, 162, 25, 133, 108, 250, 75, 197, 221, 19, 160, 147, 36, 130, 70, 224, 39, 134, 144, 149, 166, 187, 96, 155, 154, 123, 90, 241, 154, 44, 102]), - Bytes32::new_direct([95, 171, 183, 135, 121, 205, 161, 160, 212, 226, 64, 232, 180, 166, 176, 95, 51, 96, 110, 20, 76, 143, 47, 96, 197, 132, 210, 109, 174, 132, 13, 95]), - Bytes32::new_direct([66, 51, 176, 1, 106, 199, 192, 16, 106, 180, 212, 53, 72, 121, 218, 148, 77, 26, 15, 244, 124, 131, 88, 84, 147, 211, 254, 156, 187, 91, 193, 120]), + Bytes32::new_direct([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ]), + Bytes32::new_direct([ + 119, 47, 167, 222, 218, 156, 26, 105, 57, 248, 170, 182, 183, 151, 18, 150, 142, 70, 138, + 253, 54, 123, 132, 86, 170, 76, 157, 52, 113, 138, 253, 254, + ]), + Bytes32::new_direct([ + 8, 117, 27, 211, 196, 42, 6, 98, 185, 88, 231, 145, 14, 3, 207, 145, 158, 255, 69, 52, 198, + 196, 148, 154, 59, 94, 229, 157, 93, 51, 200, 69, + ]), + Bytes32::new_direct([ + 247, 208, 196, 206, 204, 168, 129, 100, 238, 95, 52, 26, 132, 138, 233, 149, 196, 72, 179, + 226, 60, 114, 27, 94, 173, 189, 197, 100, 163, 232, 180, 63, + ]), + Bytes32::new_direct([ + 178, 100, 198, 112, 40, 33, 187, 175, 130, 245, 59, 210, 133, 234, 158, 158, 133, 64, 213, + 72, 222, 157, 216, 42, 210, 134, 36, 13, 211, 156, 163, 211, + ]), + Bytes32::new_direct([ + 203, 127, 32, 130, 225, 40, 219, 15, 35, 236, 47, 201, 161, 48, 53, 145, 134, 169, 109, 29, + 26, 29, 178, 201, 118, 217, 57, 165, 116, 172, 232, 4, + ]), + Bytes32::new_direct([ + 209, 109, 33, 102, 227, 251, 133, 224, 170, 130, 65, 90, 185, 209, 146, 77, 244, 145, 181, + 206, 159, 70, 209, 64, 241, 19, 149, 223, 138, 31, 163, 61, + ]), + Bytes32::new_direct([ + 145, 168, 124, 48, 254, 12, 34, 41, 4, 213, 245, 86, 61, 29, 177, 192, 67, 165, 237, 236, + 87, 126, 193, 191, 15, 126, 104, 173, 165, 186, 1, 107, + ]), + Bytes32::new_direct([ + 235, 161, 247, 143, 69, 95, 210, 40, 243, 76, 102, 29, 118, 86, 180, 54, 81, 144, 103, 54, + 202, 164, 81, 83, 180, 90, 154, 184, 54, 28, 7, 220, + ]), + Bytes32::new_direct([ + 203, 62, 12, 83, 35, 122, 214, 199, 125, 61, 236, 8, 253, 64, 145, 34, 127, 116, 217, 118, + 245, 107, 15, 81, 9, 7, 31, 154, 89, 28, 123, 132, + ]), + Bytes32::new_direct([ + 222, 94, 234, 109, 142, 74, 142, 176, 248, 3, 172, 30, 204, 138, 241, 195, 121, 232, 104, + 219, 32, 54, 240, 77, 125, 247, 70, 137, 80, 46, 221, 247, + ]), + Bytes32::new_direct([ + 162, 122, 237, 101, 178, 31, 12, 62, 50, 133, 242, 82, 111, 215, 166, 136, 138, 185, 72, + 220, 163, 58, 58, 97, 6, 97, 167, 114, 179, 227, 19, 170, + ]), + Bytes32::new_direct([ + 67, 251, 144, 11, 175, 194, 149, 65, 173, 179, 69, 140, 213, 191, 133, 59, 81, 175, 161, + 115, 252, 125, 232, 150, 52, 241, 102, 164, 122, 32, 70, 229, + ]), + Bytes32::new_direct([ + 249, 161, 115, 93, 215, 247, 145, 182, 75, 191, 48, 38, 123, 220, 232, 47, 246, 46, 81, + 164, 98, 41, 141, 249, 137, 173, 93, 213, 96, 15, 151, 245, + ]), + Bytes32::new_direct([ + 222, 93, 144, 194, 107, 42, 144, 4, 242, 153, 203, 176, 146, 242, 94, 72, 9, 222, 194, 2, + 73, 200, 167, 147, 106, 9, 67, 73, 59, 127, 174, 178, + ]), + Bytes32::new_direct([ + 56, 228, 248, 59, 153, 215, 120, 224, 111, 48, 159, 82, 171, 227, 93, 214, 208, 151, 78, + 67, 112, 31, 218, 94, 219, 3, 79, 250, 227, 24, 222, 207, + ]), + Bytes32::new_direct([ + 26, 171, 68, 22, 162, 195, 65, 97, 219, 55, 51, 46, 178, 6, 247, 65, 123, 219, 128, 86, + 193, 3, 253, 0, 239, 228, 187, 94, 184, 240, 67, 11, + ]), + Bytes32::new_direct([ + 250, 36, 5, 131, 94, 0, 99, 187, 112, 155, 252, 52, 68, 236, 185, 152, 93, 239, 0, 185, + 101, 101, 182, 92, 112, 5, 67, 55, 121, 203, 100, 245, + ]), + Bytes32::new_direct([ + 208, 57, 149, 71, 227, 213, 246, 213, 175, 88, 95, 238, 93, 122, 168, 223, 149, 84, 30, 89, + 98, 228, 113, 72, 90, 48, 112, 171, 231, 67, 113, 216, + ]), + Bytes32::new_direct([ + 125, 48, 157, 119, 154, 38, 14, 211, 223, 68, 87, 187, 159, 126, 234, 72, 84, 60, 236, 237, + 227, 130, 87, 43, 217, 105, 81, 196, 159, 238, 240, 10, + ]), + Bytes32::new_direct([ + 141, 217, 59, 213, 245, 231, 7, 85, 178, 197, 115, 188, 31, 49, 126, 237, 83, 199, 56, 196, + 133, 169, 239, 218, 90, 131, 178, 70, 126, 132, 114, 186, + ]), + Bytes32::new_direct([ + 18, 2, 140, 12, 121, 238, 8, 160, 7, 208, 89, 194, 105, 136, 211, 58, 179, 200, 226, 138, + 186, 242, 4, 237, 18, 113, 131, 135, 31, 222, 28, 195, + ]), + Bytes32::new_direct([ + 156, 222, 183, 39, 119, 110, 130, 60, 33, 221, 36, 39, 223, 155, 33, 2, 71, 32, 209, 25, + 194, 172, 209, 1, 40, 105, 235, 140, 160, 18, 63, 168, + ]), + Bytes32::new_direct([ + 211, 210, 123, 27, 217, 111, 97, 42, 167, 191, 112, 239, 66, 42, 199, 131, 124, 213, 89, + 56, 92, 245, 166, 238, 185, 42, 48, 2, 113, 255, 156, 7, + ]), + Bytes32::new_direct([ + 66, 255, 87, 69, 86, 6, 54, 162, 162, 5, 93, 138, 194, 194, 151, 195, 57, 155, 58, 17, 21, + 149, 77, 2, 134, 107, 125, 54, 220, 247, 160, 209, + ]), + Bytes32::new_direct([ + 169, 216, 13, 41, 251, 216, 191, 87, 91, 55, 236, 6, 242, 103, 98, 209, 46, 202, 29, 55, 2, + 50, 233, 76, 107, 92, 82, 156, 113, 226, 78, 211, + ]), + Bytes32::new_direct([ + 88, 189, 113, 129, 119, 11, 141, 60, 128, 134, 113, 107, 7, 186, 81, 200, 14, 76, 197, 14, + 96, 19, 247, 220, 95, 62, 81, 153, 61, 231, 26, 86, + ]), + Bytes32::new_direct([ + 41, 214, 41, 96, 151, 11, 231, 7, 203, 70, 242, 156, 247, 133, 49, 223, 254, 164, 202, 154, + 188, 104, 124, 120, 225, 229, 148, 203, 141, 218, 228, 56, + ]), + Bytes32::new_direct([ + 181, 157, 136, 110, 158, 152, 105, 61, 125, 220, 32, 180, 53, 115, 155, 189, 91, 152, 96, + 172, 7, 121, 65, 143, 82, 180, 3, 69, 118, 219, 31, 244, + ]), + Bytes32::new_direct([ + 29, 12, 159, 30, 12, 37, 126, 102, 218, 149, 67, 116, 182, 125, 134, 208, 184, 199, 181, + 191, 87, 144, 48, 150, 87, 67, 222, 218, 254, 118, 12, 160, + ]), + Bytes32::new_direct([ + 193, 249, 209, 245, 102, 95, 15, 55, 160, 156, 203, 160, 49, 198, 203, 30, 99, 172, 89, 92, + 235, 89, 131, 205, 53, 254, 219, 168, 202, 195, 10, 242, + ]), + Bytes32::new_direct([ + 131, 64, 102, 7, 226, 96, 60, 111, 221, 120, 41, 86, 239, 157, 121, 38, 57, 244, 221, 55, + 32, 237, 13, 20, 244, 238, 133, 189, 89, 118, 204, 247, + ]), + Bytes32::new_direct([ + 239, 211, 89, 185, 191, 211, 243, 207, 134, 159, 59, 19, 87, 254, 115, 27, 152, 156, 120, + 226, 39, 63, 155, 51, 77, 130, 162, 63, 16, 43, 112, 121, + ]), + Bytes32::new_direct([ + 10, 146, 190, 23, 235, 67, 23, 169, 33, 140, 54, 209, 129, 176, 29, 218, 40, 55, 13, 80, + 57, 68, 92, 97, 44, 82, 209, 240, 207, 214, 22, 119, + ]), + Bytes32::new_direct([ + 59, 161, 125, 95, 7, 155, 141, 55, 253, 106, 238, 72, 109, 158, 201, 200, 236, 157, 227, + 178, 176, 47, 166, 84, 87, 111, 25, 133, 194, 55, 244, 254, + ]), + Bytes32::new_direct([ + 8, 134, 213, 182, 108, 15, 225, 138, 152, 138, 132, 240, 27, 80, 231, 117, 194, 157, 205, + 20, 110, 239, 166, 37, 50, 46, 213, 165, 216, 101, 245, 98, + ]), + Bytes32::new_direct([ + 137, 57, 186, 173, 198, 113, 221, 42, 0, 211, 127, 200, 128, 7, 112, 97, 75, 155, 152, 224, + 71, 220, 16, 124, 32, 50, 30, 48, 251, 132, 120, 147, + ]), + Bytes32::new_direct([ + 201, 8, 226, 108, 147, 192, 3, 240, 168, 237, 131, 47, 150, 51, 251, 126, 23, 182, 223, 99, + 162, 167, 248, 248, 233, 8, 121, 99, 71, 212, 120, 251, + ]), + Bytes32::new_direct([ + 140, 30, 196, 244, 166, 80, 95, 116, 140, 218, 94, 20, 236, 233, 241, 129, 175, 187, 110, + 88, 174, 173, 152, 203, 67, 75, 51, 232, 225, 6, 17, 134, + ]), + Bytes32::new_direct([ + 92, 132, 115, 164, 66, 159, 201, 147, 233, 228, 16, 95, 81, 233, 129, 254, 155, 148, 38, + 239, 186, 40, 118, 104, 144, 134, 17, 46, 99, 150, 211, 9, + ]), + Bytes32::new_direct([ + 81, 73, 72, 117, 215, 159, 240, 86, 136, 196, 69, 201, 149, 208, 48, 245, 105, 153, 97, + 107, 221, 85, 49, 121, 197, 129, 32, 140, 206, 231, 120, 123, + ]), + Bytes32::new_direct([ + 0, 203, 34, 135, 242, 129, 113, 204, 198, 134, 219, 134, 187, 240, 235, 59, 44, 163, 180, + 83, 174, 40, 66, 141, 95, 99, 71, 221, 186, 216, 37, 250, + ]), + Bytes32::new_direct([ + 225, 181, 151, 12, 26, 209, 127, 99, 248, 177, 126, 113, 215, 220, 252, 89, 149, 123, 19, + 65, 89, 122, 180, 169, 195, 87, 147, 9, 196, 31, 203, 178, + ]), + Bytes32::new_direct([ + 125, 81, 154, 100, 204, 138, 194, 248, 156, 95, 119, 58, 60, 221, 150, 248, 216, 19, 123, + 15, 198, 108, 228, 228, 224, 122, 16, 249, 223, 84, 117, 89, + ]), + Bytes32::new_direct([ + 99, 153, 60, 217, 168, 254, 244, 149, 214, 115, 250, 90, 117, 112, 66, 163, 143, 207, 121, + 70, 108, 92, 2, 47, 56, 109, 56, 207, 152, 27, 196, 141, + ]), + Bytes32::new_direct([ + 99, 251, 124, 97, 158, 155, 101, 251, 98, 124, 239, 73, 50, 50, 173, 142, 39, 208, 167, 53, + 5, 151, 85, 239, 25, 77, 36, 52, 141, 225, 66, 186, + ]), + Bytes32::new_direct([ + 235, 44, 31, 180, 197, 243, 114, 60, 199, 242, 167, 21, 206, 27, 116, 165, 18, 76, 162, + 163, 14, 91, 109, 104, 118, 51, 33, 172, 9, 165, 214, 38, + ]), + Bytes32::new_direct([ + 188, 4, 5, 50, 169, 70, 231, 90, 220, 90, 226, 214, 89, 19, 159, 207, 201, 80, 241, 214, + 32, 240, 63, 74, 6, 251, 177, 182, 236, 19, 156, 92, + ]), + Bytes32::new_direct([ + 128, 150, 66, 27, 197, 229, 103, 137, 175, 252, 19, 131, 213, 63, 112, 172, 182, 255, 235, + 246, 226, 37, 25, 180, 24, 38, 35, 138, 207, 149, 186, 175, + ]), + Bytes32::new_direct([ + 5, 123, 231, 106, 12, 171, 157, 189, 58, 109, 144, 7, 38, 97, 4, 148, 1, 138, 124, 123, 2, + 202, 108, 221, 194, 160, 53, 73, 115, 36, 231, 142, + ]), + Bytes32::new_direct([ + 160, 157, 243, 224, 214, 120, 59, 206, 24, 30, 231, 209, 123, 227, 15, 221, 86, 30, 128, + 117, 210, 109, 132, 117, 204, 87, 243, 213, 231, 224, 91, 75, + ]), + Bytes32::new_direct([ + 74, 238, 110, 147, 63, 110, 246, 102, 252, 212, 120, 225, 124, 218, 145, 204, 129, 63, 13, + 34, 1, 0, 15, 9, 27, 221, 39, 199, 24, 231, 9, 38, + ]), + Bytes32::new_direct([ + 194, 20, 160, 161, 90, 2, 118, 75, 103, 228, 51, 42, 191, 220, 63, 150, 140, 32, 85, 172, + 218, 29, 251, 31, 99, 96, 98, 46, 130, 157, 201, 61, + ]), + Bytes32::new_direct([ + 88, 123, 95, 139, 94, 66, 69, 27, 223, 223, 216, 130, 99, 210, 130, 54, 248, 35, 226, 252, + 151, 238, 7, 175, 12, 97, 188, 43, 233, 129, 82, 222, + ]), + Bytes32::new_direct([ + 179, 248, 157, 243, 50, 157, 172, 17, 139, 10, 245, 208, 241, 210, 67, 199, 135, 233, 234, + 39, 127, 38, 54, 39, 40, 159, 94, 122, 36, 221, 180, 195, + ]), + Bytes32::new_direct([ + 190, 185, 147, 237, 82, 32, 165, 236, 252, 183, 173, 181, 68, 44, 216, 20, 110, 243, 158, + 213, 88, 209, 218, 207, 244, 241, 121, 239, 136, 167, 245, 155, + ]), + Bytes32::new_direct([ + 114, 131, 254, 248, 183, 0, 175, 217, 194, 58, 178, 238, 250, 119, 158, 205, 19, 74, 94, + 35, 100, 175, 114, 55, 186, 192, 239, 126, 42, 86, 60, 119, + ]), + Bytes32::new_direct([ + 1, 253, 107, 150, 25, 240, 27, 172, 252, 185, 151, 152, 107, 105, 164, 230, 221, 242, 7, + 166, 142, 53, 237, 83, 19, 30, 81, 149, 150, 39, 123, 220, + ]), + Bytes32::new_direct([ + 57, 240, 92, 232, 26, 238, 69, 252, 110, 171, 164, 109, 199, 73, 110, 49, 11, 253, 109, 69, + 155, 26, 84, 52, 155, 204, 115, 99, 90, 38, 247, 167, + ]), + Bytes32::new_direct([ + 46, 87, 146, 25, 215, 40, 208, 78, 73, 60, 35, 19, 194, 41, 34, 186, 215, 131, 205, 29, + 107, 100, 95, 169, 45, 1, 242, 115, 30, 226, 93, 48, + ]), + Bytes32::new_direct([ + 95, 183, 66, 0, 196, 173, 44, 27, 175, 151, 17, 0, 159, 168, 123, 236, 124, 198, 85, 181, + 118, 89, 21, 52, 169, 104, 178, 111, 120, 173, 94, 109, + ]), + Bytes32::new_direct([ + 13, 111, 162, 25, 133, 108, 250, 75, 197, 221, 19, 160, 147, 36, 130, 70, 224, 39, 134, + 144, 149, 166, 187, 96, 155, 154, 123, 90, 241, 154, 44, 102, + ]), + Bytes32::new_direct([ + 95, 171, 183, 135, 121, 205, 161, 160, 212, 226, 64, 232, 180, 166, 176, 95, 51, 96, 110, + 20, 76, 143, 47, 96, 197, 132, 210, 109, 174, 132, 13, 95, + ]), + Bytes32::new_direct([ + 66, 51, 176, 1, 106, 199, 192, 16, 106, 180, 212, 53, 72, 121, 218, 148, 77, 26, 15, 244, + 124, 131, 88, 84, 147, 211, 254, 156, 187, 91, 193, 120, + ]), ]; const FUNCTION_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::new_direct([239, 247, 49, 255, 201, 159, 228, 149, 22, 115, 41, 139, 56, 117, 149, 46, 67, 155, 98, 70, 216, 225, 85, 100, 113, 242, 144, 167, 97, 238, 117, 207]), - Bytes32::new_direct([46, 87, 136, 101, 122, 12, 6, 120, 39, 121, 167, 193, 66, 146, 150, 1, 90, 240, 97, 225, 179, 150, 197, 127, 56, 214, 116, 24, 180, 109, 96, 51]), - Bytes32::new_direct([54, 125, 90, 195, 243, 1, 115, 18, 251, 68, 203, 216, 48, 156, 216, 200, 215, 250, 80, 152, 203, 58, 245, 128, 70, 112, 221, 104, 34, 125, 234, 138]), - Bytes32::new_direct([103, 99, 44, 86, 57, 0, 102, 201, 99, 214, 249, 24, 45, 112, 234, 183, 225, 196, 9, 162, 168, 33, 121, 118, 93, 184, 14, 70, 148, 135, 211, 214]), - Bytes32::new_direct([69, 7, 89, 47, 41, 94, 148, 139, 67, 197, 99, 98, 100, 63, 25, 230, 100, 118, 213, 25, 28, 129, 5, 39, 69, 89, 71, 21, 102, 84, 101, 175]), - Bytes32::new_direct([232, 195, 82, 123, 189, 200, 139, 61, 179, 141, 208, 69, 102, 58, 127, 66, 69, 127, 7, 179, 108, 128, 253, 154, 207, 254, 201, 18, 192, 241, 99, 208]), - Bytes32::new_direct([138, 25, 185, 215, 159, 159, 214, 251, 161, 103, 180, 78, 209, 215, 131, 132, 134, 180, 177, 37, 79, 219, 19, 93, 45, 30, 53, 125, 142, 194, 114, 34]), - Bytes32::new_direct([185, 24, 200, 28, 68, 7, 118, 226, 65, 240, 85, 120, 123, 174, 239, 85, 247, 210, 104, 247, 20, 229, 41, 91, 242, 5, 2, 121, 132, 69, 43, 33]), - Bytes32::new_direct([78, 191, 92, 97, 205, 120, 114, 216, 112, 101, 44, 98, 148, 2, 112, 221, 168, 199, 254, 55, 160, 116, 116, 105, 109, 227, 130, 219, 194, 32, 209, 196]), - Bytes32::new_direct([177, 203, 26, 1, 216, 115, 242, 158, 202, 107, 60, 221, 81, 167, 8, 233, 247, 235, 49, 54, 45, 133, 202, 193, 34, 158, 205, 29, 232, 245, 195, 194]), - Bytes32::new_direct([193, 118, 182, 153, 10, 237, 67, 229, 136, 193, 253, 250, 46, 125, 141, 22, 107, 168, 74, 130, 60, 193, 194, 196, 249, 129, 153, 82, 162, 143, 188, 42]), - Bytes32::new_direct([239, 57, 105, 90, 116, 61, 160, 214, 55, 191, 17, 228, 44, 149, 103, 180, 229, 4, 175, 240, 209, 231, 141, 95, 109, 195, 78, 142, 122, 177, 227, 20]), - Bytes32::new_direct([153, 247, 105, 126, 178, 44, 190, 57, 12, 63, 169, 27, 206, 19, 151, 38, 33, 83, 35, 3, 177, 97, 36, 182, 37, 78, 150, 243, 222, 32, 180, 148]), - Bytes32::new_direct([29, 109, 110, 167, 27, 136, 235, 226, 147, 175, 241, 236, 138, 135, 163, 200, 21, 94, 220, 238, 23, 84, 46, 14, 44, 100, 47, 131, 134, 43, 98, 173]), - Bytes32::new_direct([73, 241, 108, 102, 184, 200, 64, 80, 58, 162, 29, 211, 173, 150, 6, 195, 2, 137, 246, 51, 155, 132, 41, 255, 21, 71, 74, 143, 197, 180, 217, 159]), - Bytes32::new_direct([109, 189, 226, 33, 70, 157, 161, 166, 223, 31, 224, 221, 37, 112, 27, 215, 163, 250, 217, 155, 168, 121, 119, 232, 100, 177, 104, 210, 10, 118, 215, 0]), - Bytes32::new_direct([175, 156, 32, 156, 238, 82, 62, 25, 96, 251, 146, 24, 13, 2, 115, 174, 163, 50, 14, 251, 196, 173, 5, 87, 171, 228, 191, 9, 90, 84, 156, 63]), - Bytes32::new_direct([244, 161, 238, 217, 14, 60, 162, 139, 34, 84, 68, 121, 213, 11, 230, 95, 57, 221, 174, 107, 103, 105, 76, 137, 58, 247, 65, 209, 167, 63, 96, 212]), - Bytes32::new_direct([31, 177, 221, 130, 152, 92, 190, 4, 59, 90, 122, 63, 128, 180, 140, 201, 75, 239, 200, 151, 94, 65, 36, 227, 21, 250, 10, 253, 26, 114, 238, 188]), - Bytes32::new_direct([48, 216, 87, 30, 113, 214, 69, 1, 9, 112, 244, 232, 127, 55, 43, 162, 156, 83, 235, 199, 126, 132, 241, 106, 65, 209, 240, 32, 11, 179, 219, 135]), - Bytes32::new_direct([20, 55, 225, 132, 0, 219, 175, 17, 235, 73, 236, 16, 24, 227, 250, 155, 32, 83, 234, 123, 191, 209, 157, 133, 215, 202, 3, 221, 135, 223, 221, 90]), - Bytes32::new_direct([113, 185, 118, 164, 139, 219, 203, 140, 245, 123, 21, 186, 102, 22, 54, 14, 19, 230, 223, 120, 211, 114, 203, 77, 173, 214, 61, 80, 151, 10, 2, 205]), - Bytes32::new_direct([50, 20, 214, 105, 232, 5, 9, 101, 16, 72, 46, 139, 177, 188, 25, 93, 14, 57, 60, 168, 49, 147, 134, 5, 62, 181, 120, 75, 193, 229, 107, 67]), - Bytes32::new_direct([92, 167, 117, 18, 186, 193, 28, 56, 86, 25, 75, 64, 1, 8, 126, 212, 56, 163, 157, 242, 34, 73, 65, 58, 187, 2, 112, 58, 225, 229, 113, 58]), - Bytes32::new_direct([173, 139, 156, 215, 250, 231, 15, 123, 8, 5, 98, 192, 164, 48, 106, 203, 152, 189, 118, 120, 245, 221, 214, 26, 79, 39, 148, 232, 217, 88, 34, 246]), - Bytes32::new_direct([8, 207, 11, 196, 253, 51, 182, 90, 62, 110, 125, 142, 209, 154, 5, 203, 252, 62, 117, 215, 226, 136, 140, 201, 227, 210, 71, 34, 113, 160, 42, 68]), - Bytes32::new_direct([108, 135, 226, 117, 179, 142, 93, 181, 20, 186, 189, 217, 49, 154, 66, 244, 180, 170, 122, 233, 153, 214, 104, 71, 44, 57, 103, 240, 97, 80, 170, 198]), - Bytes32::new_direct([123, 168, 184, 254, 241, 78, 23, 91, 32, 77, 218, 176, 179, 189, 61, 162, 114, 158, 212, 7, 201, 15, 58, 4, 161, 211, 188, 156, 190, 2, 20, 183]), - Bytes32::new_direct([60, 170, 86, 130, 38, 170, 202, 88, 97, 206, 67, 69, 140, 122, 201, 38, 70, 229, 144, 202, 146, 10, 146, 148, 21, 247, 119, 196, 150, 223, 110, 67]), - Bytes32::new_direct([102, 154, 215, 132, 143, 248, 151, 101, 101, 253, 80, 211, 254, 64, 179, 73, 96, 132, 144, 216, 225, 130, 48, 56, 14, 39, 97, 223, 134, 10, 124, 138]), - Bytes32::new_direct([197, 131, 194, 166, 168, 160, 24, 116, 47, 120, 89, 3, 44, 154, 83, 250, 142, 64, 77, 63, 15, 60, 97, 100, 150, 39, 227, 139, 42, 146, 146, 104]), - Bytes32::new_direct([7, 160, 246, 93, 64, 79, 76, 208, 66, 80, 60, 123, 13, 51, 115, 251, 196, 209, 145, 106, 61, 105, 136, 58, 7, 129, 142, 203, 205, 69, 45, 203]), - Bytes32::new_direct([64, 162, 48, 187, 213, 182, 41, 85, 62, 148, 26, 161, 227, 108, 173, 249, 195, 106, 203, 18, 28, 59, 184, 85, 249, 16, 224, 222, 114, 200, 99, 22]), - Bytes32::new_direct([246, 194, 74, 122, 165, 216, 211, 144, 101, 143, 134, 9, 53, 229, 197, 227, 121, 248, 89, 169, 48, 220, 104, 216, 117, 118, 36, 234, 108, 135, 81, 162]), - Bytes32::new_direct([232, 59, 196, 2, 103, 242, 44, 129, 41, 231, 226, 115, 238, 151, 166, 210, 158, 110, 43, 45, 86, 163, 127, 8, 162, 81, 131, 145, 165, 252, 170, 12]), - Bytes32::new_direct([204, 88, 102, 180, 241, 148, 27, 183, 223, 71, 157, 119, 155, 31, 102, 239, 4, 83, 204, 246, 38, 228, 234, 20, 97, 233, 203, 149, 186, 67, 143, 51]), - Bytes32::new_direct([246, 170, 233, 8, 202, 38, 67, 219, 175, 13, 250, 174, 98, 36, 84, 166, 6, 75, 27, 43, 62, 128, 106, 23, 163, 191, 86, 115, 164, 50, 127, 151]), - Bytes32::new_direct([204, 72, 199, 57, 106, 136, 244, 66, 217, 155, 183, 211, 166, 71, 140, 211, 210, 181, 178, 218, 204, 91, 200, 204, 153, 60, 22, 32, 24, 153, 131, 31]), - Bytes32::new_direct([204, 193, 13, 167, 214, 136, 121, 99, 198, 137, 11, 223, 85, 40, 167, 126, 153, 80, 187, 35, 226, 31, 226, 42, 9, 175, 31, 206, 119, 67, 153, 39]), - Bytes32::new_direct([63, 82, 16, 182, 255, 45, 123, 220, 252, 52, 199, 222, 76, 172, 123, 232, 133, 182, 143, 202, 223, 161, 203, 91, 239, 225, 123, 184, 231, 53, 19, 253]), - Bytes32::new_direct([5, 13, 255, 217, 70, 105, 205, 70, 41, 25, 44, 3, 245, 136, 16, 255, 101, 61, 189, 225, 142, 201, 210, 226, 9, 237, 171, 109, 63, 204, 204, 139]), - Bytes32::new_direct([161, 218, 126, 252, 32, 196, 32, 105, 98, 13, 201, 117, 64, 37, 232, 32, 159, 106, 48, 121, 250, 139, 219, 137, 129, 3, 83, 194, 102, 251, 148, 71]), - Bytes32::new_direct([72, 17, 9, 21, 142, 89, 135, 91, 81, 155, 72, 247, 56, 232, 136, 57, 251, 182, 211, 35, 207, 169, 87, 123, 31, 222, 72, 85, 212, 92, 159, 171]), - Bytes32::new_direct([193, 253, 238, 224, 198, 216, 154, 52, 59, 87, 183, 80, 242, 162, 238, 7, 218, 195, 253, 210, 92, 116, 43, 181, 109, 40, 74, 38, 154, 211, 102, 173]), - Bytes32::new_direct([193, 88, 249, 81, 11, 128, 242, 239, 220, 1, 237, 199, 235, 12, 153, 73, 145, 158, 15, 111, 108, 244, 19, 51, 159, 206, 66, 25, 147, 215, 157, 165]), - Bytes32::new_direct([195, 90, 0, 163, 8, 199, 55, 59, 47, 117, 186, 204, 5, 42, 205, 164, 239, 233, 203, 210, 69, 205, 244, 152, 113, 184, 206, 110, 101, 197, 120, 101]), - Bytes32::new_direct([114, 169, 222, 11, 169, 15, 123, 245, 42, 25, 120, 198, 66, 140, 125, 123, 201, 107, 3, 50, 245, 226, 52, 46, 162, 44, 134, 157, 226, 11, 115, 186]), - Bytes32::new_direct([6, 47, 131, 89, 216, 138, 92, 250, 126, 232, 238, 50, 181, 78, 69, 115, 227, 25, 49, 50, 116, 138, 47, 61, 179, 75, 121, 124, 127, 106, 228, 178]), - Bytes32::new_direct([152, 253, 228, 228, 120, 255, 82, 66, 24, 145, 159, 223, 39, 185, 81, 201, 81, 110, 47, 57, 105, 128, 8, 42, 130, 119, 92, 7, 14, 247, 137, 135]), - Bytes32::new_direct([162, 28, 11, 245, 48, 21, 8, 137, 161, 131, 84, 18, 129, 70, 197, 122, 165, 39, 71, 213, 142, 115, 159, 52, 46, 213, 81, 10, 217, 212, 74, 20]), - Bytes32::new_direct([129, 250, 71, 119, 46, 25, 220, 212, 143, 120, 0, 101, 85, 101, 109, 107, 142, 20, 107, 174, 39, 134, 128, 244, 237, 155, 190, 19, 110, 10, 240, 94]), - Bytes32::new_direct([90, 70, 190, 48, 191, 45, 227, 17, 185, 162, 159, 12, 18, 94, 186, 251, 252, 238, 95, 174, 253, 99, 194, 204, 5, 178, 117, 139, 50, 154, 93, 170]), - Bytes32::new_direct([201, 8, 48, 126, 70, 22, 83, 82, 229, 84, 168, 86, 100, 169, 227, 175, 196, 154, 217, 150, 2, 36, 1, 100, 48, 216, 141, 205, 113, 148, 109, 126]), - Bytes32::new_direct([16, 182, 10, 119, 255, 70, 127, 242, 64, 68, 67, 44, 52, 195, 63, 185, 227, 97, 138, 244, 53, 246, 110, 99, 41, 176, 146, 206, 81, 168, 66, 140]), - Bytes32::new_direct([95, 9, 211, 227, 219, 119, 221, 132, 248, 92, 236, 190, 110, 227, 153, 109, 103, 63, 121, 221, 165, 212, 20, 141, 33, 95, 52, 157, 69, 76, 2, 70]), - Bytes32::new_direct([216, 138, 115, 198, 102, 135, 226, 247, 235, 185, 206, 147, 130, 9, 48, 166, 92, 22, 41, 158, 169, 52, 233, 1, 60, 229, 165, 208, 60, 161, 194, 166]), - Bytes32::new_direct([129, 241, 87, 138, 103, 241, 79, 26, 52, 35, 125, 237, 54, 147, 253, 137, 101, 146, 235, 127, 124, 113, 60, 203, 181, 4, 250, 12, 72, 27, 24, 7]), - Bytes32::new_direct([52, 120, 68, 97, 147, 229, 251, 178, 161, 233, 142, 136, 38, 40, 85, 46, 121, 156, 115, 186, 72, 95, 128, 43, 252, 176, 176, 51, 113, 83, 154, 232]), - Bytes32::new_direct([227, 11, 188, 57, 98, 160, 248, 247, 112, 49, 247, 92, 94, 224, 135, 182, 211, 230, 69, 185, 138, 154, 141, 157, 18, 34, 138, 236, 67, 243, 26, 132]), - Bytes32::new_direct([61, 246, 31, 52, 44, 146, 190, 215, 214, 105, 253, 86, 172, 174, 140, 112, 30, 154, 82, 173, 62, 199, 157, 180, 255, 104, 73, 136, 163, 79, 210, 252]), - Bytes32::new_direct([200, 155, 200, 87, 142, 123, 62, 176, 250, 44, 18, 238, 229, 121, 125, 109, 102, 173, 60, 203, 88, 65, 33, 122, 22, 111, 157, 143, 164, 7, 214, 26]), - Bytes32::new_direct([179, 76, 168, 179, 139, 86, 151, 173, 26, 70, 236, 116, 202, 123, 63, 80, 106, 208, 63, 138, 179, 225, 114, 64, 48, 34, 78, 124, 132, 210, 224, 190]), - Bytes32::new_direct([138, 116, 89, 240, 28, 79, 42, 149, 199, 118, 149, 49, 146, 212, 104, 62, 17, 137, 138, 223, 225, 187, 152, 43, 134, 60, 95, 55, 175, 128, 95, 144]), + Bytes32::new_direct([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ]), + Bytes32::new_direct([ + 239, 247, 49, 255, 201, 159, 228, 149, 22, 115, 41, 139, 56, 117, 149, 46, 67, 155, 98, 70, + 216, 225, 85, 100, 113, 242, 144, 167, 97, 238, 117, 207, + ]), + Bytes32::new_direct([ + 46, 87, 136, 101, 122, 12, 6, 120, 39, 121, 167, 193, 66, 146, 150, 1, 90, 240, 97, 225, + 179, 150, 197, 127, 56, 214, 116, 24, 180, 109, 96, 51, + ]), + Bytes32::new_direct([ + 54, 125, 90, 195, 243, 1, 115, 18, 251, 68, 203, 216, 48, 156, 216, 200, 215, 250, 80, 152, + 203, 58, 245, 128, 70, 112, 221, 104, 34, 125, 234, 138, + ]), + Bytes32::new_direct([ + 103, 99, 44, 86, 57, 0, 102, 201, 99, 214, 249, 24, 45, 112, 234, 183, 225, 196, 9, 162, + 168, 33, 121, 118, 93, 184, 14, 70, 148, 135, 211, 214, + ]), + Bytes32::new_direct([ + 69, 7, 89, 47, 41, 94, 148, 139, 67, 197, 99, 98, 100, 63, 25, 230, 100, 118, 213, 25, 28, + 129, 5, 39, 69, 89, 71, 21, 102, 84, 101, 175, + ]), + Bytes32::new_direct([ + 232, 195, 82, 123, 189, 200, 139, 61, 179, 141, 208, 69, 102, 58, 127, 66, 69, 127, 7, 179, + 108, 128, 253, 154, 207, 254, 201, 18, 192, 241, 99, 208, + ]), + Bytes32::new_direct([ + 138, 25, 185, 215, 159, 159, 214, 251, 161, 103, 180, 78, 209, 215, 131, 132, 134, 180, + 177, 37, 79, 219, 19, 93, 45, 30, 53, 125, 142, 194, 114, 34, + ]), + Bytes32::new_direct([ + 185, 24, 200, 28, 68, 7, 118, 226, 65, 240, 85, 120, 123, 174, 239, 85, 247, 210, 104, 247, + 20, 229, 41, 91, 242, 5, 2, 121, 132, 69, 43, 33, + ]), + Bytes32::new_direct([ + 78, 191, 92, 97, 205, 120, 114, 216, 112, 101, 44, 98, 148, 2, 112, 221, 168, 199, 254, 55, + 160, 116, 116, 105, 109, 227, 130, 219, 194, 32, 209, 196, + ]), + Bytes32::new_direct([ + 177, 203, 26, 1, 216, 115, 242, 158, 202, 107, 60, 221, 81, 167, 8, 233, 247, 235, 49, 54, + 45, 133, 202, 193, 34, 158, 205, 29, 232, 245, 195, 194, + ]), + Bytes32::new_direct([ + 193, 118, 182, 153, 10, 237, 67, 229, 136, 193, 253, 250, 46, 125, 141, 22, 107, 168, 74, + 130, 60, 193, 194, 196, 249, 129, 153, 82, 162, 143, 188, 42, + ]), + Bytes32::new_direct([ + 239, 57, 105, 90, 116, 61, 160, 214, 55, 191, 17, 228, 44, 149, 103, 180, 229, 4, 175, 240, + 209, 231, 141, 95, 109, 195, 78, 142, 122, 177, 227, 20, + ]), + Bytes32::new_direct([ + 153, 247, 105, 126, 178, 44, 190, 57, 12, 63, 169, 27, 206, 19, 151, 38, 33, 83, 35, 3, + 177, 97, 36, 182, 37, 78, 150, 243, 222, 32, 180, 148, + ]), + Bytes32::new_direct([ + 29, 109, 110, 167, 27, 136, 235, 226, 147, 175, 241, 236, 138, 135, 163, 200, 21, 94, 220, + 238, 23, 84, 46, 14, 44, 100, 47, 131, 134, 43, 98, 173, + ]), + Bytes32::new_direct([ + 73, 241, 108, 102, 184, 200, 64, 80, 58, 162, 29, 211, 173, 150, 6, 195, 2, 137, 246, 51, + 155, 132, 41, 255, 21, 71, 74, 143, 197, 180, 217, 159, + ]), + Bytes32::new_direct([ + 109, 189, 226, 33, 70, 157, 161, 166, 223, 31, 224, 221, 37, 112, 27, 215, 163, 250, 217, + 155, 168, 121, 119, 232, 100, 177, 104, 210, 10, 118, 215, 0, + ]), + Bytes32::new_direct([ + 175, 156, 32, 156, 238, 82, 62, 25, 96, 251, 146, 24, 13, 2, 115, 174, 163, 50, 14, 251, + 196, 173, 5, 87, 171, 228, 191, 9, 90, 84, 156, 63, + ]), + Bytes32::new_direct([ + 244, 161, 238, 217, 14, 60, 162, 139, 34, 84, 68, 121, 213, 11, 230, 95, 57, 221, 174, 107, + 103, 105, 76, 137, 58, 247, 65, 209, 167, 63, 96, 212, + ]), + Bytes32::new_direct([ + 31, 177, 221, 130, 152, 92, 190, 4, 59, 90, 122, 63, 128, 180, 140, 201, 75, 239, 200, 151, + 94, 65, 36, 227, 21, 250, 10, 253, 26, 114, 238, 188, + ]), + Bytes32::new_direct([ + 48, 216, 87, 30, 113, 214, 69, 1, 9, 112, 244, 232, 127, 55, 43, 162, 156, 83, 235, 199, + 126, 132, 241, 106, 65, 209, 240, 32, 11, 179, 219, 135, + ]), + Bytes32::new_direct([ + 20, 55, 225, 132, 0, 219, 175, 17, 235, 73, 236, 16, 24, 227, 250, 155, 32, 83, 234, 123, + 191, 209, 157, 133, 215, 202, 3, 221, 135, 223, 221, 90, + ]), + Bytes32::new_direct([ + 113, 185, 118, 164, 139, 219, 203, 140, 245, 123, 21, 186, 102, 22, 54, 14, 19, 230, 223, + 120, 211, 114, 203, 77, 173, 214, 61, 80, 151, 10, 2, 205, + ]), + Bytes32::new_direct([ + 50, 20, 214, 105, 232, 5, 9, 101, 16, 72, 46, 139, 177, 188, 25, 93, 14, 57, 60, 168, 49, + 147, 134, 5, 62, 181, 120, 75, 193, 229, 107, 67, + ]), + Bytes32::new_direct([ + 92, 167, 117, 18, 186, 193, 28, 56, 86, 25, 75, 64, 1, 8, 126, 212, 56, 163, 157, 242, 34, + 73, 65, 58, 187, 2, 112, 58, 225, 229, 113, 58, + ]), + Bytes32::new_direct([ + 173, 139, 156, 215, 250, 231, 15, 123, 8, 5, 98, 192, 164, 48, 106, 203, 152, 189, 118, + 120, 245, 221, 214, 26, 79, 39, 148, 232, 217, 88, 34, 246, + ]), + Bytes32::new_direct([ + 8, 207, 11, 196, 253, 51, 182, 90, 62, 110, 125, 142, 209, 154, 5, 203, 252, 62, 117, 215, + 226, 136, 140, 201, 227, 210, 71, 34, 113, 160, 42, 68, + ]), + Bytes32::new_direct([ + 108, 135, 226, 117, 179, 142, 93, 181, 20, 186, 189, 217, 49, 154, 66, 244, 180, 170, 122, + 233, 153, 214, 104, 71, 44, 57, 103, 240, 97, 80, 170, 198, + ]), + Bytes32::new_direct([ + 123, 168, 184, 254, 241, 78, 23, 91, 32, 77, 218, 176, 179, 189, 61, 162, 114, 158, 212, 7, + 201, 15, 58, 4, 161, 211, 188, 156, 190, 2, 20, 183, + ]), + Bytes32::new_direct([ + 60, 170, 86, 130, 38, 170, 202, 88, 97, 206, 67, 69, 140, 122, 201, 38, 70, 229, 144, 202, + 146, 10, 146, 148, 21, 247, 119, 196, 150, 223, 110, 67, + ]), + Bytes32::new_direct([ + 102, 154, 215, 132, 143, 248, 151, 101, 101, 253, 80, 211, 254, 64, 179, 73, 96, 132, 144, + 216, 225, 130, 48, 56, 14, 39, 97, 223, 134, 10, 124, 138, + ]), + Bytes32::new_direct([ + 197, 131, 194, 166, 168, 160, 24, 116, 47, 120, 89, 3, 44, 154, 83, 250, 142, 64, 77, 63, + 15, 60, 97, 100, 150, 39, 227, 139, 42, 146, 146, 104, + ]), + Bytes32::new_direct([ + 7, 160, 246, 93, 64, 79, 76, 208, 66, 80, 60, 123, 13, 51, 115, 251, 196, 209, 145, 106, + 61, 105, 136, 58, 7, 129, 142, 203, 205, 69, 45, 203, + ]), + Bytes32::new_direct([ + 64, 162, 48, 187, 213, 182, 41, 85, 62, 148, 26, 161, 227, 108, 173, 249, 195, 106, 203, + 18, 28, 59, 184, 85, 249, 16, 224, 222, 114, 200, 99, 22, + ]), + Bytes32::new_direct([ + 246, 194, 74, 122, 165, 216, 211, 144, 101, 143, 134, 9, 53, 229, 197, 227, 121, 248, 89, + 169, 48, 220, 104, 216, 117, 118, 36, 234, 108, 135, 81, 162, + ]), + Bytes32::new_direct([ + 232, 59, 196, 2, 103, 242, 44, 129, 41, 231, 226, 115, 238, 151, 166, 210, 158, 110, 43, + 45, 86, 163, 127, 8, 162, 81, 131, 145, 165, 252, 170, 12, + ]), + Bytes32::new_direct([ + 204, 88, 102, 180, 241, 148, 27, 183, 223, 71, 157, 119, 155, 31, 102, 239, 4, 83, 204, + 246, 38, 228, 234, 20, 97, 233, 203, 149, 186, 67, 143, 51, + ]), + Bytes32::new_direct([ + 246, 170, 233, 8, 202, 38, 67, 219, 175, 13, 250, 174, 98, 36, 84, 166, 6, 75, 27, 43, 62, + 128, 106, 23, 163, 191, 86, 115, 164, 50, 127, 151, + ]), + Bytes32::new_direct([ + 204, 72, 199, 57, 106, 136, 244, 66, 217, 155, 183, 211, 166, 71, 140, 211, 210, 181, 178, + 218, 204, 91, 200, 204, 153, 60, 22, 32, 24, 153, 131, 31, + ]), + Bytes32::new_direct([ + 204, 193, 13, 167, 214, 136, 121, 99, 198, 137, 11, 223, 85, 40, 167, 126, 153, 80, 187, + 35, 226, 31, 226, 42, 9, 175, 31, 206, 119, 67, 153, 39, + ]), + Bytes32::new_direct([ + 63, 82, 16, 182, 255, 45, 123, 220, 252, 52, 199, 222, 76, 172, 123, 232, 133, 182, 143, + 202, 223, 161, 203, 91, 239, 225, 123, 184, 231, 53, 19, 253, + ]), + Bytes32::new_direct([ + 5, 13, 255, 217, 70, 105, 205, 70, 41, 25, 44, 3, 245, 136, 16, 255, 101, 61, 189, 225, + 142, 201, 210, 226, 9, 237, 171, 109, 63, 204, 204, 139, + ]), + Bytes32::new_direct([ + 161, 218, 126, 252, 32, 196, 32, 105, 98, 13, 201, 117, 64, 37, 232, 32, 159, 106, 48, 121, + 250, 139, 219, 137, 129, 3, 83, 194, 102, 251, 148, 71, + ]), + Bytes32::new_direct([ + 72, 17, 9, 21, 142, 89, 135, 91, 81, 155, 72, 247, 56, 232, 136, 57, 251, 182, 211, 35, + 207, 169, 87, 123, 31, 222, 72, 85, 212, 92, 159, 171, + ]), + Bytes32::new_direct([ + 193, 253, 238, 224, 198, 216, 154, 52, 59, 87, 183, 80, 242, 162, 238, 7, 218, 195, 253, + 210, 92, 116, 43, 181, 109, 40, 74, 38, 154, 211, 102, 173, + ]), + Bytes32::new_direct([ + 193, 88, 249, 81, 11, 128, 242, 239, 220, 1, 237, 199, 235, 12, 153, 73, 145, 158, 15, 111, + 108, 244, 19, 51, 159, 206, 66, 25, 147, 215, 157, 165, + ]), + Bytes32::new_direct([ + 195, 90, 0, 163, 8, 199, 55, 59, 47, 117, 186, 204, 5, 42, 205, 164, 239, 233, 203, 210, + 69, 205, 244, 152, 113, 184, 206, 110, 101, 197, 120, 101, + ]), + Bytes32::new_direct([ + 114, 169, 222, 11, 169, 15, 123, 245, 42, 25, 120, 198, 66, 140, 125, 123, 201, 107, 3, 50, + 245, 226, 52, 46, 162, 44, 134, 157, 226, 11, 115, 186, + ]), + Bytes32::new_direct([ + 6, 47, 131, 89, 216, 138, 92, 250, 126, 232, 238, 50, 181, 78, 69, 115, 227, 25, 49, 50, + 116, 138, 47, 61, 179, 75, 121, 124, 127, 106, 228, 178, + ]), + Bytes32::new_direct([ + 152, 253, 228, 228, 120, 255, 82, 66, 24, 145, 159, 223, 39, 185, 81, 201, 81, 110, 47, 57, + 105, 128, 8, 42, 130, 119, 92, 7, 14, 247, 137, 135, + ]), + Bytes32::new_direct([ + 162, 28, 11, 245, 48, 21, 8, 137, 161, 131, 84, 18, 129, 70, 197, 122, 165, 39, 71, 213, + 142, 115, 159, 52, 46, 213, 81, 10, 217, 212, 74, 20, + ]), + Bytes32::new_direct([ + 129, 250, 71, 119, 46, 25, 220, 212, 143, 120, 0, 101, 85, 101, 109, 107, 142, 20, 107, + 174, 39, 134, 128, 244, 237, 155, 190, 19, 110, 10, 240, 94, + ]), + Bytes32::new_direct([ + 90, 70, 190, 48, 191, 45, 227, 17, 185, 162, 159, 12, 18, 94, 186, 251, 252, 238, 95, 174, + 253, 99, 194, 204, 5, 178, 117, 139, 50, 154, 93, 170, + ]), + Bytes32::new_direct([ + 201, 8, 48, 126, 70, 22, 83, 82, 229, 84, 168, 86, 100, 169, 227, 175, 196, 154, 217, 150, + 2, 36, 1, 100, 48, 216, 141, 205, 113, 148, 109, 126, + ]), + Bytes32::new_direct([ + 16, 182, 10, 119, 255, 70, 127, 242, 64, 68, 67, 44, 52, 195, 63, 185, 227, 97, 138, 244, + 53, 246, 110, 99, 41, 176, 146, 206, 81, 168, 66, 140, + ]), + Bytes32::new_direct([ + 95, 9, 211, 227, 219, 119, 221, 132, 248, 92, 236, 190, 110, 227, 153, 109, 103, 63, 121, + 221, 165, 212, 20, 141, 33, 95, 52, 157, 69, 76, 2, 70, + ]), + Bytes32::new_direct([ + 216, 138, 115, 198, 102, 135, 226, 247, 235, 185, 206, 147, 130, 9, 48, 166, 92, 22, 41, + 158, 169, 52, 233, 1, 60, 229, 165, 208, 60, 161, 194, 166, + ]), + Bytes32::new_direct([ + 129, 241, 87, 138, 103, 241, 79, 26, 52, 35, 125, 237, 54, 147, 253, 137, 101, 146, 235, + 127, 124, 113, 60, 203, 181, 4, 250, 12, 72, 27, 24, 7, + ]), + Bytes32::new_direct([ + 52, 120, 68, 97, 147, 229, 251, 178, 161, 233, 142, 136, 38, 40, 85, 46, 121, 156, 115, + 186, 72, 95, 128, 43, 252, 176, 176, 51, 113, 83, 154, 232, + ]), + Bytes32::new_direct([ + 227, 11, 188, 57, 98, 160, 248, 247, 112, 49, 247, 92, 94, 224, 135, 182, 211, 230, 69, + 185, 138, 154, 141, 157, 18, 34, 138, 236, 67, 243, 26, 132, + ]), + Bytes32::new_direct([ + 61, 246, 31, 52, 44, 146, 190, 215, 214, 105, 253, 86, 172, 174, 140, 112, 30, 154, 82, + 173, 62, 199, 157, 180, 255, 104, 73, 136, 163, 79, 210, 252, + ]), + Bytes32::new_direct([ + 200, 155, 200, 87, 142, 123, 62, 176, 250, 44, 18, 238, 229, 121, 125, 109, 102, 173, 60, + 203, 88, 65, 33, 122, 22, 111, 157, 143, 164, 7, 214, 26, + ]), + Bytes32::new_direct([ + 179, 76, 168, 179, 139, 86, 151, 173, 26, 70, 236, 116, 202, 123, 63, 80, 106, 208, 63, + 138, 179, 225, 114, 64, 48, 34, 78, 124, 132, 210, 224, 190, + ]), + Bytes32::new_direct([ + 138, 116, 89, 240, 28, 79, 42, 149, 199, 118, 149, 49, 146, 212, 104, 62, 17, 137, 138, + 223, 225, 187, 152, 43, 134, 60, 95, 55, 175, 128, 95, 144, + ]), ]; const INSTRUCTION_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::new_direct([248, 140, 83, 29, 241, 220, 66, 40, 126, 248, 5, 153, 77, 179, 26, 64, 221, 108, 205, 162, 173, 52, 179, 140, 202, 105, 0, 170, 166, 130, 120, 176]), - Bytes32::new_direct([35, 74, 103, 235, 245, 71, 66, 212, 99, 147, 15, 200, 1, 237, 95, 163, 10, 146, 122, 251, 243, 239, 93, 186, 46, 74, 206, 130, 63, 17, 199, 80]), - Bytes32::new_direct([113, 169, 40, 37, 169, 205, 28, 78, 37, 104, 52, 28, 29, 222, 39, 32, 208, 183, 215, 38, 255, 69, 87, 70, 174, 113, 221, 183, 206, 62, 192, 118]), - Bytes32::new_direct([1, 148, 183, 39, 234, 23, 138, 182, 169, 58, 52, 158, 248, 212, 186, 127, 60, 42, 25, 210, 20, 170, 182, 139, 20, 185, 196, 85, 241, 214, 181, 64]), - Bytes32::new_direct([241, 14, 59, 8, 168, 222, 232, 125, 149, 227, 125, 41, 223, 198, 88, 135, 54, 146, 140, 212, 164, 76, 239, 106, 10, 20, 67, 180, 24, 159, 174, 99]), - Bytes32::new_direct([117, 111, 220, 19, 204, 227, 211, 18, 61, 239, 179, 46, 142, 75, 67, 98, 159, 221, 205, 158, 125, 42, 221, 227, 148, 162, 193, 229, 147, 70, 214, 127]), - Bytes32::new_direct([20, 72, 211, 188, 38, 126, 166, 75, 54, 22, 225, 21, 113, 155, 167, 89, 161, 6, 37, 78, 227, 211, 219, 141, 161, 199, 151, 122, 81, 45, 159, 187]), - Bytes32::new_direct([69, 198, 100, 170, 106, 174, 208, 152, 152, 121, 118, 66, 111, 89, 131, 14, 159, 115, 142, 200, 205, 173, 89, 77, 68, 234, 5, 171, 105, 248, 199, 83]), - Bytes32::new_direct([17, 1, 220, 13, 154, 194, 88, 60, 253, 223, 149, 35, 44, 184, 107, 141, 205, 177, 185, 32, 22, 99, 212, 96, 194, 91, 255, 179, 121, 153, 254, 40]), - Bytes32::new_direct([222, 247, 186, 138, 222, 183, 135, 183, 170, 79, 182, 23, 69, 89, 70, 68, 88, 87, 235, 22, 178, 134, 114, 220, 249, 153, 70, 71, 229, 139, 10, 190]), - Bytes32::new_direct([183, 77, 65, 51, 207, 78, 55, 149, 222, 3, 100, 82, 232, 230, 21, 115, 249, 177, 36, 89, 12, 41, 70, 31, 199, 254, 213, 3, 184, 2, 85, 137]), - Bytes32::new_direct([82, 15, 215, 135, 95, 18, 143, 49, 239, 237, 6, 15, 213, 113, 153, 49, 149, 54, 50, 139, 100, 192, 128, 226, 168, 9, 120, 167, 157, 42, 45, 19]), - Bytes32::new_direct([70, 32, 130, 243, 186, 144, 224, 217, 130, 222, 175, 221, 218, 190, 179, 222, 217, 115, 70, 160, 141, 231, 221, 96, 2, 173, 27, 17, 158, 66, 180, 58]), - Bytes32::new_direct([76, 243, 65, 235, 12, 31, 48, 195, 62, 176, 202, 57, 99, 80, 237, 222, 138, 199, 124, 251, 143, 243, 205, 226, 18, 164, 67, 64, 68, 238, 53, 71]), - Bytes32::new_direct([70, 52, 254, 193, 211, 92, 63, 238, 92, 2, 160, 29, 154, 25, 221, 136, 2, 49, 96, 27, 15, 152, 238, 57, 241, 253, 32, 131, 73, 38, 229, 243]), - Bytes32::new_direct([214, 162, 82, 44, 146, 145, 61, 77, 36, 3, 131, 81, 217, 39, 127, 81, 66, 82, 172, 230, 246, 3, 243, 217, 210, 38, 201, 109, 240, 143, 253, 79]), - Bytes32::new_direct([127, 18, 198, 116, 112, 141, 16, 39, 115, 118, 37, 208, 118, 119, 147, 46, 196, 124, 19, 196, 34, 183, 172, 157, 18, 91, 4, 210, 77, 195, 220, 59]), - Bytes32::new_direct([87, 54, 42, 60, 39, 223, 84, 148, 158, 230, 70, 53, 191, 1, 108, 103, 139, 111, 58, 220, 114, 46, 46, 110, 20, 211, 84, 1, 173, 104, 175, 191]), - Bytes32::new_direct([182, 147, 66, 127, 229, 144, 125, 93, 84, 220, 116, 107, 51, 13, 24, 161, 68, 172, 165, 50, 12, 198, 229, 173, 49, 26, 114, 159, 84, 190, 6, 42]), - Bytes32::new_direct([183, 20, 36, 145, 76, 36, 61, 136, 224, 139, 89, 23, 124, 29, 210, 137, 1, 160, 22, 128, 48, 242, 234, 85, 84, 24, 206, 49, 143, 185, 237, 110]), - Bytes32::new_direct([38, 19, 77, 150, 92, 129, 177, 155, 139, 162, 90, 91, 231, 146, 216, 21, 54, 152, 18, 5, 98, 21, 67, 160, 154, 113, 175, 65, 214, 78, 19, 97]), - Bytes32::new_direct([163, 236, 47, 120, 121, 17, 217, 4, 200, 247, 206, 178, 211, 212, 163, 48, 38, 172, 111, 123, 75, 221, 63, 117, 42, 3, 252, 233, 104, 13, 210, 203]), - Bytes32::new_direct([127, 106, 132, 246, 28, 129, 245, 83, 159, 109, 196, 219, 68, 81, 230, 77, 254, 166, 55, 73, 169, 179, 93, 97, 117, 176, 53, 74, 121, 238, 184, 240]), - Bytes32::new_direct([255, 23, 108, 186, 145, 182, 196, 67, 163, 95, 173, 17, 67, 239, 199, 189, 145, 153, 120, 152, 159, 126, 255, 39, 55, 178, 230, 173, 91, 165, 229, 106]), - Bytes32::new_direct([184, 156, 20, 114, 222, 219, 89, 218, 102, 62, 130, 200, 179, 237, 32, 237, 127, 75, 251, 163, 160, 2, 221, 34, 166, 30, 172, 97, 115, 137, 179, 175]), - Bytes32::new_direct([244, 165, 127, 27, 66, 22, 38, 243, 235, 107, 30, 181, 31, 193, 210, 174, 254, 129, 39, 71, 59, 117, 186, 37, 217, 129, 138, 23, 146, 114, 96, 78]), - Bytes32::new_direct([27, 57, 244, 93, 208, 90, 64, 181, 161, 110, 161, 188, 62, 180, 46, 103, 136, 233, 63, 1, 243, 202, 236, 206, 173, 45, 45, 218, 238, 184, 83, 121]), - Bytes32::new_direct([138, 185, 33, 206, 120, 214, 246, 27, 100, 91, 106, 213, 60, 177, 39, 182, 149, 204, 11, 225, 254, 5, 87, 9, 19, 186, 166, 210, 33, 67, 146, 37]), - Bytes32::new_direct([243, 161, 7, 52, 35, 240, 227, 144, 29, 50, 232, 3, 101, 174, 192, 139, 89, 75, 204, 245, 173, 55, 139, 76, 126, 19, 142, 18, 230, 57, 219, 227]), - Bytes32::new_direct([97, 73, 36, 70, 120, 55, 49, 114, 107, 193, 66, 219, 47, 122, 201, 194, 52, 142, 12, 163, 108, 2, 107, 58, 185, 251, 168, 146, 57, 189, 150, 134]), - Bytes32::new_direct([11, 215, 29, 229, 151, 208, 62, 1, 172, 253, 253, 156, 177, 31, 117, 214, 161, 192, 68, 255, 140, 131, 66, 23, 247, 161, 107, 98, 199, 57, 123, 110]), - Bytes32::new_direct([41, 166, 54, 134, 242, 64, 153, 167, 5, 230, 226, 128, 71, 10, 251, 160, 19, 187, 70, 4, 95, 98, 77, 233, 181, 24, 11, 239, 142, 152, 229, 215]), - Bytes32::new_direct([221, 220, 68, 168, 143, 124, 235, 77, 241, 190, 214, 6, 102, 40, 32, 245, 131, 114, 170, 151, 134, 49, 79, 57, 242, 124, 85, 172, 83, 81, 68, 99]), - Bytes32::new_direct([142, 200, 102, 97, 170, 43, 14, 11, 139, 207, 150, 163, 99, 103, 2, 46, 44, 63, 109, 61, 62, 64, 199, 104, 36, 194, 155, 232, 139, 250, 97, 224]), - Bytes32::new_direct([162, 15, 26, 217, 96, 195, 70, 196, 253, 70, 127, 156, 39, 120, 120, 232, 197, 154, 192, 147, 104, 33, 104, 189, 120, 160, 36, 129, 208, 237, 128, 23]), - Bytes32::new_direct([42, 228, 74, 47, 20, 55, 197, 252, 173, 70, 178, 8, 2, 43, 97, 238, 155, 124, 87, 225, 217, 6, 103, 134, 136, 235, 193, 175, 33, 228, 219, 217]), - Bytes32::new_direct([219, 143, 25, 70, 78, 155, 119, 63, 126, 20, 158, 54, 27, 181, 104, 184, 74, 192, 75, 157, 42, 204, 45, 122, 25, 248, 247, 24, 225, 207, 51, 251]), - Bytes32::new_direct([151, 253, 36, 33, 104, 222, 126, 234, 112, 74, 59, 94, 239, 58, 36, 114, 90, 195, 208, 46, 250, 138, 165, 200, 178, 54, 238, 154, 219, 238, 6, 183]), - Bytes32::new_direct([205, 57, 187, 174, 221, 9, 164, 77, 76, 143, 54, 212, 115, 196, 67, 182, 200, 147, 78, 194, 245, 92, 173, 114, 180, 160, 168, 5, 200, 82, 217, 64]), - Bytes32::new_direct([211, 104, 62, 114, 157, 56, 254, 26, 32, 168, 208, 248, 62, 195, 142, 68, 53, 13, 7, 36, 216, 5, 127, 153, 97, 88, 222, 206, 91, 42, 14, 114]), - Bytes32::new_direct([203, 158, 225, 200, 62, 223, 202, 52, 207, 179, 250, 236, 29, 144, 181, 31, 87, 192, 203, 66, 56, 39, 123, 25, 123, 157, 196, 161, 34, 245, 22, 130]), - Bytes32::new_direct([147, 247, 233, 96, 190, 104, 227, 251, 99, 2, 16, 8, 77, 119, 1, 97, 243, 78, 103, 46, 24, 228, 217, 65, 219, 238, 135, 18, 164, 219, 132, 39]), - Bytes32::new_direct([239, 153, 72, 139, 52, 60, 171, 44, 72, 218, 138, 124, 45, 30, 143, 122, 147, 158, 12, 62, 213, 151, 217, 217, 212, 51, 110, 75, 122, 67, 134, 80]), - Bytes32::new_direct([46, 47, 130, 237, 178, 232, 239, 217, 165, 114, 255, 202, 132, 214, 18, 8, 72, 8, 255, 0, 162, 82, 5, 228, 141, 201, 70, 135, 255, 21, 220, 3]), - Bytes32::new_direct([21, 11, 196, 5, 215, 241, 194, 200, 198, 129, 133, 244, 204, 47, 131, 70, 138, 38, 107, 39, 211, 243, 72, 72, 34, 145, 35, 42, 14, 69, 218, 227]), - Bytes32::new_direct([73, 103, 117, 195, 67, 126, 242, 57, 232, 74, 142, 64, 169, 248, 113, 69, 110, 103, 127, 185, 177, 51, 212, 178, 48, 183, 247, 44, 246, 69, 35, 208]), - Bytes32::new_direct([125, 8, 83, 22, 215, 82, 179, 234, 169, 227, 213, 39, 170, 164, 195, 187, 63, 38, 59, 146, 144, 101, 38, 0, 110, 212, 202, 20, 245, 105, 187, 201]), - Bytes32::new_direct([186, 231, 186, 148, 68, 208, 226, 170, 120, 80, 68, 79, 23, 41, 51, 205, 240, 201, 10, 16, 24, 38, 137, 151, 7, 102, 92, 244, 3, 194, 228, 229]), - Bytes32::new_direct([46, 8, 51, 150, 63, 114, 126, 210, 30, 130, 76, 142, 13, 149, 14, 0, 205, 199, 48, 90, 86, 75, 151, 135, 164, 224, 129, 77, 174, 194, 212, 112]), - Bytes32::new_direct([150, 239, 42, 111, 3, 112, 25, 168, 179, 36, 106, 73, 212, 188, 215, 79, 180, 142, 191, 29, 219, 12, 244, 74, 254, 205, 160, 54, 68, 144, 81, 207]), - Bytes32::new_direct([23, 164, 189, 201, 250, 65, 212, 148, 132, 125, 94, 209, 115, 123, 29, 66, 3, 172, 57, 58, 46, 191, 96, 7, 212, 25, 226, 79, 120, 68, 202, 210]), - Bytes32::new_direct([252, 13, 137, 225, 208, 6, 84, 75, 97, 32, 177, 156, 248, 191, 113, 97, 254, 122, 86, 194, 3, 103, 219, 74, 227, 160, 231, 202, 13, 126, 46, 255]), - Bytes32::new_direct([70, 35, 27, 128, 17, 79, 226, 131, 144, 118, 248, 125, 188, 110, 20, 15, 255, 73, 205, 69, 0, 227, 26, 66, 39, 61, 191, 224, 239, 234, 83, 170]), - Bytes32::new_direct([129, 52, 148, 121, 230, 84, 28, 112, 75, 68, 181, 197, 80, 227, 107, 22, 60, 118, 81, 209, 198, 125, 233, 190, 84, 189, 18, 25, 72, 143, 2, 190]), - Bytes32::new_direct([244, 237, 81, 131, 251, 35, 56, 158, 229, 102, 150, 122, 213, 206, 119, 38, 54, 238, 158, 159, 1, 214, 31, 147, 245, 9, 172, 247, 156, 115, 209, 140]), - Bytes32::new_direct([47, 5, 174, 62, 80, 172, 77, 111, 136, 114, 188, 85, 249, 157, 182, 175, 187, 207, 29, 43, 152, 88, 130, 156, 138, 30, 188, 51, 82, 105, 145, 161]), - Bytes32::new_direct([102, 2, 197, 195, 206, 149, 53, 224, 61, 219, 163, 246, 208, 218, 140, 47, 16, 42, 196, 20, 145, 158, 101, 31, 225, 135, 49, 68, 95, 5, 228, 92]), - Bytes32::new_direct([78, 136, 176, 216, 253, 15, 136, 48, 162, 5, 57, 120, 93, 222, 179, 174, 129, 40, 8, 63, 18, 102, 97, 41, 58, 214, 1, 52, 58, 126, 186, 146]), - Bytes32::new_direct([145, 56, 231, 59, 247, 191, 104, 137, 240, 113, 32, 245, 235, 129, 255, 54, 99, 176, 109, 175, 107, 232, 201, 235, 95, 104, 54, 67, 252, 184, 200, 54]), - Bytes32::new_direct([181, 3, 229, 152, 113, 182, 55, 93, 138, 137, 21, 67, 27, 204, 96, 69, 72, 247, 237, 216, 28, 36, 115, 185, 111, 149, 224, 69, 66, 121, 188, 228]), - Bytes32::new_direct([212, 25, 201, 68, 187, 25, 10, 96, 40, 88, 100, 216, 145, 200, 26, 203, 220, 14, 14, 11, 190, 62, 143, 137, 53, 208, 233, 158, 37, 34, 8, 15]), - Bytes32::new_direct([80, 101, 192, 136, 203, 90, 189, 204, 181, 36, 28, 107, 220, 69, 119, 99, 145, 227, 198, 55, 37, 237, 212, 114, 31, 27, 19, 90, 231, 143, 87, 149]), - Bytes32::new_direct([248, 97, 168, 33, 15, 230, 128, 82, 157, 26, 186, 89, 200, 7, 101, 210, 117, 111, 75, 233, 244, 187, 1, 180, 30, 220, 15, 21, 203, 5, 243, 223]), + Bytes32::new_direct([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ]), + Bytes32::new_direct([ + 248, 140, 83, 29, 241, 220, 66, 40, 126, 248, 5, 153, 77, 179, 26, 64, 221, 108, 205, 162, + 173, 52, 179, 140, 202, 105, 0, 170, 166, 130, 120, 176, + ]), + Bytes32::new_direct([ + 35, 74, 103, 235, 245, 71, 66, 212, 99, 147, 15, 200, 1, 237, 95, 163, 10, 146, 122, 251, + 243, 239, 93, 186, 46, 74, 206, 130, 63, 17, 199, 80, + ]), + Bytes32::new_direct([ + 113, 169, 40, 37, 169, 205, 28, 78, 37, 104, 52, 28, 29, 222, 39, 32, 208, 183, 215, 38, + 255, 69, 87, 70, 174, 113, 221, 183, 206, 62, 192, 118, + ]), + Bytes32::new_direct([ + 1, 148, 183, 39, 234, 23, 138, 182, 169, 58, 52, 158, 248, 212, 186, 127, 60, 42, 25, 210, + 20, 170, 182, 139, 20, 185, 196, 85, 241, 214, 181, 64, + ]), + Bytes32::new_direct([ + 241, 14, 59, 8, 168, 222, 232, 125, 149, 227, 125, 41, 223, 198, 88, 135, 54, 146, 140, + 212, 164, 76, 239, 106, 10, 20, 67, 180, 24, 159, 174, 99, + ]), + Bytes32::new_direct([ + 117, 111, 220, 19, 204, 227, 211, 18, 61, 239, 179, 46, 142, 75, 67, 98, 159, 221, 205, + 158, 125, 42, 221, 227, 148, 162, 193, 229, 147, 70, 214, 127, + ]), + Bytes32::new_direct([ + 20, 72, 211, 188, 38, 126, 166, 75, 54, 22, 225, 21, 113, 155, 167, 89, 161, 6, 37, 78, + 227, 211, 219, 141, 161, 199, 151, 122, 81, 45, 159, 187, + ]), + Bytes32::new_direct([ + 69, 198, 100, 170, 106, 174, 208, 152, 152, 121, 118, 66, 111, 89, 131, 14, 159, 115, 142, + 200, 205, 173, 89, 77, 68, 234, 5, 171, 105, 248, 199, 83, + ]), + Bytes32::new_direct([ + 17, 1, 220, 13, 154, 194, 88, 60, 253, 223, 149, 35, 44, 184, 107, 141, 205, 177, 185, 32, + 22, 99, 212, 96, 194, 91, 255, 179, 121, 153, 254, 40, + ]), + Bytes32::new_direct([ + 222, 247, 186, 138, 222, 183, 135, 183, 170, 79, 182, 23, 69, 89, 70, 68, 88, 87, 235, 22, + 178, 134, 114, 220, 249, 153, 70, 71, 229, 139, 10, 190, + ]), + Bytes32::new_direct([ + 183, 77, 65, 51, 207, 78, 55, 149, 222, 3, 100, 82, 232, 230, 21, 115, 249, 177, 36, 89, + 12, 41, 70, 31, 199, 254, 213, 3, 184, 2, 85, 137, + ]), + Bytes32::new_direct([ + 82, 15, 215, 135, 95, 18, 143, 49, 239, 237, 6, 15, 213, 113, 153, 49, 149, 54, 50, 139, + 100, 192, 128, 226, 168, 9, 120, 167, 157, 42, 45, 19, + ]), + Bytes32::new_direct([ + 70, 32, 130, 243, 186, 144, 224, 217, 130, 222, 175, 221, 218, 190, 179, 222, 217, 115, 70, + 160, 141, 231, 221, 96, 2, 173, 27, 17, 158, 66, 180, 58, + ]), + Bytes32::new_direct([ + 76, 243, 65, 235, 12, 31, 48, 195, 62, 176, 202, 57, 99, 80, 237, 222, 138, 199, 124, 251, + 143, 243, 205, 226, 18, 164, 67, 64, 68, 238, 53, 71, + ]), + Bytes32::new_direct([ + 70, 52, 254, 193, 211, 92, 63, 238, 92, 2, 160, 29, 154, 25, 221, 136, 2, 49, 96, 27, 15, + 152, 238, 57, 241, 253, 32, 131, 73, 38, 229, 243, + ]), + Bytes32::new_direct([ + 214, 162, 82, 44, 146, 145, 61, 77, 36, 3, 131, 81, 217, 39, 127, 81, 66, 82, 172, 230, + 246, 3, 243, 217, 210, 38, 201, 109, 240, 143, 253, 79, + ]), + Bytes32::new_direct([ + 127, 18, 198, 116, 112, 141, 16, 39, 115, 118, 37, 208, 118, 119, 147, 46, 196, 124, 19, + 196, 34, 183, 172, 157, 18, 91, 4, 210, 77, 195, 220, 59, + ]), + Bytes32::new_direct([ + 87, 54, 42, 60, 39, 223, 84, 148, 158, 230, 70, 53, 191, 1, 108, 103, 139, 111, 58, 220, + 114, 46, 46, 110, 20, 211, 84, 1, 173, 104, 175, 191, + ]), + Bytes32::new_direct([ + 182, 147, 66, 127, 229, 144, 125, 93, 84, 220, 116, 107, 51, 13, 24, 161, 68, 172, 165, 50, + 12, 198, 229, 173, 49, 26, 114, 159, 84, 190, 6, 42, + ]), + Bytes32::new_direct([ + 183, 20, 36, 145, 76, 36, 61, 136, 224, 139, 89, 23, 124, 29, 210, 137, 1, 160, 22, 128, + 48, 242, 234, 85, 84, 24, 206, 49, 143, 185, 237, 110, + ]), + Bytes32::new_direct([ + 38, 19, 77, 150, 92, 129, 177, 155, 139, 162, 90, 91, 231, 146, 216, 21, 54, 152, 18, 5, + 98, 21, 67, 160, 154, 113, 175, 65, 214, 78, 19, 97, + ]), + Bytes32::new_direct([ + 163, 236, 47, 120, 121, 17, 217, 4, 200, 247, 206, 178, 211, 212, 163, 48, 38, 172, 111, + 123, 75, 221, 63, 117, 42, 3, 252, 233, 104, 13, 210, 203, + ]), + Bytes32::new_direct([ + 127, 106, 132, 246, 28, 129, 245, 83, 159, 109, 196, 219, 68, 81, 230, 77, 254, 166, 55, + 73, 169, 179, 93, 97, 117, 176, 53, 74, 121, 238, 184, 240, + ]), + Bytes32::new_direct([ + 255, 23, 108, 186, 145, 182, 196, 67, 163, 95, 173, 17, 67, 239, 199, 189, 145, 153, 120, + 152, 159, 126, 255, 39, 55, 178, 230, 173, 91, 165, 229, 106, + ]), + Bytes32::new_direct([ + 184, 156, 20, 114, 222, 219, 89, 218, 102, 62, 130, 200, 179, 237, 32, 237, 127, 75, 251, + 163, 160, 2, 221, 34, 166, 30, 172, 97, 115, 137, 179, 175, + ]), + Bytes32::new_direct([ + 244, 165, 127, 27, 66, 22, 38, 243, 235, 107, 30, 181, 31, 193, 210, 174, 254, 129, 39, 71, + 59, 117, 186, 37, 217, 129, 138, 23, 146, 114, 96, 78, + ]), + Bytes32::new_direct([ + 27, 57, 244, 93, 208, 90, 64, 181, 161, 110, 161, 188, 62, 180, 46, 103, 136, 233, 63, 1, + 243, 202, 236, 206, 173, 45, 45, 218, 238, 184, 83, 121, + ]), + Bytes32::new_direct([ + 138, 185, 33, 206, 120, 214, 246, 27, 100, 91, 106, 213, 60, 177, 39, 182, 149, 204, 11, + 225, 254, 5, 87, 9, 19, 186, 166, 210, 33, 67, 146, 37, + ]), + Bytes32::new_direct([ + 243, 161, 7, 52, 35, 240, 227, 144, 29, 50, 232, 3, 101, 174, 192, 139, 89, 75, 204, 245, + 173, 55, 139, 76, 126, 19, 142, 18, 230, 57, 219, 227, + ]), + Bytes32::new_direct([ + 97, 73, 36, 70, 120, 55, 49, 114, 107, 193, 66, 219, 47, 122, 201, 194, 52, 142, 12, 163, + 108, 2, 107, 58, 185, 251, 168, 146, 57, 189, 150, 134, + ]), + Bytes32::new_direct([ + 11, 215, 29, 229, 151, 208, 62, 1, 172, 253, 253, 156, 177, 31, 117, 214, 161, 192, 68, + 255, 140, 131, 66, 23, 247, 161, 107, 98, 199, 57, 123, 110, + ]), + Bytes32::new_direct([ + 41, 166, 54, 134, 242, 64, 153, 167, 5, 230, 226, 128, 71, 10, 251, 160, 19, 187, 70, 4, + 95, 98, 77, 233, 181, 24, 11, 239, 142, 152, 229, 215, + ]), + Bytes32::new_direct([ + 221, 220, 68, 168, 143, 124, 235, 77, 241, 190, 214, 6, 102, 40, 32, 245, 131, 114, 170, + 151, 134, 49, 79, 57, 242, 124, 85, 172, 83, 81, 68, 99, + ]), + Bytes32::new_direct([ + 142, 200, 102, 97, 170, 43, 14, 11, 139, 207, 150, 163, 99, 103, 2, 46, 44, 63, 109, 61, + 62, 64, 199, 104, 36, 194, 155, 232, 139, 250, 97, 224, + ]), + Bytes32::new_direct([ + 162, 15, 26, 217, 96, 195, 70, 196, 253, 70, 127, 156, 39, 120, 120, 232, 197, 154, 192, + 147, 104, 33, 104, 189, 120, 160, 36, 129, 208, 237, 128, 23, + ]), + Bytes32::new_direct([ + 42, 228, 74, 47, 20, 55, 197, 252, 173, 70, 178, 8, 2, 43, 97, 238, 155, 124, 87, 225, 217, + 6, 103, 134, 136, 235, 193, 175, 33, 228, 219, 217, + ]), + Bytes32::new_direct([ + 219, 143, 25, 70, 78, 155, 119, 63, 126, 20, 158, 54, 27, 181, 104, 184, 74, 192, 75, 157, + 42, 204, 45, 122, 25, 248, 247, 24, 225, 207, 51, 251, + ]), + Bytes32::new_direct([ + 151, 253, 36, 33, 104, 222, 126, 234, 112, 74, 59, 94, 239, 58, 36, 114, 90, 195, 208, 46, + 250, 138, 165, 200, 178, 54, 238, 154, 219, 238, 6, 183, + ]), + Bytes32::new_direct([ + 205, 57, 187, 174, 221, 9, 164, 77, 76, 143, 54, 212, 115, 196, 67, 182, 200, 147, 78, 194, + 245, 92, 173, 114, 180, 160, 168, 5, 200, 82, 217, 64, + ]), + Bytes32::new_direct([ + 211, 104, 62, 114, 157, 56, 254, 26, 32, 168, 208, 248, 62, 195, 142, 68, 53, 13, 7, 36, + 216, 5, 127, 153, 97, 88, 222, 206, 91, 42, 14, 114, + ]), + Bytes32::new_direct([ + 203, 158, 225, 200, 62, 223, 202, 52, 207, 179, 250, 236, 29, 144, 181, 31, 87, 192, 203, + 66, 56, 39, 123, 25, 123, 157, 196, 161, 34, 245, 22, 130, + ]), + Bytes32::new_direct([ + 147, 247, 233, 96, 190, 104, 227, 251, 99, 2, 16, 8, 77, 119, 1, 97, 243, 78, 103, 46, 24, + 228, 217, 65, 219, 238, 135, 18, 164, 219, 132, 39, + ]), + Bytes32::new_direct([ + 239, 153, 72, 139, 52, 60, 171, 44, 72, 218, 138, 124, 45, 30, 143, 122, 147, 158, 12, 62, + 213, 151, 217, 217, 212, 51, 110, 75, 122, 67, 134, 80, + ]), + Bytes32::new_direct([ + 46, 47, 130, 237, 178, 232, 239, 217, 165, 114, 255, 202, 132, 214, 18, 8, 72, 8, 255, 0, + 162, 82, 5, 228, 141, 201, 70, 135, 255, 21, 220, 3, + ]), + Bytes32::new_direct([ + 21, 11, 196, 5, 215, 241, 194, 200, 198, 129, 133, 244, 204, 47, 131, 70, 138, 38, 107, 39, + 211, 243, 72, 72, 34, 145, 35, 42, 14, 69, 218, 227, + ]), + Bytes32::new_direct([ + 73, 103, 117, 195, 67, 126, 242, 57, 232, 74, 142, 64, 169, 248, 113, 69, 110, 103, 127, + 185, 177, 51, 212, 178, 48, 183, 247, 44, 246, 69, 35, 208, + ]), + Bytes32::new_direct([ + 125, 8, 83, 22, 215, 82, 179, 234, 169, 227, 213, 39, 170, 164, 195, 187, 63, 38, 59, 146, + 144, 101, 38, 0, 110, 212, 202, 20, 245, 105, 187, 201, + ]), + Bytes32::new_direct([ + 186, 231, 186, 148, 68, 208, 226, 170, 120, 80, 68, 79, 23, 41, 51, 205, 240, 201, 10, 16, + 24, 38, 137, 151, 7, 102, 92, 244, 3, 194, 228, 229, + ]), + Bytes32::new_direct([ + 46, 8, 51, 150, 63, 114, 126, 210, 30, 130, 76, 142, 13, 149, 14, 0, 205, 199, 48, 90, 86, + 75, 151, 135, 164, 224, 129, 77, 174, 194, 212, 112, + ]), + Bytes32::new_direct([ + 150, 239, 42, 111, 3, 112, 25, 168, 179, 36, 106, 73, 212, 188, 215, 79, 180, 142, 191, 29, + 219, 12, 244, 74, 254, 205, 160, 54, 68, 144, 81, 207, + ]), + Bytes32::new_direct([ + 23, 164, 189, 201, 250, 65, 212, 148, 132, 125, 94, 209, 115, 123, 29, 66, 3, 172, 57, 58, + 46, 191, 96, 7, 212, 25, 226, 79, 120, 68, 202, 210, + ]), + Bytes32::new_direct([ + 252, 13, 137, 225, 208, 6, 84, 75, 97, 32, 177, 156, 248, 191, 113, 97, 254, 122, 86, 194, + 3, 103, 219, 74, 227, 160, 231, 202, 13, 126, 46, 255, + ]), + Bytes32::new_direct([ + 70, 35, 27, 128, 17, 79, 226, 131, 144, 118, 248, 125, 188, 110, 20, 15, 255, 73, 205, 69, + 0, 227, 26, 66, 39, 61, 191, 224, 239, 234, 83, 170, + ]), + Bytes32::new_direct([ + 129, 52, 148, 121, 230, 84, 28, 112, 75, 68, 181, 197, 80, 227, 107, 22, 60, 118, 81, 209, + 198, 125, 233, 190, 84, 189, 18, 25, 72, 143, 2, 190, + ]), + Bytes32::new_direct([ + 244, 237, 81, 131, 251, 35, 56, 158, 229, 102, 150, 122, 213, 206, 119, 38, 54, 238, 158, + 159, 1, 214, 31, 147, 245, 9, 172, 247, 156, 115, 209, 140, + ]), + Bytes32::new_direct([ + 47, 5, 174, 62, 80, 172, 77, 111, 136, 114, 188, 85, 249, 157, 182, 175, 187, 207, 29, 43, + 152, 88, 130, 156, 138, 30, 188, 51, 82, 105, 145, 161, + ]), + Bytes32::new_direct([ + 102, 2, 197, 195, 206, 149, 53, 224, 61, 219, 163, 246, 208, 218, 140, 47, 16, 42, 196, 20, + 145, 158, 101, 31, 225, 135, 49, 68, 95, 5, 228, 92, + ]), + Bytes32::new_direct([ + 78, 136, 176, 216, 253, 15, 136, 48, 162, 5, 57, 120, 93, 222, 179, 174, 129, 40, 8, 63, + 18, 102, 97, 41, 58, 214, 1, 52, 58, 126, 186, 146, + ]), + Bytes32::new_direct([ + 145, 56, 231, 59, 247, 191, 104, 137, 240, 113, 32, 245, 235, 129, 255, 54, 99, 176, 109, + 175, 107, 232, 201, 235, 95, 104, 54, 67, 252, 184, 200, 54, + ]), + Bytes32::new_direct([ + 181, 3, 229, 152, 113, 182, 55, 93, 138, 137, 21, 67, 27, 204, 96, 69, 72, 247, 237, 216, + 28, 36, 115, 185, 111, 149, 224, 69, 66, 121, 188, 228, + ]), + Bytes32::new_direct([ + 212, 25, 201, 68, 187, 25, 10, 96, 40, 88, 100, 216, 145, 200, 26, 203, 220, 14, 14, 11, + 190, 62, 143, 137, 53, 208, 233, 158, 37, 34, 8, 15, + ]), + Bytes32::new_direct([ + 80, 101, 192, 136, 203, 90, 189, 204, 181, 36, 28, 107, 220, 69, 119, 99, 145, 227, 198, + 55, 37, 237, 212, 114, 31, 27, 19, 90, 231, 143, 87, 149, + ]), + Bytes32::new_direct([ + 248, 97, 168, 33, 15, 230, 128, 82, 157, 26, 186, 89, 200, 7, 101, 210, 117, 111, 75, 233, + 244, 187, 1, 180, 30, 220, 15, 21, 203, 5, 243, 223, + ]), ]; const MEMORY_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::new_direct([66, 208, 130, 169, 194, 116, 5, 27, 68, 75, 235, 175, 164, 169, 41, 91, 88, 134, 51, 194, 219, 201, 182, 199, 1, 52, 173, 215, 20, 37, 51, 0]), - Bytes32::new_direct([90, 210, 50, 227, 58, 173, 147, 92, 139, 15, 127, 190, 196, 111, 142, 207, 31, 223, 70, 96, 17, 251, 164, 200, 133, 0, 76, 35, 200, 9, 51, 218]), - Bytes32::new_direct([97, 5, 162, 226, 92, 108, 172, 8, 7, 65, 104, 176, 216, 3, 144, 47, 14, 88, 50, 101, 194, 94, 10, 132, 192, 76, 37, 152, 42, 73, 30, 2]), - Bytes32::new_direct([68, 59, 208, 14, 89, 37, 33, 1, 177, 225, 235, 66, 129, 28, 103, 156, 46, 206, 94, 141, 33, 152, 141, 26, 209, 161, 53, 237, 198, 163, 115, 57]), - Bytes32::new_direct([28, 94, 12, 53, 70, 163, 95, 44, 168, 42, 196, 126, 181, 231, 174, 247, 89, 100, 77, 238, 211, 74, 116, 144, 183, 111, 254, 75, 30, 187, 228, 222]), - Bytes32::new_direct([238, 133, 50, 189, 14, 89, 244, 88, 239, 50, 172, 85, 172, 1, 131, 2, 24, 161, 70, 94, 0, 204, 50, 199, 48, 107, 30, 70, 6, 8, 18, 90]), - Bytes32::new_direct([165, 239, 71, 173, 192, 165, 25, 35, 4, 130, 148, 158, 177, 193, 129, 45, 115, 209, 7, 233, 136, 108, 245, 126, 74, 200, 22, 204, 190, 137, 191, 105]), - Bytes32::new_direct([173, 102, 127, 73, 167, 249, 117, 26, 190, 231, 26, 60, 201, 138, 160, 182, 180, 44, 34, 132, 171, 254, 91, 8, 167, 114, 188, 157, 181, 148, 169, 165]), - Bytes32::new_direct([71, 62, 70, 89, 203, 1, 105, 187, 178, 167, 217, 118, 42, 217, 154, 234, 238, 109, 145, 231, 247, 199, 40, 110, 162, 11, 173, 144, 103, 110, 99, 101]), - Bytes32::new_direct([121, 36, 94, 4, 25, 134, 16, 98, 198, 109, 123, 42, 56, 151, 224, 7, 232, 155, 231, 154, 229, 162, 250, 149, 231, 198, 0, 65, 17, 27, 181, 28]), - Bytes32::new_direct([247, 158, 162, 102, 242, 117, 166, 252, 175, 158, 107, 157, 244, 44, 17, 99, 93, 52, 43, 136, 5, 211, 32, 152, 91, 148, 41, 32, 231, 18, 237, 208]), - Bytes32::new_direct([147, 52, 155, 255, 81, 242, 75, 54, 54, 66, 166, 41, 131, 177, 183, 151, 229, 177, 232, 86, 146, 137, 106, 68, 226, 117, 20, 210, 224, 170, 249, 68]), - Bytes32::new_direct([160, 89, 180, 156, 119, 172, 38, 10, 97, 101, 64, 56, 98, 133, 199, 228, 58, 66, 139, 128, 88, 140, 143, 85, 148, 167, 79, 75, 34, 45, 204, 68]), - Bytes32::new_direct([165, 233, 117, 3, 27, 56, 166, 16, 56, 132, 198, 32, 11, 149, 212, 98, 64, 236, 180, 106, 174, 80, 122, 220, 102, 67, 67, 110, 67, 8, 48, 217]), - Bytes32::new_direct([113, 74, 209, 139, 250, 181, 182, 127, 178, 77, 17, 63, 79, 109, 145, 74, 52, 102, 125, 154, 22, 241, 177, 177, 34, 189, 124, 22, 4, 200, 201, 76]), - Bytes32::new_direct([67, 7, 240, 151, 128, 149, 238, 113, 130, 127, 174, 223, 142, 124, 230, 10, 91, 89, 113, 157, 230, 21, 213, 3, 146, 249, 26, 80, 239, 90, 4, 216]), - Bytes32::new_direct([152, 20, 80, 244, 232, 182, 1, 145, 31, 191, 46, 207, 83, 199, 209, 104, 0, 75, 106, 230, 16, 98, 121, 127, 175, 78, 119, 154, 69, 55, 66, 169]), - Bytes32::new_direct([123, 50, 162, 158, 51, 112, 129, 232, 242, 158, 150, 72, 244, 40, 191, 63, 205, 61, 144, 39, 65, 122, 28, 88, 253, 146, 29, 29, 15, 40, 122, 95]), - Bytes32::new_direct([231, 253, 202, 45, 165, 158, 212, 29, 104, 165, 209, 179, 188, 154, 89, 18, 216, 23, 140, 66, 150, 49, 99, 200, 163, 155, 50, 9, 250, 22, 19, 203]), - Bytes32::new_direct([127, 172, 110, 243, 156, 134, 199, 15, 248, 216, 12, 196, 221, 66, 202, 186, 105, 197, 43, 245, 46, 116, 251, 133, 111, 118, 56, 214, 157, 244, 187, 58]), - Bytes32::new_direct([181, 181, 163, 95, 7, 188, 245, 128, 161, 210, 137, 217, 103, 101, 120, 255, 47, 83, 102, 68, 238, 195, 206, 105, 24, 150, 216, 50, 74, 6, 94, 95]), - Bytes32::new_direct([171, 250, 198, 40, 153, 26, 240, 152, 96, 169, 15, 123, 33, 155, 57, 172, 89, 205, 9, 65, 45, 126, 155, 143, 224, 145, 25, 214, 19, 227, 213, 195]), - Bytes32::new_direct([44, 177, 244, 220, 119, 33, 203, 59, 209, 72, 28, 4, 210, 54, 86, 20, 119, 41, 45, 231, 143, 104, 57, 206, 212, 222, 81, 62, 92, 221, 200, 32]), - Bytes32::new_direct([37, 200, 165, 195, 67, 224, 131, 227, 97, 54, 21, 233, 76, 186, 6, 122, 178, 131, 252, 59, 97, 218, 239, 62, 124, 255, 201, 178, 241, 236, 4, 214]), - Bytes32::new_direct([77, 171, 229, 183, 46, 112, 203, 177, 89, 90, 64, 114, 109, 220, 32, 120, 41, 223, 72, 86, 59, 211, 110, 17, 129, 112, 194, 186, 200, 92, 144, 49]), - Bytes32::new_direct([2, 198, 61, 112, 181, 185, 194, 114, 149, 63, 65, 76, 55, 179, 170, 62, 91, 112, 189, 100, 13, 34, 98, 187, 85, 132, 202, 86, 47, 27, 236, 200]), - Bytes32::new_direct([164, 238, 109, 209, 155, 118, 236, 237, 84, 43, 56, 99, 51, 60, 116, 235, 100, 39, 163, 105, 34, 93, 8, 187, 228, 213, 35, 200, 43, 8, 32, 68]), - Bytes32::new_direct([32, 220, 39, 200, 214, 245, 102, 200, 167, 204, 3, 54, 140, 126, 129, 35, 139, 60, 112, 133, 52, 166, 162, 63, 119, 20, 2, 116, 132, 244, 246, 225]), - Bytes32::new_direct([5, 54, 145, 188, 188, 251, 36, 4, 103, 140, 229, 143, 83, 11, 77, 207, 57, 125, 51, 127, 89, 130, 138, 193, 190, 17, 17, 23, 68, 168, 231, 106]), - Bytes32::new_direct([239, 112, 72, 74, 116, 134, 210, 24, 226, 242, 91, 113, 99, 59, 19, 7, 226, 215, 254, 220, 14, 225, 75, 245, 11, 234, 138, 52, 195, 86, 79, 124]), - Bytes32::new_direct([187, 35, 132, 188, 162, 128, 96, 71, 124, 213, 251, 229, 73, 52, 187, 22, 166, 35, 214, 14, 121, 189, 37, 5, 77, 54, 201, 51, 95, 179, 75, 229]), - Bytes32::new_direct([5, 54, 88, 42, 68, 200, 45, 209, 121, 70, 128, 8, 178, 212, 197, 39, 101, 90, 101, 111, 77, 133, 13, 77, 19, 111, 113, 122, 222, 85, 180, 82]), - Bytes32::new_direct([34, 182, 144, 13, 35, 35, 79, 14, 239, 80, 21, 255, 67, 48, 210, 174, 159, 182, 239, 236, 68, 46, 125, 105, 243, 202, 218, 64, 53, 94, 159, 253]), - Bytes32::new_direct([224, 189, 145, 186, 43, 169, 131, 161, 223, 161, 72, 72, 229, 97, 113, 233, 2, 250, 109, 31, 19, 125, 57, 135, 144, 3, 187, 18, 102, 108, 232, 9]), - Bytes32::new_direct([68, 94, 11, 104, 95, 110, 179, 226, 157, 245, 113, 68, 44, 122, 17, 22, 244, 35, 248, 126, 131, 192, 20, 169, 129, 236, 60, 54, 157, 30, 231, 36]), - Bytes32::new_direct([101, 198, 107, 156, 226, 8, 67, 168, 197, 91, 189, 166, 187, 16, 121, 93, 114, 243, 137, 162, 125, 142, 50, 206, 160, 168, 165, 27, 207, 10, 22, 19]), - Bytes32::new_direct([222, 29, 134, 137, 98, 73, 58, 143, 166, 134, 210, 47, 68, 23, 214, 237, 241, 207, 226, 83, 113, 222, 184, 139, 16, 1, 200, 56, 34, 208, 197, 152]), - Bytes32::new_direct([107, 200, 189, 222, 185, 32, 192, 130, 237, 238, 168, 137, 14, 94, 3, 26, 41, 238, 19, 119, 207, 158, 25, 177, 116, 70, 170, 161, 141, 129, 16, 88]), - Bytes32::new_direct([131, 243, 131, 161, 236, 101, 108, 81, 59, 123, 150, 6, 250, 124, 103, 101, 75, 234, 98, 223, 129, 87, 202, 59, 184, 173, 44, 191, 200, 30, 223, 66]), - Bytes32::new_direct([17, 226, 72, 31, 180, 33, 229, 83, 154, 39, 104, 45, 93, 117, 153, 249, 216, 127, 120, 182, 4, 19, 169, 87, 127, 70, 7, 237, 80, 251, 220, 126]), - Bytes32::new_direct([88, 122, 134, 181, 173, 175, 100, 74, 28, 141, 45, 215, 245, 170, 222, 54, 106, 118, 146, 59, 207, 251, 133, 155, 164, 75, 240, 208, 10, 185, 187, 163]), - Bytes32::new_direct([214, 1, 209, 99, 53, 101, 233, 225, 55, 171, 69, 200, 44, 144, 169, 11, 65, 85, 84, 158, 233, 227, 37, 59, 42, 52, 153, 13, 0, 158, 122, 208]), - Bytes32::new_direct([124, 146, 1, 221, 33, 138, 233, 130, 184, 163, 121, 110, 95, 242, 123, 251, 110, 46, 41, 197, 75, 145, 121, 95, 29, 1, 19, 19, 167, 220, 177, 153]), - Bytes32::new_direct([77, 38, 54, 170, 19, 128, 180, 248, 208, 75, 27, 53, 228, 104, 7, 216, 188, 186, 40, 84, 87, 11, 121, 3, 175, 89, 49, 46, 191, 94, 80, 97]), - Bytes32::new_direct([134, 127, 37, 206, 212, 70, 146, 143, 81, 104, 140, 28, 135, 233, 171, 88, 18, 2, 148, 143, 111, 208, 149, 138, 167, 84, 183, 100, 67, 181, 243, 135]), - Bytes32::new_direct([218, 16, 220, 189, 192, 237, 252, 168, 45, 33, 177, 81, 53, 115, 141, 190, 99, 138, 113, 85, 60, 230, 244, 222, 205, 16, 152, 26, 185, 207, 114, 143]), - Bytes32::new_direct([9, 85, 193, 163, 186, 152, 83, 149, 29, 71, 50, 13, 175, 149, 184, 51, 246, 97, 20, 22, 57, 201, 27, 72, 146, 19, 213, 102, 164, 148, 176, 45]), - Bytes32::new_direct([140, 94, 218, 31, 232, 0, 167, 218, 122, 119, 62, 179, 181, 51, 100, 6, 150, 159, 212, 207, 160, 94, 212, 108, 225, 196, 190, 210, 145, 110, 120, 114]), - Bytes32::new_direct([152, 169, 229, 240, 162, 212, 61, 59, 167, 135, 124, 147, 212, 248, 177, 85, 243, 72, 150, 127, 122, 60, 143, 125, 226, 186, 67, 219, 50, 112, 242, 212]), - Bytes32::new_direct([47, 244, 81, 140, 243, 189, 116, 0, 2, 158, 242, 188, 215, 90, 177, 37, 175, 221, 80, 226, 209, 79, 2, 62, 112, 245, 1, 132, 7, 78, 0, 117]), - Bytes32::new_direct([247, 236, 252, 118, 6, 245, 132, 187, 48, 36, 77, 0, 167, 150, 109, 72, 234, 9, 224, 162, 223, 191, 21, 19, 180, 201, 138, 56, 109, 97, 152, 170]), - Bytes32::new_direct([77, 23, 112, 52, 78, 204, 135, 173, 2, 206, 148, 200, 60, 155, 60, 179, 201, 111, 73, 138, 76, 104, 79, 174, 190, 173, 42, 51, 38, 48, 237, 241]), - Bytes32::new_direct([117, 234, 73, 183, 4, 144, 12, 196, 78, 228, 178, 218, 206, 147, 147, 94, 190, 22, 22, 233, 88, 118, 135, 55, 63, 29, 212, 38, 223, 160, 121, 230]), - Bytes32::new_direct([74, 138, 173, 10, 77, 129, 10, 115, 18, 90, 57, 215, 221, 171, 109, 152, 31, 219, 235, 122, 189, 201, 210, 186, 52, 200, 81, 218, 112, 79, 80, 54]), - Bytes32::new_direct([189, 150, 224, 30, 110, 73, 249, 62, 100, 244, 206, 110, 206, 239, 233, 213, 61, 213, 65, 139, 103, 19, 20, 123, 167, 65, 161, 165, 216, 217, 255, 248]), - Bytes32::new_direct([119, 71, 56, 219, 155, 139, 253, 40, 100, 132, 185, 98, 24, 34, 156, 225, 120, 176, 76, 147, 31, 105, 245, 216, 165, 161, 89, 157, 246, 17, 251, 234]), - Bytes32::new_direct([192, 39, 162, 126, 222, 211, 173, 195, 198, 124, 1, 124, 140, 2, 252, 191, 185, 85, 10, 125, 226, 7, 88, 221, 164, 13, 221, 74, 200, 7, 249, 177]), - Bytes32::new_direct([251, 226, 24, 5, 54, 89, 9, 93, 217, 202, 148, 172, 208, 197, 65, 172, 98, 96, 58, 194, 61, 253, 157, 193, 135, 32, 206, 97, 133, 234, 199, 197]), - Bytes32::new_direct([130, 3, 195, 156, 210, 123, 23, 44, 223, 25, 153, 169, 250, 88, 127, 239, 206, 196, 156, 143, 182, 185, 35, 77, 162, 48, 143, 64, 231, 129, 216, 185]), - Bytes32::new_direct([123, 201, 97, 230, 121, 13, 207, 138, 137, 3, 122, 92, 105, 155, 214, 204, 142, 18, 119, 138, 135, 165, 249, 58, 184, 53, 27, 31, 109, 214, 176, 147]), - Bytes32::new_direct([46, 71, 246, 155, 247, 109, 236, 225, 147, 51, 250, 72, 97, 116, 162, 36, 115, 164, 80, 28, 252, 238, 98, 92, 16, 66, 190, 208, 180, 39, 179, 211]), - Bytes32::new_direct([38, 76, 13, 227, 149, 18, 84, 170, 83, 231, 122, 59, 237, 66, 32, 171, 158, 251, 78, 156, 186, 160, 29, 30, 207, 178, 16, 193, 221, 158, 49, 48]), - Bytes32::new_direct([166, 13, 210, 208, 250, 131, 27, 163, 99, 204, 199, 134, 152, 131, 28, 164, 8, 222, 176, 200, 34, 40, 74, 188, 120, 46, 167, 44, 95, 199, 86, 225]), + Bytes32::new_direct([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ]), + Bytes32::new_direct([ + 66, 208, 130, 169, 194, 116, 5, 27, 68, 75, 235, 175, 164, 169, 41, 91, 88, 134, 51, 194, + 219, 201, 182, 199, 1, 52, 173, 215, 20, 37, 51, 0, + ]), + Bytes32::new_direct([ + 90, 210, 50, 227, 58, 173, 147, 92, 139, 15, 127, 190, 196, 111, 142, 207, 31, 223, 70, 96, + 17, 251, 164, 200, 133, 0, 76, 35, 200, 9, 51, 218, + ]), + Bytes32::new_direct([ + 97, 5, 162, 226, 92, 108, 172, 8, 7, 65, 104, 176, 216, 3, 144, 47, 14, 88, 50, 101, 194, + 94, 10, 132, 192, 76, 37, 152, 42, 73, 30, 2, + ]), + Bytes32::new_direct([ + 68, 59, 208, 14, 89, 37, 33, 1, 177, 225, 235, 66, 129, 28, 103, 156, 46, 206, 94, 141, 33, + 152, 141, 26, 209, 161, 53, 237, 198, 163, 115, 57, + ]), + Bytes32::new_direct([ + 28, 94, 12, 53, 70, 163, 95, 44, 168, 42, 196, 126, 181, 231, 174, 247, 89, 100, 77, 238, + 211, 74, 116, 144, 183, 111, 254, 75, 30, 187, 228, 222, + ]), + Bytes32::new_direct([ + 238, 133, 50, 189, 14, 89, 244, 88, 239, 50, 172, 85, 172, 1, 131, 2, 24, 161, 70, 94, 0, + 204, 50, 199, 48, 107, 30, 70, 6, 8, 18, 90, + ]), + Bytes32::new_direct([ + 165, 239, 71, 173, 192, 165, 25, 35, 4, 130, 148, 158, 177, 193, 129, 45, 115, 209, 7, 233, + 136, 108, 245, 126, 74, 200, 22, 204, 190, 137, 191, 105, + ]), + Bytes32::new_direct([ + 173, 102, 127, 73, 167, 249, 117, 26, 190, 231, 26, 60, 201, 138, 160, 182, 180, 44, 34, + 132, 171, 254, 91, 8, 167, 114, 188, 157, 181, 148, 169, 165, + ]), + Bytes32::new_direct([ + 71, 62, 70, 89, 203, 1, 105, 187, 178, 167, 217, 118, 42, 217, 154, 234, 238, 109, 145, + 231, 247, 199, 40, 110, 162, 11, 173, 144, 103, 110, 99, 101, + ]), + Bytes32::new_direct([ + 121, 36, 94, 4, 25, 134, 16, 98, 198, 109, 123, 42, 56, 151, 224, 7, 232, 155, 231, 154, + 229, 162, 250, 149, 231, 198, 0, 65, 17, 27, 181, 28, + ]), + Bytes32::new_direct([ + 247, 158, 162, 102, 242, 117, 166, 252, 175, 158, 107, 157, 244, 44, 17, 99, 93, 52, 43, + 136, 5, 211, 32, 152, 91, 148, 41, 32, 231, 18, 237, 208, + ]), + Bytes32::new_direct([ + 147, 52, 155, 255, 81, 242, 75, 54, 54, 66, 166, 41, 131, 177, 183, 151, 229, 177, 232, 86, + 146, 137, 106, 68, 226, 117, 20, 210, 224, 170, 249, 68, + ]), + Bytes32::new_direct([ + 160, 89, 180, 156, 119, 172, 38, 10, 97, 101, 64, 56, 98, 133, 199, 228, 58, 66, 139, 128, + 88, 140, 143, 85, 148, 167, 79, 75, 34, 45, 204, 68, + ]), + Bytes32::new_direct([ + 165, 233, 117, 3, 27, 56, 166, 16, 56, 132, 198, 32, 11, 149, 212, 98, 64, 236, 180, 106, + 174, 80, 122, 220, 102, 67, 67, 110, 67, 8, 48, 217, + ]), + Bytes32::new_direct([ + 113, 74, 209, 139, 250, 181, 182, 127, 178, 77, 17, 63, 79, 109, 145, 74, 52, 102, 125, + 154, 22, 241, 177, 177, 34, 189, 124, 22, 4, 200, 201, 76, + ]), + Bytes32::new_direct([ + 67, 7, 240, 151, 128, 149, 238, 113, 130, 127, 174, 223, 142, 124, 230, 10, 91, 89, 113, + 157, 230, 21, 213, 3, 146, 249, 26, 80, 239, 90, 4, 216, + ]), + Bytes32::new_direct([ + 152, 20, 80, 244, 232, 182, 1, 145, 31, 191, 46, 207, 83, 199, 209, 104, 0, 75, 106, 230, + 16, 98, 121, 127, 175, 78, 119, 154, 69, 55, 66, 169, + ]), + Bytes32::new_direct([ + 123, 50, 162, 158, 51, 112, 129, 232, 242, 158, 150, 72, 244, 40, 191, 63, 205, 61, 144, + 39, 65, 122, 28, 88, 253, 146, 29, 29, 15, 40, 122, 95, + ]), + Bytes32::new_direct([ + 231, 253, 202, 45, 165, 158, 212, 29, 104, 165, 209, 179, 188, 154, 89, 18, 216, 23, 140, + 66, 150, 49, 99, 200, 163, 155, 50, 9, 250, 22, 19, 203, + ]), + Bytes32::new_direct([ + 127, 172, 110, 243, 156, 134, 199, 15, 248, 216, 12, 196, 221, 66, 202, 186, 105, 197, 43, + 245, 46, 116, 251, 133, 111, 118, 56, 214, 157, 244, 187, 58, + ]), + Bytes32::new_direct([ + 181, 181, 163, 95, 7, 188, 245, 128, 161, 210, 137, 217, 103, 101, 120, 255, 47, 83, 102, + 68, 238, 195, 206, 105, 24, 150, 216, 50, 74, 6, 94, 95, + ]), + Bytes32::new_direct([ + 171, 250, 198, 40, 153, 26, 240, 152, 96, 169, 15, 123, 33, 155, 57, 172, 89, 205, 9, 65, + 45, 126, 155, 143, 224, 145, 25, 214, 19, 227, 213, 195, + ]), + Bytes32::new_direct([ + 44, 177, 244, 220, 119, 33, 203, 59, 209, 72, 28, 4, 210, 54, 86, 20, 119, 41, 45, 231, + 143, 104, 57, 206, 212, 222, 81, 62, 92, 221, 200, 32, + ]), + Bytes32::new_direct([ + 37, 200, 165, 195, 67, 224, 131, 227, 97, 54, 21, 233, 76, 186, 6, 122, 178, 131, 252, 59, + 97, 218, 239, 62, 124, 255, 201, 178, 241, 236, 4, 214, + ]), + Bytes32::new_direct([ + 77, 171, 229, 183, 46, 112, 203, 177, 89, 90, 64, 114, 109, 220, 32, 120, 41, 223, 72, 86, + 59, 211, 110, 17, 129, 112, 194, 186, 200, 92, 144, 49, + ]), + Bytes32::new_direct([ + 2, 198, 61, 112, 181, 185, 194, 114, 149, 63, 65, 76, 55, 179, 170, 62, 91, 112, 189, 100, + 13, 34, 98, 187, 85, 132, 202, 86, 47, 27, 236, 200, + ]), + Bytes32::new_direct([ + 164, 238, 109, 209, 155, 118, 236, 237, 84, 43, 56, 99, 51, 60, 116, 235, 100, 39, 163, + 105, 34, 93, 8, 187, 228, 213, 35, 200, 43, 8, 32, 68, + ]), + Bytes32::new_direct([ + 32, 220, 39, 200, 214, 245, 102, 200, 167, 204, 3, 54, 140, 126, 129, 35, 139, 60, 112, + 133, 52, 166, 162, 63, 119, 20, 2, 116, 132, 244, 246, 225, + ]), + Bytes32::new_direct([ + 5, 54, 145, 188, 188, 251, 36, 4, 103, 140, 229, 143, 83, 11, 77, 207, 57, 125, 51, 127, + 89, 130, 138, 193, 190, 17, 17, 23, 68, 168, 231, 106, + ]), + Bytes32::new_direct([ + 239, 112, 72, 74, 116, 134, 210, 24, 226, 242, 91, 113, 99, 59, 19, 7, 226, 215, 254, 220, + 14, 225, 75, 245, 11, 234, 138, 52, 195, 86, 79, 124, + ]), + Bytes32::new_direct([ + 187, 35, 132, 188, 162, 128, 96, 71, 124, 213, 251, 229, 73, 52, 187, 22, 166, 35, 214, 14, + 121, 189, 37, 5, 77, 54, 201, 51, 95, 179, 75, 229, + ]), + Bytes32::new_direct([ + 5, 54, 88, 42, 68, 200, 45, 209, 121, 70, 128, 8, 178, 212, 197, 39, 101, 90, 101, 111, 77, + 133, 13, 77, 19, 111, 113, 122, 222, 85, 180, 82, + ]), + Bytes32::new_direct([ + 34, 182, 144, 13, 35, 35, 79, 14, 239, 80, 21, 255, 67, 48, 210, 174, 159, 182, 239, 236, + 68, 46, 125, 105, 243, 202, 218, 64, 53, 94, 159, 253, + ]), + Bytes32::new_direct([ + 224, 189, 145, 186, 43, 169, 131, 161, 223, 161, 72, 72, 229, 97, 113, 233, 2, 250, 109, + 31, 19, 125, 57, 135, 144, 3, 187, 18, 102, 108, 232, 9, + ]), + Bytes32::new_direct([ + 68, 94, 11, 104, 95, 110, 179, 226, 157, 245, 113, 68, 44, 122, 17, 22, 244, 35, 248, 126, + 131, 192, 20, 169, 129, 236, 60, 54, 157, 30, 231, 36, + ]), + Bytes32::new_direct([ + 101, 198, 107, 156, 226, 8, 67, 168, 197, 91, 189, 166, 187, 16, 121, 93, 114, 243, 137, + 162, 125, 142, 50, 206, 160, 168, 165, 27, 207, 10, 22, 19, + ]), + Bytes32::new_direct([ + 222, 29, 134, 137, 98, 73, 58, 143, 166, 134, 210, 47, 68, 23, 214, 237, 241, 207, 226, 83, + 113, 222, 184, 139, 16, 1, 200, 56, 34, 208, 197, 152, + ]), + Bytes32::new_direct([ + 107, 200, 189, 222, 185, 32, 192, 130, 237, 238, 168, 137, 14, 94, 3, 26, 41, 238, 19, 119, + 207, 158, 25, 177, 116, 70, 170, 161, 141, 129, 16, 88, + ]), + Bytes32::new_direct([ + 131, 243, 131, 161, 236, 101, 108, 81, 59, 123, 150, 6, 250, 124, 103, 101, 75, 234, 98, + 223, 129, 87, 202, 59, 184, 173, 44, 191, 200, 30, 223, 66, + ]), + Bytes32::new_direct([ + 17, 226, 72, 31, 180, 33, 229, 83, 154, 39, 104, 45, 93, 117, 153, 249, 216, 127, 120, 182, + 4, 19, 169, 87, 127, 70, 7, 237, 80, 251, 220, 126, + ]), + Bytes32::new_direct([ + 88, 122, 134, 181, 173, 175, 100, 74, 28, 141, 45, 215, 245, 170, 222, 54, 106, 118, 146, + 59, 207, 251, 133, 155, 164, 75, 240, 208, 10, 185, 187, 163, + ]), + Bytes32::new_direct([ + 214, 1, 209, 99, 53, 101, 233, 225, 55, 171, 69, 200, 44, 144, 169, 11, 65, 85, 84, 158, + 233, 227, 37, 59, 42, 52, 153, 13, 0, 158, 122, 208, + ]), + Bytes32::new_direct([ + 124, 146, 1, 221, 33, 138, 233, 130, 184, 163, 121, 110, 95, 242, 123, 251, 110, 46, 41, + 197, 75, 145, 121, 95, 29, 1, 19, 19, 167, 220, 177, 153, + ]), + Bytes32::new_direct([ + 77, 38, 54, 170, 19, 128, 180, 248, 208, 75, 27, 53, 228, 104, 7, 216, 188, 186, 40, 84, + 87, 11, 121, 3, 175, 89, 49, 46, 191, 94, 80, 97, + ]), + Bytes32::new_direct([ + 134, 127, 37, 206, 212, 70, 146, 143, 81, 104, 140, 28, 135, 233, 171, 88, 18, 2, 148, 143, + 111, 208, 149, 138, 167, 84, 183, 100, 67, 181, 243, 135, + ]), + Bytes32::new_direct([ + 218, 16, 220, 189, 192, 237, 252, 168, 45, 33, 177, 81, 53, 115, 141, 190, 99, 138, 113, + 85, 60, 230, 244, 222, 205, 16, 152, 26, 185, 207, 114, 143, + ]), + Bytes32::new_direct([ + 9, 85, 193, 163, 186, 152, 83, 149, 29, 71, 50, 13, 175, 149, 184, 51, 246, 97, 20, 22, 57, + 201, 27, 72, 146, 19, 213, 102, 164, 148, 176, 45, + ]), + Bytes32::new_direct([ + 140, 94, 218, 31, 232, 0, 167, 218, 122, 119, 62, 179, 181, 51, 100, 6, 150, 159, 212, 207, + 160, 94, 212, 108, 225, 196, 190, 210, 145, 110, 120, 114, + ]), + Bytes32::new_direct([ + 152, 169, 229, 240, 162, 212, 61, 59, 167, 135, 124, 147, 212, 248, 177, 85, 243, 72, 150, + 127, 122, 60, 143, 125, 226, 186, 67, 219, 50, 112, 242, 212, + ]), + Bytes32::new_direct([ + 47, 244, 81, 140, 243, 189, 116, 0, 2, 158, 242, 188, 215, 90, 177, 37, 175, 221, 80, 226, + 209, 79, 2, 62, 112, 245, 1, 132, 7, 78, 0, 117, + ]), + Bytes32::new_direct([ + 247, 236, 252, 118, 6, 245, 132, 187, 48, 36, 77, 0, 167, 150, 109, 72, 234, 9, 224, 162, + 223, 191, 21, 19, 180, 201, 138, 56, 109, 97, 152, 170, + ]), + Bytes32::new_direct([ + 77, 23, 112, 52, 78, 204, 135, 173, 2, 206, 148, 200, 60, 155, 60, 179, 201, 111, 73, 138, + 76, 104, 79, 174, 190, 173, 42, 51, 38, 48, 237, 241, + ]), + Bytes32::new_direct([ + 117, 234, 73, 183, 4, 144, 12, 196, 78, 228, 178, 218, 206, 147, 147, 94, 190, 22, 22, 233, + 88, 118, 135, 55, 63, 29, 212, 38, 223, 160, 121, 230, + ]), + Bytes32::new_direct([ + 74, 138, 173, 10, 77, 129, 10, 115, 18, 90, 57, 215, 221, 171, 109, 152, 31, 219, 235, 122, + 189, 201, 210, 186, 52, 200, 81, 218, 112, 79, 80, 54, + ]), + Bytes32::new_direct([ + 189, 150, 224, 30, 110, 73, 249, 62, 100, 244, 206, 110, 206, 239, 233, 213, 61, 213, 65, + 139, 103, 19, 20, 123, 167, 65, 161, 165, 216, 217, 255, 248, + ]), + Bytes32::new_direct([ + 119, 71, 56, 219, 155, 139, 253, 40, 100, 132, 185, 98, 24, 34, 156, 225, 120, 176, 76, + 147, 31, 105, 245, 216, 165, 161, 89, 157, 246, 17, 251, 234, + ]), + Bytes32::new_direct([ + 192, 39, 162, 126, 222, 211, 173, 195, 198, 124, 1, 124, 140, 2, 252, 191, 185, 85, 10, + 125, 226, 7, 88, 221, 164, 13, 221, 74, 200, 7, 249, 177, + ]), + Bytes32::new_direct([ + 251, 226, 24, 5, 54, 89, 9, 93, 217, 202, 148, 172, 208, 197, 65, 172, 98, 96, 58, 194, 61, + 253, 157, 193, 135, 32, 206, 97, 133, 234, 199, 197, + ]), + Bytes32::new_direct([ + 130, 3, 195, 156, 210, 123, 23, 44, 223, 25, 153, 169, 250, 88, 127, 239, 206, 196, 156, + 143, 182, 185, 35, 77, 162, 48, 143, 64, 231, 129, 216, 185, + ]), + Bytes32::new_direct([ + 123, 201, 97, 230, 121, 13, 207, 138, 137, 3, 122, 92, 105, 155, 214, 204, 142, 18, 119, + 138, 135, 165, 249, 58, 184, 53, 27, 31, 109, 214, 176, 147, + ]), + Bytes32::new_direct([ + 46, 71, 246, 155, 247, 109, 236, 225, 147, 51, 250, 72, 97, 116, 162, 36, 115, 164, 80, 28, + 252, 238, 98, 92, 16, 66, 190, 208, 180, 39, 179, 211, + ]), + Bytes32::new_direct([ + 38, 76, 13, 227, 149, 18, 84, 170, 83, 231, 122, 59, 237, 66, 32, 171, 158, 251, 78, 156, + 186, 160, 29, 30, 207, 178, 16, 193, 221, 158, 49, 48, + ]), + Bytes32::new_direct([ + 166, 13, 210, 208, 250, 131, 27, 163, 99, 204, 199, 134, 152, 131, 28, 164, 8, 222, 176, + 200, 34, 40, 74, 188, 120, 46, 167, 44, 95, 199, 86, 225, + ]), ]; const TABLE_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::new_direct([164, 47, 121, 69, 150, 44, 30, 204, 210, 181, 242, 154, 59, 111, 5, 10, 47, 121, 213, 80, 163, 196, 205, 188, 241, 64, 202, 26, 242, 47, 50, 205]), - Bytes32::new_direct([166, 9, 224, 145, 14, 138, 194, 78, 202, 114, 110, 38, 244, 33, 189, 185, 170, 85, 144, 229, 123, 63, 229, 194, 59, 130, 156, 6, 184, 154, 187, 17]), - Bytes32::new_direct([32, 51, 186, 232, 39, 244, 218, 98, 243, 254, 82, 247, 63, 120, 34, 123, 128, 240, 220, 145, 41, 114, 251, 208, 209, 244, 10, 9, 179, 5, 105, 181]), - Bytes32::new_direct([73, 148, 74, 132, 241, 45, 129, 169, 83, 223, 101, 12, 184, 60, 10, 201, 169, 197, 75, 17, 198, 168, 79, 171, 207, 195, 123, 47, 249, 30, 176, 216]), - Bytes32::new_direct([145, 224, 51, 196, 211, 137, 189, 133, 232, 210, 170, 157, 227, 160, 218, 143, 15, 82, 170, 226, 241, 83, 7, 112, 138, 227, 58, 59, 149, 168, 81, 94]), - Bytes32::new_direct([241, 90, 42, 7, 231, 63, 36, 86, 238, 131, 19, 20, 38, 118, 65, 180, 109, 121, 147, 147, 213, 142, 203, 244, 239, 75, 5, 160, 16, 85, 221, 95]), - Bytes32::new_direct([213, 113, 178, 221, 213, 107, 77, 153, 222, 48, 148, 140, 250, 1, 17, 59, 73, 19, 110, 106, 94, 195, 126, 49, 126, 109, 65, 55, 104, 111, 18, 171]), - Bytes32::new_direct([43, 198, 12, 197, 95, 201, 76, 108, 96, 235, 76, 8, 117, 99, 42, 20, 177, 45, 112, 40, 2, 180, 68, 19, 25, 11, 210, 168, 170, 178, 99, 27]), - Bytes32::new_direct([142, 205, 24, 125, 81, 234, 138, 161, 206, 121, 163, 225, 50, 9, 180, 102, 0, 25, 93, 180, 137, 164, 206, 249, 222, 20, 175, 177, 199, 14, 115, 207]), - Bytes32::new_direct([213, 41, 249, 19, 173, 165, 236, 103, 42, 146, 223, 6, 190, 229, 161, 13, 96, 163, 110, 23, 203, 238, 24, 95, 130, 203, 35, 211, 63, 234, 32, 137]), - Bytes32::new_direct([176, 82, 229, 48, 113, 46, 179, 38, 231, 83, 50, 136, 179, 190, 242, 126, 152, 210, 141, 102, 191, 21, 20, 96, 235, 245, 81, 254, 231, 117, 159, 146]), - Bytes32::new_direct([216, 15, 120, 147, 70, 215, 12, 160, 223, 73, 246, 73, 195, 189, 200, 3, 19, 131, 102, 61, 173, 79, 50, 76, 39, 150, 151, 147, 35, 251, 200, 0]), - Bytes32::new_direct([88, 215, 168, 30, 218, 72, 206, 159, 91, 121, 14, 133, 241, 220, 195, 46, 93, 244, 179, 53, 158, 75, 211, 161, 8, 120, 167, 141, 235, 16, 232, 42]), - Bytes32::new_direct([114, 99, 218, 52, 203, 162, 199, 16, 225, 154, 182, 20, 59, 121, 250, 249, 166, 35, 118, 18, 142, 57, 122, 131, 32, 219, 83, 126, 147, 91, 116, 16]), - Bytes32::new_direct([193, 157, 15, 251, 179, 155, 215, 190, 98, 93, 30, 167, 23, 175, 178, 172, 142, 143, 222, 20, 18, 157, 215, 42, 105, 107, 64, 16, 216, 143, 109, 45]), - Bytes32::new_direct([178, 2, 203, 32, 83, 90, 114, 97, 124, 210, 81, 81, 179, 213, 71, 19, 181, 173, 227, 88, 226, 83, 48, 169, 134, 163, 62, 103, 222, 82, 128, 30]), - Bytes32::new_direct([252, 17, 142, 50, 185, 19, 111, 148, 204, 30, 199, 138, 143, 207, 30, 212, 254, 7, 129, 43, 100, 167, 52, 115, 247, 143, 64, 106, 220, 5, 7, 89]), - Bytes32::new_direct([117, 136, 111, 98, 95, 97, 253, 43, 82, 22, 43, 187, 65, 154, 132, 105, 55, 194, 240, 148, 170, 199, 185, 91, 157, 138, 43, 117, 218, 176, 110, 101]), - Bytes32::new_direct([228, 56, 186, 202, 73, 47, 253, 151, 48, 173, 2, 101, 153, 197, 108, 145, 227, 170, 247, 86, 80, 70, 30, 93, 232, 148, 63, 211, 197, 135, 23, 97]), - Bytes32::new_direct([162, 35, 93, 45, 208, 241, 87, 57, 138, 79, 231, 83, 75, 81, 102, 91, 115, 58, 1, 205, 193, 197, 62, 210, 144, 88, 59, 52, 149, 234, 121, 224]), - Bytes32::new_direct([165, 67, 16, 239, 234, 92, 207, 81, 64, 93, 227, 154, 132, 33, 54, 53, 102, 198, 90, 134, 24, 29, 190, 158, 121, 23, 127, 30, 27, 239, 140, 88]), - Bytes32::new_direct([61, 125, 183, 139, 186, 82, 193, 166, 2, 147, 231, 215, 179, 107, 163, 67, 122, 0, 90, 188, 142, 216, 72, 20, 63, 146, 85, 89, 231, 41, 153, 117]), - Bytes32::new_direct([206, 31, 38, 182, 78, 170, 183, 207, 211, 114, 212, 4, 108, 84, 62, 99, 245, 196, 10, 1, 188, 63, 240, 199, 27, 85, 68, 101, 212, 222, 85, 12]), - Bytes32::new_direct([106, 0, 225, 130, 195, 87, 113, 106, 101, 80, 56, 119, 93, 45, 74, 168, 240, 209, 155, 123, 8, 129, 73, 225, 204, 125, 42, 73, 102, 122, 228, 158]), - Bytes32::new_direct([251, 63, 88, 92, 59, 176, 71, 194, 46, 19, 18, 27, 83, 57, 197, 231, 202, 242, 155, 63, 252, 240, 205, 216, 96, 130, 161, 197, 123, 110, 175, 220]), - Bytes32::new_direct([239, 6, 249, 150, 189, 234, 197, 18, 79, 222, 80, 72, 205, 147, 251, 135, 226, 33, 46, 111, 186, 185, 4, 33, 219, 129, 30, 182, 57, 229, 34, 16]), - Bytes32::new_direct([192, 35, 149, 149, 16, 111, 3, 119, 173, 215, 223, 247, 70, 25, 31, 107, 104, 5, 249, 243, 193, 66, 99, 48, 107, 158, 25, 147, 163, 151, 96, 149]), - Bytes32::new_direct([197, 133, 241, 197, 67, 52, 255, 227, 180, 235, 137, 164, 174, 160, 183, 9, 159, 254, 210, 180, 231, 140, 176, 165, 113, 215, 182, 1, 177, 204, 219, 246]), - Bytes32::new_direct([51, 32, 109, 173, 131, 6, 99, 63, 75, 191, 207, 187, 73, 26, 5, 139, 167, 216, 123, 26, 199, 176, 84, 215, 158, 243, 105, 0, 91, 254, 59, 146]), - Bytes32::new_direct([229, 120, 15, 22, 225, 50, 131, 240, 190, 232, 83, 119, 169, 246, 172, 35, 99, 163, 58, 146, 234, 253, 252, 83, 5, 48, 54, 142, 172, 91, 145, 13]), - Bytes32::new_direct([159, 9, 100, 20, 215, 92, 217, 43, 208, 254, 65, 234, 124, 167, 250, 53, 159, 151, 124, 70, 26, 0, 113, 28, 78, 44, 238, 8, 34, 255, 19, 36]), - Bytes32::new_direct([193, 135, 44, 144, 13, 46, 76, 43, 127, 208, 79, 196, 229, 58, 125, 33, 71, 118, 215, 240, 80, 123, 44, 181, 174, 47, 102, 42, 137, 98, 190, 41]), - Bytes32::new_direct([78, 19, 3, 217, 174, 154, 142, 109, 189, 14, 241, 12, 23, 185, 224, 152, 209, 108, 223, 202, 191, 11, 190, 149, 31, 236, 104, 234, 22, 38, 196, 3]), - Bytes32::new_direct([60, 93, 237, 228, 186, 222, 179, 231, 151, 95, 147, 20, 188, 10, 191, 34, 126, 57, 253, 161, 154, 117, 182, 108, 143, 72, 48, 102, 191, 240, 81, 208]), - Bytes32::new_direct([179, 114, 163, 89, 172, 211, 154, 204, 11, 125, 140, 186, 107, 90, 17, 116, 214, 31, 165, 94, 36, 187, 184, 151, 210, 208, 76, 215, 75, 166, 107, 91]), - Bytes32::new_direct([125, 131, 52, 139, 120, 156, 163, 243, 206, 143, 204, 221, 123, 140, 1, 103, 235, 186, 64, 82, 194, 191, 205, 2, 32, 242, 38, 77, 184, 23, 236, 228]), - Bytes32::new_direct([137, 224, 90, 1, 116, 95, 215, 47, 8, 3, 227, 132, 154, 232, 216, 63, 3, 80, 52, 18, 42, 29, 85, 38, 117, 255, 9, 99, 88, 233, 129, 92]), - Bytes32::new_direct([54, 182, 145, 174, 54, 24, 168, 13, 71, 43, 178, 49, 153, 246, 94, 79, 228, 254, 134, 0, 21, 210, 176, 242, 82, 117, 76, 40, 221, 181, 30, 62]), - Bytes32::new_direct([145, 171, 156, 87, 15, 174, 31, 111, 175, 161, 31, 116, 123, 123, 37, 216, 43, 147, 197, 79, 218, 49, 236, 111, 35, 49, 44, 188, 197, 79, 136, 45]), - Bytes32::new_direct([169, 48, 186, 93, 10, 48, 80, 103, 68, 226, 103, 31, 176, 154, 146, 199, 166, 89, 48, 149, 116, 101, 157, 149, 149, 72, 123, 54, 153, 26, 210, 122]), - Bytes32::new_direct([225, 45, 163, 167, 213, 84, 40, 87, 106, 253, 206, 80, 189, 71, 153, 5, 15, 107, 151, 150, 14, 22, 143, 207, 4, 192, 63, 250, 207, 207, 179, 26]), - Bytes32::new_direct([110, 249, 172, 218, 206, 202, 107, 64, 48, 153, 226, 127, 165, 227, 50, 146, 140, 239, 220, 252, 188, 157, 77, 210, 92, 73, 38, 6, 16, 87, 244, 66]), - Bytes32::new_direct([39, 217, 230, 91, 60, 231, 96, 137, 37, 58, 93, 51, 79, 222, 132, 171, 196, 109, 155, 4, 252, 213, 17, 33, 160, 24, 250, 118, 187, 62, 107, 113]), - Bytes32::new_direct([120, 167, 145, 121, 184, 31, 185, 178, 241, 54, 20, 48, 132, 89, 132, 127, 235, 189, 197, 127, 249, 58, 255, 197, 40, 229, 130, 254, 213, 186, 114, 74]), - Bytes32::new_direct([7, 40, 187, 172, 225, 196, 3, 77, 113, 16, 118, 148, 95, 65, 42, 234, 233, 29, 120, 223, 105, 77, 250, 119, 245, 20, 21, 155, 177, 13, 56, 151]), - Bytes32::new_direct([22, 248, 25, 75, 36, 179, 251, 57, 101, 170, 213, 19, 216, 64, 164, 253, 151, 199, 88, 5, 92, 129, 138, 185, 9, 236, 231, 68, 112, 24, 218, 216]), - Bytes32::new_direct([95, 141, 49, 39, 213, 214, 130, 49, 143, 124, 178, 114, 200, 136, 160, 90, 233, 73, 233, 185, 60, 250, 174, 74, 2, 123, 2, 62, 192, 174, 115, 158]), - Bytes32::new_direct([142, 29, 212, 35, 71, 107, 91, 164, 226, 225, 180, 218, 99, 34, 200, 171, 33, 235, 113, 105, 191, 78, 105, 70, 221, 135, 167, 148, 24, 225, 6, 146]), - Bytes32::new_direct([176, 194, 115, 243, 138, 104, 3, 247, 184, 74, 81, 60, 173, 45, 29, 189, 252, 202, 206, 66, 129, 65, 150, 25, 246, 145, 133, 4, 93, 201, 201, 240]), - Bytes32::new_direct([18, 233, 186, 158, 43, 12, 206, 228, 80, 102, 187, 25, 78, 77, 180, 28, 82, 62, 168, 252, 14, 113, 126, 91, 243, 120, 213, 91, 189, 244, 247, 177]), - Bytes32::new_direct([79, 126, 97, 23, 112, 98, 93, 86, 24, 103, 82, 33, 155, 188, 202, 61, 29, 146, 132, 169, 116, 207, 216, 35, 29, 229, 213, 120, 135, 240, 129, 205]), - Bytes32::new_direct([146, 121, 255, 202, 145, 53, 46, 8, 102, 205, 56, 234, 49, 42, 85, 231, 217, 114, 235, 141, 233, 187, 29, 9, 122, 232, 61, 253, 42, 104, 4, 113]), - Bytes32::new_direct([103, 174, 255, 6, 115, 155, 156, 65, 84, 251, 208, 55, 89, 124, 171, 167, 133, 227, 22, 134, 32, 71, 243, 181, 16, 100, 81, 63, 22, 207, 58, 190]), - Bytes32::new_direct([69, 10, 247, 243, 56, 0, 64, 72, 218, 21, 211, 192, 62, 243, 66, 244, 230, 58, 107, 54, 180, 29, 216, 23, 86, 211, 173, 181, 118, 188, 238, 72]), - Bytes32::new_direct([25, 179, 4, 93, 169, 76, 76, 69, 158, 3, 24, 146, 130, 9, 225, 198, 102, 238, 29, 73, 74, 179, 159, 74, 40, 111, 181, 110, 76, 173, 251, 255]), - Bytes32::new_direct([236, 113, 37, 202, 149, 150, 90, 50, 233, 141, 125, 12, 212, 163, 137, 176, 15, 214, 194, 73, 138, 104, 4, 33, 235, 76, 185, 58, 125, 182, 56, 0]), - Bytes32::new_direct([238, 54, 183, 94, 50, 33, 98, 31, 133, 181, 230, 98, 43, 154, 95, 111, 250, 71, 15, 197, 156, 60, 8, 90, 208, 50, 62, 127, 30, 18, 181, 176]), - Bytes32::new_direct([246, 143, 72, 228, 143, 15, 15, 131, 178, 105, 113, 46, 85, 36, 165, 116, 63, 131, 61, 228, 98, 144, 232, 209, 228, 110, 168, 171, 252, 47, 79, 165]), - Bytes32::new_direct([146, 70, 74, 79, 139, 107, 73, 28, 231, 88, 235, 214, 163, 185, 87, 195, 147, 186, 153, 222, 191, 214, 30, 231, 173, 166, 151, 169, 244, 15, 15, 227]), - Bytes32::new_direct([137, 182, 175, 97, 212, 23, 62, 70, 50, 150, 67, 153, 253, 52, 179, 105, 147, 177, 217, 170, 125, 251, 1, 96, 4, 127, 196, 37, 254, 7, 217, 100]), - Bytes32::new_direct([32, 253, 229, 209, 120, 43, 120, 189, 245, 227, 178, 79, 134, 175, 240, 107, 25, 124, 5, 67, 120, 213, 187, 200, 159, 9, 26, 119, 13, 1, 8, 120]), - Bytes32::new_direct([115, 241, 26, 44, 83, 229, 130, 21, 249, 87, 72, 212, 75, 220, 95, 22, 151, 77, 182, 8, 196, 207, 95, 18, 9, 92, 89, 206, 114, 80, 36, 159]), - Bytes32::new_direct([174, 151, 88, 171, 52, 40, 161, 16, 106, 45, 44, 9, 142, 95, 5, 205, 82, 24, 172, 103, 152, 202, 187, 34, 217, 173, 236, 129, 32, 203, 205, 38]), + Bytes32::new_direct([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ]), + Bytes32::new_direct([ + 164, 47, 121, 69, 150, 44, 30, 204, 210, 181, 242, 154, 59, 111, 5, 10, 47, 121, 213, 80, + 163, 196, 205, 188, 241, 64, 202, 26, 242, 47, 50, 205, + ]), + Bytes32::new_direct([ + 166, 9, 224, 145, 14, 138, 194, 78, 202, 114, 110, 38, 244, 33, 189, 185, 170, 85, 144, + 229, 123, 63, 229, 194, 59, 130, 156, 6, 184, 154, 187, 17, + ]), + Bytes32::new_direct([ + 32, 51, 186, 232, 39, 244, 218, 98, 243, 254, 82, 247, 63, 120, 34, 123, 128, 240, 220, + 145, 41, 114, 251, 208, 209, 244, 10, 9, 179, 5, 105, 181, + ]), + Bytes32::new_direct([ + 73, 148, 74, 132, 241, 45, 129, 169, 83, 223, 101, 12, 184, 60, 10, 201, 169, 197, 75, 17, + 198, 168, 79, 171, 207, 195, 123, 47, 249, 30, 176, 216, + ]), + Bytes32::new_direct([ + 145, 224, 51, 196, 211, 137, 189, 133, 232, 210, 170, 157, 227, 160, 218, 143, 15, 82, 170, + 226, 241, 83, 7, 112, 138, 227, 58, 59, 149, 168, 81, 94, + ]), + Bytes32::new_direct([ + 241, 90, 42, 7, 231, 63, 36, 86, 238, 131, 19, 20, 38, 118, 65, 180, 109, 121, 147, 147, + 213, 142, 203, 244, 239, 75, 5, 160, 16, 85, 221, 95, + ]), + Bytes32::new_direct([ + 213, 113, 178, 221, 213, 107, 77, 153, 222, 48, 148, 140, 250, 1, 17, 59, 73, 19, 110, 106, + 94, 195, 126, 49, 126, 109, 65, 55, 104, 111, 18, 171, + ]), + Bytes32::new_direct([ + 43, 198, 12, 197, 95, 201, 76, 108, 96, 235, 76, 8, 117, 99, 42, 20, 177, 45, 112, 40, 2, + 180, 68, 19, 25, 11, 210, 168, 170, 178, 99, 27, + ]), + Bytes32::new_direct([ + 142, 205, 24, 125, 81, 234, 138, 161, 206, 121, 163, 225, 50, 9, 180, 102, 0, 25, 93, 180, + 137, 164, 206, 249, 222, 20, 175, 177, 199, 14, 115, 207, + ]), + Bytes32::new_direct([ + 213, 41, 249, 19, 173, 165, 236, 103, 42, 146, 223, 6, 190, 229, 161, 13, 96, 163, 110, 23, + 203, 238, 24, 95, 130, 203, 35, 211, 63, 234, 32, 137, + ]), + Bytes32::new_direct([ + 176, 82, 229, 48, 113, 46, 179, 38, 231, 83, 50, 136, 179, 190, 242, 126, 152, 210, 141, + 102, 191, 21, 20, 96, 235, 245, 81, 254, 231, 117, 159, 146, + ]), + Bytes32::new_direct([ + 216, 15, 120, 147, 70, 215, 12, 160, 223, 73, 246, 73, 195, 189, 200, 3, 19, 131, 102, 61, + 173, 79, 50, 76, 39, 150, 151, 147, 35, 251, 200, 0, + ]), + Bytes32::new_direct([ + 88, 215, 168, 30, 218, 72, 206, 159, 91, 121, 14, 133, 241, 220, 195, 46, 93, 244, 179, 53, + 158, 75, 211, 161, 8, 120, 167, 141, 235, 16, 232, 42, + ]), + Bytes32::new_direct([ + 114, 99, 218, 52, 203, 162, 199, 16, 225, 154, 182, 20, 59, 121, 250, 249, 166, 35, 118, + 18, 142, 57, 122, 131, 32, 219, 83, 126, 147, 91, 116, 16, + ]), + Bytes32::new_direct([ + 193, 157, 15, 251, 179, 155, 215, 190, 98, 93, 30, 167, 23, 175, 178, 172, 142, 143, 222, + 20, 18, 157, 215, 42, 105, 107, 64, 16, 216, 143, 109, 45, + ]), + Bytes32::new_direct([ + 178, 2, 203, 32, 83, 90, 114, 97, 124, 210, 81, 81, 179, 213, 71, 19, 181, 173, 227, 88, + 226, 83, 48, 169, 134, 163, 62, 103, 222, 82, 128, 30, + ]), + Bytes32::new_direct([ + 252, 17, 142, 50, 185, 19, 111, 148, 204, 30, 199, 138, 143, 207, 30, 212, 254, 7, 129, 43, + 100, 167, 52, 115, 247, 143, 64, 106, 220, 5, 7, 89, + ]), + Bytes32::new_direct([ + 117, 136, 111, 98, 95, 97, 253, 43, 82, 22, 43, 187, 65, 154, 132, 105, 55, 194, 240, 148, + 170, 199, 185, 91, 157, 138, 43, 117, 218, 176, 110, 101, + ]), + Bytes32::new_direct([ + 228, 56, 186, 202, 73, 47, 253, 151, 48, 173, 2, 101, 153, 197, 108, 145, 227, 170, 247, + 86, 80, 70, 30, 93, 232, 148, 63, 211, 197, 135, 23, 97, + ]), + Bytes32::new_direct([ + 162, 35, 93, 45, 208, 241, 87, 57, 138, 79, 231, 83, 75, 81, 102, 91, 115, 58, 1, 205, 193, + 197, 62, 210, 144, 88, 59, 52, 149, 234, 121, 224, + ]), + Bytes32::new_direct([ + 165, 67, 16, 239, 234, 92, 207, 81, 64, 93, 227, 154, 132, 33, 54, 53, 102, 198, 90, 134, + 24, 29, 190, 158, 121, 23, 127, 30, 27, 239, 140, 88, + ]), + Bytes32::new_direct([ + 61, 125, 183, 139, 186, 82, 193, 166, 2, 147, 231, 215, 179, 107, 163, 67, 122, 0, 90, 188, + 142, 216, 72, 20, 63, 146, 85, 89, 231, 41, 153, 117, + ]), + Bytes32::new_direct([ + 206, 31, 38, 182, 78, 170, 183, 207, 211, 114, 212, 4, 108, 84, 62, 99, 245, 196, 10, 1, + 188, 63, 240, 199, 27, 85, 68, 101, 212, 222, 85, 12, + ]), + Bytes32::new_direct([ + 106, 0, 225, 130, 195, 87, 113, 106, 101, 80, 56, 119, 93, 45, 74, 168, 240, 209, 155, 123, + 8, 129, 73, 225, 204, 125, 42, 73, 102, 122, 228, 158, + ]), + Bytes32::new_direct([ + 251, 63, 88, 92, 59, 176, 71, 194, 46, 19, 18, 27, 83, 57, 197, 231, 202, 242, 155, 63, + 252, 240, 205, 216, 96, 130, 161, 197, 123, 110, 175, 220, + ]), + Bytes32::new_direct([ + 239, 6, 249, 150, 189, 234, 197, 18, 79, 222, 80, 72, 205, 147, 251, 135, 226, 33, 46, 111, + 186, 185, 4, 33, 219, 129, 30, 182, 57, 229, 34, 16, + ]), + Bytes32::new_direct([ + 192, 35, 149, 149, 16, 111, 3, 119, 173, 215, 223, 247, 70, 25, 31, 107, 104, 5, 249, 243, + 193, 66, 99, 48, 107, 158, 25, 147, 163, 151, 96, 149, + ]), + Bytes32::new_direct([ + 197, 133, 241, 197, 67, 52, 255, 227, 180, 235, 137, 164, 174, 160, 183, 9, 159, 254, 210, + 180, 231, 140, 176, 165, 113, 215, 182, 1, 177, 204, 219, 246, + ]), + Bytes32::new_direct([ + 51, 32, 109, 173, 131, 6, 99, 63, 75, 191, 207, 187, 73, 26, 5, 139, 167, 216, 123, 26, + 199, 176, 84, 215, 158, 243, 105, 0, 91, 254, 59, 146, + ]), + Bytes32::new_direct([ + 229, 120, 15, 22, 225, 50, 131, 240, 190, 232, 83, 119, 169, 246, 172, 35, 99, 163, 58, + 146, 234, 253, 252, 83, 5, 48, 54, 142, 172, 91, 145, 13, + ]), + Bytes32::new_direct([ + 159, 9, 100, 20, 215, 92, 217, 43, 208, 254, 65, 234, 124, 167, 250, 53, 159, 151, 124, 70, + 26, 0, 113, 28, 78, 44, 238, 8, 34, 255, 19, 36, + ]), + Bytes32::new_direct([ + 193, 135, 44, 144, 13, 46, 76, 43, 127, 208, 79, 196, 229, 58, 125, 33, 71, 118, 215, 240, + 80, 123, 44, 181, 174, 47, 102, 42, 137, 98, 190, 41, + ]), + Bytes32::new_direct([ + 78, 19, 3, 217, 174, 154, 142, 109, 189, 14, 241, 12, 23, 185, 224, 152, 209, 108, 223, + 202, 191, 11, 190, 149, 31, 236, 104, 234, 22, 38, 196, 3, + ]), + Bytes32::new_direct([ + 60, 93, 237, 228, 186, 222, 179, 231, 151, 95, 147, 20, 188, 10, 191, 34, 126, 57, 253, + 161, 154, 117, 182, 108, 143, 72, 48, 102, 191, 240, 81, 208, + ]), + Bytes32::new_direct([ + 179, 114, 163, 89, 172, 211, 154, 204, 11, 125, 140, 186, 107, 90, 17, 116, 214, 31, 165, + 94, 36, 187, 184, 151, 210, 208, 76, 215, 75, 166, 107, 91, + ]), + Bytes32::new_direct([ + 125, 131, 52, 139, 120, 156, 163, 243, 206, 143, 204, 221, 123, 140, 1, 103, 235, 186, 64, + 82, 194, 191, 205, 2, 32, 242, 38, 77, 184, 23, 236, 228, + ]), + Bytes32::new_direct([ + 137, 224, 90, 1, 116, 95, 215, 47, 8, 3, 227, 132, 154, 232, 216, 63, 3, 80, 52, 18, 42, + 29, 85, 38, 117, 255, 9, 99, 88, 233, 129, 92, + ]), + Bytes32::new_direct([ + 54, 182, 145, 174, 54, 24, 168, 13, 71, 43, 178, 49, 153, 246, 94, 79, 228, 254, 134, 0, + 21, 210, 176, 242, 82, 117, 76, 40, 221, 181, 30, 62, + ]), + Bytes32::new_direct([ + 145, 171, 156, 87, 15, 174, 31, 111, 175, 161, 31, 116, 123, 123, 37, 216, 43, 147, 197, + 79, 218, 49, 236, 111, 35, 49, 44, 188, 197, 79, 136, 45, + ]), + Bytes32::new_direct([ + 169, 48, 186, 93, 10, 48, 80, 103, 68, 226, 103, 31, 176, 154, 146, 199, 166, 89, 48, 149, + 116, 101, 157, 149, 149, 72, 123, 54, 153, 26, 210, 122, + ]), + Bytes32::new_direct([ + 225, 45, 163, 167, 213, 84, 40, 87, 106, 253, 206, 80, 189, 71, 153, 5, 15, 107, 151, 150, + 14, 22, 143, 207, 4, 192, 63, 250, 207, 207, 179, 26, + ]), + Bytes32::new_direct([ + 110, 249, 172, 218, 206, 202, 107, 64, 48, 153, 226, 127, 165, 227, 50, 146, 140, 239, 220, + 252, 188, 157, 77, 210, 92, 73, 38, 6, 16, 87, 244, 66, + ]), + Bytes32::new_direct([ + 39, 217, 230, 91, 60, 231, 96, 137, 37, 58, 93, 51, 79, 222, 132, 171, 196, 109, 155, 4, + 252, 213, 17, 33, 160, 24, 250, 118, 187, 62, 107, 113, + ]), + Bytes32::new_direct([ + 120, 167, 145, 121, 184, 31, 185, 178, 241, 54, 20, 48, 132, 89, 132, 127, 235, 189, 197, + 127, 249, 58, 255, 197, 40, 229, 130, 254, 213, 186, 114, 74, + ]), + Bytes32::new_direct([ + 7, 40, 187, 172, 225, 196, 3, 77, 113, 16, 118, 148, 95, 65, 42, 234, 233, 29, 120, 223, + 105, 77, 250, 119, 245, 20, 21, 155, 177, 13, 56, 151, + ]), + Bytes32::new_direct([ + 22, 248, 25, 75, 36, 179, 251, 57, 101, 170, 213, 19, 216, 64, 164, 253, 151, 199, 88, 5, + 92, 129, 138, 185, 9, 236, 231, 68, 112, 24, 218, 216, + ]), + Bytes32::new_direct([ + 95, 141, 49, 39, 213, 214, 130, 49, 143, 124, 178, 114, 200, 136, 160, 90, 233, 73, 233, + 185, 60, 250, 174, 74, 2, 123, 2, 62, 192, 174, 115, 158, + ]), + Bytes32::new_direct([ + 142, 29, 212, 35, 71, 107, 91, 164, 226, 225, 180, 218, 99, 34, 200, 171, 33, 235, 113, + 105, 191, 78, 105, 70, 221, 135, 167, 148, 24, 225, 6, 146, + ]), + Bytes32::new_direct([ + 176, 194, 115, 243, 138, 104, 3, 247, 184, 74, 81, 60, 173, 45, 29, 189, 252, 202, 206, 66, + 129, 65, 150, 25, 246, 145, 133, 4, 93, 201, 201, 240, + ]), + Bytes32::new_direct([ + 18, 233, 186, 158, 43, 12, 206, 228, 80, 102, 187, 25, 78, 77, 180, 28, 82, 62, 168, 252, + 14, 113, 126, 91, 243, 120, 213, 91, 189, 244, 247, 177, + ]), + Bytes32::new_direct([ + 79, 126, 97, 23, 112, 98, 93, 86, 24, 103, 82, 33, 155, 188, 202, 61, 29, 146, 132, 169, + 116, 207, 216, 35, 29, 229, 213, 120, 135, 240, 129, 205, + ]), + Bytes32::new_direct([ + 146, 121, 255, 202, 145, 53, 46, 8, 102, 205, 56, 234, 49, 42, 85, 231, 217, 114, 235, 141, + 233, 187, 29, 9, 122, 232, 61, 253, 42, 104, 4, 113, + ]), + Bytes32::new_direct([ + 103, 174, 255, 6, 115, 155, 156, 65, 84, 251, 208, 55, 89, 124, 171, 167, 133, 227, 22, + 134, 32, 71, 243, 181, 16, 100, 81, 63, 22, 207, 58, 190, + ]), + Bytes32::new_direct([ + 69, 10, 247, 243, 56, 0, 64, 72, 218, 21, 211, 192, 62, 243, 66, 244, 230, 58, 107, 54, + 180, 29, 216, 23, 86, 211, 173, 181, 118, 188, 238, 72, + ]), + Bytes32::new_direct([ + 25, 179, 4, 93, 169, 76, 76, 69, 158, 3, 24, 146, 130, 9, 225, 198, 102, 238, 29, 73, 74, + 179, 159, 74, 40, 111, 181, 110, 76, 173, 251, 255, + ]), + Bytes32::new_direct([ + 236, 113, 37, 202, 149, 150, 90, 50, 233, 141, 125, 12, 212, 163, 137, 176, 15, 214, 194, + 73, 138, 104, 4, 33, 235, 76, 185, 58, 125, 182, 56, 0, + ]), + Bytes32::new_direct([ + 238, 54, 183, 94, 50, 33, 98, 31, 133, 181, 230, 98, 43, 154, 95, 111, 250, 71, 15, 197, + 156, 60, 8, 90, 208, 50, 62, 127, 30, 18, 181, 176, + ]), + Bytes32::new_direct([ + 246, 143, 72, 228, 143, 15, 15, 131, 178, 105, 113, 46, 85, 36, 165, 116, 63, 131, 61, 228, + 98, 144, 232, 209, 228, 110, 168, 171, 252, 47, 79, 165, + ]), + Bytes32::new_direct([ + 146, 70, 74, 79, 139, 107, 73, 28, 231, 88, 235, 214, 163, 185, 87, 195, 147, 186, 153, + 222, 191, 214, 30, 231, 173, 166, 151, 169, 244, 15, 15, 227, + ]), + Bytes32::new_direct([ + 137, 182, 175, 97, 212, 23, 62, 70, 50, 150, 67, 153, 253, 52, 179, 105, 147, 177, 217, + 170, 125, 251, 1, 96, 4, 127, 196, 37, 254, 7, 217, 100, + ]), + Bytes32::new_direct([ + 32, 253, 229, 209, 120, 43, 120, 189, 245, 227, 178, 79, 134, 175, 240, 107, 25, 124, 5, + 67, 120, 213, 187, 200, 159, 9, 26, 119, 13, 1, 8, 120, + ]), + Bytes32::new_direct([ + 115, 241, 26, 44, 83, 229, 130, 21, 249, 87, 72, 212, 75, 220, 95, 22, 151, 77, 182, 8, + 196, 207, 95, 18, 9, 92, 89, 206, 114, 80, 36, 159, + ]), + Bytes32::new_direct([ + 174, 151, 88, 171, 52, 40, 161, 16, 106, 45, 44, 9, 142, 95, 5, 205, 82, 24, 172, 103, 152, + 202, 187, 34, 217, 173, 236, 129, 32, 203, 205, 38, + ]), ]; const TABLE_ELEMENT_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::new_direct([145, 218, 63, 74, 131, 182, 204, 163, 74, 206, 234, 50, 47, 3, 51, 74, 121, 225, 146, 237, 5, 128, 20, 230, 243, 89, 33, 248, 136, 154, 189, 5]), - Bytes32::new_direct([36, 240, 95, 13, 214, 136, 92, 102, 96, 137, 39, 96, 108, 223, 147, 130, 220, 61, 147, 226, 52, 133, 67, 223, 211, 164, 6, 53, 45, 117, 120, 241]), - Bytes32::new_direct([9, 2, 218, 34, 228, 8, 178, 127, 160, 30, 104, 198, 49, 37, 71, 115, 14, 35, 20, 15, 253, 160, 147, 143, 24, 186, 12, 90, 41, 169, 30, 8]), - Bytes32::new_direct([137, 242, 105, 78, 161, 99, 76, 224, 226, 100, 216, 235, 156, 132, 214, 154, 107, 120, 197, 113, 45, 221, 170, 119, 92, 228, 76, 139, 170, 159, 111, 58]), - Bytes32::new_direct([231, 165, 221, 185, 139, 22, 70, 40, 67, 162, 123, 94, 161, 156, 57, 53, 102, 217, 128, 227, 18, 132, 17, 170, 90, 31, 214, 181, 249, 220, 70, 37]), - Bytes32::new_direct([171, 253, 174, 187, 9, 186, 87, 37, 22, 83, 13, 88, 75, 11, 177, 226, 237, 136, 132, 137, 101, 109, 135, 192, 224, 80, 87, 105, 95, 81, 255, 21]), - Bytes32::new_direct([179, 50, 36, 230, 159, 162, 184, 132, 140, 121, 133, 155, 189, 44, 132, 93, 80, 79, 32, 244, 131, 57, 79, 222, 104, 63, 224, 182, 91, 162, 73, 122]), - Bytes32::new_direct([17, 55, 206, 87, 127, 185, 135, 231, 41, 56, 166, 104, 229, 102, 222, 181, 236, 233, 230, 39, 43, 163, 16, 1, 225, 86, 211, 51, 145, 7, 169, 84]), - Bytes32::new_direct([201, 174, 3, 154, 104, 190, 240, 99, 123, 201, 7, 118, 196, 85, 28, 247, 35, 232, 39, 25, 151, 52, 167, 136, 179, 13, 213, 60, 138, 158, 39, 131]), - Bytes32::new_direct([35, 33, 109, 155, 171, 252, 195, 80, 10, 115, 40, 199, 250, 1, 241, 82, 146, 225, 118, 237, 11, 125, 198, 97, 57, 21, 171, 237, 94, 60, 49, 32]), - Bytes32::new_direct([126, 95, 42, 157, 183, 168, 137, 120, 114, 64, 148, 170, 32, 156, 137, 96, 194, 91, 119, 11, 20, 3, 30, 62, 118, 12, 31, 48, 245, 144, 252, 29]), - Bytes32::new_direct([48, 135, 201, 114, 103, 35, 8, 96, 5, 101, 125, 26, 87, 0, 98, 122, 239, 140, 230, 10, 102, 112, 155, 87, 249, 181, 152, 235, 28, 79, 176, 56]), - Bytes32::new_direct([76, 70, 222, 210, 242, 159, 52, 123, 112, 106, 253, 140, 55, 160, 189, 255, 220, 64, 8, 168, 39, 196, 160, 8, 105, 154, 91, 184, 62, 63, 227, 156]), - Bytes32::new_direct([138, 201, 8, 240, 218, 190, 210, 227, 236, 168, 45, 161, 209, 115, 126, 165, 235, 162, 6, 117, 76, 239, 3, 225, 163, 251, 111, 233, 233, 228, 14, 92]), - Bytes32::new_direct([190, 166, 27, 117, 242, 0, 25, 148, 230, 125, 237, 22, 153, 158, 151, 56, 121, 194, 221, 198, 184, 147, 249, 149, 27, 29, 166, 243, 254, 181, 209, 102]), - Bytes32::new_direct([235, 63, 149, 47, 164, 152, 80, 11, 178, 203, 99, 178, 176, 226, 164, 151, 39, 65, 83, 200, 102, 90, 12, 102, 178, 15, 232, 16, 222, 141, 78, 3]), - Bytes32::new_direct([37, 179, 99, 114, 214, 120, 87, 53, 198, 229, 207, 47, 16, 112, 208, 33, 216, 152, 209, 228, 196, 14, 237, 250, 212, 90, 176, 185, 21, 248, 92, 109]), - Bytes32::new_direct([237, 200, 122, 93, 145, 116, 138, 59, 86, 220, 58, 171, 160, 31, 142, 193, 231, 131, 106, 164, 166, 44, 120, 170, 62, 81, 73, 85, 0, 52, 219, 220]), - Bytes32::new_direct([244, 173, 85, 141, 81, 198, 214, 0, 54, 21, 20, 169, 177, 235, 104, 206, 43, 218, 96, 68, 73, 37, 252, 77, 253, 18, 30, 97, 223, 122, 1, 12]), - Bytes32::new_direct([104, 169, 247, 140, 131, 245, 193, 3, 36, 119, 249, 119, 108, 102, 115, 250, 173, 225, 33, 156, 116, 87, 180, 27, 84, 215, 126, 15, 187, 189, 32, 139]), - Bytes32::new_direct([47, 156, 244, 88, 145, 227, 224, 87, 233, 138, 138, 9, 169, 96, 29, 204, 100, 170, 23, 105, 63, 4, 119, 90, 167, 161, 72, 109, 82, 254, 123, 48]), - Bytes32::new_direct([196, 68, 107, 111, 141, 253, 138, 140, 162, 104, 247, 104, 87, 144, 123, 240, 105, 251, 246, 210, 172, 172, 241, 162, 155, 90, 83, 175, 131, 251, 107, 215]), - Bytes32::new_direct([28, 100, 243, 226, 32, 234, 211, 106, 197, 179, 14, 192, 70, 11, 203, 125, 151, 53, 20, 77, 175, 99, 154, 100, 159, 249, 54, 39, 73, 168, 162, 66]), - Bytes32::new_direct([83, 176, 7, 180, 201, 178, 172, 98, 47, 34, 80, 6, 62, 10, 4, 112, 43, 93, 10, 227, 74, 91, 11, 217, 83, 230, 104, 0, 167, 2, 114, 89]), - Bytes32::new_direct([185, 162, 212, 82, 149, 182, 104, 215, 62, 244, 114, 124, 181, 74, 226, 119, 4, 42, 181, 238, 25, 212, 215, 219, 174, 231, 32, 170, 9, 234, 12, 212]), - Bytes32::new_direct([173, 38, 241, 20, 137, 119, 33, 252, 174, 245, 252, 234, 165, 181, 128, 225, 14, 147, 182, 97, 145, 19, 40, 193, 90, 238, 140, 87, 0, 222, 70, 254]), - Bytes32::new_direct([51, 218, 162, 213, 211, 23, 9, 158, 185, 156, 39, 145, 5, 146, 70, 144, 172, 10, 26, 212, 253, 37, 24, 32, 21, 65, 179, 140, 64, 237, 96, 157]), - Bytes32::new_direct([221, 87, 57, 81, 246, 126, 53, 163, 190, 220, 109, 205, 114, 234, 85, 151, 75, 245, 254, 16, 140, 131, 239, 120, 9, 209, 54, 61, 177, 6, 188, 252]), - Bytes32::new_direct([54, 161, 25, 198, 75, 151, 214, 76, 83, 74, 117, 229, 155, 237, 88, 95, 143, 119, 56, 12, 201, 164, 235, 20, 117, 49, 177, 88, 14, 248, 95, 198]), - Bytes32::new_direct([60, 16, 183, 115, 241, 45, 253, 24, 105, 43, 79, 72, 212, 238, 24, 156, 132, 93, 78, 246, 1, 228, 222, 200, 254, 130, 170, 46, 91, 254, 205, 143]), - Bytes32::new_direct([184, 30, 34, 235, 214, 40, 120, 64, 182, 15, 162, 189, 164, 202, 89, 146, 202, 177, 16, 105, 172, 158, 1, 95, 101, 146, 253, 115, 226, 233, 38, 171]), - Bytes32::new_direct([70, 152, 3, 73, 249, 222, 93, 214, 74, 179, 140, 47, 34, 42, 149, 214, 152, 75, 34, 145, 68, 226, 151, 101, 121, 54, 252, 240, 206, 140, 81, 165]), - Bytes32::new_direct([9, 88, 51, 124, 67, 108, 84, 244, 61, 241, 110, 246, 184, 105, 6, 116, 242, 58, 15, 144, 43, 76, 176, 107, 0, 138, 155, 235, 210, 138, 226, 215]), - Bytes32::new_direct([98, 170, 168, 147, 158, 223, 186, 7, 58, 130, 89, 200, 153, 24, 158, 251, 69, 100, 7, 57, 96, 115, 136, 170, 57, 145, 143, 240, 102, 6, 248, 111]), - Bytes32::new_direct([76, 75, 216, 216, 194, 146, 2, 59, 247, 64, 98, 160, 62, 105, 193, 186, 161, 191, 64, 154, 254, 196, 55, 214, 201, 103, 223, 131, 181, 192, 152, 176]), - Bytes32::new_direct([188, 141, 114, 199, 33, 45, 183, 18, 123, 231, 92, 215, 51, 191, 11, 199, 253, 46, 28, 10, 156, 23, 92, 255, 219, 236, 176, 247, 52, 105, 210, 223]), - Bytes32::new_direct([200, 67, 112, 29, 180, 70, 50, 18, 220, 122, 39, 122, 83, 186, 81, 77, 241, 44, 190, 3, 162, 217, 76, 61, 230, 237, 157, 230, 205, 172, 186, 247]), - Bytes32::new_direct([131, 131, 129, 83, 251, 217, 83, 88, 93, 39, 66, 174, 51, 19, 190, 91, 16, 187, 95, 63, 35, 178, 94, 237, 194, 42, 231, 227, 138, 202, 216, 93]), - Bytes32::new_direct([18, 177, 28, 41, 199, 59, 160, 244, 26, 162, 73, 48, 16, 74, 190, 195, 249, 216, 64, 229, 145, 65, 18, 131, 75, 57, 71, 74, 127, 239, 112, 13]), - Bytes32::new_direct([41, 120, 53, 253, 151, 12, 143, 213, 212, 31, 245, 61, 168, 113, 30, 38, 112, 126, 156, 133, 241, 102, 110, 237, 4, 138, 50, 160, 79, 235, 52, 35]), - Bytes32::new_direct([38, 74, 146, 27, 110, 86, 122, 250, 58, 243, 64, 185, 207, 174, 28, 124, 35, 183, 53, 88, 34, 234, 89, 58, 98, 223, 69, 13, 48, 15, 239, 230]), - Bytes32::new_direct([221, 132, 1, 28, 157, 232, 235, 132, 32, 58, 26, 36, 60, 217, 197, 165, 141, 19, 64, 120, 197, 139, 190, 86, 153, 152, 235, 11, 99, 129, 222, 91]), - Bytes32::new_direct([237, 76, 61, 239, 169, 108, 131, 62, 163, 67, 158, 210, 14, 45, 91, 105, 36, 182, 206, 182, 71, 11, 159, 169, 159, 248, 247, 176, 6, 176, 237, 123]), - Bytes32::new_direct([232, 190, 198, 78, 12, 148, 86, 176, 221, 115, 1, 22, 122, 163, 223, 234, 74, 129, 125, 53, 211, 137, 115, 18, 241, 170, 69, 42, 34, 74, 180, 172]), - Bytes32::new_direct([215, 199, 144, 158, 222, 153, 123, 125, 150, 97, 127, 151, 96, 43, 69, 155, 150, 119, 75, 82, 218, 48, 101, 70, 121, 18, 42, 146, 215, 183, 100, 158]), - Bytes32::new_direct([121, 182, 45, 62, 255, 78, 32, 48, 107, 186, 208, 155, 158, 80, 231, 241, 90, 227, 219, 113, 52, 20, 66, 45, 124, 67, 209, 61, 167, 74, 60, 34]), - Bytes32::new_direct([34, 136, 15, 103, 128, 220, 202, 103, 150, 123, 249, 145, 218, 227, 17, 64, 142, 129, 4, 42, 93, 7, 6, 147, 111, 117, 25, 185, 88, 104, 85, 115]), - Bytes32::new_direct([144, 191, 235, 38, 205, 102, 127, 160, 139, 105, 75, 63, 86, 192, 194, 49, 240, 35, 65, 154, 4, 113, 51, 87, 40, 70, 32, 58, 243, 16, 136, 67]), - Bytes32::new_direct([217, 150, 254, 250, 111, 69, 45, 227, 111, 59, 199, 149, 59, 216, 17, 117, 8, 226, 85, 250, 183, 187, 21, 129, 208, 0, 63, 158, 232, 106, 131, 16]), - Bytes32::new_direct([148, 212, 84, 16, 204, 49, 69, 96, 137, 125, 102, 221, 111, 8, 41, 51, 221, 241, 87, 231, 88, 215, 211, 24, 254, 131, 111, 56, 160, 143, 230, 109]), - Bytes32::new_direct([144, 48, 37, 157, 153, 7, 123, 206, 46, 224, 211, 249, 208, 217, 91, 243, 128, 62, 100, 126, 3, 253, 223, 161, 50, 108, 26, 151, 129, 242, 94, 132]), - Bytes32::new_direct([97, 167, 177, 53, 183, 154, 164, 1, 129, 184, 234, 182, 190, 197, 244, 226, 150, 217, 57, 152, 243, 206, 60, 76, 114, 194, 51, 240, 58, 93, 219, 76]), - Bytes32::new_direct([139, 70, 147, 227, 94, 147, 130, 53, 38, 112, 138, 176, 7, 148, 6, 21, 50, 199, 70, 33, 87, 180, 33, 167, 56, 89, 66, 95, 245, 247, 135, 24]), - Bytes32::new_direct([175, 169, 204, 13, 145, 18, 40, 29, 84, 88, 206, 99, 208, 137, 249, 146, 0, 237, 188, 130, 135, 223, 121, 54, 126, 251, 247, 109, 141, 217, 62, 127]), - Bytes32::new_direct([139, 188, 3, 234, 198, 124, 194, 238, 217, 237, 214, 250, 66, 220, 0, 51, 1, 203, 122, 125, 46, 213, 22, 253, 8, 218, 145, 253, 170, 156, 159, 96]), - Bytes32::new_direct([107, 130, 208, 55, 16, 249, 46, 4, 98, 236, 130, 52, 190, 126, 232, 229, 108, 126, 239, 175, 25, 229, 84, 33, 249, 66, 128, 162, 47, 221, 110, 163]), - Bytes32::new_direct([239, 176, 14, 134, 210, 125, 177, 40, 200, 42, 229, 32, 200, 58, 9, 73, 210, 161, 8, 105, 4, 70, 19, 134, 117, 132, 167, 18, 16, 108, 207, 113]), - Bytes32::new_direct([237, 116, 250, 79, 151, 228, 171, 189, 89, 213, 122, 121, 55, 25, 52, 238, 79, 19, 31, 194, 73, 158, 43, 78, 86, 194, 36, 141, 105, 10, 87, 58]), - Bytes32::new_direct([216, 125, 158, 123, 121, 158, 74, 152, 46, 18, 196, 115, 233, 149, 205, 189, 10, 232, 174, 21, 2, 52, 202, 111, 74, 160, 191, 196, 84, 93, 98, 46]), - Bytes32::new_direct([201, 148, 124, 172, 62, 154, 127, 129, 205, 197, 134, 133, 144, 78, 47, 190, 197, 190, 103, 44, 129, 57, 155, 227, 152, 212, 130, 12, 192, 223, 244, 68]), - Bytes32::new_direct([102, 147, 19, 104, 237, 188, 140, 66, 166, 77, 105, 55, 5, 165, 143, 107, 91, 247, 53, 203, 187, 163, 109, 66, 19, 164, 153, 170, 82, 251, 148, 10]), - Bytes32::new_direct([33, 89, 246, 96, 201, 15, 77, 99, 252, 111, 250, 152, 124, 80, 50, 57, 197, 124, 254, 202, 246, 131, 11, 219, 249, 102, 35, 79, 100, 173, 146, 167]), - Bytes32::new_direct([6, 27, 205, 165, 249, 112, 70, 105, 232, 156, 155, 204, 71, 5, 21, 239, 91, 69, 248, 111, 218, 154, 187, 85, 118, 72, 210, 99, 138, 40, 233, 75]), + Bytes32::new_direct([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ]), + Bytes32::new_direct([ + 145, 218, 63, 74, 131, 182, 204, 163, 74, 206, 234, 50, 47, 3, 51, 74, 121, 225, 146, 237, + 5, 128, 20, 230, 243, 89, 33, 248, 136, 154, 189, 5, + ]), + Bytes32::new_direct([ + 36, 240, 95, 13, 214, 136, 92, 102, 96, 137, 39, 96, 108, 223, 147, 130, 220, 61, 147, 226, + 52, 133, 67, 223, 211, 164, 6, 53, 45, 117, 120, 241, + ]), + Bytes32::new_direct([ + 9, 2, 218, 34, 228, 8, 178, 127, 160, 30, 104, 198, 49, 37, 71, 115, 14, 35, 20, 15, 253, + 160, 147, 143, 24, 186, 12, 90, 41, 169, 30, 8, + ]), + Bytes32::new_direct([ + 137, 242, 105, 78, 161, 99, 76, 224, 226, 100, 216, 235, 156, 132, 214, 154, 107, 120, 197, + 113, 45, 221, 170, 119, 92, 228, 76, 139, 170, 159, 111, 58, + ]), + Bytes32::new_direct([ + 231, 165, 221, 185, 139, 22, 70, 40, 67, 162, 123, 94, 161, 156, 57, 53, 102, 217, 128, + 227, 18, 132, 17, 170, 90, 31, 214, 181, 249, 220, 70, 37, + ]), + Bytes32::new_direct([ + 171, 253, 174, 187, 9, 186, 87, 37, 22, 83, 13, 88, 75, 11, 177, 226, 237, 136, 132, 137, + 101, 109, 135, 192, 224, 80, 87, 105, 95, 81, 255, 21, + ]), + Bytes32::new_direct([ + 179, 50, 36, 230, 159, 162, 184, 132, 140, 121, 133, 155, 189, 44, 132, 93, 80, 79, 32, + 244, 131, 57, 79, 222, 104, 63, 224, 182, 91, 162, 73, 122, + ]), + Bytes32::new_direct([ + 17, 55, 206, 87, 127, 185, 135, 231, 41, 56, 166, 104, 229, 102, 222, 181, 236, 233, 230, + 39, 43, 163, 16, 1, 225, 86, 211, 51, 145, 7, 169, 84, + ]), + Bytes32::new_direct([ + 201, 174, 3, 154, 104, 190, 240, 99, 123, 201, 7, 118, 196, 85, 28, 247, 35, 232, 39, 25, + 151, 52, 167, 136, 179, 13, 213, 60, 138, 158, 39, 131, + ]), + Bytes32::new_direct([ + 35, 33, 109, 155, 171, 252, 195, 80, 10, 115, 40, 199, 250, 1, 241, 82, 146, 225, 118, 237, + 11, 125, 198, 97, 57, 21, 171, 237, 94, 60, 49, 32, + ]), + Bytes32::new_direct([ + 126, 95, 42, 157, 183, 168, 137, 120, 114, 64, 148, 170, 32, 156, 137, 96, 194, 91, 119, + 11, 20, 3, 30, 62, 118, 12, 31, 48, 245, 144, 252, 29, + ]), + Bytes32::new_direct([ + 48, 135, 201, 114, 103, 35, 8, 96, 5, 101, 125, 26, 87, 0, 98, 122, 239, 140, 230, 10, 102, + 112, 155, 87, 249, 181, 152, 235, 28, 79, 176, 56, + ]), + Bytes32::new_direct([ + 76, 70, 222, 210, 242, 159, 52, 123, 112, 106, 253, 140, 55, 160, 189, 255, 220, 64, 8, + 168, 39, 196, 160, 8, 105, 154, 91, 184, 62, 63, 227, 156, + ]), + Bytes32::new_direct([ + 138, 201, 8, 240, 218, 190, 210, 227, 236, 168, 45, 161, 209, 115, 126, 165, 235, 162, 6, + 117, 76, 239, 3, 225, 163, 251, 111, 233, 233, 228, 14, 92, + ]), + Bytes32::new_direct([ + 190, 166, 27, 117, 242, 0, 25, 148, 230, 125, 237, 22, 153, 158, 151, 56, 121, 194, 221, + 198, 184, 147, 249, 149, 27, 29, 166, 243, 254, 181, 209, 102, + ]), + Bytes32::new_direct([ + 235, 63, 149, 47, 164, 152, 80, 11, 178, 203, 99, 178, 176, 226, 164, 151, 39, 65, 83, 200, + 102, 90, 12, 102, 178, 15, 232, 16, 222, 141, 78, 3, + ]), + Bytes32::new_direct([ + 37, 179, 99, 114, 214, 120, 87, 53, 198, 229, 207, 47, 16, 112, 208, 33, 216, 152, 209, + 228, 196, 14, 237, 250, 212, 90, 176, 185, 21, 248, 92, 109, + ]), + Bytes32::new_direct([ + 237, 200, 122, 93, 145, 116, 138, 59, 86, 220, 58, 171, 160, 31, 142, 193, 231, 131, 106, + 164, 166, 44, 120, 170, 62, 81, 73, 85, 0, 52, 219, 220, + ]), + Bytes32::new_direct([ + 244, 173, 85, 141, 81, 198, 214, 0, 54, 21, 20, 169, 177, 235, 104, 206, 43, 218, 96, 68, + 73, 37, 252, 77, 253, 18, 30, 97, 223, 122, 1, 12, + ]), + Bytes32::new_direct([ + 104, 169, 247, 140, 131, 245, 193, 3, 36, 119, 249, 119, 108, 102, 115, 250, 173, 225, 33, + 156, 116, 87, 180, 27, 84, 215, 126, 15, 187, 189, 32, 139, + ]), + Bytes32::new_direct([ + 47, 156, 244, 88, 145, 227, 224, 87, 233, 138, 138, 9, 169, 96, 29, 204, 100, 170, 23, 105, + 63, 4, 119, 90, 167, 161, 72, 109, 82, 254, 123, 48, + ]), + Bytes32::new_direct([ + 196, 68, 107, 111, 141, 253, 138, 140, 162, 104, 247, 104, 87, 144, 123, 240, 105, 251, + 246, 210, 172, 172, 241, 162, 155, 90, 83, 175, 131, 251, 107, 215, + ]), + Bytes32::new_direct([ + 28, 100, 243, 226, 32, 234, 211, 106, 197, 179, 14, 192, 70, 11, 203, 125, 151, 53, 20, 77, + 175, 99, 154, 100, 159, 249, 54, 39, 73, 168, 162, 66, + ]), + Bytes32::new_direct([ + 83, 176, 7, 180, 201, 178, 172, 98, 47, 34, 80, 6, 62, 10, 4, 112, 43, 93, 10, 227, 74, 91, + 11, 217, 83, 230, 104, 0, 167, 2, 114, 89, + ]), + Bytes32::new_direct([ + 185, 162, 212, 82, 149, 182, 104, 215, 62, 244, 114, 124, 181, 74, 226, 119, 4, 42, 181, + 238, 25, 212, 215, 219, 174, 231, 32, 170, 9, 234, 12, 212, + ]), + Bytes32::new_direct([ + 173, 38, 241, 20, 137, 119, 33, 252, 174, 245, 252, 234, 165, 181, 128, 225, 14, 147, 182, + 97, 145, 19, 40, 193, 90, 238, 140, 87, 0, 222, 70, 254, + ]), + Bytes32::new_direct([ + 51, 218, 162, 213, 211, 23, 9, 158, 185, 156, 39, 145, 5, 146, 70, 144, 172, 10, 26, 212, + 253, 37, 24, 32, 21, 65, 179, 140, 64, 237, 96, 157, + ]), + Bytes32::new_direct([ + 221, 87, 57, 81, 246, 126, 53, 163, 190, 220, 109, 205, 114, 234, 85, 151, 75, 245, 254, + 16, 140, 131, 239, 120, 9, 209, 54, 61, 177, 6, 188, 252, + ]), + Bytes32::new_direct([ + 54, 161, 25, 198, 75, 151, 214, 76, 83, 74, 117, 229, 155, 237, 88, 95, 143, 119, 56, 12, + 201, 164, 235, 20, 117, 49, 177, 88, 14, 248, 95, 198, + ]), + Bytes32::new_direct([ + 60, 16, 183, 115, 241, 45, 253, 24, 105, 43, 79, 72, 212, 238, 24, 156, 132, 93, 78, 246, + 1, 228, 222, 200, 254, 130, 170, 46, 91, 254, 205, 143, + ]), + Bytes32::new_direct([ + 184, 30, 34, 235, 214, 40, 120, 64, 182, 15, 162, 189, 164, 202, 89, 146, 202, 177, 16, + 105, 172, 158, 1, 95, 101, 146, 253, 115, 226, 233, 38, 171, + ]), + Bytes32::new_direct([ + 70, 152, 3, 73, 249, 222, 93, 214, 74, 179, 140, 47, 34, 42, 149, 214, 152, 75, 34, 145, + 68, 226, 151, 101, 121, 54, 252, 240, 206, 140, 81, 165, + ]), + Bytes32::new_direct([ + 9, 88, 51, 124, 67, 108, 84, 244, 61, 241, 110, 246, 184, 105, 6, 116, 242, 58, 15, 144, + 43, 76, 176, 107, 0, 138, 155, 235, 210, 138, 226, 215, + ]), + Bytes32::new_direct([ + 98, 170, 168, 147, 158, 223, 186, 7, 58, 130, 89, 200, 153, 24, 158, 251, 69, 100, 7, 57, + 96, 115, 136, 170, 57, 145, 143, 240, 102, 6, 248, 111, + ]), + Bytes32::new_direct([ + 76, 75, 216, 216, 194, 146, 2, 59, 247, 64, 98, 160, 62, 105, 193, 186, 161, 191, 64, 154, + 254, 196, 55, 214, 201, 103, 223, 131, 181, 192, 152, 176, + ]), + Bytes32::new_direct([ + 188, 141, 114, 199, 33, 45, 183, 18, 123, 231, 92, 215, 51, 191, 11, 199, 253, 46, 28, 10, + 156, 23, 92, 255, 219, 236, 176, 247, 52, 105, 210, 223, + ]), + Bytes32::new_direct([ + 200, 67, 112, 29, 180, 70, 50, 18, 220, 122, 39, 122, 83, 186, 81, 77, 241, 44, 190, 3, + 162, 217, 76, 61, 230, 237, 157, 230, 205, 172, 186, 247, + ]), + Bytes32::new_direct([ + 131, 131, 129, 83, 251, 217, 83, 88, 93, 39, 66, 174, 51, 19, 190, 91, 16, 187, 95, 63, 35, + 178, 94, 237, 194, 42, 231, 227, 138, 202, 216, 93, + ]), + Bytes32::new_direct([ + 18, 177, 28, 41, 199, 59, 160, 244, 26, 162, 73, 48, 16, 74, 190, 195, 249, 216, 64, 229, + 145, 65, 18, 131, 75, 57, 71, 74, 127, 239, 112, 13, + ]), + Bytes32::new_direct([ + 41, 120, 53, 253, 151, 12, 143, 213, 212, 31, 245, 61, 168, 113, 30, 38, 112, 126, 156, + 133, 241, 102, 110, 237, 4, 138, 50, 160, 79, 235, 52, 35, + ]), + Bytes32::new_direct([ + 38, 74, 146, 27, 110, 86, 122, 250, 58, 243, 64, 185, 207, 174, 28, 124, 35, 183, 53, 88, + 34, 234, 89, 58, 98, 223, 69, 13, 48, 15, 239, 230, + ]), + Bytes32::new_direct([ + 221, 132, 1, 28, 157, 232, 235, 132, 32, 58, 26, 36, 60, 217, 197, 165, 141, 19, 64, 120, + 197, 139, 190, 86, 153, 152, 235, 11, 99, 129, 222, 91, + ]), + Bytes32::new_direct([ + 237, 76, 61, 239, 169, 108, 131, 62, 163, 67, 158, 210, 14, 45, 91, 105, 36, 182, 206, 182, + 71, 11, 159, 169, 159, 248, 247, 176, 6, 176, 237, 123, + ]), + Bytes32::new_direct([ + 232, 190, 198, 78, 12, 148, 86, 176, 221, 115, 1, 22, 122, 163, 223, 234, 74, 129, 125, 53, + 211, 137, 115, 18, 241, 170, 69, 42, 34, 74, 180, 172, + ]), + Bytes32::new_direct([ + 215, 199, 144, 158, 222, 153, 123, 125, 150, 97, 127, 151, 96, 43, 69, 155, 150, 119, 75, + 82, 218, 48, 101, 70, 121, 18, 42, 146, 215, 183, 100, 158, + ]), + Bytes32::new_direct([ + 121, 182, 45, 62, 255, 78, 32, 48, 107, 186, 208, 155, 158, 80, 231, 241, 90, 227, 219, + 113, 52, 20, 66, 45, 124, 67, 209, 61, 167, 74, 60, 34, + ]), + Bytes32::new_direct([ + 34, 136, 15, 103, 128, 220, 202, 103, 150, 123, 249, 145, 218, 227, 17, 64, 142, 129, 4, + 42, 93, 7, 6, 147, 111, 117, 25, 185, 88, 104, 85, 115, + ]), + Bytes32::new_direct([ + 144, 191, 235, 38, 205, 102, 127, 160, 139, 105, 75, 63, 86, 192, 194, 49, 240, 35, 65, + 154, 4, 113, 51, 87, 40, 70, 32, 58, 243, 16, 136, 67, + ]), + Bytes32::new_direct([ + 217, 150, 254, 250, 111, 69, 45, 227, 111, 59, 199, 149, 59, 216, 17, 117, 8, 226, 85, 250, + 183, 187, 21, 129, 208, 0, 63, 158, 232, 106, 131, 16, + ]), + Bytes32::new_direct([ + 148, 212, 84, 16, 204, 49, 69, 96, 137, 125, 102, 221, 111, 8, 41, 51, 221, 241, 87, 231, + 88, 215, 211, 24, 254, 131, 111, 56, 160, 143, 230, 109, + ]), + Bytes32::new_direct([ + 144, 48, 37, 157, 153, 7, 123, 206, 46, 224, 211, 249, 208, 217, 91, 243, 128, 62, 100, + 126, 3, 253, 223, 161, 50, 108, 26, 151, 129, 242, 94, 132, + ]), + Bytes32::new_direct([ + 97, 167, 177, 53, 183, 154, 164, 1, 129, 184, 234, 182, 190, 197, 244, 226, 150, 217, 57, + 152, 243, 206, 60, 76, 114, 194, 51, 240, 58, 93, 219, 76, + ]), + Bytes32::new_direct([ + 139, 70, 147, 227, 94, 147, 130, 53, 38, 112, 138, 176, 7, 148, 6, 21, 50, 199, 70, 33, 87, + 180, 33, 167, 56, 89, 66, 95, 245, 247, 135, 24, + ]), + Bytes32::new_direct([ + 175, 169, 204, 13, 145, 18, 40, 29, 84, 88, 206, 99, 208, 137, 249, 146, 0, 237, 188, 130, + 135, 223, 121, 54, 126, 251, 247, 109, 141, 217, 62, 127, + ]), + Bytes32::new_direct([ + 139, 188, 3, 234, 198, 124, 194, 238, 217, 237, 214, 250, 66, 220, 0, 51, 1, 203, 122, 125, + 46, 213, 22, 253, 8, 218, 145, 253, 170, 156, 159, 96, + ]), + Bytes32::new_direct([ + 107, 130, 208, 55, 16, 249, 46, 4, 98, 236, 130, 52, 190, 126, 232, 229, 108, 126, 239, + 175, 25, 229, 84, 33, 249, 66, 128, 162, 47, 221, 110, 163, + ]), + Bytes32::new_direct([ + 239, 176, 14, 134, 210, 125, 177, 40, 200, 42, 229, 32, 200, 58, 9, 73, 210, 161, 8, 105, + 4, 70, 19, 134, 117, 132, 167, 18, 16, 108, 207, 113, + ]), + Bytes32::new_direct([ + 237, 116, 250, 79, 151, 228, 171, 189, 89, 213, 122, 121, 55, 25, 52, 238, 79, 19, 31, 194, + 73, 158, 43, 78, 86, 194, 36, 141, 105, 10, 87, 58, + ]), + Bytes32::new_direct([ + 216, 125, 158, 123, 121, 158, 74, 152, 46, 18, 196, 115, 233, 149, 205, 189, 10, 232, 174, + 21, 2, 52, 202, 111, 74, 160, 191, 196, 84, 93, 98, 46, + ]), + Bytes32::new_direct([ + 201, 148, 124, 172, 62, 154, 127, 129, 205, 197, 134, 133, 144, 78, 47, 190, 197, 190, 103, + 44, 129, 57, 155, 227, 152, 212, 130, 12, 192, 223, 244, 68, + ]), + Bytes32::new_direct([ + 102, 147, 19, 104, 237, 188, 140, 66, 166, 77, 105, 55, 5, 165, 143, 107, 91, 247, 53, 203, + 187, 163, 109, 66, 19, 164, 153, 170, 82, 251, 148, 10, + ]), + Bytes32::new_direct([ + 33, 89, 246, 96, 201, 15, 77, 99, 252, 111, 250, 152, 124, 80, 50, 57, 197, 124, 254, 202, + 246, 131, 11, 219, 249, 102, 35, 79, 100, 173, 146, 167, + ]), + Bytes32::new_direct([ + 6, 27, 205, 165, 249, 112, 70, 105, 232, 156, 155, 204, 71, 5, 21, 239, 91, 69, 248, 111, + 218, 154, 187, 85, 118, 72, 210, 99, 138, 40, 233, 75, + ]), ]; const MODULE_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - Bytes32::new_direct([252, 178, 61, 5, 174, 66, 106, 30, 131, 163, 114, 90, 231, 83, 228, 153, 108, 255, 60, 37, 254, 139, 153, 129, 208, 156, 109, 74, 233, 129, 174, 182]), - Bytes32::new_direct([128, 23, 154, 62, 181, 220, 154, 183, 222, 214, 79, 76, 162, 169, 179, 162, 185, 93, 179, 115, 161, 55, 19, 63, 227, 168, 140, 66, 182, 6, 60, 120]), - Bytes32::new_direct([243, 119, 126, 55, 151, 128, 119, 12, 124, 84, 146, 243, 156, 68, 82, 174, 201, 162, 29, 73, 29, 77, 103, 205, 194, 250, 45, 133, 39, 71, 224, 177]), - Bytes32::new_direct([209, 179, 222, 187, 184, 84, 131, 182, 172, 78, 20, 104, 236, 246, 114, 74, 55, 98, 29, 34, 117, 249, 89, 76, 85, 38, 248, 193, 75, 10, 243, 100]), - Bytes32::new_direct([195, 14, 58, 139, 148, 140, 218, 174, 131, 204, 69, 84, 127, 8, 142, 88, 136, 83, 253, 241, 74, 247, 143, 204, 38, 15, 138, 98, 47, 188, 255, 245]), - Bytes32::new_direct([167, 4, 177, 126, 159, 76, 19, 220, 160, 159, 81, 227, 110, 147, 179, 175, 253, 187, 46, 24, 15, 168, 153, 84, 4, 167, 247, 225, 121, 175, 134, 85]), - Bytes32::new_direct([237, 144, 152, 155, 211, 100, 202, 187, 41, 181, 45, 224, 143, 139, 18, 77, 110, 34, 212, 207, 239, 180, 73, 84, 166, 194, 22, 149, 89, 215, 86, 21]), - Bytes32::new_direct([226, 192, 91, 176, 242, 185, 212, 189, 178, 80, 238, 252, 183, 82, 220, 242, 22, 237, 84, 142, 132, 91, 95, 219, 252, 171, 51, 76, 28, 146, 86, 155]), - Bytes32::new_direct([199, 200, 237, 66, 220, 14, 221, 121, 117, 150, 118, 36, 138, 142, 50, 173, 12, 195, 131, 90, 27, 189, 247, 221, 89, 151, 41, 27, 135, 207, 137, 172]), - Bytes32::new_direct([160, 60, 124, 200, 56, 240, 67, 161, 121, 95, 247, 51, 153, 249, 125, 88, 231, 2, 85, 167, 251, 187, 21, 103, 49, 132, 213, 52, 219, 30, 146, 59]), - Bytes32::new_direct([123, 52, 142, 254, 117, 160, 215, 99, 155, 130, 134, 183, 76, 99, 166, 246, 49, 51, 142, 67, 116, 234, 69, 199, 201, 19, 70, 3, 208, 247, 40, 82]), - Bytes32::new_direct([165, 32, 183, 79, 246, 224, 220, 103, 11, 160, 233, 66, 129, 238, 194, 73, 17, 37, 128, 185, 175, 88, 144, 228, 231, 185, 22, 17, 149, 174, 72, 1]), - Bytes32::new_direct([12, 24, 45, 128, 57, 246, 187, 176, 154, 247, 169, 18, 116, 176, 70, 246, 203, 141, 211, 104, 5, 147, 78, 214, 161, 71, 33, 97, 7, 21, 158, 61]), - Bytes32::new_direct([215, 18, 110, 29, 36, 34, 133, 219, 15, 204, 206, 158, 186, 213, 181, 41, 184, 160, 71, 165, 163, 121, 88, 106, 228, 58, 34, 105, 112, 168, 84, 123]), - Bytes32::new_direct([6, 169, 156, 220, 55, 53, 26, 229, 104, 60, 113, 111, 153, 18, 251, 234, 179, 159, 56, 14, 112, 7, 144, 199, 45, 180, 116, 239, 21, 207, 173, 205]), - Bytes32::new_direct([24, 172, 76, 192, 21, 91, 250, 75, 196, 119, 231, 221, 13, 239, 113, 39, 62, 40, 165, 26, 245, 16, 61, 106, 39, 28, 78, 212, 249, 230, 84, 108]), - Bytes32::new_direct([248, 34, 1, 62, 213, 235, 20, 21, 220, 78, 178, 126, 184, 102, 242, 50, 49, 174, 163, 122, 166, 96, 40, 110, 78, 199, 89, 158, 155, 251, 233, 49]), - Bytes32::new_direct([103, 54, 133, 19, 189, 117, 46, 209, 17, 2, 64, 251, 77, 195, 197, 91, 38, 48, 214, 36, 96, 255, 133, 87, 244, 101, 166, 218, 167, 129, 225, 167]), - Bytes32::new_direct([196, 159, 226, 85, 100, 246, 179, 251, 133, 33, 114, 51, 104, 245, 81, 54, 137, 126, 245, 76, 112, 146, 139, 185, 190, 19, 106, 132, 48, 203, 34, 237]), - Bytes32::new_direct([41, 190, 7, 23, 227, 80, 13, 134, 244, 18, 215, 148, 1, 72, 1, 22, 91, 165, 182, 69, 160, 179, 241, 106, 254, 116, 245, 131, 136, 35, 190, 226]), - Bytes32::new_direct([205, 132, 211, 121, 67, 210, 191, 102, 218, 92, 56, 204, 68, 160, 188, 100, 229, 80, 77, 27, 26, 86, 248, 86, 216, 39, 242, 211, 183, 139, 219, 83]), - Bytes32::new_direct([13, 215, 68, 100, 180, 74, 23, 58, 157, 140, 76, 31, 114, 254, 85, 78, 234, 40, 251, 199, 35, 204, 111, 243, 163, 64, 221, 21, 96, 55, 127, 118]), - Bytes32::new_direct([225, 14, 246, 105, 64, 96, 225, 200, 186, 66, 40, 253, 131, 80, 102, 178, 83, 22, 150, 32, 15, 139, 76, 172, 144, 3, 30, 43, 217, 213, 89, 43]), - Bytes32::new_direct([200, 83, 93, 27, 98, 246, 87, 100, 53, 166, 89, 138, 157, 88, 148, 245, 61, 115, 246, 20, 142, 156, 54, 237, 179, 64, 148, 218, 67, 5, 142, 248]), - Bytes32::new_direct([159, 25, 150, 25, 114, 252, 162, 57, 21, 125, 147, 111, 220, 117, 17, 107, 40, 21, 157, 183, 6, 63, 226, 37, 64, 179, 133, 58, 107, 245, 78, 14]), - Bytes32::new_direct([58, 243, 16, 193, 174, 42, 255, 46, 40, 128, 26, 167, 173, 164, 71, 226, 155, 205, 26, 127, 154, 24, 74, 244, 106, 251, 25, 221, 197, 176, 194, 17]), - Bytes32::new_direct([51, 47, 251, 206, 27, 9, 142, 27, 253, 132, 189, 62, 109, 150, 246, 2, 137, 90, 157, 185, 59, 96, 0, 154, 29, 17, 231, 3, 84, 95, 49, 51]), - Bytes32::new_direct([250, 158, 158, 248, 206, 150, 95, 254, 53, 140, 80, 102, 67, 26, 76, 127, 236, 86, 182, 120, 72, 239, 190, 118, 60, 77, 28, 82, 152, 234, 73, 201]), - Bytes32::new_direct([255, 137, 155, 144, 74, 231, 231, 43, 187, 202, 137, 66, 205, 37, 40, 225, 0, 33, 87, 137, 113, 163, 58, 64, 147, 74, 123, 128, 19, 156, 46, 83]), - Bytes32::new_direct([207, 61, 79, 4, 202, 96, 238, 144, 154, 230, 145, 65, 230, 130, 246, 10, 140, 71, 66, 246, 53, 230, 148, 1, 248, 103, 145, 149, 157, 38, 169, 8]), - Bytes32::new_direct([33, 168, 110, 82, 84, 151, 70, 98, 115, 2, 221, 116, 210, 10, 247, 189, 203, 245, 186, 86, 121, 142, 218, 95, 68, 241, 21, 219, 131, 241, 185, 203]), - Bytes32::new_direct([125, 247, 7, 149, 181, 71, 68, 141, 123, 207, 144, 83, 170, 27, 244, 37, 210, 148, 0, 140, 144, 159, 237, 216, 227, 247, 85, 229, 80, 174, 40, 48]), - Bytes32::new_direct([0, 205, 68, 89, 77, 97, 204, 140, 113, 244, 168, 76, 49, 137, 236, 21, 132, 99, 10, 206, 195, 206, 208, 120, 227, 77, 21, 223, 145, 227, 48, 139]), - Bytes32::new_direct([10, 153, 106, 155, 149, 65, 211, 247, 246, 5, 129, 126, 74, 14, 113, 168, 152, 154, 205, 139, 49, 2, 182, 65, 163, 15, 62, 126, 62, 16, 26, 36]), - Bytes32::new_direct([24, 251, 204, 187, 179, 146, 114, 66, 110, 182, 131, 248, 36, 170, 169, 128, 22, 221, 134, 193, 121, 189, 128, 94, 83, 255, 226, 37, 133, 83, 220, 181]), - Bytes32::new_direct([25, 52, 245, 155, 53, 39, 73, 130, 12, 73, 106, 255, 44, 204, 208, 41, 32, 126, 159, 98, 197, 67, 58, 90, 6, 146, 25, 166, 195, 194, 215, 70]), - Bytes32::new_direct([194, 167, 206, 222, 96, 6, 86, 241, 95, 105, 225, 147, 99, 93, 201, 220, 166, 145, 4, 25, 168, 188, 21, 168, 80, 163, 132, 216, 239, 19, 115, 36]), - Bytes32::new_direct([243, 16, 4, 9, 140, 42, 62, 105, 97, 7, 4, 234, 200, 227, 42, 10, 51, 167, 38, 148, 69, 154, 143, 179, 94, 177, 248, 28, 33, 61, 166, 187]), - Bytes32::new_direct([156, 201, 97, 197, 223, 83, 229, 186, 187, 33, 49, 210, 181, 222, 180, 234, 150, 33, 99, 168, 157, 26, 241, 1, 213, 220, 165, 8, 31, 76, 134, 243]), - Bytes32::new_direct([34, 218, 29, 74, 212, 218, 95, 6, 53, 10, 63, 174, 119, 90, 90, 35, 92, 124, 169, 222, 75, 61, 199, 118, 132, 40, 193, 9, 250, 80, 12, 197]), - Bytes32::new_direct([102, 137, 75, 155, 181, 222, 86, 192, 140, 167, 3, 178, 212, 165, 49, 163, 86, 8, 76, 240, 32, 202, 34, 159, 217, 173, 101, 125, 237, 34, 48, 179]), - Bytes32::new_direct([136, 53, 156, 19, 107, 234, 210, 218, 180, 236, 9, 7, 80, 63, 146, 57, 77, 106, 135, 64, 23, 184, 9, 139, 61, 237, 225, 157, 183, 182, 137, 31]), - Bytes32::new_direct([237, 226, 115, 218, 228, 122, 45, 46, 67, 21, 130, 204, 80, 2, 28, 47, 148, 191, 28, 33, 177, 47, 207, 14, 33, 117, 28, 46, 88, 254, 97, 227]), - Bytes32::new_direct([38, 87, 252, 28, 105, 20, 117, 29, 234, 237, 60, 91, 48, 101, 219, 219, 24, 52, 169, 243, 71, 214, 117, 41, 207, 17, 148, 77, 218, 44, 122, 167]), - Bytes32::new_direct([235, 31, 185, 222, 3, 22, 222, 174, 126, 128, 55, 67, 201, 229, 55, 28, 241, 144, 184, 85, 141, 153, 183, 211, 66, 80, 152, 248, 214, 130, 64, 205]), - Bytes32::new_direct([52, 169, 226, 179, 195, 44, 245, 101, 35, 92, 145, 174, 152, 212, 192, 148, 241, 72, 248, 61, 239, 124, 98, 213, 181, 75, 84, 121, 57, 90, 172, 164]), - Bytes32::new_direct([27, 19, 12, 74, 128, 193, 65, 63, 15, 6, 174, 167, 79, 56, 88, 13, 117, 6, 189, 14, 11, 13, 133, 136, 141, 64, 74, 17, 159, 192, 251, 242]), - Bytes32::new_direct([101, 69, 132, 221, 127, 162, 162, 92, 248, 131, 39, 52, 169, 170, 231, 137, 123, 106, 161, 16, 202, 242, 216, 245, 211, 170, 74, 128, 108, 243, 166, 38]), - Bytes32::new_direct([157, 82, 193, 234, 117, 199, 118, 245, 63, 31, 186, 32, 135, 233, 29, 213, 217, 119, 208, 64, 149, 116, 117, 129, 211, 225, 207, 22, 225, 99, 194, 222]), - Bytes32::new_direct([112, 194, 64, 229, 154, 223, 109, 8, 191, 120, 32, 176, 154, 7, 174, 103, 2, 156, 230, 164, 245, 252, 0, 116, 213, 40, 20, 239, 135, 62, 198, 42]), - Bytes32::new_direct([32, 91, 5, 170, 221, 134, 167, 144, 16, 130, 237, 114, 71, 184, 131, 223, 92, 149, 161, 68, 196, 56, 73, 148, 203, 187, 174, 178, 178, 53, 156, 177]), - Bytes32::new_direct([234, 97, 64, 211, 81, 59, 14, 249, 38, 8, 247, 37, 243, 37, 88, 234, 19, 54, 146, 63, 88, 79, 127, 190, 144, 51, 240, 19, 15, 143, 18, 9]), - Bytes32::new_direct([247, 102, 43, 28, 24, 201, 189, 198, 66, 58, 210, 51, 174, 234, 52, 239, 37, 83, 212, 184, 127, 170, 168, 127, 47, 11, 248, 213, 84, 3, 201, 181]), - Bytes32::new_direct([126, 18, 116, 33, 129, 25, 247, 2, 162, 202, 103, 201, 237, 67, 28, 80, 46, 182, 163, 239, 90, 204, 47, 196, 137, 79, 19, 165, 209, 84, 140, 132]), - Bytes32::new_direct([189, 160, 148, 101, 82, 248, 215, 206, 90, 91, 205, 148, 37, 38, 172, 82, 223, 228, 66, 173, 220, 246, 194, 73, 231, 17, 220, 47, 222, 175, 7, 24]), - Bytes32::new_direct([237, 149, 54, 210, 99, 72, 182, 55, 69, 140, 161, 215, 104, 90, 104, 26, 216, 241, 232, 210, 37, 77, 56, 216, 6, 160, 199, 247, 164, 227, 142, 255]), - Bytes32::new_direct([11, 57, 131, 77, 203, 89, 156, 126, 200, 215, 103, 209, 70, 235, 78, 247, 0, 126, 209, 248, 220, 135, 158, 244, 141, 74, 6, 158, 19, 37, 42, 39]), - Bytes32::new_direct([107, 131, 231, 102, 64, 182, 78, 253, 77, 143, 94, 34, 199, 93, 44, 131, 169, 211, 71, 223, 53, 230, 59, 107, 146, 22, 188, 207, 210, 220, 168, 129]), - Bytes32::new_direct([78, 71, 246, 216, 154, 188, 152, 6, 234, 254, 21, 1, 128, 148, 56, 91, 250, 95, 76, 103, 15, 250, 137, 186, 114, 254, 122, 69, 208, 242, 69, 111]), - Bytes32::new_direct([82, 241, 242, 155, 248, 109, 84, 118, 225, 255, 122, 40, 3, 87, 20, 223, 212, 205, 141, 178, 32, 229, 234, 146, 101, 73, 79, 55, 28, 82, 81, 178]), - Bytes32::new_direct([35, 169, 243, 198, 215, 220, 113, 91, 6, 79, 48, 201, 97, 143, 212, 34, 247, 46, 38, 93, 166, 213, 158, 218, 61, 86, 240, 149, 224, 174, 225, 73]), - Bytes32::new_direct([25, 108, 21, 212, 193, 192, 96, 39, 57, 72, 193, 99, 239, 0, 231, 83, 183, 195, 105, 33, 220, 187, 18, 148, 43, 30, 42, 127, 192, 240, 13, 224]), - Bytes32::new_direct([119, 117, 186, 31, 43, 128, 143, 25, 182, 135, 156, 58, 152, 81, 70, 116, 171, 137, 125, 157, 152, 163, 34, 65, 240, 178, 12, 24, 168, 111, 39, 35]), + Bytes32::new_direct([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ]), + Bytes32::new_direct([ + 252, 178, 61, 5, 174, 66, 106, 30, 131, 163, 114, 90, 231, 83, 228, 153, 108, 255, 60, 37, + 254, 139, 153, 129, 208, 156, 109, 74, 233, 129, 174, 182, + ]), + Bytes32::new_direct([ + 128, 23, 154, 62, 181, 220, 154, 183, 222, 214, 79, 76, 162, 169, 179, 162, 185, 93, 179, + 115, 161, 55, 19, 63, 227, 168, 140, 66, 182, 6, 60, 120, + ]), + Bytes32::new_direct([ + 243, 119, 126, 55, 151, 128, 119, 12, 124, 84, 146, 243, 156, 68, 82, 174, 201, 162, 29, + 73, 29, 77, 103, 205, 194, 250, 45, 133, 39, 71, 224, 177, + ]), + Bytes32::new_direct([ + 209, 179, 222, 187, 184, 84, 131, 182, 172, 78, 20, 104, 236, 246, 114, 74, 55, 98, 29, 34, + 117, 249, 89, 76, 85, 38, 248, 193, 75, 10, 243, 100, + ]), + Bytes32::new_direct([ + 195, 14, 58, 139, 148, 140, 218, 174, 131, 204, 69, 84, 127, 8, 142, 88, 136, 83, 253, 241, + 74, 247, 143, 204, 38, 15, 138, 98, 47, 188, 255, 245, + ]), + Bytes32::new_direct([ + 167, 4, 177, 126, 159, 76, 19, 220, 160, 159, 81, 227, 110, 147, 179, 175, 253, 187, 46, + 24, 15, 168, 153, 84, 4, 167, 247, 225, 121, 175, 134, 85, + ]), + Bytes32::new_direct([ + 237, 144, 152, 155, 211, 100, 202, 187, 41, 181, 45, 224, 143, 139, 18, 77, 110, 34, 212, + 207, 239, 180, 73, 84, 166, 194, 22, 149, 89, 215, 86, 21, + ]), + Bytes32::new_direct([ + 226, 192, 91, 176, 242, 185, 212, 189, 178, 80, 238, 252, 183, 82, 220, 242, 22, 237, 84, + 142, 132, 91, 95, 219, 252, 171, 51, 76, 28, 146, 86, 155, + ]), + Bytes32::new_direct([ + 199, 200, 237, 66, 220, 14, 221, 121, 117, 150, 118, 36, 138, 142, 50, 173, 12, 195, 131, + 90, 27, 189, 247, 221, 89, 151, 41, 27, 135, 207, 137, 172, + ]), + Bytes32::new_direct([ + 160, 60, 124, 200, 56, 240, 67, 161, 121, 95, 247, 51, 153, 249, 125, 88, 231, 2, 85, 167, + 251, 187, 21, 103, 49, 132, 213, 52, 219, 30, 146, 59, + ]), + Bytes32::new_direct([ + 123, 52, 142, 254, 117, 160, 215, 99, 155, 130, 134, 183, 76, 99, 166, 246, 49, 51, 142, + 67, 116, 234, 69, 199, 201, 19, 70, 3, 208, 247, 40, 82, + ]), + Bytes32::new_direct([ + 165, 32, 183, 79, 246, 224, 220, 103, 11, 160, 233, 66, 129, 238, 194, 73, 17, 37, 128, + 185, 175, 88, 144, 228, 231, 185, 22, 17, 149, 174, 72, 1, + ]), + Bytes32::new_direct([ + 12, 24, 45, 128, 57, 246, 187, 176, 154, 247, 169, 18, 116, 176, 70, 246, 203, 141, 211, + 104, 5, 147, 78, 214, 161, 71, 33, 97, 7, 21, 158, 61, + ]), + Bytes32::new_direct([ + 215, 18, 110, 29, 36, 34, 133, 219, 15, 204, 206, 158, 186, 213, 181, 41, 184, 160, 71, + 165, 163, 121, 88, 106, 228, 58, 34, 105, 112, 168, 84, 123, + ]), + Bytes32::new_direct([ + 6, 169, 156, 220, 55, 53, 26, 229, 104, 60, 113, 111, 153, 18, 251, 234, 179, 159, 56, 14, + 112, 7, 144, 199, 45, 180, 116, 239, 21, 207, 173, 205, + ]), + Bytes32::new_direct([ + 24, 172, 76, 192, 21, 91, 250, 75, 196, 119, 231, 221, 13, 239, 113, 39, 62, 40, 165, 26, + 245, 16, 61, 106, 39, 28, 78, 212, 249, 230, 84, 108, + ]), + Bytes32::new_direct([ + 248, 34, 1, 62, 213, 235, 20, 21, 220, 78, 178, 126, 184, 102, 242, 50, 49, 174, 163, 122, + 166, 96, 40, 110, 78, 199, 89, 158, 155, 251, 233, 49, + ]), + Bytes32::new_direct([ + 103, 54, 133, 19, 189, 117, 46, 209, 17, 2, 64, 251, 77, 195, 197, 91, 38, 48, 214, 36, 96, + 255, 133, 87, 244, 101, 166, 218, 167, 129, 225, 167, + ]), + Bytes32::new_direct([ + 196, 159, 226, 85, 100, 246, 179, 251, 133, 33, 114, 51, 104, 245, 81, 54, 137, 126, 245, + 76, 112, 146, 139, 185, 190, 19, 106, 132, 48, 203, 34, 237, + ]), + Bytes32::new_direct([ + 41, 190, 7, 23, 227, 80, 13, 134, 244, 18, 215, 148, 1, 72, 1, 22, 91, 165, 182, 69, 160, + 179, 241, 106, 254, 116, 245, 131, 136, 35, 190, 226, + ]), + Bytes32::new_direct([ + 205, 132, 211, 121, 67, 210, 191, 102, 218, 92, 56, 204, 68, 160, 188, 100, 229, 80, 77, + 27, 26, 86, 248, 86, 216, 39, 242, 211, 183, 139, 219, 83, + ]), + Bytes32::new_direct([ + 13, 215, 68, 100, 180, 74, 23, 58, 157, 140, 76, 31, 114, 254, 85, 78, 234, 40, 251, 199, + 35, 204, 111, 243, 163, 64, 221, 21, 96, 55, 127, 118, + ]), + Bytes32::new_direct([ + 225, 14, 246, 105, 64, 96, 225, 200, 186, 66, 40, 253, 131, 80, 102, 178, 83, 22, 150, 32, + 15, 139, 76, 172, 144, 3, 30, 43, 217, 213, 89, 43, + ]), + Bytes32::new_direct([ + 200, 83, 93, 27, 98, 246, 87, 100, 53, 166, 89, 138, 157, 88, 148, 245, 61, 115, 246, 20, + 142, 156, 54, 237, 179, 64, 148, 218, 67, 5, 142, 248, + ]), + Bytes32::new_direct([ + 159, 25, 150, 25, 114, 252, 162, 57, 21, 125, 147, 111, 220, 117, 17, 107, 40, 21, 157, + 183, 6, 63, 226, 37, 64, 179, 133, 58, 107, 245, 78, 14, + ]), + Bytes32::new_direct([ + 58, 243, 16, 193, 174, 42, 255, 46, 40, 128, 26, 167, 173, 164, 71, 226, 155, 205, 26, 127, + 154, 24, 74, 244, 106, 251, 25, 221, 197, 176, 194, 17, + ]), + Bytes32::new_direct([ + 51, 47, 251, 206, 27, 9, 142, 27, 253, 132, 189, 62, 109, 150, 246, 2, 137, 90, 157, 185, + 59, 96, 0, 154, 29, 17, 231, 3, 84, 95, 49, 51, + ]), + Bytes32::new_direct([ + 250, 158, 158, 248, 206, 150, 95, 254, 53, 140, 80, 102, 67, 26, 76, 127, 236, 86, 182, + 120, 72, 239, 190, 118, 60, 77, 28, 82, 152, 234, 73, 201, + ]), + Bytes32::new_direct([ + 255, 137, 155, 144, 74, 231, 231, 43, 187, 202, 137, 66, 205, 37, 40, 225, 0, 33, 87, 137, + 113, 163, 58, 64, 147, 74, 123, 128, 19, 156, 46, 83, + ]), + Bytes32::new_direct([ + 207, 61, 79, 4, 202, 96, 238, 144, 154, 230, 145, 65, 230, 130, 246, 10, 140, 71, 66, 246, + 53, 230, 148, 1, 248, 103, 145, 149, 157, 38, 169, 8, + ]), + Bytes32::new_direct([ + 33, 168, 110, 82, 84, 151, 70, 98, 115, 2, 221, 116, 210, 10, 247, 189, 203, 245, 186, 86, + 121, 142, 218, 95, 68, 241, 21, 219, 131, 241, 185, 203, + ]), + Bytes32::new_direct([ + 125, 247, 7, 149, 181, 71, 68, 141, 123, 207, 144, 83, 170, 27, 244, 37, 210, 148, 0, 140, + 144, 159, 237, 216, 227, 247, 85, 229, 80, 174, 40, 48, + ]), + Bytes32::new_direct([ + 0, 205, 68, 89, 77, 97, 204, 140, 113, 244, 168, 76, 49, 137, 236, 21, 132, 99, 10, 206, + 195, 206, 208, 120, 227, 77, 21, 223, 145, 227, 48, 139, + ]), + Bytes32::new_direct([ + 10, 153, 106, 155, 149, 65, 211, 247, 246, 5, 129, 126, 74, 14, 113, 168, 152, 154, 205, + 139, 49, 2, 182, 65, 163, 15, 62, 126, 62, 16, 26, 36, + ]), + Bytes32::new_direct([ + 24, 251, 204, 187, 179, 146, 114, 66, 110, 182, 131, 248, 36, 170, 169, 128, 22, 221, 134, + 193, 121, 189, 128, 94, 83, 255, 226, 37, 133, 83, 220, 181, + ]), + Bytes32::new_direct([ + 25, 52, 245, 155, 53, 39, 73, 130, 12, 73, 106, 255, 44, 204, 208, 41, 32, 126, 159, 98, + 197, 67, 58, 90, 6, 146, 25, 166, 195, 194, 215, 70, + ]), + Bytes32::new_direct([ + 194, 167, 206, 222, 96, 6, 86, 241, 95, 105, 225, 147, 99, 93, 201, 220, 166, 145, 4, 25, + 168, 188, 21, 168, 80, 163, 132, 216, 239, 19, 115, 36, + ]), + Bytes32::new_direct([ + 243, 16, 4, 9, 140, 42, 62, 105, 97, 7, 4, 234, 200, 227, 42, 10, 51, 167, 38, 148, 69, + 154, 143, 179, 94, 177, 248, 28, 33, 61, 166, 187, + ]), + Bytes32::new_direct([ + 156, 201, 97, 197, 223, 83, 229, 186, 187, 33, 49, 210, 181, 222, 180, 234, 150, 33, 99, + 168, 157, 26, 241, 1, 213, 220, 165, 8, 31, 76, 134, 243, + ]), + Bytes32::new_direct([ + 34, 218, 29, 74, 212, 218, 95, 6, 53, 10, 63, 174, 119, 90, 90, 35, 92, 124, 169, 222, 75, + 61, 199, 118, 132, 40, 193, 9, 250, 80, 12, 197, + ]), + Bytes32::new_direct([ + 102, 137, 75, 155, 181, 222, 86, 192, 140, 167, 3, 178, 212, 165, 49, 163, 86, 8, 76, 240, + 32, 202, 34, 159, 217, 173, 101, 125, 237, 34, 48, 179, + ]), + Bytes32::new_direct([ + 136, 53, 156, 19, 107, 234, 210, 218, 180, 236, 9, 7, 80, 63, 146, 57, 77, 106, 135, 64, + 23, 184, 9, 139, 61, 237, 225, 157, 183, 182, 137, 31, + ]), + Bytes32::new_direct([ + 237, 226, 115, 218, 228, 122, 45, 46, 67, 21, 130, 204, 80, 2, 28, 47, 148, 191, 28, 33, + 177, 47, 207, 14, 33, 117, 28, 46, 88, 254, 97, 227, + ]), + Bytes32::new_direct([ + 38, 87, 252, 28, 105, 20, 117, 29, 234, 237, 60, 91, 48, 101, 219, 219, 24, 52, 169, 243, + 71, 214, 117, 41, 207, 17, 148, 77, 218, 44, 122, 167, + ]), + Bytes32::new_direct([ + 235, 31, 185, 222, 3, 22, 222, 174, 126, 128, 55, 67, 201, 229, 55, 28, 241, 144, 184, 85, + 141, 153, 183, 211, 66, 80, 152, 248, 214, 130, 64, 205, + ]), + Bytes32::new_direct([ + 52, 169, 226, 179, 195, 44, 245, 101, 35, 92, 145, 174, 152, 212, 192, 148, 241, 72, 248, + 61, 239, 124, 98, 213, 181, 75, 84, 121, 57, 90, 172, 164, + ]), + Bytes32::new_direct([ + 27, 19, 12, 74, 128, 193, 65, 63, 15, 6, 174, 167, 79, 56, 88, 13, 117, 6, 189, 14, 11, 13, + 133, 136, 141, 64, 74, 17, 159, 192, 251, 242, + ]), + Bytes32::new_direct([ + 101, 69, 132, 221, 127, 162, 162, 92, 248, 131, 39, 52, 169, 170, 231, 137, 123, 106, 161, + 16, 202, 242, 216, 245, 211, 170, 74, 128, 108, 243, 166, 38, + ]), + Bytes32::new_direct([ + 157, 82, 193, 234, 117, 199, 118, 245, 63, 31, 186, 32, 135, 233, 29, 213, 217, 119, 208, + 64, 149, 116, 117, 129, 211, 225, 207, 22, 225, 99, 194, 222, + ]), + Bytes32::new_direct([ + 112, 194, 64, 229, 154, 223, 109, 8, 191, 120, 32, 176, 154, 7, 174, 103, 2, 156, 230, 164, + 245, 252, 0, 116, 213, 40, 20, 239, 135, 62, 198, 42, + ]), + Bytes32::new_direct([ + 32, 91, 5, 170, 221, 134, 167, 144, 16, 130, 237, 114, 71, 184, 131, 223, 92, 149, 161, 68, + 196, 56, 73, 148, 203, 187, 174, 178, 178, 53, 156, 177, + ]), + Bytes32::new_direct([ + 234, 97, 64, 211, 81, 59, 14, 249, 38, 8, 247, 37, 243, 37, 88, 234, 19, 54, 146, 63, 88, + 79, 127, 190, 144, 51, 240, 19, 15, 143, 18, 9, + ]), + Bytes32::new_direct([ + 247, 102, 43, 28, 24, 201, 189, 198, 66, 58, 210, 51, 174, 234, 52, 239, 37, 83, 212, 184, + 127, 170, 168, 127, 47, 11, 248, 213, 84, 3, 201, 181, + ]), + Bytes32::new_direct([ + 126, 18, 116, 33, 129, 25, 247, 2, 162, 202, 103, 201, 237, 67, 28, 80, 46, 182, 163, 239, + 90, 204, 47, 196, 137, 79, 19, 165, 209, 84, 140, 132, + ]), + Bytes32::new_direct([ + 189, 160, 148, 101, 82, 248, 215, 206, 90, 91, 205, 148, 37, 38, 172, 82, 223, 228, 66, + 173, 220, 246, 194, 73, 231, 17, 220, 47, 222, 175, 7, 24, + ]), + Bytes32::new_direct([ + 237, 149, 54, 210, 99, 72, 182, 55, 69, 140, 161, 215, 104, 90, 104, 26, 216, 241, 232, + 210, 37, 77, 56, 216, 6, 160, 199, 247, 164, 227, 142, 255, + ]), + Bytes32::new_direct([ + 11, 57, 131, 77, 203, 89, 156, 126, 200, 215, 103, 209, 70, 235, 78, 247, 0, 126, 209, 248, + 220, 135, 158, 244, 141, 74, 6, 158, 19, 37, 42, 39, + ]), + Bytes32::new_direct([ + 107, 131, 231, 102, 64, 182, 78, 253, 77, 143, 94, 34, 199, 93, 44, 131, 169, 211, 71, 223, + 53, 230, 59, 107, 146, 22, 188, 207, 210, 220, 168, 129, + ]), + Bytes32::new_direct([ + 78, 71, 246, 216, 154, 188, 152, 6, 234, 254, 21, 1, 128, 148, 56, 91, 250, 95, 76, 103, + 15, 250, 137, 186, 114, 254, 122, 69, 208, 242, 69, 111, + ]), + Bytes32::new_direct([ + 82, 241, 242, 155, 248, 109, 84, 118, 225, 255, 122, 40, 3, 87, 20, 223, 212, 205, 141, + 178, 32, 229, 234, 146, 101, 73, 79, 55, 28, 82, 81, 178, + ]), + Bytes32::new_direct([ + 35, 169, 243, 198, 215, 220, 113, 91, 6, 79, 48, 201, 97, 143, 212, 34, 247, 46, 38, 93, + 166, 213, 158, 218, 61, 86, 240, 149, 224, 174, 225, 73, + ]), + Bytes32::new_direct([ + 25, 108, 21, 212, 193, 192, 96, 39, 57, 72, 193, 99, 239, 0, 231, 83, 183, 195, 105, 33, + 220, 187, 18, 148, 43, 30, 42, 127, 192, 240, 13, 224, + ]), + Bytes32::new_direct([ + 119, 117, 186, 31, 43, 128, 143, 25, 182, 135, 156, 58, 152, 81, 70, 116, 171, 137, 125, + 157, 152, 163, 34, 65, 240, 178, 12, 24, 168, 111, 39, 35, + ]), ]; +pub const EMPTY_HASH: &Bytes32 = &Bytes32::new_direct([0; 32]); + pub const ZERO_HASHES: &[&[Bytes32; 64]; 7] = &[ VALUE_HASHES, FUNCTION_HASHES, @@ -477,4 +1823,4 @@ pub const ZERO_HASHES: &[&[Bytes32; 64]; 7] = &[ TABLE_HASHES, TABLE_ELEMENT_HASHES, MODULE_HASHES, -]; \ No newline at end of file +]; From b14bc8fa588ebbbea161977a731278ffdee17f16 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 2 May 2024 19:14:54 +0200 Subject: [PATCH 041/268] Fix the merkle_bench. Those pesky shift operators. --- arbitrator/prover/benches/merkle_bench.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arbitrator/prover/benches/merkle_bench.rs b/arbitrator/prover/benches/merkle_bench.rs index ee8905964f..a5f3059f97 100644 --- a/arbitrator/prover/benches/merkle_bench.rs +++ b/arbitrator/prover/benches/merkle_bench.rs @@ -44,8 +44,8 @@ fn merkle_benchmark(c: &mut Criterion) { fn merkle_construction(c: &mut Criterion) { let mut rng = rand::thread_rng(); - let mut leaves: Vec = Vec::with_capacity(1 >> 20); - for _ in 0..(1 >> 20) { + let mut leaves: Vec = Vec::with_capacity(1 << 20); + for _ in 0..(1 << 20) { leaves.push(Bytes32::from([rng.gen_range(0u8..9); 32])); } From 0a31e538fcb78d6b26ab958d96a4722fdd7b079f Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 2 May 2024 19:56:30 +0200 Subject: [PATCH 042/268] Maybe 10x performance improvement. This change has the internal mutability implemented with the `Arc>` pattern as well as changing the `memory.rs` to no longer pre-allocate the empty hashes for all of the memory it wants to consume. There is still some inefficency in that the `Merkle::resize()` method is still allocating a bunch of actual leaf entries when it doesn't need to. We should be allocating those when needed by the `Merkle::set` calls. It's also possible that this code doesn't actually work when tied into a real machine. Testing that next. --- arbitrator/bench/src/bin.rs | 1 + arbitrator/prover/src/memory.rs | 22 +++---- arbitrator/prover/src/merkle.rs | 110 +++++++++++++++++++++++++++++++- 3 files changed, 117 insertions(+), 16 deletions(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 23930652c2..a46614bedb 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -33,6 +33,7 @@ struct Args { fn main() -> eyre::Result<()> { let args = Args::parse(); + // let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24]; let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24]; if args.always_merkleize { println!("Running benchmark with always merkleize feature on"); diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 72407b15c7..36b5fd1175 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -111,22 +111,19 @@ impl Memory { #[cfg(not(feature = "rayon"))] let leaf_hashes = self.buffer.chunks(Self::LEAF_SIZE); - let mut leaf_hashes: Vec = leaf_hashes + let leaf_hashes: Vec = leaf_hashes .map(|leaf| { let mut full_leaf = [0u8; 32]; full_leaf[..leaf.len()].copy_from_slice(leaf); hash_leaf(full_leaf) }) .collect(); - if leaf_hashes.len() < leaves { - let empty_hash = hash_leaf([0u8; 32]); - leaf_hashes.resize(leaves, empty_hash); + let size = leaf_hashes.len(); + let mut m = Merkle::new_advanced(MerkleType::Memory, leaf_hashes, Self::MEMORY_LAYERS); + if size < leaves { + m.resize(leaves).expect("Couldn't resize merkle tree"); } - Cow::Owned(Merkle::new_advanced( - MerkleType::Memory, - leaf_hashes, - Self::MEMORY_LAYERS, - )) + Cow::Owned(m) } pub fn get_leaf_data(&self, leaf_idx: usize) -> [u8; Self::LEAF_SIZE] { @@ -309,11 +306,10 @@ impl Memory { pub fn resize(&mut self, new_size: usize) { self.buffer.resize(new_size, 0); - if let Some(merkle) = self.merkle.take() { - let extra = new_size - merkle.len(); + if let Some(mut merkle) = self.merkle.take() { merkle - .extend(vec![hash_leaf([0u8; 32]); extra]) - .expect("Couldn't extend merkle tree"); + .resize(new_size) + .expect("Couldn't resize merkle tree"); self.merkle = Some(merkle); } } diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 90671bde17..854dffb995 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -184,6 +184,9 @@ fn hash_node(ty: MerkleType, a: impl AsRef<[u8]>, b: impl AsRef<[u8]>) -> Bytes3 #[inline] fn capacity(layers: &Vec>) -> usize { + if layers.is_empty() { + return 0; + } let base: usize = 2; base.pow((layers.len() - 1).try_into().unwrap()) } @@ -235,7 +238,7 @@ impl Merkle { pub fn new_advanced(ty: MerkleType, hashes: Vec, min_depth: usize) -> Merkle { #[cfg(feature = "counters")] NEW_COUNTERS[&ty].fetch_add(1, Ordering::Relaxed); - if hashes.is_empty() { + if hashes.is_empty() && min_depth == 0 { return Merkle::default(); } let mut depth = (hashes.len() as f64).log2().ceil() as usize; @@ -306,7 +309,6 @@ impl Merkle { // Returns the total number of leaves the tree can hold. #[inline] - #[cfg(test)] fn capacity(&self) -> usize { return capacity(self.layers.lock().unwrap().as_ref()); } @@ -410,6 +412,28 @@ impl Merkle { } Ok(layers[0].len()) } + + /// Resizes the number of leaves the tree can hold. + /// + /// The extra space is filled with empty hashes. + pub fn resize(&mut self, new_len: usize) -> Result { + if new_len > self.capacity() { + return Err( + "Cannot resize to a length greater than the capacity of the tree.".to_owned(), + ); + } + let mut layers = self.layers.lock().unwrap(); + let mut layer_size = new_len; + for (layer_i, layer) in layers.iter_mut().enumerate() { + layer.resize(layer_size, *empty_hash_at(self.ty, layer_i)); + layer_size = max(layer_size >> 1, 1); + } + let start = layers[0].len(); + for i in start..new_len { + self.dirty_layers.lock().unwrap()[0].insert(i); + } + Ok(layers[0].len()) + } } impl PartialEq for Merkle { @@ -525,6 +549,86 @@ fn extend_works() { merkle.prove(1).unwrap(); } +#[test] +fn resize_works() { + let hashes = vec![ + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + Bytes32::from([5; 32]), + ]; + let mut expected = hash_node( + MerkleType::Value, + hash_node( + MerkleType::Value, + hash_node( + MerkleType::Value, + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + ), + ), + hash_node( + MerkleType::Value, + hash_node( + MerkleType::Value, + Bytes32::from([5; 32]), + Bytes32::from([0; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([0; 32]), + Bytes32::from([0; 32]), + ), + ), + ); + let mut merkle = Merkle::new(MerkleType::Value, hashes.clone()); + assert_eq!(merkle.capacity(), 8); + assert_eq!(merkle.root(), expected); + + let new_size = match merkle.resize(6) { + Ok(size) => size, + Err(e) => panic!("{}", e), + }; + assert_eq!(new_size, 6); + merkle.set(5, Bytes32::from([6; 32])); + expected = hash_node( + MerkleType::Value, + hash_node( + MerkleType::Value, + hash_node( + MerkleType::Value, + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + ), + ), + hash_node( + MerkleType::Value, + hash_node( + MerkleType::Value, + Bytes32::from([5; 32]), + Bytes32::from([6; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([0; 32]), + Bytes32::from([0; 32]), + ), + ), + ); + assert_eq!(merkle.root(), expected); +} + #[test] fn correct_capacity() { let merkle = Merkle::new(MerkleType::Value, vec![Bytes32::from([1; 32])]); @@ -536,7 +640,7 @@ fn correct_capacity() { #[test] #[should_panic(expected = "index out of bounds")] fn set_with_bad_index_panics() { - let mut merkle = Merkle::new( + let merkle = Merkle::new( MerkleType::Value, vec![Bytes32::default(), Bytes32::default()], ); From 19fcd64f8fde5635880395588a541b7b41b0c71f Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 2 May 2024 22:20:01 +0200 Subject: [PATCH 043/268] Update the zerohashes to use the ones from memory.rs. Before this change, the MerkleType::MEMORY was loosely coupled to the Memory class. But, the Memory::merkleize() method was doing a lot of work to pass in a long vector of empty leaf hashes, and overriding the default empty node's hash. This change makes it the responsibility of the zerohashes constants to know what the correct empty node hashes are for each layer in a MEMORY merkle tree. But, that just happens to be the same value that the Memory::merkleize method would have used if it were allowed to specify it. This way, the code doesn't break backward compatibility with anywhere the old values were stored. --- arbitrator/prover/src/memory.rs | 14 ++ arbitrator/prover/src/merkle.rs | 31 ++- arbitrator/prover/src/merkle/zerohashes.rs | 257 +++++++++++---------- 3 files changed, 172 insertions(+), 130 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 36b5fd1175..576770fde6 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -319,6 +319,20 @@ impl Memory { mod test { use crate::memory::round_up_to_power_of_two; + #[test] + pub fn empty_leaf_hash() { + let leaf = [0u8; 32]; + let hash = super::hash_leaf(leaf); + print!("Bytes32::new_direct(["); + for i in 0..32 { + print!("{}", hash[i]); + if i < 31 { + print!(", "); + } + } + print!("]);"); + } + #[test] pub fn test_round_up_power_of_two() { assert_eq!(round_up_to_power_of_two(0), 1); diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 854dffb995..560c514ced 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -3,12 +3,12 @@ use arbutil::Bytes32; use digest::Digest; -use itertools::sorted; use enum_iterator::Sequence; #[cfg(feature = "counters")] use enum_iterator::all; +use itertools::Itertools; use std::cmp::max; @@ -274,7 +274,7 @@ impl Merkle { for layer_i in 1..layers.len() { let dirty_i = layer_i - 1; let dirt = dirty_layers[dirty_i].clone(); - for idx in sorted(dirt.iter()) { + for idx in dirt.iter().sorted() { let left_child_idx = idx << 1; let right_child_idx = left_child_idx + 1; let left = layers[layer_i - 1][left_child_idx]; @@ -334,6 +334,7 @@ impl Merkle { /// creates a merkle proof regardless of if the leaf has content #[must_use] pub fn prove_any(&self, mut idx: usize) -> Vec { + self.rehash(); let layers = self.layers.lock().unwrap(); let mut proof = vec![u8::try_from(layers.len() - 1).unwrap()]; for (layer_i, layer) in layers.iter().enumerate() { @@ -637,6 +638,32 @@ fn correct_capacity() { assert_eq!(merkle.capacity(), 1024); } +#[test] +#[ignore = "This is just used for generating the zero hashes for the memory merkle trees."] +fn emit_memory_zerohashes() { + // The following code was generated from the empty_leaf_hash() test in the memory package. + let mut left = Bytes32::new_direct([ + 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, 186, + 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, + ]); + let mut right = Bytes32::new_direct([ + 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, 186, + 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, + ]); + for _ in 0..64 { + print!("Bytes32::new_direct(["); + for i in 0..32 { + print!("{}", left[i]); + if i < 31 { + print!(", "); + } + } + println!("]),"); + left = hash_node(MerkleType::Memory, left, right); + right = hash_node(MerkleType::Memory, left, right); + } +} + #[test] #[should_panic(expected = "index out of bounds")] fn set_with_bad_index_panics() { diff --git a/arbitrator/prover/src/merkle/zerohashes.rs b/arbitrator/prover/src/merkle/zerohashes.rs index acb5757d61..16a4bd8457 100644 --- a/arbitrator/prover/src/merkle/zerohashes.rs +++ b/arbitrator/prover/src/merkle/zerohashes.rs @@ -777,262 +777,263 @@ const INSTRUCTION_HASHES: &[Bytes32; 64] = &[ ]), ]; +/// These have been pre-calculated to match the current implementation of Memory::hash_leaf. const MEMORY_HASHES: &[Bytes32; 64] = &[ Bytes32::new_direct([ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, + 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, 186, + 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, ]), Bytes32::new_direct([ - 66, 208, 130, 169, 194, 116, 5, 27, 68, 75, 235, 175, 164, 169, 41, 91, 88, 134, 51, 194, - 219, 201, 182, 199, 1, 52, 173, 215, 20, 37, 51, 0, + 190, 70, 141, 125, 34, 236, 162, 217, 92, 130, 99, 237, 252, 176, 62, 93, 182, 71, 180, + 204, 178, 127, 225, 18, 119, 68, 89, 244, 245, 143, 151, 9, ]), Bytes32::new_direct([ - 90, 210, 50, 227, 58, 173, 147, 92, 139, 15, 127, 190, 196, 111, 142, 207, 31, 223, 70, 96, - 17, 251, 164, 200, 133, 0, 76, 35, 200, 9, 51, 218, + 138, 210, 20, 48, 168, 152, 201, 72, 74, 157, 83, 120, 248, 186, 217, 22, 74, 60, 199, 181, + 52, 97, 24, 26, 166, 215, 235, 19, 24, 173, 50, 5, ]), Bytes32::new_direct([ - 97, 5, 162, 226, 92, 108, 172, 8, 7, 65, 104, 176, 216, 3, 144, 47, 14, 88, 50, 101, 194, - 94, 10, 132, 192, 76, 37, 152, 42, 73, 30, 2, + 132, 142, 241, 159, 152, 112, 200, 35, 177, 158, 88, 170, 78, 253, 191, 235, 187, 54, 23, + 74, 119, 177, 79, 61, 245, 5, 125, 130, 89, 112, 8, 215, ]), Bytes32::new_direct([ - 68, 59, 208, 14, 89, 37, 33, 1, 177, 225, 235, 66, 129, 28, 103, 156, 46, 206, 94, 141, 33, - 152, 141, 26, 209, 161, 53, 237, 198, 163, 115, 57, + 232, 72, 169, 41, 1, 17, 49, 197, 245, 83, 27, 42, 83, 152, 126, 121, 123, 161, 152, 55, + 217, 150, 120, 17, 175, 27, 60, 133, 32, 99, 101, 250, ]), Bytes32::new_direct([ - 28, 94, 12, 53, 70, 163, 95, 44, 168, 42, 196, 126, 181, 231, 174, 247, 89, 100, 77, 238, - 211, 74, 116, 144, 183, 111, 254, 75, 30, 187, 228, 222, + 209, 26, 146, 121, 215, 34, 75, 215, 173, 237, 120, 5, 194, 146, 223, 43, 239, 13, 187, 30, + 20, 47, 249, 110, 83, 166, 67, 199, 182, 55, 163, 148, ]), Bytes32::new_direct([ - 238, 133, 50, 189, 14, 89, 244, 88, 239, 50, 172, 85, 172, 1, 131, 2, 24, 161, 70, 94, 0, - 204, 50, 199, 48, 107, 30, 70, 6, 8, 18, 90, + 135, 209, 119, 98, 227, 84, 19, 108, 100, 236, 155, 117, 164, 95, 218, 166, 179, 7, 107, + 113, 206, 187, 188, 255, 134, 99, 57, 190, 193, 203, 40, 160, ]), Bytes32::new_direct([ - 165, 239, 71, 173, 192, 165, 25, 35, 4, 130, 148, 158, 177, 193, 129, 45, 115, 209, 7, 233, - 136, 108, 245, 126, 74, 200, 22, 204, 190, 137, 191, 105, + 32, 32, 24, 177, 70, 250, 175, 6, 212, 200, 28, 52, 130, 190, 221, 115, 130, 66, 87, 39, + 149, 242, 233, 170, 150, 241, 111, 201, 37, 170, 53, 157, ]), Bytes32::new_direct([ - 173, 102, 127, 73, 167, 249, 117, 26, 190, 231, 26, 60, 201, 138, 160, 182, 180, 44, 34, - 132, 171, 254, 91, 8, 167, 114, 188, 157, 181, 148, 169, 165, + 46, 83, 161, 19, 97, 192, 213, 207, 160, 235, 147, 29, 45, 186, 80, 204, 85, 149, 79, 64, + 242, 252, 127, 68, 37, 126, 65, 219, 105, 166, 239, 58, ]), Bytes32::new_direct([ - 71, 62, 70, 89, 203, 1, 105, 187, 178, 167, 217, 118, 42, 217, 154, 234, 238, 109, 145, - 231, 247, 199, 40, 110, 162, 11, 173, 144, 103, 110, 99, 101, + 92, 232, 243, 48, 112, 221, 12, 155, 90, 24, 101, 39, 52, 148, 44, 192, 33, 241, 250, 139, + 215, 204, 3, 148, 172, 247, 133, 116, 34, 15, 96, 171, ]), Bytes32::new_direct([ - 121, 36, 94, 4, 25, 134, 16, 98, 198, 109, 123, 42, 56, 151, 224, 7, 232, 155, 231, 154, - 229, 162, 250, 149, 231, 198, 0, 65, 17, 27, 181, 28, + 178, 251, 194, 203, 145, 18, 131, 236, 77, 185, 182, 102, 222, 1, 0, 200, 162, 94, 165, + 131, 73, 210, 194, 149, 123, 198, 77, 105, 40, 162, 188, 220, ]), Bytes32::new_direct([ - 247, 158, 162, 102, 242, 117, 166, 252, 175, 158, 107, 157, 244, 44, 17, 99, 93, 52, 43, - 136, 5, 211, 32, 152, 91, 148, 41, 32, 231, 18, 237, 208, + 212, 120, 226, 169, 131, 103, 29, 244, 133, 118, 133, 194, 150, 180, 119, 78, 209, 199, + 231, 248, 150, 30, 208, 248, 202, 98, 173, 195, 192, 150, 207, 41, ]), Bytes32::new_direct([ - 147, 52, 155, 255, 81, 242, 75, 54, 54, 66, 166, 41, 131, 177, 183, 151, 229, 177, 232, 86, - 146, 137, 106, 68, 226, 117, 20, 210, 224, 170, 249, 68, + 2, 68, 204, 114, 30, 60, 87, 24, 156, 226, 181, 122, 95, 226, 120, 216, 82, 237, 156, 142, + 190, 105, 2, 224, 55, 63, 204, 98, 216, 226, 141, 42, ]), Bytes32::new_direct([ - 160, 89, 180, 156, 119, 172, 38, 10, 97, 101, 64, 56, 98, 133, 199, 228, 58, 66, 139, 128, - 88, 140, 143, 85, 148, 167, 79, 75, 34, 45, 204, 68, + 11, 217, 134, 64, 229, 175, 220, 212, 248, 63, 138, 216, 241, 116, 151, 248, 104, 232, 207, + 232, 67, 106, 138, 62, 180, 178, 46, 83, 36, 101, 169, 244, ]), Bytes32::new_direct([ - 165, 233, 117, 3, 27, 56, 166, 16, 56, 132, 198, 32, 11, 149, 212, 98, 64, 236, 180, 106, - 174, 80, 122, 220, 102, 67, 67, 110, 67, 8, 48, 217, + 178, 176, 193, 132, 188, 190, 13, 56, 161, 182, 230, 231, 145, 233, 98, 31, 142, 60, 139, + 145, 38, 166, 104, 140, 244, 19, 236, 208, 164, 199, 195, 185, ]), Bytes32::new_direct([ - 113, 74, 209, 139, 250, 181, 182, 127, 178, 77, 17, 63, 79, 109, 145, 74, 52, 102, 125, - 154, 22, 241, 177, 177, 34, 189, 124, 22, 4, 200, 201, 76, + 90, 202, 183, 64, 67, 146, 97, 5, 29, 214, 222, 104, 152, 252, 74, 122, 100, 43, 41, 221, + 222, 25, 247, 226, 197, 190, 93, 192, 86, 114, 147, 131, ]), Bytes32::new_direct([ - 67, 7, 240, 151, 128, 149, 238, 113, 130, 127, 174, 223, 142, 124, 230, 10, 91, 89, 113, - 157, 230, 21, 213, 3, 146, 249, 26, 80, 239, 90, 4, 216, + 159, 87, 235, 78, 106, 222, 69, 92, 125, 102, 216, 34, 85, 52, 156, 187, 167, 111, 156, + 183, 215, 169, 246, 3, 194, 74, 194, 158, 239, 123, 204, 201, ]), Bytes32::new_direct([ - 152, 20, 80, 244, 232, 182, 1, 145, 31, 191, 46, 207, 83, 199, 209, 104, 0, 75, 106, 230, - 16, 98, 121, 127, 175, 78, 119, 154, 69, 55, 66, 169, + 79, 225, 161, 133, 98, 124, 23, 177, 237, 126, 97, 48, 89, 98, 189, 200, 80, 234, 250, 231, + 188, 89, 185, 167, 139, 37, 35, 24, 112, 253, 165, 232, ]), Bytes32::new_direct([ - 123, 50, 162, 158, 51, 112, 129, 232, 242, 158, 150, 72, 244, 40, 191, 63, 205, 61, 144, - 39, 65, 122, 28, 88, 253, 146, 29, 29, 15, 40, 122, 95, + 198, 248, 143, 133, 37, 221, 33, 117, 172, 103, 241, 199, 2, 137, 186, 107, 166, 47, 179, + 169, 221, 65, 254, 170, 206, 104, 117, 243, 169, 180, 252, 103, ]), Bytes32::new_direct([ - 231, 253, 202, 45, 165, 158, 212, 29, 104, 165, 209, 179, 188, 154, 89, 18, 216, 23, 140, - 66, 150, 49, 99, 200, 163, 155, 50, 9, 250, 22, 19, 203, + 227, 45, 217, 82, 36, 209, 164, 147, 113, 11, 26, 171, 37, 59, 161, 15, 217, 146, 38, 34, + 13, 149, 85, 67, 113, 115, 113, 192, 144, 255, 31, 227, ]), Bytes32::new_direct([ - 127, 172, 110, 243, 156, 134, 199, 15, 248, 216, 12, 196, 221, 66, 202, 186, 105, 197, 43, - 245, 46, 116, 251, 133, 111, 118, 56, 214, 157, 244, 187, 58, + 232, 69, 104, 93, 119, 165, 151, 208, 91, 19, 184, 192, 189, 65, 2, 101, 113, 11, 201, 57, + 76, 79, 177, 65, 72, 112, 203, 61, 33, 147, 104, 218, ]), Bytes32::new_direct([ - 181, 181, 163, 95, 7, 188, 245, 128, 161, 210, 137, 217, 103, 101, 120, 255, 47, 83, 102, - 68, 238, 195, 206, 105, 24, 150, 216, 50, 74, 6, 94, 95, + 53, 124, 30, 59, 195, 224, 250, 252, 201, 173, 143, 69, 253, 249, 201, 120, 178, 107, 234, + 244, 106, 3, 203, 223, 32, 193, 17, 23, 229, 108, 83, 83, ]), Bytes32::new_direct([ - 171, 250, 198, 40, 153, 26, 240, 152, 96, 169, 15, 123, 33, 155, 57, 172, 89, 205, 9, 65, - 45, 126, 155, 143, 224, 145, 25, 214, 19, 227, 213, 195, + 111, 38, 112, 152, 63, 120, 95, 83, 255, 53, 254, 22, 61, 218, 177, 18, 63, 73, 239, 119, + 109, 21, 2, 171, 152, 196, 246, 85, 251, 83, 141, 107, ]), Bytes32::new_direct([ - 44, 177, 244, 220, 119, 33, 203, 59, 209, 72, 28, 4, 210, 54, 86, 20, 119, 41, 45, 231, - 143, 104, 57, 206, 212, 222, 81, 62, 92, 221, 200, 32, + 12, 210, 136, 9, 253, 193, 146, 161, 74, 199, 75, 177, 83, 196, 149, 95, 8, 100, 216, 157, + 210, 237, 179, 35, 30, 78, 8, 22, 5, 167, 244, 106, ]), Bytes32::new_direct([ - 37, 200, 165, 195, 67, 224, 131, 227, 97, 54, 21, 233, 76, 186, 6, 122, 178, 131, 252, 59, - 97, 218, 239, 62, 124, 255, 201, 178, 241, 236, 4, 214, + 243, 71, 83, 219, 108, 40, 60, 96, 203, 129, 93, 149, 23, 152, 80, 88, 31, 214, 120, 50, + 178, 251, 197, 216, 50, 191, 146, 242, 107, 117, 120, 241, ]), Bytes32::new_direct([ - 77, 171, 229, 183, 46, 112, 203, 177, 89, 90, 64, 114, 109, 220, 32, 120, 41, 223, 72, 86, - 59, 211, 110, 17, 129, 112, 194, 186, 200, 92, 144, 49, + 131, 216, 197, 129, 234, 215, 44, 252, 0, 196, 182, 81, 58, 35, 73, 134, 221, 222, 183, 49, + 234, 120, 75, 197, 162, 30, 175, 200, 138, 50, 29, 53, ]), Bytes32::new_direct([ - 2, 198, 61, 112, 181, 185, 194, 114, 149, 63, 65, 76, 55, 179, 170, 62, 91, 112, 189, 100, - 13, 34, 98, 187, 85, 132, 202, 86, 47, 27, 236, 200, + 192, 239, 89, 211, 179, 226, 174, 23, 223, 197, 246, 12, 192, 241, 143, 221, 244, 36, 31, + 100, 254, 237, 147, 207, 173, 228, 9, 193, 51, 242, 18, 134, ]), Bytes32::new_direct([ - 164, 238, 109, 209, 155, 118, 236, 237, 84, 43, 56, 99, 51, 60, 116, 235, 100, 39, 163, - 105, 34, 93, 8, 187, 228, 213, 35, 200, 43, 8, 32, 68, + 77, 66, 182, 195, 7, 198, 199, 94, 24, 221, 103, 169, 91, 239, 34, 46, 177, 172, 213, 70, + 120, 32, 25, 101, 48, 214, 104, 125, 133, 90, 176, 242, ]), Bytes32::new_direct([ - 32, 220, 39, 200, 214, 245, 102, 200, 167, 204, 3, 54, 140, 126, 129, 35, 139, 60, 112, - 133, 52, 166, 162, 63, 119, 20, 2, 116, 132, 244, 246, 225, + 73, 194, 146, 182, 168, 1, 41, 95, 74, 146, 7, 16, 189, 96, 68, 218, 13, 28, 28, 126, 34, + 95, 188, 90, 36, 37, 123, 123, 53, 210, 23, 71, ]), Bytes32::new_direct([ - 5, 54, 145, 188, 188, 251, 36, 4, 103, 140, 229, 143, 83, 11, 77, 207, 57, 125, 51, 127, - 89, 130, 138, 193, 190, 17, 17, 23, 68, 168, 231, 106, + 160, 84, 92, 145, 163, 106, 94, 229, 208, 172, 17, 30, 90, 138, 5, 21, 70, 113, 113, 24, + 231, 220, 117, 38, 242, 226, 1, 63, 150, 13, 126, 125, ]), Bytes32::new_direct([ - 239, 112, 72, 74, 116, 134, 210, 24, 226, 242, 91, 113, 99, 59, 19, 7, 226, 215, 254, 220, - 14, 225, 75, 245, 11, 234, 138, 52, 195, 86, 79, 124, + 60, 239, 17, 50, 191, 31, 160, 151, 44, 128, 44, 89, 85, 11, 4, 91, 129, 104, 0, 4, 197, + 196, 189, 249, 73, 206, 63, 225, 7, 61, 107, 169, ]), Bytes32::new_direct([ - 187, 35, 132, 188, 162, 128, 96, 71, 124, 213, 251, 229, 73, 52, 187, 22, 166, 35, 214, 14, - 121, 189, 37, 5, 77, 54, 201, 51, 95, 179, 75, 229, + 254, 250, 117, 203, 85, 163, 150, 58, 59, 247, 98, 144, 14, 70, 100, 248, 28, 14, 157, 212, + 104, 137, 17, 133, 43, 206, 209, 152, 236, 229, 94, 67, ]), Bytes32::new_direct([ - 5, 54, 88, 42, 68, 200, 45, 209, 121, 70, 128, 8, 178, 212, 197, 39, 101, 90, 101, 111, 77, - 133, 13, 77, 19, 111, 113, 122, 222, 85, 180, 82, + 49, 191, 233, 164, 188, 247, 147, 203, 222, 173, 79, 244, 84, 143, 112, 144, 96, 96, 165, + 199, 199, 196, 229, 133, 15, 38, 219, 209, 133, 47, 199, 245, ]), Bytes32::new_direct([ - 34, 182, 144, 13, 35, 35, 79, 14, 239, 80, 21, 255, 67, 48, 210, 174, 159, 182, 239, 236, - 68, 46, 125, 105, 243, 202, 218, 64, 53, 94, 159, 253, + 164, 27, 202, 130, 161, 245, 153, 150, 235, 26, 152, 212, 54, 239, 71, 55, 172, 81, 226, + 79, 44, 110, 71, 168, 43, 210, 243, 189, 163, 3, 57, 199, ]), Bytes32::new_direct([ - 224, 189, 145, 186, 43, 169, 131, 161, 223, 161, 72, 72, 229, 97, 113, 233, 2, 250, 109, - 31, 19, 125, 57, 135, 144, 3, 187, 18, 102, 108, 232, 9, + 22, 164, 24, 66, 118, 132, 197, 4, 124, 220, 178, 135, 160, 220, 15, 3, 122, 35, 22, 59, + 233, 15, 104, 230, 58, 145, 34, 216, 88, 153, 185, 112, ]), Bytes32::new_direct([ - 68, 94, 11, 104, 95, 110, 179, 226, 157, 245, 113, 68, 44, 122, 17, 22, 244, 35, 248, 126, - 131, 192, 20, 169, 129, 236, 60, 54, 157, 30, 231, 36, + 0, 205, 118, 44, 73, 143, 223, 186, 81, 174, 155, 253, 228, 4, 180, 221, 161, 180, 52, 21, + 100, 245, 119, 27, 164, 117, 78, 83, 26, 44, 201, 86, ]), Bytes32::new_direct([ - 101, 198, 107, 156, 226, 8, 67, 168, 197, 91, 189, 166, 187, 16, 121, 93, 114, 243, 137, - 162, 125, 142, 50, 206, 160, 168, 165, 27, 207, 10, 22, 19, + 21, 129, 118, 136, 79, 243, 222, 252, 204, 71, 191, 92, 189, 137, 123, 186, 148, 64, 181, + 133, 153, 156, 200, 226, 208, 87, 198, 250, 41, 221, 24, 135, ]), Bytes32::new_direct([ - 222, 29, 134, 137, 98, 73, 58, 143, 166, 134, 210, 47, 68, 23, 214, 237, 241, 207, 226, 83, - 113, 222, 184, 139, 16, 1, 200, 56, 34, 208, 197, 152, + 91, 144, 142, 242, 140, 89, 186, 182, 117, 237, 219, 108, 171, 187, 73, 250, 44, 182, 218, + 198, 56, 95, 124, 63, 224, 243, 199, 197, 205, 91, 161, 154, ]), Bytes32::new_direct([ - 107, 200, 189, 222, 185, 32, 192, 130, 237, 238, 168, 137, 14, 94, 3, 26, 41, 238, 19, 119, - 207, 158, 25, 177, 116, 70, 170, 161, 141, 129, 16, 88, + 10, 144, 56, 15, 178, 20, 198, 125, 196, 91, 57, 157, 241, 65, 123, 5, 195, 57, 107, 168, + 237, 187, 21, 19, 152, 82, 237, 250, 93, 203, 146, 125, ]), Bytes32::new_direct([ - 131, 243, 131, 161, 236, 101, 108, 81, 59, 123, 150, 6, 250, 124, 103, 101, 75, 234, 98, - 223, 129, 87, 202, 59, 184, 173, 44, 191, 200, 30, 223, 66, + 156, 227, 136, 163, 205, 20, 145, 89, 169, 47, 18, 43, 3, 130, 215, 55, 252, 165, 93, 54, + 22, 147, 40, 204, 120, 21, 124, 192, 73, 196, 82, 220, ]), Bytes32::new_direct([ - 17, 226, 72, 31, 180, 33, 229, 83, 154, 39, 104, 45, 93, 117, 153, 249, 216, 127, 120, 182, - 4, 19, 169, 87, 127, 70, 7, 237, 80, 251, 220, 126, + 188, 197, 120, 225, 29, 24, 128, 255, 217, 132, 186, 180, 4, 188, 73, 228, 121, 32, 25, + 163, 176, 41, 243, 225, 186, 81, 164, 24, 79, 5, 35, 227, ]), Bytes32::new_direct([ - 88, 122, 134, 181, 173, 175, 100, 74, 28, 141, 45, 215, 245, 170, 222, 54, 106, 118, 146, - 59, 207, 251, 133, 155, 164, 75, 240, 208, 10, 185, 187, 163, + 84, 113, 19, 5, 166, 195, 71, 42, 97, 34, 54, 121, 3, 80, 24, 196, 230, 57, 170, 145, 165, + 196, 209, 152, 17, 90, 91, 119, 221, 26, 183, 235, ]), Bytes32::new_direct([ - 214, 1, 209, 99, 53, 101, 233, 225, 55, 171, 69, 200, 44, 144, 169, 11, 65, 85, 84, 158, - 233, 227, 37, 59, 42, 52, 153, 13, 0, 158, 122, 208, + 206, 130, 4, 187, 195, 196, 128, 242, 2, 78, 199, 54, 253, 218, 182, 101, 15, 43, 236, 20, + 21, 23, 21, 190, 66, 44, 26, 157, 0, 98, 237, 221, ]), Bytes32::new_direct([ - 124, 146, 1, 221, 33, 138, 233, 130, 184, 163, 121, 110, 95, 242, 123, 251, 110, 46, 41, - 197, 75, 145, 121, 95, 29, 1, 19, 19, 167, 220, 177, 153, + 34, 108, 26, 191, 92, 65, 54, 67, 122, 253, 14, 0, 206, 232, 154, 156, 115, 1, 138, 147, + 206, 80, 14, 100, 8, 45, 10, 59, 92, 161, 247, 128, ]), Bytes32::new_direct([ - 77, 38, 54, 170, 19, 128, 180, 248, 208, 75, 27, 53, 228, 104, 7, 216, 188, 186, 40, 84, - 87, 11, 121, 3, 175, 89, 49, 46, 191, 94, 80, 97, + 33, 254, 66, 47, 39, 246, 253, 139, 15, 24, 173, 65, 172, 180, 203, 209, 251, 63, 93, 61, + 194, 40, 92, 238, 254, 191, 131, 137, 96, 237, 145, 214, ]), Bytes32::new_direct([ - 134, 127, 37, 206, 212, 70, 146, 143, 81, 104, 140, 28, 135, 233, 171, 88, 18, 2, 148, 143, - 111, 208, 149, 138, 167, 84, 183, 100, 67, 181, 243, 135, + 169, 2, 98, 144, 126, 101, 115, 235, 191, 147, 27, 11, 155, 77, 246, 66, 111, 50, 255, 110, + 135, 0, 1, 215, 69, 149, 27, 216, 9, 73, 225, 38, ]), Bytes32::new_direct([ - 218, 16, 220, 189, 192, 237, 252, 168, 45, 33, 177, 81, 53, 115, 141, 190, 99, 138, 113, - 85, 60, 230, 244, 222, 205, 16, 152, 26, 185, 207, 114, 143, + 121, 40, 115, 164, 82, 28, 188, 24, 211, 118, 23, 80, 128, 153, 92, 58, 88, 216, 184, 149, + 223, 221, 166, 100, 194, 220, 229, 218, 38, 15, 248, 238, ]), Bytes32::new_direct([ - 9, 85, 193, 163, 186, 152, 83, 149, 29, 71, 50, 13, 175, 149, 184, 51, 246, 97, 20, 22, 57, - 201, 27, 72, 146, 19, 213, 102, 164, 148, 176, 45, + 161, 215, 55, 238, 78, 56, 105, 60, 180, 70, 67, 195, 251, 65, 176, 52, 192, 50, 125, 100, + 176, 29, 236, 254, 85, 70, 108, 72, 133, 198, 244, 252, ]), Bytes32::new_direct([ - 140, 94, 218, 31, 232, 0, 167, 218, 122, 119, 62, 179, 181, 51, 100, 6, 150, 159, 212, 207, - 160, 94, 212, 108, 225, 196, 190, 210, 145, 110, 120, 114, + 147, 181, 91, 230, 48, 95, 75, 51, 230, 110, 16, 100, 161, 179, 210, 224, 48, 188, 14, 253, + 193, 84, 146, 132, 154, 65, 156, 38, 186, 18, 140, 33, ]), Bytes32::new_direct([ - 152, 169, 229, 240, 162, 212, 61, 59, 167, 135, 124, 147, 212, 248, 177, 85, 243, 72, 150, - 127, 122, 60, 143, 125, 226, 186, 67, 219, 50, 112, 242, 212, + 165, 53, 235, 177, 241, 80, 162, 5, 0, 5, 194, 37, 194, 128, 139, 81, 10, 9, 183, 190, 253, + 249, 183, 68, 238, 65, 170, 118, 64, 27, 11, 247, ]), Bytes32::new_direct([ - 47, 244, 81, 140, 243, 189, 116, 0, 2, 158, 242, 188, 215, 90, 177, 37, 175, 221, 80, 226, - 209, 79, 2, 62, 112, 245, 1, 132, 7, 78, 0, 117, + 81, 161, 108, 242, 250, 24, 230, 19, 215, 71, 127, 99, 143, 60, 107, 94, 206, 84, 253, 61, + 95, 166, 61, 115, 36, 251, 200, 113, 53, 218, 238, 118, ]), Bytes32::new_direct([ - 247, 236, 252, 118, 6, 245, 132, 187, 48, 36, 77, 0, 167, 150, 109, 72, 234, 9, 224, 162, - 223, 191, 21, 19, 180, 201, 138, 56, 109, 97, 152, 170, + 180, 71, 94, 29, 235, 115, 230, 231, 127, 221, 61, 28, 254, 34, 168, 198, 147, 192, 145, + 149, 72, 14, 242, 199, 247, 163, 6, 170, 170, 81, 60, 117, ]), Bytes32::new_direct([ - 77, 23, 112, 52, 78, 204, 135, 173, 2, 206, 148, 200, 60, 155, 60, 179, 201, 111, 73, 138, - 76, 104, 79, 174, 190, 173, 42, 51, 38, 48, 237, 241, + 231, 128, 41, 88, 214, 20, 249, 173, 50, 99, 41, 24, 173, 180, 239, 242, 52, 140, 64, 196, + 136, 157, 70, 127, 249, 136, 95, 72, 17, 218, 147, 135, ]), Bytes32::new_direct([ - 117, 234, 73, 183, 4, 144, 12, 196, 78, 228, 178, 218, 206, 147, 147, 94, 190, 22, 22, 233, - 88, 118, 135, 55, 63, 29, 212, 38, 223, 160, 121, 230, + 16, 126, 81, 169, 209, 164, 223, 20, 51, 200, 127, 87, 33, 90, 84, 163, 27, 203, 109, 158, + 103, 139, 177, 230, 237, 200, 125, 185, 73, 209, 225, 105, ]), Bytes32::new_direct([ - 74, 138, 173, 10, 77, 129, 10, 115, 18, 90, 57, 215, 221, 171, 109, 152, 31, 219, 235, 122, - 189, 201, 210, 186, 52, 200, 81, 218, 112, 79, 80, 54, + 254, 57, 105, 93, 192, 211, 240, 133, 102, 82, 38, 36, 40, 35, 225, 251, 59, 12, 0, 90, + 218, 98, 80, 150, 194, 54, 149, 19, 121, 139, 133, 160, ]), Bytes32::new_direct([ - 189, 150, 224, 30, 110, 73, 249, 62, 100, 244, 206, 110, 206, 239, 233, 213, 61, 213, 65, - 139, 103, 19, 20, 123, 167, 65, 161, 165, 216, 217, 255, 248, + 86, 157, 112, 81, 110, 241, 241, 115, 223, 147, 236, 79, 102, 7, 28, 4, 221, 199, 177, 129, + 70, 220, 204, 33, 204, 224, 9, 73, 43, 147, 248, 254, ]), Bytes32::new_direct([ - 119, 71, 56, 219, 155, 139, 253, 40, 100, 132, 185, 98, 24, 34, 156, 225, 120, 176, 76, - 147, 31, 105, 245, 216, 165, 161, 89, 157, 246, 17, 251, 234, + 113, 250, 103, 109, 150, 73, 88, 15, 107, 161, 114, 23, 138, 205, 223, 15, 144, 152, 219, + 43, 48, 97, 105, 9, 222, 177, 245, 180, 239, 177, 101, 61, ]), Bytes32::new_direct([ - 192, 39, 162, 126, 222, 211, 173, 195, 198, 124, 1, 124, 140, 2, 252, 191, 185, 85, 10, - 125, 226, 7, 88, 221, 164, 13, 221, 74, 200, 7, 249, 177, + 242, 174, 251, 43, 179, 62, 244, 186, 120, 156, 215, 116, 63, 214, 52, 100, 224, 143, 85, + 232, 222, 219, 11, 174, 86, 254, 213, 157, 226, 186, 150, 230, ]), Bytes32::new_direct([ - 251, 226, 24, 5, 54, 89, 9, 93, 217, 202, 148, 172, 208, 197, 65, 172, 98, 96, 58, 194, 61, - 253, 157, 193, 135, 32, 206, 97, 133, 234, 199, 197, + 27, 85, 85, 232, 12, 198, 143, 163, 91, 98, 184, 35, 189, 211, 164, 22, 239, 190, 137, 112, + 91, 173, 225, 226, 70, 62, 72, 228, 24, 98, 76, 20, ]), Bytes32::new_direct([ - 130, 3, 195, 156, 210, 123, 23, 44, 223, 25, 153, 169, 250, 88, 127, 239, 206, 196, 156, - 143, 182, 185, 35, 77, 162, 48, 143, 64, 231, 129, 216, 185, + 13, 36, 217, 220, 17, 175, 152, 226, 44, 101, 141, 85, 241, 126, 202, 89, 228, 213, 87, 3, + 78, 54, 136, 22, 209, 245, 199, 223, 57, 24, 42, 27, ]), Bytes32::new_direct([ - 123, 201, 97, 230, 121, 13, 207, 138, 137, 3, 122, 92, 105, 155, 214, 204, 142, 18, 119, - 138, 135, 165, 249, 58, 184, 53, 27, 31, 109, 214, 176, 147, + 92, 133, 208, 68, 232, 200, 77, 193, 48, 118, 241, 188, 57, 119, 181, 243, 180, 9, 158, + 219, 40, 130, 128, 203, 246, 91, 33, 169, 153, 242, 169, 10, ]), Bytes32::new_direct([ - 46, 71, 246, 155, 247, 109, 236, 225, 147, 51, 250, 72, 97, 116, 162, 36, 115, 164, 80, 28, - 252, 238, 98, 92, 16, 66, 190, 208, 180, 39, 179, 211, + 181, 35, 6, 153, 249, 128, 73, 10, 93, 63, 85, 26, 13, 176, 129, 126, 131, 173, 175, 185, + 91, 127, 162, 93, 199, 126, 27, 12, 114, 120, 235, 76, ]), Bytes32::new_direct([ - 38, 76, 13, 227, 149, 18, 84, 170, 83, 231, 122, 59, 237, 66, 32, 171, 158, 251, 78, 156, - 186, 160, 29, 30, 207, 178, 16, 193, 221, 158, 49, 48, + 117, 84, 164, 120, 249, 77, 72, 94, 182, 107, 122, 35, 142, 16, 243, 149, 74, 84, 22, 0, 8, + 16, 194, 26, 33, 102, 122, 46, 226, 118, 82, 113, ]), Bytes32::new_direct([ - 166, 13, 210, 208, 250, 131, 27, 163, 99, 204, 199, 134, 152, 131, 28, 164, 8, 222, 176, - 200, 34, 40, 74, 188, 120, 46, 167, 44, 95, 199, 86, 225, + 226, 237, 125, 140, 144, 97, 153, 126, 209, 251, 156, 249, 109, 242, 202, 211, 140, 35, + 223, 224, 89, 200, 147, 112, 151, 147, 10, 75, 34, 110, 97, 204, ]), ]; From 9bca51b34ea9b27fa2b9908017dabfea1219b662 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 2 May 2024 22:30:27 +0200 Subject: [PATCH 044/268] Cleanup outdated comment. --- arbitrator/bench/src/bin.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index a46614bedb..23930652c2 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -33,7 +33,6 @@ struct Args { fn main() -> eyre::Result<()> { let args = Args::parse(); - // let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24]; let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24]; if args.always_merkleize { println!("Running benchmark with always merkleize feature on"); From 13de7de0f804cd96c5dd75f08bb9681663ac3af1 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 2 May 2024 23:25:02 +0200 Subject: [PATCH 045/268] Remove the extend method. This change also improves the internal mutability contract by making resize take an immutable reference instead of a mutable one. --- arbitrator/prover/benches/merkle_bench.rs | 16 +--- arbitrator/prover/src/memory.rs | 4 +- arbitrator/prover/src/merkle.rs | 107 +--------------------- 3 files changed, 8 insertions(+), 119 deletions(-) diff --git a/arbitrator/prover/benches/merkle_bench.rs b/arbitrator/prover/benches/merkle_bench.rs index 69cdbd7427..98ac09a20e 100644 --- a/arbitrator/prover/benches/merkle_bench.rs +++ b/arbitrator/prover/benches/merkle_bench.rs @@ -3,17 +3,9 @@ use criterion::{criterion_group, criterion_main, Criterion}; use prover::merkle::{Merkle, MerkleType}; use rand::Rng; -fn extend_and_set_leavees(merkle: Merkle, rng: &mut rand::rngs::ThreadRng) { - let new_leaves = vec![ - Bytes32::from([6; 32]), - Bytes32::from([7; 32]), - Bytes32::from([8; 32]), - Bytes32::from([9; 32]), - Bytes32::from([10; 32]), - ]; - +fn resize_and_set_leaves(merkle: Merkle, rng: &mut rand::rngs::ThreadRng) { for _ in 0..100 { - merkle.extend(new_leaves.clone()).expect("extend failed"); + merkle.resize(merkle.len() + 5).expect("resize failed"); for _ in 0..(merkle.len() / 10) { let random_index = rng.gen_range(0..merkle.len()); merkle.set(random_index, Bytes32::from([rng.gen_range(0u8..9); 32])); @@ -33,10 +25,10 @@ fn merkle_benchmark(c: &mut Criterion) { ]; // Perform many calls to set leaves to new values - c.bench_function("extend_set_leaves_and_root", |b| { + c.bench_function("resize_set_leaves_and_root", |b| { b.iter(|| { let merkle = Merkle::new_advanced(MerkleType::Memory, leaves.clone(), 20); - extend_and_set_leavees(merkle.clone(), &mut rng); + resize_and_set_leaves(merkle.clone(), &mut rng); }) }); } diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 576770fde6..d894287db3 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -119,7 +119,7 @@ impl Memory { }) .collect(); let size = leaf_hashes.len(); - let mut m = Merkle::new_advanced(MerkleType::Memory, leaf_hashes, Self::MEMORY_LAYERS); + let m = Merkle::new_advanced(MerkleType::Memory, leaf_hashes, Self::MEMORY_LAYERS); if size < leaves { m.resize(leaves).expect("Couldn't resize merkle tree"); } @@ -306,7 +306,7 @@ impl Memory { pub fn resize(&mut self, new_size: usize) { self.buffer.resize(new_size, 0); - if let Some(mut merkle) = self.merkle.take() { + if let Some(merkle) = self.merkle.take() { merkle .resize(new_size) .expect("Couldn't resize merkle tree"); diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 560c514ced..827652757a 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -391,33 +391,10 @@ impl Merkle { self.dirty_layers.lock().unwrap()[0].insert(idx >> 1); } - /// Extends the leaves of the tree with the given hashes. - /// - /// Returns the new number of leaves in the tree. - /// Erorrs if the number of hashes plus the current leaves is greater than - /// the capacity of the tree. - pub fn extend(&self, hashes: Vec) -> Result { - let mut layers = self.layers.lock().unwrap(); - if hashes.len() > capacity(layers.as_ref()) - layers[0].len() { - return Err("Cannot extend with more leaves than the capicity of the tree.".to_owned()); - } - let mut idx = layers[0].len(); - let mut new_size = idx + hashes.len(); - for (layer_i, layer) in layers.iter_mut().enumerate() { - layer.resize(new_size, *empty_hash_at(self.ty, layer_i)); - new_size = max(new_size >> 1, 1); - } - for hash in hashes { - self.locked_set(&mut layers, idx, hash); - idx += 1; - } - Ok(layers[0].len()) - } - /// Resizes the number of leaves the tree can hold. /// /// The extra space is filled with empty hashes. - pub fn resize(&mut self, new_len: usize) -> Result { + pub fn resize(&self, new_len: usize) -> Result { if new_len > self.capacity() { return Err( "Cannot resize to a length greater than the capacity of the tree.".to_owned(), @@ -470,86 +447,6 @@ pub mod arc_mutex_sedre { } } -#[test] -fn extend_works() { - let hashes = vec![ - Bytes32::from([1; 32]), - Bytes32::from([2; 32]), - Bytes32::from([3; 32]), - Bytes32::from([4; 32]), - Bytes32::from([5; 32]), - ]; - let mut expected = hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - Bytes32::from([1; 32]), - Bytes32::from([2; 32]), - ), - hash_node( - MerkleType::Value, - Bytes32::from([3; 32]), - Bytes32::from([4; 32]), - ), - ), - hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - Bytes32::from([5; 32]), - Bytes32::from([0; 32]), - ), - hash_node( - MerkleType::Value, - Bytes32::from([0; 32]), - Bytes32::from([0; 32]), - ), - ), - ); - let merkle = Merkle::new(MerkleType::Value, hashes.clone()); - assert_eq!(merkle.capacity(), 8); - assert_eq!(merkle.root(), expected); - - let new_size = match merkle.extend(vec![Bytes32::from([6; 32])]) { - Ok(size) => size, - Err(e) => panic!("{}", e), - }; - assert_eq!(new_size, 6); - expected = hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - Bytes32::from([1; 32]), - Bytes32::from([2; 32]), - ), - hash_node( - MerkleType::Value, - Bytes32::from([3; 32]), - Bytes32::from([4; 32]), - ), - ), - hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - Bytes32::from([5; 32]), - Bytes32::from([6; 32]), - ), - hash_node( - MerkleType::Value, - Bytes32::from([0; 32]), - Bytes32::from([0; 32]), - ), - ), - ); - assert_eq!(merkle.root(), expected); - merkle.prove(1).unwrap(); -} - #[test] fn resize_works() { let hashes = vec![ @@ -588,7 +485,7 @@ fn resize_works() { ), ), ); - let mut merkle = Merkle::new(MerkleType::Value, hashes.clone()); + let merkle = Merkle::new(MerkleType::Value, hashes.clone()); assert_eq!(merkle.capacity(), 8); assert_eq!(merkle.root(), expected); From bc55504cf097e44867908b35c369947630fac929 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 3 May 2024 00:04:03 +0200 Subject: [PATCH 046/268] Add a test for serialization and make it pass. --- arbitrator/prover/src/merkle.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 827652757a..515adc1693 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -170,7 +170,7 @@ pub struct Merkle { #[serde(with = "arc_mutex_sedre")] layers: Arc>>>, min_depth: usize, - #[serde(skip)] + #[serde(with = "arc_mutex_sedre")] dirty_layers: Arc>>>, } @@ -561,6 +561,16 @@ fn emit_memory_zerohashes() { } } +#[test] +fn serialization_roundtrip() { + let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); + merkle.resize(4).expect("resize failed"); + merkle.set(3, Bytes32::from([2; 32])); + let serialized = bincode::serialize(&merkle).unwrap(); + let deserialized: Merkle = bincode::deserialize(&serialized).unwrap(); + assert_eq!(merkle, deserialized); +} + #[test] #[should_panic(expected = "index out of bounds")] fn set_with_bad_index_panics() { From 9ebd8ba5c3ea99dad410107295d0bd7257ba66e8 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 3 May 2024 17:13:33 +0200 Subject: [PATCH 047/268] Fix the bugged MEMORY_HASHES in the zerohashes.rs More specfically, the code that was generating them had a stupid bug. --- arbitrator/prover/src/memory.rs | 14 ++ arbitrator/prover/src/merkle.rs | 14 +- arbitrator/prover/src/merkle/zerohashes.rs | 248 ++++++++++----------- 3 files changed, 143 insertions(+), 133 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index d894287db3..4709c406a7 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -317,8 +317,22 @@ impl Memory { #[cfg(test)] mod test { + use arbutil::Bytes32; + use crate::memory::round_up_to_power_of_two; + use super::Memory; + + #[test] + pub fn fixed_memory_hash() { + let module_memory_hash = Bytes32::from([ + 86u8, 177, 192, 60, 217, 123, 221, 153, 118, 79, 229, 122, 210, 48, 187, 104, 40, 84, + 112, 63, 137, 86, 54, 2, 56, 118, 72, 158, 242, 225, 65, 80, + ]); + let memory = Memory::new(65536, 1); + assert_eq!(memory.hash(), module_memory_hash); + } + #[test] pub fn empty_leaf_hash() { let leaf = [0u8; 32]; diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 515adc1693..dc182419eb 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -539,25 +539,21 @@ fn correct_capacity() { #[ignore = "This is just used for generating the zero hashes for the memory merkle trees."] fn emit_memory_zerohashes() { // The following code was generated from the empty_leaf_hash() test in the memory package. - let mut left = Bytes32::new_direct([ + let mut empty_node = Bytes32::new_direct([ 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, 186, 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, - ]); - let mut right = Bytes32::new_direct([ - 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, 186, - 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, - ]); + ]) + .clone(); for _ in 0..64 { print!("Bytes32::new_direct(["); for i in 0..32 { - print!("{}", left[i]); + print!("{}", empty_node[i]); if i < 31 { print!(", "); } } println!("]),"); - left = hash_node(MerkleType::Memory, left, right); - right = hash_node(MerkleType::Memory, left, right); + empty_node = hash_node(MerkleType::Memory, empty_node, empty_node); } } diff --git a/arbitrator/prover/src/merkle/zerohashes.rs b/arbitrator/prover/src/merkle/zerohashes.rs index 16a4bd8457..1eef9b8557 100644 --- a/arbitrator/prover/src/merkle/zerohashes.rs +++ b/arbitrator/prover/src/merkle/zerohashes.rs @@ -788,252 +788,252 @@ const MEMORY_HASHES: &[Bytes32; 64] = &[ 204, 178, 127, 225, 18, 119, 68, 89, 244, 245, 143, 151, 9, ]), Bytes32::new_direct([ - 138, 210, 20, 48, 168, 152, 201, 72, 74, 157, 83, 120, 248, 186, 217, 22, 74, 60, 199, 181, - 52, 97, 24, 26, 166, 215, 235, 19, 24, 173, 50, 5, + 9, 87, 12, 3, 155, 102, 114, 211, 160, 40, 161, 7, 3, 192, 11, 145, 241, 17, 215, 209, 18, + 230, 221, 198, 189, 52, 34, 224, 245, 121, 253, 194, ]), Bytes32::new_direct([ - 132, 142, 241, 159, 152, 112, 200, 35, 177, 158, 88, 170, 78, 253, 191, 235, 187, 54, 23, - 74, 119, 177, 79, 61, 245, 5, 125, 130, 89, 112, 8, 215, + 10, 61, 178, 250, 4, 50, 245, 174, 54, 189, 184, 161, 208, 164, 55, 145, 70, 4, 81, 28, + 129, 97, 216, 23, 41, 192, 91, 97, 9, 83, 1, 215, ]), Bytes32::new_direct([ - 232, 72, 169, 41, 1, 17, 49, 197, 245, 83, 27, 42, 83, 152, 126, 121, 123, 161, 152, 55, - 217, 150, 120, 17, 175, 27, 60, 133, 32, 99, 101, 250, + 244, 167, 192, 124, 155, 131, 227, 49, 180, 187, 181, 23, 114, 255, 114, 237, 129, 149, + 159, 244, 63, 138, 0, 237, 37, 38, 159, 106, 4, 153, 119, 255, ]), Bytes32::new_direct([ - 209, 26, 146, 121, 215, 34, 75, 215, 173, 237, 120, 5, 194, 146, 223, 43, 239, 13, 187, 30, - 20, 47, 249, 110, 83, 166, 67, 199, 182, 55, 163, 148, + 63, 174, 225, 251, 118, 10, 96, 200, 132, 107, 27, 128, 250, 62, 47, 221, 227, 241, 107, + 254, 3, 171, 26, 81, 199, 162, 154, 249, 154, 72, 185, 196, ]), Bytes32::new_direct([ - 135, 209, 119, 98, 227, 84, 19, 108, 100, 236, 155, 117, 164, 95, 218, 166, 179, 7, 107, - 113, 206, 187, 188, 255, 134, 99, 57, 190, 193, 203, 40, 160, + 89, 112, 167, 92, 33, 192, 100, 158, 137, 92, 61, 197, 73, 216, 188, 164, 72, 37, 5, 0, + 161, 144, 254, 18, 10, 4, 248, 174, 26, 5, 149, 142, ]), Bytes32::new_direct([ - 32, 32, 24, 177, 70, 250, 175, 6, 212, 200, 28, 52, 130, 190, 221, 115, 130, 66, 87, 39, - 149, 242, 233, 170, 150, 241, 111, 201, 37, 170, 53, 157, + 202, 243, 125, 81, 15, 253, 233, 83, 91, 186, 151, 205, 84, 225, 16, 241, 42, 27, 7, 15, + 143, 128, 189, 233, 206, 106, 21, 7, 96, 167, 149, 2, ]), Bytes32::new_direct([ - 46, 83, 161, 19, 97, 192, 213, 207, 160, 235, 147, 29, 45, 186, 80, 204, 85, 149, 79, 64, - 242, 252, 127, 68, 37, 126, 65, 219, 105, 166, 239, 58, + 155, 19, 224, 94, 41, 7, 172, 244, 76, 43, 181, 160, 220, 80, 64, 0, 140, 33, 238, 79, 87, + 43, 40, 34, 162, 57, 122, 232, 216, 48, 64, 114, ]), Bytes32::new_direct([ - 92, 232, 243, 48, 112, 221, 12, 155, 90, 24, 101, 39, 52, 148, 44, 192, 33, 241, 250, 139, - 215, 204, 3, 148, 172, 247, 133, 116, 34, 15, 96, 171, + 64, 199, 52, 187, 21, 58, 215, 47, 174, 163, 203, 89, 35, 199, 187, 86, 137, 145, 236, 145, + 66, 21, 218, 151, 88, 61, 109, 238, 61, 58, 215, 247, ]), Bytes32::new_direct([ - 178, 251, 194, 203, 145, 18, 131, 236, 77, 185, 182, 102, 222, 1, 0, 200, 162, 94, 165, - 131, 73, 210, 194, 149, 123, 198, 77, 105, 40, 162, 188, 220, + 197, 59, 74, 219, 191, 151, 46, 252, 54, 248, 228, 94, 22, 143, 69, 197, 114, 247, 37, 212, + 243, 158, 179, 192, 205, 50, 50, 36, 40, 130, 115, 247, ]), Bytes32::new_direct([ - 212, 120, 226, 169, 131, 103, 29, 244, 133, 118, 133, 194, 150, 180, 119, 78, 209, 199, - 231, 248, 150, 30, 208, 248, 202, 98, 173, 195, 192, 150, 207, 41, + 168, 115, 30, 246, 210, 241, 88, 129, 115, 193, 107, 199, 199, 35, 118, 28, 145, 183, 82, + 101, 162, 52, 67, 147, 208, 234, 115, 58, 40, 124, 16, 79, ]), Bytes32::new_direct([ - 2, 68, 204, 114, 30, 60, 87, 24, 156, 226, 181, 122, 95, 226, 120, 216, 82, 237, 156, 142, - 190, 105, 2, 224, 55, 63, 204, 98, 216, 226, 141, 42, + 253, 6, 238, 29, 37, 160, 45, 23, 26, 114, 137, 254, 44, 68, 147, 33, 212, 149, 16, 188, + 28, 174, 189, 22, 12, 228, 99, 101, 60, 248, 174, 34, ]), Bytes32::new_direct([ - 11, 217, 134, 64, 229, 175, 220, 212, 248, 63, 138, 216, 241, 116, 151, 248, 104, 232, 207, - 232, 67, 106, 138, 62, 180, 178, 46, 83, 36, 101, 169, 244, + 0, 89, 208, 120, 115, 63, 79, 9, 29, 16, 81, 231, 78, 251, 117, 98, 172, 207, 54, 97, 38, + 72, 37, 110, 102, 207, 38, 198, 165, 157, 208, 6, ]), Bytes32::new_direct([ - 178, 176, 193, 132, 188, 190, 13, 56, 161, 182, 230, 231, 145, 233, 98, 31, 142, 60, 139, - 145, 38, 166, 104, 140, 244, 19, 236, 208, 164, 199, 195, 185, + 193, 144, 83, 148, 50, 15, 138, 224, 145, 12, 222, 94, 88, 91, 151, 74, 180, 47, 102, 38, + 244, 38, 251, 13, 230, 130, 141, 133, 10, 194, 108, 211, ]), Bytes32::new_direct([ - 90, 202, 183, 64, 67, 146, 97, 5, 29, 214, 222, 104, 152, 252, 74, 122, 100, 43, 41, 221, - 222, 25, 247, 226, 197, 190, 93, 192, 86, 114, 147, 131, + 182, 202, 171, 144, 153, 127, 43, 239, 77, 89, 56, 144, 39, 180, 30, 164, 1, 120, 105, 55, + 21, 17, 147, 96, 185, 219, 67, 146, 86, 42, 44, 117, ]), Bytes32::new_direct([ - 159, 87, 235, 78, 106, 222, 69, 92, 125, 102, 216, 34, 85, 52, 156, 187, 167, 111, 156, - 183, 215, 169, 246, 3, 194, 74, 194, 158, 239, 123, 204, 201, + 240, 76, 90, 37, 238, 134, 53, 105, 125, 238, 19, 80, 162, 60, 63, 104, 193, 201, 233, 10, + 246, 175, 15, 167, 239, 50, 201, 138, 153, 127, 40, 247, ]), Bytes32::new_direct([ - 79, 225, 161, 133, 98, 124, 23, 177, 237, 126, 97, 48, 89, 98, 189, 200, 80, 234, 250, 231, - 188, 89, 185, 167, 139, 37, 35, 24, 112, 253, 165, 232, + 127, 96, 10, 125, 139, 9, 213, 13, 60, 75, 10, 85, 88, 169, 180, 24, 18, 171, 157, 161, + 252, 181, 178, 191, 227, 200, 140, 72, 205, 231, 67, 34, ]), Bytes32::new_direct([ - 198, 248, 143, 133, 37, 221, 33, 117, 172, 103, 241, 199, 2, 137, 186, 107, 166, 47, 179, - 169, 221, 65, 254, 170, 206, 104, 117, 243, 169, 180, 252, 103, + 8, 81, 79, 192, 81, 171, 28, 73, 80, 93, 207, 58, 0, 192, 109, 40, 59, 227, 148, 172, 144, + 146, 237, 103, 47, 77, 112, 155, 215, 125, 49, 205, ]), Bytes32::new_direct([ - 227, 45, 217, 82, 36, 209, 164, 147, 113, 11, 26, 171, 37, 59, 161, 15, 217, 146, 38, 34, - 13, 149, 85, 67, 113, 115, 113, 192, 144, 255, 31, 227, + 181, 244, 223, 157, 69, 161, 149, 150, 31, 65, 52, 113, 11, 233, 51, 145, 135, 161, 34, + 114, 133, 86, 133, 255, 161, 176, 170, 255, 21, 163, 146, 79, ]), Bytes32::new_direct([ - 232, 69, 104, 93, 119, 165, 151, 208, 91, 19, 184, 192, 189, 65, 2, 101, 113, 11, 201, 57, - 76, 79, 177, 65, 72, 112, 203, 61, 33, 147, 104, 218, + 251, 112, 107, 186, 121, 118, 206, 118, 164, 136, 208, 159, 220, 188, 218, 111, 190, 44, + 16, 16, 251, 116, 206, 236, 111, 184, 20, 247, 252, 129, 200, 164, ]), Bytes32::new_direct([ - 53, 124, 30, 59, 195, 224, 250, 252, 201, 173, 143, 69, 253, 249, 201, 120, 178, 107, 234, - 244, 106, 3, 203, 223, 32, 193, 17, 23, 229, 108, 83, 83, + 101, 111, 124, 218, 143, 90, 110, 65, 52, 118, 81, 72, 234, 164, 106, 84, 54, 136, 212, + 192, 46, 87, 56, 241, 227, 38, 37, 101, 250, 134, 254, 144, ]), Bytes32::new_direct([ - 111, 38, 112, 152, 63, 120, 95, 83, 255, 53, 254, 22, 61, 218, 177, 18, 63, 73, 239, 119, - 109, 21, 2, 171, 152, 196, 246, 85, 251, 83, 141, 107, + 209, 232, 185, 167, 159, 116, 4, 11, 114, 98, 71, 225, 233, 246, 135, 173, 175, 126, 125, + 101, 16, 27, 254, 198, 79, 21, 181, 120, 50, 139, 76, 4, ]), Bytes32::new_direct([ - 12, 210, 136, 9, 253, 193, 146, 161, 74, 199, 75, 177, 83, 196, 149, 95, 8, 100, 216, 157, - 210, 237, 179, 35, 30, 78, 8, 22, 5, 167, 244, 106, + 30, 122, 82, 142, 43, 26, 170, 27, 0, 177, 218, 106, 39, 13, 154, 151, 92, 47, 144, 113, + 173, 242, 169, 89, 230, 135, 188, 190, 57, 170, 66, 220, ]), Bytes32::new_direct([ - 243, 71, 83, 219, 108, 40, 60, 96, 203, 129, 93, 149, 23, 152, 80, 88, 31, 214, 120, 50, - 178, 251, 197, 216, 50, 191, 146, 242, 107, 117, 120, 241, + 39, 137, 200, 154, 57, 148, 82, 232, 82, 214, 232, 251, 187, 13, 253, 222, 184, 161, 144, + 231, 67, 116, 160, 231, 214, 47, 228, 88, 146, 14, 244, 108, ]), Bytes32::new_direct([ - 131, 216, 197, 129, 234, 215, 44, 252, 0, 196, 182, 81, 58, 35, 73, 134, 221, 222, 183, 49, - 234, 120, 75, 197, 162, 30, 175, 200, 138, 50, 29, 53, + 122, 9, 214, 205, 84, 161, 177, 137, 68, 9, 178, 177, 141, 219, 162, 109, 116, 124, 124, + 56, 189, 139, 28, 220, 98, 165, 217, 156, 157, 148, 43, 232, ]), Bytes32::new_direct([ - 192, 239, 89, 211, 179, 226, 174, 23, 223, 197, 246, 12, 192, 241, 143, 221, 244, 36, 31, - 100, 254, 237, 147, 207, 173, 228, 9, 193, 51, 242, 18, 134, + 83, 209, 1, 98, 176, 225, 170, 233, 144, 110, 148, 135, 159, 243, 202, 14, 201, 243, 218, + 255, 75, 90, 222, 25, 141, 148, 128, 132, 101, 8, 178, 180, ]), Bytes32::new_direct([ - 77, 66, 182, 195, 7, 198, 199, 94, 24, 221, 103, 169, 91, 239, 34, 46, 177, 172, 213, 70, - 120, 32, 25, 101, 48, 214, 104, 125, 133, 90, 176, 242, + 93, 131, 135, 74, 118, 43, 37, 103, 218, 116, 47, 5, 212, 230, 133, 11, 76, 199, 46, 91, + 17, 222, 122, 114, 166, 228, 113, 213, 31, 5, 32, 164, ]), Bytes32::new_direct([ - 73, 194, 146, 182, 168, 1, 41, 95, 74, 146, 7, 16, 189, 96, 68, 218, 13, 28, 28, 126, 34, - 95, 188, 90, 36, 37, 123, 123, 53, 210, 23, 71, + 230, 49, 245, 147, 146, 113, 214, 229, 67, 34, 234, 170, 14, 37, 33, 105, 12, 192, 127, + 177, 195, 70, 29, 44, 232, 191, 3, 56, 70, 40, 70, 69, ]), Bytes32::new_direct([ - 160, 84, 92, 145, 163, 106, 94, 229, 208, 172, 17, 30, 90, 138, 5, 21, 70, 113, 113, 24, - 231, 220, 117, 38, 242, 226, 1, 63, 150, 13, 126, 125, + 64, 48, 103, 64, 135, 164, 51, 233, 201, 62, 5, 28, 35, 183, 178, 104, 54, 238, 0, 58, 215, + 157, 29, 149, 57, 23, 224, 247, 85, 104, 240, 113, ]), Bytes32::new_direct([ - 60, 239, 17, 50, 191, 31, 160, 151, 44, 128, 44, 89, 85, 11, 4, 91, 129, 104, 0, 4, 197, - 196, 189, 249, 73, 206, 63, 225, 7, 61, 107, 169, + 12, 156, 88, 246, 58, 5, 82, 65, 113, 178, 127, 112, 138, 170, 91, 11, 79, 54, 122, 65, 87, + 104, 104, 93, 134, 176, 56, 5, 139, 142, 73, 54, ]), Bytes32::new_direct([ - 254, 250, 117, 203, 85, 163, 150, 58, 59, 247, 98, 144, 14, 70, 100, 248, 28, 14, 157, 212, - 104, 137, 17, 133, 43, 206, 209, 152, 236, 229, 94, 67, + 92, 41, 81, 165, 165, 210, 34, 91, 127, 46, 250, 148, 104, 192, 211, 77, 108, 49, 111, 57, + 161, 242, 142, 46, 100, 47, 24, 24, 51, 219, 92, 186, ]), Bytes32::new_direct([ - 49, 191, 233, 164, 188, 247, 147, 203, 222, 173, 79, 244, 84, 143, 112, 144, 96, 96, 165, - 199, 199, 196, 229, 133, 15, 38, 219, 209, 133, 47, 199, 245, + 201, 120, 116, 179, 124, 183, 117, 97, 200, 35, 138, 235, 77, 177, 138, 42, 47, 58, 69, + 188, 70, 2, 71, 95, 51, 233, 69, 14, 22, 24, 195, 153, ]), Bytes32::new_direct([ - 164, 27, 202, 130, 161, 245, 153, 150, 235, 26, 152, 212, 54, 239, 71, 55, 172, 81, 226, - 79, 44, 110, 71, 168, 43, 210, 243, 189, 163, 3, 57, 199, + 249, 189, 13, 189, 45, 69, 100, 141, 50, 145, 24, 54, 91, 45, 125, 223, 181, 222, 63, 49, + 66, 49, 106, 175, 55, 85, 112, 25, 69, 187, 44, 171, ]), Bytes32::new_direct([ - 22, 164, 24, 66, 118, 132, 197, 4, 124, 220, 178, 135, 160, 220, 15, 3, 122, 35, 22, 59, - 233, 15, 104, 230, 58, 145, 34, 216, 88, 153, 185, 112, + 86, 114, 135, 219, 78, 73, 34, 205, 239, 144, 56, 231, 164, 101, 129, 115, 51, 167, 158, + 96, 1, 241, 178, 216, 54, 84, 97, 185, 200, 239, 215, 7, ]), Bytes32::new_direct([ - 0, 205, 118, 44, 73, 143, 223, 186, 81, 174, 155, 253, 228, 4, 180, 221, 161, 180, 52, 21, - 100, 245, 119, 27, 164, 117, 78, 83, 26, 44, 201, 86, + 35, 232, 131, 249, 70, 6, 185, 10, 58, 53, 72, 254, 74, 166, 76, 41, 122, 234, 77, 61, 16, + 39, 26, 66, 102, 78, 102, 159, 55, 113, 195, 19, ]), Bytes32::new_direct([ - 21, 129, 118, 136, 79, 243, 222, 252, 204, 71, 191, 92, 189, 137, 123, 186, 148, 64, 181, - 133, 153, 156, 200, 226, 208, 87, 198, 250, 41, 221, 24, 135, + 204, 120, 229, 250, 86, 164, 18, 58, 82, 11, 112, 225, 76, 253, 63, 35, 245, 72, 81, 254, + 193, 182, 255, 159, 200, 120, 135, 60, 253, 180, 185, 112, ]), Bytes32::new_direct([ - 91, 144, 142, 242, 140, 89, 186, 182, 117, 237, 219, 108, 171, 187, 73, 250, 44, 182, 218, - 198, 56, 95, 124, 63, 224, 243, 199, 197, 205, 91, 161, 154, + 35, 194, 73, 72, 85, 35, 3, 215, 21, 38, 67, 254, 195, 250, 173, 177, 156, 70, 47, 13, 178, + 120, 227, 214, 92, 71, 181, 40, 213, 43, 193, 147, ]), Bytes32::new_direct([ - 10, 144, 56, 15, 178, 20, 198, 125, 196, 91, 57, 157, 241, 65, 123, 5, 195, 57, 107, 168, - 237, 187, 21, 19, 152, 82, 237, 250, 93, 203, 146, 125, + 148, 91, 40, 131, 45, 85, 232, 203, 101, 47, 189, 225, 128, 118, 138, 12, 83, 98, 227, 166, + 192, 69, 188, 19, 84, 13, 162, 250, 65, 209, 47, 191, ]), Bytes32::new_direct([ - 156, 227, 136, 163, 205, 20, 145, 89, 169, 47, 18, 43, 3, 130, 215, 55, 252, 165, 93, 54, - 22, 147, 40, 204, 120, 21, 124, 192, 73, 196, 82, 220, + 100, 36, 35, 232, 157, 164, 39, 175, 77, 211, 19, 26, 20, 226, 226, 255, 121, 134, 19, 46, + 185, 213, 2, 4, 6, 92, 47, 239, 206, 240, 225, 58, ]), Bytes32::new_direct([ - 188, 197, 120, 225, 29, 24, 128, 255, 217, 132, 186, 180, 4, 188, 73, 228, 121, 32, 25, - 163, 176, 41, 243, 225, 186, 81, 164, 24, 79, 5, 35, 227, + 121, 36, 6, 138, 185, 33, 130, 28, 55, 238, 127, 203, 99, 32, 56, 245, 237, 135, 207, 190, + 72, 243, 137, 32, 218, 103, 150, 171, 3, 246, 48, 225, ]), Bytes32::new_direct([ - 84, 113, 19, 5, 166, 195, 71, 42, 97, 34, 54, 121, 3, 80, 24, 196, 230, 57, 170, 145, 165, - 196, 209, 152, 17, 90, 91, 119, 221, 26, 183, 235, + 233, 56, 238, 34, 238, 134, 69, 104, 220, 255, 47, 202, 241, 144, 207, 249, 107, 153, 38, + 120, 101, 12, 177, 64, 151, 114, 146, 6, 227, 159, 40, 107, ]), Bytes32::new_direct([ - 206, 130, 4, 187, 195, 196, 128, 242, 2, 78, 199, 54, 253, 218, 182, 101, 15, 43, 236, 20, - 21, 23, 21, 190, 66, 44, 26, 157, 0, 98, 237, 221, + 237, 115, 194, 93, 160, 113, 23, 120, 250, 186, 21, 163, 155, 20, 179, 177, 55, 20, 24, 89, + 77, 113, 163, 0, 176, 130, 228, 133, 239, 122, 177, 65, ]), Bytes32::new_direct([ - 34, 108, 26, 191, 92, 65, 54, 67, 122, 253, 14, 0, 206, 232, 154, 156, 115, 1, 138, 147, - 206, 80, 14, 100, 8, 45, 10, 59, 92, 161, 247, 128, + 108, 150, 128, 44, 189, 57, 148, 254, 56, 134, 118, 165, 95, 15, 168, 179, 162, 252, 169, + 58, 223, 20, 38, 221, 25, 138, 101, 131, 32, 8, 2, 58, ]), Bytes32::new_direct([ - 33, 254, 66, 47, 39, 246, 253, 139, 15, 24, 173, 65, 172, 180, 203, 209, 251, 63, 93, 61, - 194, 40, 92, 238, 254, 191, 131, 137, 96, 237, 145, 214, + 154, 13, 160, 129, 192, 79, 86, 40, 135, 113, 123, 38, 53, 254, 62, 94, 255, 14, 119, 4, + 102, 168, 200, 191, 112, 245, 29, 200, 164, 155, 141, 139, ]), Bytes32::new_direct([ - 169, 2, 98, 144, 126, 101, 115, 235, 191, 147, 27, 11, 155, 77, 246, 66, 111, 50, 255, 110, - 135, 0, 1, 215, 69, 149, 27, 216, 9, 73, 225, 38, + 238, 189, 209, 174, 202, 251, 240, 99, 133, 44, 221, 34, 17, 88, 220, 143, 188, 160, 235, + 121, 167, 96, 106, 249, 213, 176, 31, 84, 26, 144, 201, 89, ]), Bytes32::new_direct([ - 121, 40, 115, 164, 82, 28, 188, 24, 211, 118, 23, 80, 128, 153, 92, 58, 88, 216, 184, 149, - 223, 221, 166, 100, 194, 220, 229, 218, 38, 15, 248, 238, + 178, 186, 146, 221, 228, 41, 150, 76, 220, 216, 144, 64, 108, 178, 242, 120, 153, 191, 212, + 37, 114, 21, 30, 117, 45, 238, 46, 19, 132, 212, 112, 44, ]), Bytes32::new_direct([ - 161, 215, 55, 238, 78, 56, 105, 60, 180, 70, 67, 195, 251, 65, 176, 52, 192, 50, 125, 100, - 176, 29, 236, 254, 85, 70, 108, 72, 133, 198, 244, 252, + 191, 19, 180, 171, 125, 68, 104, 43, 66, 173, 194, 168, 213, 192, 117, 82, 167, 41, 139, + 133, 92, 103, 124, 85, 241, 66, 1, 154, 68, 72, 171, 80, ]), Bytes32::new_direct([ - 147, 181, 91, 230, 48, 95, 75, 51, 230, 110, 16, 100, 161, 179, 210, 224, 48, 188, 14, 253, - 193, 84, 146, 132, 154, 65, 156, 38, 186, 18, 140, 33, + 79, 215, 118, 157, 123, 16, 70, 30, 101, 234, 117, 41, 35, 186, 99, 5, 232, 45, 253, 142, + 185, 18, 172, 187, 36, 50, 218, 252, 111, 184, 158, 254, ]), Bytes32::new_direct([ - 165, 53, 235, 177, 241, 80, 162, 5, 0, 5, 194, 37, 194, 128, 139, 81, 10, 9, 183, 190, 253, - 249, 183, 68, 238, 65, 170, 118, 64, 27, 11, 247, + 17, 193, 206, 44, 67, 98, 171, 63, 78, 209, 71, 20, 196, 255, 64, 114, 191, 19, 246, 131, + 8, 105, 211, 169, 192, 114, 249, 240, 28, 55, 230, 143, ]), Bytes32::new_direct([ - 81, 161, 108, 242, 250, 24, 230, 19, 215, 71, 127, 99, 143, 60, 107, 94, 206, 84, 253, 61, - 95, 166, 61, 115, 36, 251, 200, 113, 53, 218, 238, 118, + 200, 94, 187, 80, 140, 194, 238, 35, 62, 228, 202, 122, 136, 119, 228, 133, 33, 147, 161, + 218, 94, 19, 207, 129, 48, 252, 242, 19, 56, 251, 92, 76, ]), Bytes32::new_direct([ - 180, 71, 94, 29, 235, 115, 230, 231, 127, 221, 61, 28, 254, 34, 168, 198, 147, 192, 145, - 149, 72, 14, 242, 199, 247, 163, 6, 170, 170, 81, 60, 117, + 223, 124, 52, 170, 180, 101, 70, 1, 153, 22, 178, 138, 181, 253, 35, 113, 159, 136, 77, 23, + 158, 62, 11, 48, 6, 185, 147, 81, 220, 191, 94, 3, ]), Bytes32::new_direct([ - 231, 128, 41, 88, 214, 20, 249, 173, 50, 99, 41, 24, 173, 180, 239, 242, 52, 140, 64, 196, - 136, 157, 70, 127, 249, 136, 95, 72, 17, 218, 147, 135, + 126, 124, 205, 157, 16, 239, 172, 241, 70, 70, 205, 98, 211, 8, 84, 204, 149, 9, 208, 56, + 122, 51, 224, 231, 200, 59, 41, 215, 141, 183, 91, 223, ]), Bytes32::new_direct([ - 16, 126, 81, 169, 209, 164, 223, 20, 51, 200, 127, 87, 33, 90, 84, 163, 27, 203, 109, 158, - 103, 139, 177, 230, 237, 200, 125, 185, 73, 209, 225, 105, + 20, 122, 156, 134, 248, 95, 140, 199, 59, 151, 120, 164, 109, 202, 165, 126, 108, 161, 8, + 253, 18, 35, 36, 83, 219, 162, 58, 83, 136, 57, 43, 35, ]), Bytes32::new_direct([ - 254, 57, 105, 93, 192, 211, 240, 133, 102, 82, 38, 36, 40, 35, 225, 251, 59, 12, 0, 90, - 218, 98, 80, 150, 194, 54, 149, 19, 121, 139, 133, 160, + 58, 175, 246, 31, 114, 109, 109, 219, 230, 129, 128, 99, 175, 228, 65, 148, 53, 233, 226, + 171, 44, 254, 222, 211, 200, 28, 193, 130, 251, 152, 160, 210, ]), Bytes32::new_direct([ - 86, 157, 112, 81, 110, 241, 241, 115, 223, 147, 236, 79, 102, 7, 28, 4, 221, 199, 177, 129, - 70, 220, 204, 33, 204, 224, 9, 73, 43, 147, 248, 254, + 177, 255, 19, 82, 14, 229, 84, 206, 156, 198, 252, 176, 126, 211, 226, 255, 154, 231, 131, + 158, 165, 154, 142, 166, 131, 221, 203, 30, 251, 205, 27, 217, ]), Bytes32::new_direct([ - 113, 250, 103, 109, 150, 73, 88, 15, 107, 161, 114, 23, 138, 205, 223, 15, 144, 152, 219, - 43, 48, 97, 105, 9, 222, 177, 245, 180, 239, 177, 101, 61, + 32, 168, 192, 93, 240, 173, 218, 42, 78, 215, 104, 243, 154, 2, 50, 159, 21, 176, 28, 59, + 29, 57, 193, 122, 32, 244, 91, 148, 91, 184, 126, 31, ]), Bytes32::new_direct([ - 242, 174, 251, 43, 179, 62, 244, 186, 120, 156, 215, 116, 63, 214, 52, 100, 224, 143, 85, - 232, 222, 219, 11, 174, 86, 254, 213, 157, 226, 186, 150, 230, + 28, 66, 164, 117, 43, 120, 84, 240, 48, 3, 55, 95, 44, 229, 231, 29, 217, 67, 49, 130, 110, + 209, 72, 71, 46, 208, 63, 81, 218, 98, 167, 207, ]), Bytes32::new_direct([ - 27, 85, 85, 232, 12, 198, 143, 163, 91, 98, 184, 35, 189, 211, 164, 22, 239, 190, 137, 112, - 91, 173, 225, 226, 70, 62, 72, 228, 24, 98, 76, 20, + 38, 192, 60, 175, 136, 217, 168, 69, 90, 236, 62, 137, 9, 116, 244, 151, 181, 57, 229, 198, + 100, 125, 114, 46, 80, 136, 150, 94, 225, 162, 170, 91, ]), Bytes32::new_direct([ - 13, 36, 217, 220, 17, 175, 152, 226, 44, 101, 141, 85, 241, 126, 202, 89, 228, 213, 87, 3, - 78, 54, 136, 22, 209, 245, 199, 223, 57, 24, 42, 27, + 121, 67, 11, 63, 56, 140, 67, 231, 175, 126, 41, 37, 252, 62, 35, 215, 250, 206, 190, 3, + 154, 83, 237, 174, 65, 86, 83, 251, 110, 8, 44, 216, ]), Bytes32::new_direct([ - 92, 133, 208, 68, 232, 200, 77, 193, 48, 118, 241, 188, 57, 119, 181, 243, 180, 9, 158, - 219, 40, 130, 128, 203, 246, 91, 33, 169, 153, 242, 169, 10, + 25, 251, 117, 251, 14, 64, 166, 211, 216, 123, 38, 1, 98, 19, 119, 194, 60, 234, 185, 148, + 118, 201, 4, 233, 69, 135, 13, 191, 8, 6, 136, 240, ]), Bytes32::new_direct([ - 181, 35, 6, 153, 249, 128, 73, 10, 93, 63, 85, 26, 13, 176, 129, 126, 131, 173, 175, 185, - 91, 127, 162, 93, 199, 126, 27, 12, 114, 120, 235, 76, + 137, 1, 201, 130, 166, 152, 216, 48, 178, 242, 46, 3, 66, 92, 4, 81, 11, 145, 205, 82, 253, + 102, 78, 6, 53, 13, 36, 171, 48, 75, 165, 153, ]), Bytes32::new_direct([ - 117, 84, 164, 120, 249, 77, 72, 94, 182, 107, 122, 35, 142, 16, 243, 149, 74, 84, 22, 0, 8, - 16, 194, 26, 33, 102, 122, 46, 226, 118, 82, 113, + 126, 38, 201, 183, 226, 145, 26, 196, 124, 127, 185, 12, 77, 198, 146, 16, 202, 189, 113, + 44, 100, 87, 81, 53, 172, 227, 97, 191, 120, 241, 86, 110, ]), Bytes32::new_direct([ - 226, 237, 125, 140, 144, 97, 153, 126, 209, 251, 156, 249, 109, 242, 202, 211, 140, 35, - 223, 224, 89, 200, 147, 112, 151, 147, 10, 75, 34, 110, 97, 204, + 45, 8, 41, 170, 235, 127, 133, 14, 253, 53, 201, 220, 96, 192, 168, 234, 110, 20, 174, 226, + 18, 4, 230, 182, 204, 99, 138, 27, 82, 209, 28, 68, ]), ]; From 2ce703fd963ecdeafb5930347bdab1116d8b5377 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 3 May 2024 17:55:57 +0200 Subject: [PATCH 048/268] Remove flat_merkle.rs. This implementation change wasn't necessary to speed up performance. And, it wasn't correctly handling the per-layer empty hashes. We *might* want to consider a complete rewrite of the merkle tree implementation to make the datastructures more friendly to various memory caches. But, not yet. --- arbitrator/prover/src/flat_merkle.rs | 226 --------------------------- arbitrator/prover/src/lib.rs | 1 - 2 files changed, 227 deletions(-) delete mode 100644 arbitrator/prover/src/flat_merkle.rs diff --git a/arbitrator/prover/src/flat_merkle.rs b/arbitrator/prover/src/flat_merkle.rs deleted file mode 100644 index 87ce55d14b..0000000000 --- a/arbitrator/prover/src/flat_merkle.rs +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2021-2022, Offchain Labs, Inc. -// For license information, see https://github.com/nitro/blob/master/LICENSE - -use arbutil::Bytes32; -use digest::Digest; -// use rayon::prelude::*; -use sha3::Keccak256; - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MerkleType { - Empty, - Value, - Function, - Instruction, - Memory, - Table, - TableElement, - Module, -} - -impl Default for MerkleType { - fn default() -> Self { - Self::Empty - } -} - -impl MerkleType { - pub fn get_prefix(self) -> &'static str { - match self { - MerkleType::Empty => panic!("Attempted to get prefix of empty merkle type"), - MerkleType::Value => "Value merkle tree:", - MerkleType::Function => "Function merkle tree:", - MerkleType::Instruction => "Instruction merkle tree:", - MerkleType::Memory => "Memory merkle tree:", - MerkleType::Table => "Table merkle tree:", - MerkleType::TableElement => "Table element merkle tree:", - MerkleType::Module => "Module merkle tree:", - } - } -} - -#[derive(Debug, Clone, PartialEq, Eq, Default)] -pub struct Merkle { - tree: Vec, - empty_hash: Bytes32, -} - -#[inline] -fn hash_node(a: &[u8], b: &[u8]) -> Bytes32 { - let mut h = Keccak256::new(); - h.update(a); - h.update(b); - h.finalize().into() -} - -impl Merkle { - pub fn new(ty: MerkleType, hashes: Vec) -> Merkle { - Self::new_advanced(ty, hashes, Bytes32::default(), 0) - } - pub fn new_advanced( - _ty: MerkleType, - hashes: Vec, - empty_hash: Bytes32, - min_depth: usize, - ) -> Merkle { - if hashes.is_empty() { - return Merkle::default(); - } - - let empty_layer_hash = hash_node(empty_hash.as_slice(), empty_hash.as_slice()); - - let hash_count = hashes.len(); - let mut current_level_size = hash_count; - - // Calculate the total capacity needed for the tree - let mut total_capacity = hash_count * 32; // 32 bytes per hash - let mut depth = min_depth; - while current_level_size > 1 || depth > 0 { - current_level_size = (current_level_size + 1) / 2; - total_capacity += current_level_size * 32; - depth = depth.saturating_sub(1); - } - let mut tree = Vec::with_capacity(total_capacity); - - // Append initial hashes to the tree - for hash in hashes.into_iter() { - tree.extend_from_slice(hash.as_slice()); - } - - let mut next_level_offset = tree.len(); - let mut depth = min_depth; - - while current_level_size > 1 || depth > 0 { - let mut i = next_level_offset - current_level_size * 32; - while i < next_level_offset { - let left = &tree[i..i + 32]; - let right = if i + 32 < next_level_offset { - &tree[i + 32..i + 64] - } else { - empty_layer_hash.as_slice() - }; - - let parent_hash = hash_node(left, right); - tree.extend(parent_hash.as_slice()); - - i += 64; - } - - current_level_size = (current_level_size + 1) / 2; - next_level_offset = tree.len(); - depth = depth.saturating_sub(1); - } - - Merkle { - tree, - empty_hash: empty_layer_hash, - } - } - - pub fn root(&self) -> Bytes32 { - let len = self.tree.len(); - let mut root = [0u8; 32]; - root.copy_from_slice(&self.tree[len - 32..len]); - root.into() - } - - pub fn leaves(&self) -> &[u8] { - let leaf_layer_size = self.calculate_layer_size(0); - &self.tree[..leaf_layer_size * 32] - } - - pub fn prove(&self, idx: usize) -> Option> { - let leaf_count = self.calculate_layer_size(0); - if idx >= leaf_count { - return None; - } - - let mut proof = Vec::new(); - let mut node_index = idx; - let mut layer_start = 0; - - for depth in 0.. { - let layer_size = self.calculate_layer_size(depth); - if layer_size <= 1 { - break; - } - - let sibling_index = if node_index % 2 == 0 { - node_index + 1 - } else { - node_index - 1 - }; - if sibling_index < layer_size { - proof.extend(self.get_node(layer_start, sibling_index)); - } - - node_index /= 2; - layer_start += layer_size * 32; - } - - Some(proof) - } - - // Helper function to get a node from the tree - #[inline(always)] - fn get_node(&self, layer_start: usize, index: usize) -> Bytes32 { - let start = layer_start + index * 32; - let mut node = [0u8; 32]; - node.copy_from_slice(&self.tree[start..start + 32]); - node.into() - } - - pub fn set(&mut self, mut idx: usize, hash: Bytes32) { - // Calculate the offset in the flat tree for the given index - let mut offset = idx * 32; - - // Check if the hash at the calculated position is the same as the input hash - if &self.tree[offset..offset + 32] == hash.as_slice() { - return; - } - - // Copy the new hash into the tree at the calculated position - self.tree[offset..offset + 32].copy_from_slice(hash.as_slice()); - - // Calculate the total number of nodes in the tree - let total_nodes = self.tree.len() / 32; - - // Update parent hashes up the tree - let mut next_hash = hash; - while idx > 0 { - idx = (idx - 1) / 2; // Move to the parent index - offset = idx * 32; - - // Calculate the position of the sibling in the flat tree - let sibling_idx = if idx % 2 == 0 { idx + 1 } else { idx - 1 }; - let sibling_offset = sibling_idx * 32; - - // Handle the case where the sibling index is out of bounds - let sibling_hash = if sibling_offset < total_nodes * 32 { - &self.tree[sibling_offset..sibling_offset + 32] - } else { - self.empty_hash.as_slice() - }; - - // Calculate the parent hash - next_hash = if idx % 2 == 0 { - hash_node(next_hash.as_slice(), sibling_hash) - } else { - hash_node(sibling_hash, next_hash.as_slice()) - }; - - // Update the parent node in the flat tree - self.tree[offset..offset + 32].copy_from_slice(next_hash.as_slice()); - } - } - - // Helper function to calculate the size of a given layer - #[inline(always)] - fn calculate_layer_size(&self, depth: usize) -> usize { - let mut size = self.tree.len() / 32; // Total number of nodes - for _ in 0..depth { - size = (size + 1) / 2; // Size of the current layer - } - size - } -} diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index 2992c6d13a..4895f0cba7 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -4,7 +4,6 @@ #![allow(clippy::missing_safety_doc, clippy::too_many_arguments)] pub mod binary; -pub mod flat_merkle; mod host; #[cfg(feature = "native")] mod kzg; From e67b0e1d1baa929526e13b59e58cbb8ef9c6f104 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 3 May 2024 18:23:07 +0200 Subject: [PATCH 049/268] Remove inlined capacity function. At some point, it was being used on its own, but now, it can just be a method on Merkle. --- arbitrator/prover/src/merkle.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index dc182419eb..b429be2d64 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -182,15 +182,6 @@ fn hash_node(ty: MerkleType, a: impl AsRef<[u8]>, b: impl AsRef<[u8]>) -> Bytes3 h.finalize().into() } -#[inline] -fn capacity(layers: &Vec>) -> usize { - if layers.is_empty() { - return 0; - } - let base: usize = 2; - base.pow((layers.len() - 1).try_into().unwrap()) -} - const fn empty_hash_at(ty: MerkleType, layer_i: usize) -> &'static Bytes32 { match ty { MerkleType::Empty => EMPTY_HASH, @@ -310,7 +301,12 @@ impl Merkle { // Returns the total number of leaves the tree can hold. #[inline] fn capacity(&self) -> usize { - return capacity(self.layers.lock().unwrap().as_ref()); + let layers = self.layers.lock().unwrap(); + if layers.is_empty() { + return 0; + } + let base: usize = 2; + base.pow((layers.len() - 1).try_into().unwrap()) } // Returns the number of leaves in the tree. From fc9e88ffda73e1a8538e9e6a80f784338a870137 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 3 May 2024 18:25:34 +0200 Subject: [PATCH 050/268] Remove the locked_set method. This was shared at one point between the set and expand functions. Since expand was replaced by `resize`, it is no longer needed. --- arbitrator/prover/src/merkle.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index b429be2d64..5a3cbadbc7 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -30,7 +30,7 @@ use sha3::Keccak256; use std::{ collections::HashSet, convert::{TryFrom, TryInto}, - sync::{Arc, Mutex, MutexGuard}, + sync::{Arc, Mutex}, }; #[cfg(feature = "rayon")] @@ -371,19 +371,10 @@ impl Merkle { #[cfg(feature = "counters")] SET_COUNTERS[&self.ty].fetch_add(1, Ordering::Relaxed); let mut layers = self.layers.lock().unwrap(); - self.locked_set(&mut layers, idx, hash); - } - - fn locked_set( - &self, - locked_layers: &mut MutexGuard>>, - idx: usize, - hash: Bytes32, - ) { - if locked_layers[0][idx] == hash { + if layers[0][idx] == hash { return; } - locked_layers[0][idx] = hash; + layers[0][idx] = hash; self.dirty_layers.lock().unwrap()[0].insert(idx >> 1); } From 35ce996eb1399126cbfb31125fb97e274839968c Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 8 May 2024 13:49:20 +0200 Subject: [PATCH 051/268] Use the json format from the go code for ValidationInputs. This allows us to dump ValidationInput messages from a runing nitro node, or even a system test, and use them to drive the benchmarking code. --- arbitrator/Cargo.lock | 168 ++++++++++++++++++++++++- arbitrator/bench/Cargo.toml | 5 +- arbitrator/bench/src/bin.rs | 10 +- arbitrator/bench/src/parse_input.rs | 187 ++++++++-------------------- arbitrator/bench/src/prepare.rs | 18 ++- 5 files changed, 234 insertions(+), 154 deletions(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 7c05d1fcf4..312042cfb0 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -55,6 +55,21 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anes" version = "0.1.6" @@ -181,6 +196,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "bench" version = "0.1.0" @@ -191,6 +212,9 @@ dependencies = [ "gperftools", "hex", "prover", + "serde", + "serde_json", + "serde_with 3.8.1", ] [[package]] @@ -375,6 +399,19 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets 0.52.5", +] + [[package]] name = "ciborium" version = "0.2.2" @@ -469,6 +506,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "corosensei" version = "0.1.4" @@ -704,6 +747,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim 0.10.0", "syn 2.0.52", ] @@ -742,6 +786,16 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + [[package]] name = "derivative" version = "2.2.0" @@ -1050,6 +1104,32 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] [[package]] name = "ident_case" @@ -1071,6 +1151,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", + "serde", ] [[package]] @@ -1081,6 +1162,7 @@ checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown 0.14.3", + "serde", ] [[package]] @@ -1376,6 +1458,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-derive" version = "0.4.2" @@ -1558,6 +1646,12 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1637,7 +1731,7 @@ dependencies = [ "rustc-demangle", "serde", "serde_json", - "serde_with", + "serde_with 1.14.0", "sha2 0.9.9", "sha3 0.9.1", "smallvec", @@ -1966,7 +2060,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ "serde", - "serde_with_macros", + "serde_with_macros 1.5.2", +] + +[[package]] +name = "serde_with" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +dependencies = [ + "base64", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.2.5", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros 3.8.1", + "time", ] [[package]] @@ -1981,6 +2093,18 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "serde_with_macros" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +dependencies = [ + "darling 0.20.8", + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "sha2" version = "0.9.9" @@ -2219,6 +2343,37 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -2682,6 +2837,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.5", +] + [[package]] name = "windows-sys" version = "0.33.0" diff --git a/arbitrator/bench/Cargo.toml b/arbitrator/bench/Cargo.toml index 396988ed83..3ab5b99b08 100644 --- a/arbitrator/bench/Cargo.toml +++ b/arbitrator/bench/Cargo.toml @@ -12,12 +12,15 @@ name = "benchbin" path = "src/bin.rs" [dependencies] -hex = "0.4.3" +hex = { version = "0.4.3", features = ["serde"] } eyre = "0.6.5" prover = { path = "../prover" } arbutil = { path = "../arbutil" } clap = { version = "4.4.8", features = ["derive"] } gperftools = { version = "0.2.0", optional = true } +serde = { version = "1.0.130", features = ["derive", "rc"] } +serde_json = "1.0.67" +serde_with = { version = "3.8.1", features = ["base64"] } [features] counters = [] diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 23930652c2..5fc7bae72f 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -33,7 +33,7 @@ struct Args { fn main() -> eyre::Result<()> { let args = Args::parse(); - let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24]; + let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24, 1 << 26, 1 << 28]; if args.always_merkleize { println!("Running benchmark with always merkleize feature on"); } else { @@ -82,14 +82,16 @@ fn main() -> eyre::Result<()> { bail!("Machine too far => position {}", machine.get_steps()) } MachineStatus::Running => {} - MachineStatus::Finished => return Ok(()), + MachineStatus::Finished => { + break; + } } let start = std::time::Instant::now(); let _ = machine.hash(); let hash_end_time = start.elapsed(); hash_times.push(hash_end_time); num_iters += 1; - if num_iters == 100 { + if num_iters == 200 { break; } } @@ -102,7 +104,7 @@ fn main() -> eyre::Result<()> { let total_end_time = total.elapsed(); println!( - "avg hash time {:>12?}, avg step time {:>12?}, step size {:>8}, num_iters {}, total time {:>12?}", + "avg hash time {:>11?}, avg step time {:>12?}, step size {:>9}, num_iters {:>3}, total time {:>12?}", average(&hash_times), average(&step_times), step_size, diff --git a/arbitrator/bench/src/parse_input.rs b/arbitrator/bench/src/parse_input.rs index 32f1c15ed3..f04150ea22 100644 --- a/arbitrator/bench/src/parse_input.rs +++ b/arbitrator/bench/src/parse_input.rs @@ -1,163 +1,76 @@ -use std::io::{self, BufRead}; +use arbutil::Bytes32; +use serde::{Deserialize, Serialize}; +use serde_json; +use serde_with::base64::Base64; +use serde_with::As; +use serde_with::DisplayFromStr; +use std::{ + collections::HashMap, + io::{self, BufRead}, +}; + +mod prefixed_hex { + use serde::{self, Deserialize, Deserializer, Serializer}; + + pub fn serialize(bytes: &Vec, serializer: S) -> Result + where + S: Serializer, + { + serializer.serialize_str(&format!("0x{}", hex::encode(bytes))) + } -#[derive(Debug, Clone)] -pub struct Preimage { - pub type_: u32, - pub hash: Vec, - pub data: Vec, + pub fn deserialize<'de, D>(deserializer: D) -> Result, D::Error> + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + if s.starts_with("0x") { + hex::decode(&s[2..]).map_err(serde::de::Error::custom) + } else { + Err(serde::de::Error::custom("missing 0x prefix")) + } + } } -#[derive(Debug, Clone)] -pub struct Item { - pub preimages: Vec, -} +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct PreimageMap(HashMap>); -#[derive(Debug)] +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "PascalCase")] pub struct BatchInfo { pub number: u64, - pub data: Vec, + #[serde(with = "As::")] + pub data_b64: Vec, } -#[derive(Debug)] +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "PascalCase")] pub struct StartState { + #[serde(with = "prefixed_hex")] pub block_hash: Vec, + #[serde(with = "prefixed_hex")] pub send_root: Vec, pub batch: u64, pub pos_in_batch: u64, } -#[derive(Debug)] +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "PascalCase")] pub struct FileData { pub id: u64, pub has_delayed_msg: bool, pub delayed_msg_nr: u64, - pub items: Vec, - pub batch_info: BatchInfo, - pub delayed_msg: Vec, + #[serde(with = "As::>>")] + pub preimages_b64: HashMap>>, + pub batch_info: Vec, + #[serde(with = "As::")] + pub delayed_msg_b64: Vec, pub start_state: StartState, } impl FileData { pub fn from_reader(mut reader: R) -> io::Result { - let mut items = Vec::new(); - let mut batch_info = BatchInfo { - number: 0, - data: Vec::new(), - }; - let mut id = 0; - let mut has_delayed_msg = false; - let mut delayed_msg_nr = 0; - let mut delayed_msg = Vec::new(); - let mut start_state = StartState { - block_hash: Vec::new(), - send_root: Vec::new(), - batch: 0, - pos_in_batch: 0, - }; - - let mut line = String::new(); - while reader.read_line(&mut line)? > 0 { - if line.starts_with("Id:") { - id = line.split(':').nth(1).unwrap().trim().parse().unwrap(); - } else if line.starts_with("HasDelayedMsg:") { - has_delayed_msg = line.split(':').nth(1).unwrap().trim().parse().unwrap(); - } else if line.starts_with("DelayedMsgNr:") { - delayed_msg_nr = line.split(':').nth(1).unwrap().trim().parse().unwrap(); - } else if line.starts_with("Preimages:") { - items.push(Item::from_reader(&mut reader, &mut line)?); - } else if line.starts_with("BatchInfo:") { - let parts: Vec<_> = line.split(',').collect(); - batch_info.number = parts[0].split(':').nth(2).unwrap().trim().parse().unwrap(); - batch_info.data = hex::decode(parts[1].split(':').nth(1).unwrap().trim()).unwrap(); - } else if line.starts_with("DelayedMsg:") { - delayed_msg = hex::decode(line.split(':').nth(1).unwrap().trim()).unwrap(); - } else if line.starts_with("StartState:") { - let parts: Vec<_> = line.split(',').collect(); - - // Parsing block_hash - let block_hash_str = parts[0].split("BlockHash:").nth(1).unwrap().trim(); - start_state.block_hash = - hex::decode(block_hash_str.strip_prefix("0x").unwrap()).unwrap(); - - // Parsing send_root - let send_root_str = parts[1].split(':').nth(1).unwrap().trim(); - start_state.send_root = - hex::decode(send_root_str.strip_prefix("0x").unwrap()).unwrap(); - - // Parsing batch - start_state.batch = parts[2] - .split(':') - .nth(1) - .unwrap() - .trim() - .parse::() - .unwrap(); - - // Parsing pos_in_batch - start_state.pos_in_batch = parts[3] - .split(':') - .nth(1) - .unwrap() - .trim() - .parse::() - .unwrap(); - } - line.clear(); - } - - Ok(FileData { - id, - has_delayed_msg, - delayed_msg_nr, - items, - batch_info, - delayed_msg, - start_state, - }) - } -} - -impl Item { - pub fn from_reader(reader: &mut R, line: &mut String) -> io::Result { - let mut preimages = Vec::new(); - - loop { - if line.is_empty() - || line.starts_with("BatchInfo:") - || line.starts_with("DelayedMsg:") - || line.starts_with("StartState:") - { - break; - } - if line.starts_with("Preimages:") { - line.clear(); - while reader.read_line(line)? > 0 && line.starts_with('\t') { - let parts: Vec<_> = line.trim().split(',').collect(); - let type_ = parts[0].split(':').nth(1).unwrap().trim().parse().unwrap(); - let hash = hex::decode( - parts[1] - .split(':') - .nth(1) - .unwrap() - .trim() - .strip_prefix("0x") - .unwrap(), - ) - .unwrap(); - let data = hex::decode(parts[2].split(':').nth(1).unwrap().trim()).unwrap(); - preimages.push(Preimage { type_, hash, data }); - line.clear(); - } - continue; // To skip line.clear() at the end of the loop for this case - } - - line.clear(); - if reader.read_line(line)? == 0 { - // If EOF is reached - break; - } - } - - Ok(Item { preimages }) + let data = serde_json::from_reader(&mut reader)?; + return Ok(data); } } diff --git a/arbitrator/bench/src/prepare.rs b/arbitrator/bench/src/prepare.rs index daf0f48f8f..3cc884db6d 100644 --- a/arbitrator/bench/src/prepare.rs +++ b/arbitrator/bench/src/prepare.rs @@ -18,15 +18,11 @@ pub fn prepare_machine( let reader = BufReader::new(file); let data = FileData::from_reader(reader)?; - let item = data.items.first().unwrap().clone(); - let preimages = item.preimages; - let preimages = preimages + let preimages = data + .preimages_b64 .into_iter() - .map(|preimage| { - let hash: [u8; 32] = preimage.hash.try_into().unwrap(); - let hash: Bytes32 = hash.into(); - (hash, preimage.data) - }) + .map(|preimage| preimage.1.into_iter().map(|(k, v)| (k, v))) + .flatten() .collect::>>(); let preimage_resolver = move |_: u64, _: PreimageType, hash: Bytes32| -> Option { preimages @@ -59,11 +55,13 @@ pub fn prepare_machine( // println!("Adding sequencer inbox message"); let identifier = argument_data_to_inbox(0).unwrap(); - mach.add_inbox_msg(identifier, data.batch_info.number, data.batch_info.data); + for batch_info in data.batch_info.iter() { + mach.add_inbox_msg(identifier, batch_info.number, batch_info.data_b64.clone()); + } // println!("Adding delayed inbox message"); let identifier = argument_data_to_inbox(1).unwrap(); - mach.add_inbox_msg(identifier, data.delayed_msg_nr, data.delayed_msg); + mach.add_inbox_msg(identifier, data.delayed_msg_nr, data.delayed_msg_b64); Ok(mach) } From b9bad0c6892ab0a49cedb0c77c9f6e39cd8cdc3e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 8 May 2024 17:00:31 +0200 Subject: [PATCH 052/268] Fix a bug in Memory::store_slice_aligned() The method was taking the value of the merkle tree and not returning it. --- arbitrator/prover/src/memory.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 4709c406a7..bba8e4124f 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -263,6 +263,7 @@ impl Memory { merkle.set(start_leaf, hash_leaf(self.get_leaf_data(start_leaf))); // No need for second merkle assert!(value.len() <= Self::LEAF_SIZE); + self.merkle = Some(merkle); } true From 9453b4024108b88a6b680fee27707ba48fe8f5ca Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 10 May 2024 16:41:52 +0200 Subject: [PATCH 053/268] Add more counters. We need to be able to see how frequently the memory is being hashed and from where. The problem is that with always_merkleize off, there are thousands of fewer calls to `Merkle::root()` and this is to help us figure out where the calls are coming from. Spoiler alert: It's from the flush_module macro. --- arbitrator/bench/src/bin.rs | 16 ++++++++++++--- arbitrator/prover/src/lib.rs | 2 +- arbitrator/prover/src/machine.rs | 34 ++++++++++++++++++++++++++++++++ arbitrator/prover/src/memory.rs | 22 +++++++++++++++++++++ arbitrator/prover/src/merkle.rs | 23 +++++++++++++++++++-- 5 files changed, 91 insertions(+), 6 deletions(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 5fc7bae72f..185f7e2642 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -13,7 +13,7 @@ use gperftools::heap_profiler::HEAP_PROFILER; use prover::machine::MachineStatus; #[cfg(feature = "counters")] -use prover::merkle; +use prover::{machine, memory, merkle}; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] @@ -34,6 +34,8 @@ struct Args { fn main() -> eyre::Result<()> { let args = Args::parse(); let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24, 1 << 26, 1 << 28]; + // let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24]; + if args.always_merkleize { println!("Running benchmark with always merkleize feature on"); } else { @@ -65,7 +67,11 @@ fn main() -> eyre::Result<()> { .unwrap(); #[cfg(feature = "counters")] - merkle::reset_counters(); + { + machine::reset_counters(); + memory::reset_counters(); + merkle::reset_counters(); + } let total = std::time::Instant::now(); loop { let start = std::time::Instant::now(); @@ -112,7 +118,11 @@ fn main() -> eyre::Result<()> { total_end_time, ); #[cfg(feature = "counters")] - merkle::print_counters(); + { + machine::print_counters(); + memory::print_counters(); + merkle::print_counters(); + } } Ok(()) } diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index 4895f0cba7..1e3ecf4cd6 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -9,7 +9,7 @@ mod host; mod kzg; pub mod machine; /// cbindgen:ignore -mod memory; +pub mod memory; pub mod merkle; mod print; pub mod programs; diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index 6b0e1df3e1..fbbacd9fb6 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -32,6 +32,10 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; use sha3::Keccak256; use smallvec::SmallVec; + +#[cfg(feature = "counters")] +use std::sync::atomic::{AtomicUsize, Ordering}; + use std::{ borrow::Cow, convert::{TryFrom, TryInto}, @@ -44,12 +48,37 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; + use wasmer_types::FunctionIndex; use wasmparser::{DataKind, ElementItems, ElementKind, Operator, RefType, TableType}; #[cfg(feature = "rayon")] use rayon::prelude::*; +#[cfg(feature = "counters")] +static GET_MODULES_MERKLE_COUNTER: AtomicUsize = AtomicUsize::new(0); + +#[cfg(feature = "counters")] +static FLUSH_MODULE_COUNTER: AtomicUsize = AtomicUsize::new(0); + +#[cfg(feature = "counters")] +pub fn print_counters() { + println!( + "GET_MODULES_MERKLE_COUNTER: {}", + GET_MODULES_MERKLE_COUNTER.load(Ordering::Relaxed) + ); + println!( + "FLUSH_MODULE_COUNTER: {}", + FLUSH_MODULE_COUNTER.load(Ordering::Relaxed) + ); +} + +#[cfg(feature = "counters")] +pub fn reset_counters() { + GET_MODULES_MERKLE_COUNTER.store(0, Ordering::Relaxed); + FLUSH_MODULE_COUNTER.store(0, Ordering::Relaxed); +} + fn hash_call_indirect_data(table: u32, ty: &FunctionType) -> Bytes32 { let mut h = Keccak256::new(); h.update("Call indirect:"); @@ -1918,6 +1947,8 @@ impl Machine { } macro_rules! flush_module { () => { + #[cfg(feature = "counters")] + FLUSH_MODULE_COUNTER.fetch_add(1, Ordering::Relaxed); if let Some(merkle) = self.modules_merkle.as_mut() { merkle.set(self.pc.module(), module.hash()); } @@ -2696,6 +2727,9 @@ impl Machine { } fn get_modules_merkle(&self) -> Cow { + #[cfg(feature = "counters")] + GET_MODULES_MERKLE_COUNTER.fetch_add(1, Ordering::Relaxed); + if let Some(merkle) = &self.modules_merkle { Cow::Borrowed(merkle) } else { diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index bba8e4124f..0c49a1b54b 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -11,11 +11,31 @@ use eyre::{bail, ErrReport, Result}; use serde::{Deserialize, Serialize}; use sha3::Keccak256; use std::{borrow::Cow, convert::TryFrom}; + +#[cfg(feature = "counters")] +use std::sync::atomic::{AtomicUsize, Ordering}; + use wasmer_types::Pages; #[cfg(feature = "rayon")] use rayon::prelude::*; +#[cfg(feature = "counters")] +static MEM_HASH_COUNTER: AtomicUsize = AtomicUsize::new(0); + +#[cfg(feature = "counters")] +pub fn reset_counters() { + MEM_HASH_COUNTER.store(0, Ordering::Relaxed); +} + +#[cfg(feature = "counters")] +pub fn print_counters() { + println!( + "Memory hash count: {}", + MEM_HASH_COUNTER.load(Ordering::Relaxed) + ); +} + pub struct MemoryType { pub min: Pages, pub max: Option, @@ -138,6 +158,8 @@ impl Memory { } pub fn hash(&self) -> Bytes32 { + #[cfg(feature = "counters")] + MEM_HASH_COUNTER.fetch_add(1, Ordering::Relaxed); let mut h = Keccak256::new(); h.update("Memory:"); h.update((self.buffer.len() as u64).to_be_bytes()); diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 5a3cbadbc7..82c03e5d66 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -87,6 +87,21 @@ lazy_static! { map }; } +#[cfg(feature = "counters")] +lazy_static! { + static ref RESIZE_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { + let mut map = HashMap::new(); + map.insert(&MerkleType::Empty, AtomicUsize::new(0)); + map.insert(&MerkleType::Value, AtomicUsize::new(0)); + map.insert(&MerkleType::Function, AtomicUsize::new(0)); + map.insert(&MerkleType::Instruction, AtomicUsize::new(0)); + map.insert(&MerkleType::Memory, AtomicUsize::new(0)); + map.insert(&MerkleType::Table, AtomicUsize::new(0)); + map.insert(&MerkleType::TableElement, AtomicUsize::new(0)); + map.insert(&MerkleType::Module, AtomicUsize::new(0)); + map + }; +} #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Sequence)] pub enum MerkleType { @@ -113,11 +128,12 @@ pub fn print_counters() { continue; } println!( - "{} New: {}, Root: {}, Set: {}", + "{} New: {}, Root: {}, Set: {} Resize: {}", ty.get_prefix(), NEW_COUNTERS[&ty].load(Ordering::Relaxed), ROOT_COUNTERS[&ty].load(Ordering::Relaxed), - SET_COUNTERS[&ty].load(Ordering::Relaxed) + SET_COUNTERS[&ty].load(Ordering::Relaxed), + RESIZE_COUNTERS[&ty].load(Ordering::Relaxed), ); } } @@ -131,6 +147,7 @@ pub fn reset_counters() { NEW_COUNTERS[&ty].store(0, Ordering::Relaxed); ROOT_COUNTERS[&ty].store(0, Ordering::Relaxed); SET_COUNTERS[&ty].store(0, Ordering::Relaxed); + RESIZE_COUNTERS[&ty].store(0, Ordering::Relaxed); } } @@ -382,6 +399,8 @@ impl Merkle { /// /// The extra space is filled with empty hashes. pub fn resize(&self, new_len: usize) -> Result { + #[cfg(feature = "counters")] + RESIZE_COUNTERS[&self.ty].fetch_add(1, Ordering::Relaxed); if new_len > self.capacity() { return Err( "Cannot resize to a length greater than the capacity of the tree.".to_owned(), From e8c750adc5fa5ecc39a8efbeb1a3eea60382ccf5 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 10 May 2024 17:02:09 +0200 Subject: [PATCH 054/268] Remove flush_module macro. The high-level benefit of this change is a 16.5% reduction in block processing time from ~17.6s to ~14.7s. The only job of that macro was to recalculate the hash of the module and update the module merkle tree's corresponding leaf with the new hash. Instead, the waits until the hash for the module is about to be calculated and calls `Merkle::set()` for each module in the modules vector. This eliminates thousands of calls to the possibly expensive `Merkle::root()` call on the `Memory` of each module. This pattern of delaying when to actually update the leaves of merkle trees until they will be used has a lot of potential for additional performance boosts. --- arbitrator/prover/src/machine.rs | 34 +++----------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index fbbacd9fb6..5c4471a9fd 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -58,25 +58,17 @@ use rayon::prelude::*; #[cfg(feature = "counters")] static GET_MODULES_MERKLE_COUNTER: AtomicUsize = AtomicUsize::new(0); -#[cfg(feature = "counters")] -static FLUSH_MODULE_COUNTER: AtomicUsize = AtomicUsize::new(0); - #[cfg(feature = "counters")] pub fn print_counters() { println!( "GET_MODULES_MERKLE_COUNTER: {}", GET_MODULES_MERKLE_COUNTER.load(Ordering::Relaxed) ); - println!( - "FLUSH_MODULE_COUNTER: {}", - FLUSH_MODULE_COUNTER.load(Ordering::Relaxed) - ); } #[cfg(feature = "counters")] pub fn reset_counters() { GET_MODULES_MERKLE_COUNTER.store(0, Ordering::Relaxed); - FLUSH_MODULE_COUNTER.store(0, Ordering::Relaxed); } fn hash_call_indirect_data(table: u32, ty: &FunctionType) -> Bytes32 { @@ -1945,22 +1937,11 @@ impl Machine { func = &module.funcs[self.pc.func()]; }; } - macro_rules! flush_module { - () => { - #[cfg(feature = "counters")] - FLUSH_MODULE_COUNTER.fetch_add(1, Ordering::Relaxed); - if let Some(merkle) = self.modules_merkle.as_mut() { - merkle.set(self.pc.module(), module.hash()); - } - }; - } macro_rules! error { () => { error!("") }; ($format:expr $(, $message:expr)*) => {{ - flush_module!(); - if self.debug_info { println!("\n{} {}", "error on line".grey(), line!().pink()); println!($format, $($message.pink()),*); @@ -1979,7 +1960,6 @@ impl Machine { continue; } self.status = MachineStatus::Errored; - module = &mut self.modules[self.pc.module()]; break; }}; } @@ -1990,7 +1970,6 @@ impl Machine { println!("\n{}", "Machine out of steps".red()); self.status = MachineStatus::Errored; self.print_backtrace(true); - module = &mut self.modules[self.pc.module()]; break; } @@ -2050,9 +2029,6 @@ impl Machine { Value::RefNull => error!(), Value::InternalRef(pc) => { let changing_module = pc.module != self.pc.module; - if changing_module { - flush_module!(); - } self.pc = pc; if changing_module { module = &mut self.modules[self.pc.module()]; @@ -2072,7 +2048,6 @@ impl Machine { func = &module.funcs[self.pc.func()]; } Opcode::CrossModuleCall => { - flush_module!(); value_stack.push(Value::InternalRef(self.pc)); value_stack.push(self.pc.module.into()); value_stack.push(module.internals_offset.into()); @@ -2083,7 +2058,6 @@ impl Machine { reset_refs!(); } Opcode::CrossModuleForward => { - flush_module!(); let frame = frame_stack.last().unwrap(); value_stack.push(Value::InternalRef(self.pc)); value_stack.push(frame.caller_module.into()); @@ -2095,7 +2069,6 @@ impl Machine { reset_refs!(); } Opcode::CrossModuleInternalCall => { - flush_module!(); let call_internal = inst.argument_data as u32; let call_module = value_stack.pop().unwrap().assume_u32(); value_stack.push(Value::InternalRef(self.pc)); @@ -2118,7 +2091,6 @@ impl Machine { .ok() .and_then(|o| current_frame.caller_module_internals.checked_add(o)) .expect("Internal call function index overflow"); - flush_module!(); self.pc.module = current_frame.caller_module; self.pc.func = func_idx; self.pc.inst = 0; @@ -2550,7 +2522,6 @@ impl Machine { let dots = (modules.len() > 16).then_some("...").unwrap_or_default(); bail!("no program for {hash} in {{{}{dots}}}", keys.join(", ")) }; - flush_module!(); // put the new module's offset on the stack let index = self.modules.len() as u32; @@ -2563,7 +2534,6 @@ impl Machine { reset_refs!(); } Opcode::UnlinkModule => { - flush_module!(); self.modules.pop(); if let Some(cached) = &mut self.modules_merkle { cached.pop_leaf(); @@ -2603,7 +2573,6 @@ impl Machine { } } } - flush_module!(); if self.is_halted() && !self.stdio_output.is_empty() { // If we halted, print out any trailing output that didn't have a newline. Self::say(String::from_utf8_lossy(&self.stdio_output)); @@ -2731,6 +2700,9 @@ impl Machine { GET_MODULES_MERKLE_COUNTER.fetch_add(1, Ordering::Relaxed); if let Some(merkle) = &self.modules_merkle { + for (i, module) in self.modules.iter().enumerate() { + merkle.set(i, module.hash()); + } Cow::Borrowed(merkle) } else { Cow::Owned(Merkle::new( From 6ba0a693f58289c5acf9ff9c4bcaf604c7cb2d93 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 13 May 2024 14:27:03 +0200 Subject: [PATCH 055/268] Speed up block validation by another 27%. This change just marks memory as dirty when storing new values rather than actually calculating the new hash for the data in memory and then calculates the hashes for dirty indices just before creating the merkle tree. On one test block, this ended up saving 23 million calls to keccack. --- arbitrator/bench/src/bin.rs | 1 - arbitrator/prover/src/memory.rs | 50 ++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 185f7e2642..3b527fb8dd 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -34,7 +34,6 @@ struct Args { fn main() -> eyre::Result<()> { let args = Args::parse(); let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24, 1 << 26, 1 << 28]; - // let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24]; if args.always_merkleize { println!("Running benchmark with always merkleize feature on"); diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 0c49a1b54b..78b5ba7259 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -10,7 +10,13 @@ use digest::Digest; use eyre::{bail, ErrReport, Result}; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use std::{borrow::Cow, convert::TryFrom}; +use std::{ + borrow::Cow, + collections::HashSet, + convert::TryFrom, + ops::Deref, + sync::{Arc, Mutex}, +}; #[cfg(feature = "counters")] use std::sync::atomic::{AtomicUsize, Ordering}; @@ -64,12 +70,14 @@ impl TryFrom<&wasmparser::MemoryType> for MemoryType { } } -#[derive(PartialEq, Eq, Clone, Debug, Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct Memory { buffer: Vec, #[serde(skip)] pub merkle: Option, pub max_size: u64, + #[serde(skip)] + dirty_indices: Arc>>, } fn hash_leaf(bytes: [u8; Memory::LEAF_SIZE]) -> Bytes32 { @@ -98,6 +106,16 @@ fn div_round_up(num: usize, denom: usize) -> usize { res } +impl PartialEq for Memory { + fn eq(&self, other: &Memory) -> bool { + self.buffer == other.buffer + && self.merkle == other.merkle + && self.max_size == other.max_size + && self.dirty_indices.lock().unwrap().deref() + == other.dirty_indices.lock().unwrap().deref() + } +} + impl Memory { pub const LEAF_SIZE: usize = 32; /// Only used when initializing a memory to determine its size @@ -111,6 +129,7 @@ impl Memory { buffer: vec![0u8; size], merkle: None, max_size, + dirty_indices: Arc::new(Mutex::new(HashSet::new())), } } @@ -120,6 +139,11 @@ impl Memory { pub fn merkelize(&self) -> Cow<'_, Merkle> { if let Some(m) = &self.merkle { + for idx in self.dirty_indices.lock().unwrap().iter() { + let leaf_idx = idx / Self::LEAF_SIZE; + m.set(leaf_idx, hash_leaf(self.get_leaf_data(leaf_idx))); + } + self.dirty_indices.lock().unwrap().clear(); return Cow::Borrowed(m); } // Round the size up to 8 byte long leaves, then round up to the next power of two number of leaves @@ -143,6 +167,7 @@ impl Memory { if size < leaves { m.resize(leaves).expect("Couldn't resize merkle tree"); } + self.dirty_indices.lock().unwrap().clear(); Cow::Owned(m) } @@ -251,16 +276,8 @@ impl Memory { let end_idx = end_idx as usize; let buf = value.to_le_bytes(); self.buffer[idx..end_idx].copy_from_slice(&buf[..bytes.into()]); - - if let Some(merkle) = self.merkle.take() { - let start_leaf = idx / Self::LEAF_SIZE; - merkle.set(start_leaf, hash_leaf(self.get_leaf_data(start_leaf))); - let end_leaf = (end_idx - 1) / Self::LEAF_SIZE; - if end_leaf != start_leaf { - merkle.set(end_leaf, hash_leaf(self.get_leaf_data(end_leaf))); - } - self.merkle = Some(merkle); - } + self.dirty_indices.lock().unwrap().insert(idx); + self.dirty_indices.lock().unwrap().insert(end_idx - 1); true } @@ -279,14 +296,7 @@ impl Memory { let idx = idx as usize; let end_idx = end_idx as usize; self.buffer[idx..end_idx].copy_from_slice(value); - - if let Some(merkle) = self.merkle.take() { - let start_leaf = idx / Self::LEAF_SIZE; - merkle.set(start_leaf, hash_leaf(self.get_leaf_data(start_leaf))); - // No need for second merkle - assert!(value.len() <= Self::LEAF_SIZE); - self.merkle = Some(merkle); - } + self.dirty_indices.lock().unwrap().insert(idx); true } From d247ebdca167fe6208325197f13c47de3575b88e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 13 May 2024 15:23:22 +0200 Subject: [PATCH 056/268] Enable always_merkleize everywhere. This is to prove that the code is still fast enough to pass the test-go suite of tests if the `always_merkleize` feature is enabled. --- arbitrator/prover/src/lib.rs | 4 ++-- arbitrator/prover/src/machine.rs | 2 +- arbitrator/stylus/src/test/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index 1e3ecf4cd6..b9dc032f40 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -101,7 +101,7 @@ unsafe fn arbitrator_load_machine_impl( &libraries, binary_path, true, - false, + true, false, debug_chain, debug_chain, @@ -117,7 +117,7 @@ unsafe fn arbitrator_load_machine_impl( pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char) -> *mut Machine { let binary_path = cstr_to_string(binary_path); let binary_path = Path::new(&binary_path); - match Machine::new_from_wavm(binary_path, false) { + match Machine::new_from_wavm(binary_path, true) { Ok(mach) => Box::into_raw(Box::new(mach)), Err(err) => { eprintln!("Error loading binary: {err}"); diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index 5c4471a9fd..5aa7954653 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1276,7 +1276,7 @@ impl Machine { &[soft_float, wasi_stub, user_test], bin, false, - false, + true, false, compile.debug.debug_funcs, true, diff --git a/arbitrator/stylus/src/test/mod.rs b/arbitrator/stylus/src/test/mod.rs index d7f3248d31..2f8819df86 100644 --- a/arbitrator/stylus/src/test/mod.rs +++ b/arbitrator/stylus/src/test/mod.rs @@ -150,7 +150,7 @@ fn new_test_machine(path: &str, compile: &CompileConfig) -> Result { &[lib], bin, false, - false, + true, true, compile.debug.debug_funcs, true, From 701327647c1a17b21e6c59ae297e5b9227a79b90 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 13 May 2024 16:24:03 +0200 Subject: [PATCH 057/268] Make always_merkleize the only strategy. This is now fast enough to just use it as the only implementation and simplify the code a bit. --- arbitrator/bench/src/bin.rs | 16 ++----------- arbitrator/bench/src/prepare.rs | 8 ++----- arbitrator/prover/src/lib.rs | 3 +-- arbitrator/prover/src/machine.rs | 37 +++++++++---------------------- arbitrator/prover/src/main.rs | 3 --- arbitrator/stylus/src/test/mod.rs | 1 - 6 files changed, 16 insertions(+), 52 deletions(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 3b527fb8dd..5c71448991 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -25,27 +25,15 @@ struct Args { /// Path to a machine.wavm.br #[arg(short, long)] machine_path: PathBuf, - - /// Should the memory tree always Merkleize - #[arg(short, long)] - always_merkleize: bool, } fn main() -> eyre::Result<()> { let args = Args::parse(); let step_sizes = [1, 1 << 10, 1 << 15, 1 << 20, 1 << 24, 1 << 26, 1 << 28]; - if args.always_merkleize { - println!("Running benchmark with always merkleize feature on"); - } else { - println!("Running benchmark with always merkleize feature off"); - } + println!("Running benchmark with always merkleize feature on"); for step_size in step_sizes { - let mut machine = prepare_machine( - args.preimages_path.clone(), - args.machine_path.clone(), - args.always_merkleize, - )?; + let mut machine = prepare_machine(args.preimages_path.clone(), args.machine_path.clone())?; let _ = machine.hash(); let mut hash_times = vec![]; let mut step_times = vec![]; diff --git a/arbitrator/bench/src/prepare.rs b/arbitrator/bench/src/prepare.rs index 3cc884db6d..aebc7ae895 100644 --- a/arbitrator/bench/src/prepare.rs +++ b/arbitrator/bench/src/prepare.rs @@ -9,11 +9,7 @@ use std::sync::Arc; use crate::parse_input::*; -pub fn prepare_machine( - preimages: PathBuf, - machines: PathBuf, - always_merkleize: bool, -) -> eyre::Result { +pub fn prepare_machine(preimages: PathBuf, machines: PathBuf) -> eyre::Result { let file = File::open(preimages)?; let reader = BufReader::new(file); @@ -33,7 +29,7 @@ pub fn prepare_machine( let binary_path = Path::new(&machines); // println!("Creating machine from binary_path"); - let mut mach = Machine::new_from_wavm(binary_path, always_merkleize)?; + let mut mach = Machine::new_from_wavm(binary_path)?; let block_hash: [u8; 32] = data.start_state.block_hash.try_into().unwrap(); let block_hash: Bytes32 = block_hash.into(); diff --git a/arbitrator/prover/src/lib.rs b/arbitrator/prover/src/lib.rs index b9dc032f40..0f537478eb 100644 --- a/arbitrator/prover/src/lib.rs +++ b/arbitrator/prover/src/lib.rs @@ -102,7 +102,6 @@ unsafe fn arbitrator_load_machine_impl( binary_path, true, true, - false, debug_chain, debug_chain, Default::default(), @@ -117,7 +116,7 @@ unsafe fn arbitrator_load_machine_impl( pub unsafe extern "C" fn arbitrator_load_wavm_binary(binary_path: *const c_char) -> *mut Machine { let binary_path = cstr_to_string(binary_path); let binary_path = Path::new(&binary_path); - match Machine::new_from_wavm(binary_path, true) { + match Machine::new_from_wavm(binary_path) { Ok(mach) => Box::into_raw(Box::new(mach)), Err(err) => { eprintln!("Error loading binary: {err}"); diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index 5aa7954653..c7550e642a 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1221,7 +1221,6 @@ impl Machine { library_paths: &[PathBuf], binary_path: &Path, language_support: bool, - always_merkleize: bool, allow_hostapi_from_main: bool, debug_funcs: bool, debug_info: bool, @@ -1246,7 +1245,6 @@ impl Machine { &libraries, bin, language_support, - always_merkleize, allow_hostapi_from_main, debug_funcs, debug_info, @@ -1277,7 +1275,6 @@ impl Machine { bin, false, true, - false, compile.debug.debug_funcs, true, GlobalState::default(), @@ -1324,7 +1321,6 @@ impl Machine { libraries: &[WasmBinary<'_>], bin: WasmBinary<'_>, runtime_support: bool, - always_merkleize: bool, allow_hostapi_from_main: bool, debug_funcs: bool, debug_info: bool, @@ -1527,18 +1523,12 @@ impl Machine { let tables_hashes: Result<_, _> = module.tables.iter().map(Table::hash).collect(); module.tables_merkle = Merkle::new(MerkleType::Table, tables_hashes?); - - if always_merkleize { - module.memory.cache_merkle_tree(); - } - } - let mut modules_merkle = None; - if always_merkleize { - modules_merkle = Some(Merkle::new( - MerkleType::Module, - modules.iter().map(Module::hash).collect(), - )); + module.memory.cache_merkle_tree(); } + let modules_merkle = Some(Merkle::new( + MerkleType::Module, + modules.iter().map(Module::hash).collect(), + )); // find the first inbox index that's out of bounds let first_too_far = inbox_contents @@ -1572,7 +1562,7 @@ impl Machine { Ok(mach) } - pub fn new_from_wavm(wavm_binary: &Path, always_merkleize: bool) -> Result { + pub fn new_from_wavm(wavm_binary: &Path) -> Result { let mut modules: Vec = { let compressed = std::fs::read(wavm_binary)?; let Ok(modules) = brotli::decompress(&compressed, Dictionary::Empty) else { @@ -1598,17 +1588,12 @@ impl Machine { MerkleType::Function, module.funcs.iter().map(Function::hash).collect(), )); - if always_merkleize { - module.memory.cache_merkle_tree(); - } - } - let mut modules_merkle: Option = None; - if always_merkleize { - modules_merkle = Some(Merkle::new( - MerkleType::Module, - modules.iter().map(Module::hash).collect(), - )); + module.memory.cache_merkle_tree(); } + let modules_merkle = Some(Merkle::new( + MerkleType::Module, + modules.iter().map(Module::hash).collect(), + )); let mut mach = Machine { status: MachineStatus::Running, thread_state: ThreadState::Main, diff --git a/arbitrator/prover/src/main.rs b/arbitrator/prover/src/main.rs index 697d178fc7..01001b0794 100644 --- a/arbitrator/prover/src/main.rs +++ b/arbitrator/prover/src/main.rs @@ -35,8 +35,6 @@ struct Opts { #[structopt(long)] inbox_add_stub_headers: bool, #[structopt(long)] - always_merkleize: bool, - #[structopt(long)] debug_funcs: bool, #[structopt(long)] /// print modules to the console @@ -192,7 +190,6 @@ fn main() -> Result<()> { &opts.libraries, &opts.binary, true, - opts.always_merkleize, opts.allow_hostapi, opts.debug_funcs, true, diff --git a/arbitrator/stylus/src/test/mod.rs b/arbitrator/stylus/src/test/mod.rs index 2f8819df86..236e5639e6 100644 --- a/arbitrator/stylus/src/test/mod.rs +++ b/arbitrator/stylus/src/test/mod.rs @@ -151,7 +151,6 @@ fn new_test_machine(path: &str, compile: &CompileConfig) -> Result { bin, false, true, - true, compile.debug.debug_funcs, true, GlobalState::default(), From 4087fd466ff87a01e9c621be77ef1eabb931e3d1 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 17 May 2024 17:28:53 +0200 Subject: [PATCH 058/268] Fix the Cargo.lock file It had been merged incorrectly from master. --- arbitrator/Cargo.lock | 237 ++++++++++++++++++++++++------------------ 1 file changed, 133 insertions(+), 104 deletions(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 1a0cc4f053..3d2ddcc04e 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -55,6 +55,12 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -66,47 +72,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -349,9 +356,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" dependencies = [ "jobserver", "libc", @@ -443,7 +450,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.64", ] [[package]] @@ -454,9 +461,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "convert_case" @@ -667,12 +674,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ - "darling_core 0.20.8", - "darling_macro 0.20.8", + "darling_core 0.20.9", + "darling_macro 0.20.9", ] [[package]] @@ -691,15 +698,15 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -715,13 +722,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ - "darling_core 0.20.8", + "darling_core 0.20.9", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -808,9 +815,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "enum-iterator" @@ -823,11 +830,11 @@ dependencies = [ [[package]] name = "enum-iterator" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0b48d2b80ff6b002339547442496ea29d66a8c66ce8e1a6bd8c58b9cec7cf3" +checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" dependencies = [ - "enum-iterator-derive 1.3.1", + "enum-iterator-derive 1.4.0", ] [[package]] @@ -843,13 +850,13 @@ dependencies = [ [[package]] name = "enum-iterator-derive" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19cbb53d33b57ac4df1f0af6b92c38c107cded663c4aea9fae1189dcfc17cf5" +checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.64", ] [[package]] @@ -867,10 +874,10 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ - "darling 0.20.8", + "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -1114,6 +1121,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.10.5" @@ -1194,9 +1207,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.154" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libfuzzer-sys" @@ -1348,9 +1361,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -1362,20 +1375,19 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", ] [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] @@ -1388,7 +1400,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -1413,11 +1425,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -1460,7 +1471,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -1519,7 +1530,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets", ] [[package]] @@ -1528,6 +1539,40 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1569,9 +1614,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -1587,7 +1632,7 @@ dependencies = [ "criterion", "derivative", "digest 0.9.0", - "enum-iterator 2.0.1", + "enum-iterator 2.1.0", "eyre", "fnv", "hex", @@ -1835,9 +1880,9 @@ checksum = "89dc553bc0cf4512a8b96caa2e21ed5f6e4b66bf28a1bd08fd9eb07c0b39b28c" [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" @@ -1850,9 +1895,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -1883,15 +1928,15 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.200" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] @@ -1909,20 +1954,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.200" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -2130,9 +2175,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" dependencies = [ "proc-macro2", "quote", @@ -2162,22 +2207,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -2225,9 +2270,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" [[package]] name = "toml_edit" @@ -2259,7 +2304,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -2367,7 +2412,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", "wasm-bindgen-shared", ] @@ -2389,7 +2434,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2639,11 +2684,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -2690,22 +2735,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.5", ] -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", - "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.5" @@ -2804,22 +2833,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.33" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "087eca3c1eaf8c47b94d02790dd086cd594b912d2043d4de4bfdd466b3befb7c" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.33" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f4b6c273f496d8fd4eaf18853e6b448760225dc030ff2c485a786859aea6393" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] [[package]] @@ -2839,5 +2868,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.64", ] From ccc1ee02b3e3bbc010790e4a2a156c9dbb0fed4c Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 17 May 2024 18:54:38 +0200 Subject: [PATCH 059/268] Regenerate the Cargo.lock --- arbitrator/Cargo.lock | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 5b82f10e8e..af9a89b149 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -55,6 +55,21 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anes" version = "0.1.6" @@ -396,7 +411,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-targets 0.52.5", + "windows-targets", ] [[package]] @@ -734,6 +749,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim 0.11.1", "syn 2.0.64", ] @@ -1148,6 +1164,7 @@ checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.5", + "serde", ] [[package]] @@ -1644,6 +1661,12 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2065,7 +2088,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_derive", "serde_json", @@ -2091,10 +2114,10 @@ version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ - "darling 0.20.8", + "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.64", ] [[package]] @@ -2835,7 +2858,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets", ] [[package]] From d8c832a01589ef8e3267432bfa9326ea62185ff7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 21 May 2024 09:18:32 +0200 Subject: [PATCH 060/268] Move the layer data and dirty indices to a struct. This allows us to lock a single Mutex to gain access to both parts of the data structure. This helps us to prevent deadlocks caused by accessing the separate locks in different order from various call sites. --- arbitrator/prover/src/merkle.rs | 80 ++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 5a3cbadbc7..b37e0140ba 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -149,6 +149,12 @@ impl MerkleType { } } +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +struct Layers { + data: Vec>, + dirt: Vec>, +} + /// A Merkle tree with a fixed number of layers /// /// https://en.wikipedia.org/wiki/Merkle_tree @@ -168,10 +174,8 @@ impl MerkleType { pub struct Merkle { ty: MerkleType, #[serde(with = "arc_mutex_sedre")] - layers: Arc>>>, + layers: Arc>, min_depth: usize, - #[serde(with = "arc_mutex_sedre")] - dirty_layers: Arc>>>, } fn hash_node(ty: MerkleType, a: impl AsRef<[u8]>, b: impl AsRef<[u8]>) -> Bytes32 { @@ -247,42 +251,43 @@ impl Merkle { layers.push(new_layer); layer_i += 1; } - let dirty_layers = Arc::new(Mutex::new(dirty_indices)); + let layers = Arc::new(Mutex::new(Layers { + data: layers, + dirt: dirty_indices, + })); Merkle { ty, - layers: Arc::new(Mutex::new(layers)), + layers, min_depth, - dirty_layers, } } fn rehash(&self) { - let dirty_layers = &mut self.dirty_layers.lock().unwrap(); - if dirty_layers.is_empty() || dirty_layers[0].is_empty() { + let layers = &mut self.layers.lock().unwrap(); + if layers.dirt.is_empty() || layers.dirt[0].is_empty() { return; } - let layers = &mut self.layers.lock().unwrap(); - for layer_i in 1..layers.len() { + for layer_i in 1..layers.data.len() { let dirty_i = layer_i - 1; - let dirt = dirty_layers[dirty_i].clone(); + let dirt = layers.dirt[dirty_i].clone(); for idx in dirt.iter().sorted() { let left_child_idx = idx << 1; let right_child_idx = left_child_idx + 1; - let left = layers[layer_i - 1][left_child_idx]; - let right = layers[layer_i - 1] + let left = layers.data[layer_i - 1][left_child_idx]; + let right = layers.data[layer_i - 1] .get(right_child_idx) .unwrap_or(empty_hash_at(self.ty, layer_i - 1)); let new_hash = hash_node(self.ty, left, right); - if *idx < layers[layer_i].len() { - layers[layer_i][*idx] = new_hash; + if *idx < layers.data[layer_i].len() { + layers.data[layer_i][*idx] = new_hash; } else { - layers[layer_i].push(new_hash); + layers.data[layer_i].push(new_hash); } - if layer_i < layers.len() - 1 { - dirty_layers[dirty_i + 1].insert(idx >> 1); + if layer_i < layers.data.len() - 1 { + layers.dirt[dirty_i + 1].insert(idx >> 1); } } - dirty_layers[dirty_i].clear(); + layers.dirt[dirty_i].clear(); } } @@ -290,7 +295,7 @@ impl Merkle { #[cfg(feature = "counters")] ROOT_COUNTERS[&self.ty].fetch_add(1, Ordering::Relaxed); self.rehash(); - if let Some(layer) = self.layers.lock().unwrap().last() { + if let Some(layer) = self.layers.lock().unwrap().data.last() { assert_eq!(layer.len(), 1); layer[0] } else { @@ -302,26 +307,27 @@ impl Merkle { #[inline] fn capacity(&self) -> usize { let layers = self.layers.lock().unwrap(); - if layers.is_empty() { + if layers.data.is_empty() { return 0; } let base: usize = 2; - base.pow((layers.len() - 1).try_into().unwrap()) + base.pow((layers.data.len() - 1).try_into().unwrap()) } // Returns the number of leaves in the tree. pub fn len(&self) -> usize { - self.layers.lock().unwrap()[0].len() + self.layers.lock().unwrap().data[0].len() } pub fn is_empty(&self) -> bool { let layers = self.layers.lock().unwrap(); - layers.is_empty() || layers[0].is_empty() + layers.data.is_empty() || layers.data[0].is_empty() } #[must_use] pub fn prove(&self, idx: usize) -> Option> { - if self.layers.lock().unwrap().is_empty() || idx >= self.layers.lock().unwrap()[0].len() { + let layers = self.layers.lock().unwrap(); + if layers.data.is_empty() || idx >= layers.data[0].len() { return None; } Some(self.prove_any(idx)) @@ -332,9 +338,9 @@ impl Merkle { pub fn prove_any(&self, mut idx: usize) -> Vec { self.rehash(); let layers = self.layers.lock().unwrap(); - let mut proof = vec![u8::try_from(layers.len() - 1).unwrap()]; - for (layer_i, layer) in layers.iter().enumerate() { - if layer_i == layers.len() - 1 { + let mut proof = vec![u8::try_from(layers.data.len() - 1).unwrap()]; + for (layer_i, layer) in layers.data.iter().enumerate() { + if layer_i == layers.data.len() - 1 { break; } let counterpart = idx ^ 1; @@ -352,7 +358,7 @@ impl Merkle { /// Adds a new leaf to the merkle /// Currently O(n) in the number of leaves (could be log(n)) pub fn push_leaf(&mut self, leaf: Bytes32) { - let mut leaves = self.layers.lock().unwrap().swap_remove(0); + let mut leaves = self.layers.lock().unwrap().data.swap_remove(0); leaves.push(leaf); *self = Self::new_advanced(self.ty, leaves, self.min_depth); } @@ -360,7 +366,7 @@ impl Merkle { /// Removes the rightmost leaf from the merkle /// Currently O(n) in the number of leaves (could be log(n)) pub fn pop_leaf(&mut self) { - let mut leaves = self.layers.lock().unwrap().swap_remove(0); + let mut leaves = self.layers.lock().unwrap().data.swap_remove(0); leaves.pop(); *self = Self::new_advanced(self.ty, leaves, self.min_depth); } @@ -371,11 +377,11 @@ impl Merkle { #[cfg(feature = "counters")] SET_COUNTERS[&self.ty].fetch_add(1, Ordering::Relaxed); let mut layers = self.layers.lock().unwrap(); - if layers[0][idx] == hash { + if layers.data[0][idx] == hash { return; } - layers[0][idx] = hash; - self.dirty_layers.lock().unwrap()[0].insert(idx >> 1); + layers.data[0][idx] = hash; + layers.dirt[0].insert(idx >> 1); } /// Resizes the number of leaves the tree can hold. @@ -389,15 +395,15 @@ impl Merkle { } let mut layers = self.layers.lock().unwrap(); let mut layer_size = new_len; - for (layer_i, layer) in layers.iter_mut().enumerate() { + for (layer_i, layer) in layers.data.iter_mut().enumerate() { layer.resize(layer_size, *empty_hash_at(self.ty, layer_i)); layer_size = max(layer_size >> 1, 1); } - let start = layers[0].len(); + let start = layers.data[0].len(); for i in start..new_len { - self.dirty_layers.lock().unwrap()[0].insert(i); + layers.dirt[0].insert(i); } - Ok(layers[0].len()) + Ok(layers.data[0].len()) } } From bd49d472689554433b6b49f1d952fee50da29605 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 21 May 2024 12:52:01 +0200 Subject: [PATCH 061/268] Remove deadlocks. --- arbitrator/prover/src/merkle.rs | 51 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index b37e0140ba..70884da096 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -6,6 +6,8 @@ use digest::Digest; use enum_iterator::Sequence; +use parking_lot::Mutex; + #[cfg(feature = "counters")] use enum_iterator::all; use itertools::Itertools; @@ -30,7 +32,7 @@ use sha3::Keccak256; use std::{ collections::HashSet, convert::{TryFrom, TryInto}, - sync::{Arc, Mutex}, + sync::Arc, }; #[cfg(feature = "rayon")] @@ -262,8 +264,7 @@ impl Merkle { } } - fn rehash(&self) { - let layers = &mut self.layers.lock().unwrap(); + fn rehash(&self, layers: &mut Layers) { if layers.dirt.is_empty() || layers.dirt[0].is_empty() { return; } @@ -294,8 +295,9 @@ impl Merkle { pub fn root(&self) -> Bytes32 { #[cfg(feature = "counters")] ROOT_COUNTERS[&self.ty].fetch_add(1, Ordering::Relaxed); - self.rehash(); - if let Some(layer) = self.layers.lock().unwrap().data.last() { + let mut layers = self.layers.lock(); + self.rehash(&mut layers); + if let Some(layer) = layers.data.last() { assert_eq!(layer.len(), 1); layer[0] } else { @@ -306,7 +308,7 @@ impl Merkle { // Returns the total number of leaves the tree can hold. #[inline] fn capacity(&self) -> usize { - let layers = self.layers.lock().unwrap(); + let layers = self.layers.lock(); if layers.data.is_empty() { return 0; } @@ -316,18 +318,17 @@ impl Merkle { // Returns the number of leaves in the tree. pub fn len(&self) -> usize { - self.layers.lock().unwrap().data[0].len() + self.layers.lock().data[0].len() } pub fn is_empty(&self) -> bool { - let layers = self.layers.lock().unwrap(); + let layers = self.layers.lock(); layers.data.is_empty() || layers.data[0].is_empty() } #[must_use] pub fn prove(&self, idx: usize) -> Option> { - let layers = self.layers.lock().unwrap(); - if layers.data.is_empty() || idx >= layers.data[0].len() { + if self.layers.lock().data.is_empty() || idx >= self.layers.lock().data[0].len() { return None; } Some(self.prove_any(idx)) @@ -336,8 +337,8 @@ impl Merkle { /// creates a merkle proof regardless of if the leaf has content #[must_use] pub fn prove_any(&self, mut idx: usize) -> Vec { - self.rehash(); - let layers = self.layers.lock().unwrap(); + let mut layers = self.layers.lock(); + self.rehash(&mut layers); let mut proof = vec![u8::try_from(layers.data.len() - 1).unwrap()]; for (layer_i, layer) in layers.data.iter().enumerate() { if layer_i == layers.data.len() - 1 { @@ -358,7 +359,7 @@ impl Merkle { /// Adds a new leaf to the merkle /// Currently O(n) in the number of leaves (could be log(n)) pub fn push_leaf(&mut self, leaf: Bytes32) { - let mut leaves = self.layers.lock().unwrap().data.swap_remove(0); + let mut leaves = self.layers.lock().data.swap_remove(0); leaves.push(leaf); *self = Self::new_advanced(self.ty, leaves, self.min_depth); } @@ -366,7 +367,7 @@ impl Merkle { /// Removes the rightmost leaf from the merkle /// Currently O(n) in the number of leaves (could be log(n)) pub fn pop_leaf(&mut self) { - let mut leaves = self.layers.lock().unwrap().data.swap_remove(0); + let mut leaves = self.layers.lock().data.swap_remove(0); leaves.pop(); *self = Self::new_advanced(self.ty, leaves, self.min_depth); } @@ -376,7 +377,7 @@ impl Merkle { pub fn set(&self, idx: usize, hash: Bytes32) { #[cfg(feature = "counters")] SET_COUNTERS[&self.ty].fetch_add(1, Ordering::Relaxed); - let mut layers = self.layers.lock().unwrap(); + let mut layers = self.layers.lock(); if layers.data[0][idx] == hash { return; } @@ -393,7 +394,7 @@ impl Merkle { "Cannot resize to a length greater than the capacity of the tree.".to_owned(), ); } - let mut layers = self.layers.lock().unwrap(); + let mut layers = self.layers.lock(); let mut layer_size = new_len; for (layer_i, layer) in layers.data.iter_mut().enumerate() { layer.resize(layer_size, *empty_hash_at(self.ty, layer_i)); @@ -416,27 +417,23 @@ impl PartialEq for Merkle { impl Eq for Merkle {} pub mod arc_mutex_sedre { - pub fn serialize( - data: &std::sync::Arc>, - serializer: S, - ) -> Result + use parking_lot::Mutex; + use std::sync::Arc; + + pub fn serialize(data: &Arc>, serializer: S) -> Result where S: serde::Serializer, T: serde::Serialize, { - data.lock().unwrap().serialize(serializer) + data.lock().serialize(serializer) } - pub fn deserialize<'de, D, T>( - deserializer: D, - ) -> Result>, D::Error> + pub fn deserialize<'de, D, T>(deserializer: D) -> Result>, D::Error> where D: serde::Deserializer<'de>, T: serde::Deserialize<'de>, { - Ok(std::sync::Arc::new(std::sync::Mutex::new(T::deserialize( - deserializer, - )?))) + Ok(Arc::new(Mutex::new(T::deserialize(deserializer)?))) } } From d2398d85d7fbee5897de260ed76308ab48c3f898 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 21 May 2024 13:33:32 +0200 Subject: [PATCH 062/268] Remove --always-merkleize The prover no longer runs in any other mode. --- Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 53b89c8d72..223fc08593 100644 --- a/Makefile +++ b/Makefile @@ -427,10 +427,10 @@ $(stylus_test_erc20_wasm): $(stylus_test_erc20_src) @touch -c $@ # cargo might decide to not rebuild the binary contracts/test/prover/proofs/float%.json: $(arbitrator_cases)/float%.wasm $(prover_bin) $(output_latest)/soft-float.wasm - $(prover_bin) $< -l $(output_latest)/soft-float.wasm -o $@ -b --allow-hostapi --require-success --always-merkleize + $(prover_bin) $< -l $(output_latest)/soft-float.wasm -o $@ -b --allow-hostapi --require-success contracts/test/prover/proofs/no-stack-pollution.json: $(arbitrator_cases)/no-stack-pollution.wasm $(prover_bin) - $(prover_bin) $< -o $@ --allow-hostapi --require-success --always-merkleize + $(prover_bin) $< -o $@ --allow-hostapi --require-success target/testdata/preimages.bin: mkdir -p `dirname $@` @@ -454,19 +454,19 @@ contracts/test/prover/proofs/global-state.json: echo "[]" > $@ contracts/test/prover/proofs/forward-test.json: $(arbitrator_cases)/forward-test.wasm $(arbitrator_tests_forward_deps) $(prover_bin) - $(prover_bin) $< -o $@ --allow-hostapi --always-merkleize $(patsubst %,-l %, $(arbitrator_tests_forward_deps)) + $(prover_bin) $< -o $@ --allow-hostapi $(patsubst %,-l %, $(arbitrator_tests_forward_deps)) contracts/test/prover/proofs/link.json: $(arbitrator_cases)/link.wasm $(arbitrator_tests_link_deps) $(prover_bin) - $(prover_bin) $< -o $@ --allow-hostapi --always-merkleize --stylus-modules $(arbitrator_tests_link_deps) --require-success + $(prover_bin) $< -o $@ --allow-hostapi --stylus-modules $(arbitrator_tests_link_deps) --require-success contracts/test/prover/proofs/dynamic.json: $(patsubst %,$(arbitrator_cases)/%.wasm, dynamic user) $(prover_bin) - $(prover_bin) $< -o $@ --allow-hostapi --always-merkleize --stylus-modules $(arbitrator_cases)/user.wasm --require-success + $(prover_bin) $< -o $@ --allow-hostapi --stylus-modules $(arbitrator_cases)/user.wasm --require-success contracts/test/prover/proofs/bulk-memory.json: $(patsubst %,$(arbitrator_cases)/%.wasm, bulk-memory) $(prover_bin) - $(prover_bin) $< -o $@ --allow-hostapi --always-merkleize --stylus-modules $(arbitrator_cases)/user.wasm -b + $(prover_bin) $< -o $@ --allow-hostapi --stylus-modules $(arbitrator_cases)/user.wasm -b contracts/test/prover/proofs/%.json: $(arbitrator_cases)/%.wasm $(prover_bin) - $(prover_bin) $< -o $@ --allow-hostapi --always-merkleize + $(prover_bin) $< -o $@ --allow-hostapi # strategic rules to minimize dependency building From 9539e9a2fbb9b8fe62e7912072315fba691466e2 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 22 May 2024 11:20:44 +0200 Subject: [PATCH 063/268] Make clone create completely independent layers structs. The default behavior of an Arc is to allow sharing between different threads and different instances. So, the derived behavior for cloning was to put the same references on the clone as on the orignal. But, we actually want separate clones of our merkle trees to be independent. That is, changing the data on the clone, should have no affect on the original (and vice versa.) The test added in this commit failed before the change and passes afer. --- arbitrator/prover/src/merkle.rs | 35 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index ab7b458fda..56cbf56d99 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -32,7 +32,6 @@ use sha3::Keccak256; use std::{ collections::HashSet, convert::{TryFrom, TryInto}, - sync::Arc, }; #[cfg(feature = "rayon")] @@ -189,11 +188,11 @@ struct Layers { /// and passing a minimum depth. /// /// This structure does not contain the data itself, only the hashes. -#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[derive(Debug, Default, Serialize, Deserialize)] pub struct Merkle { ty: MerkleType, - #[serde(with = "arc_mutex_sedre")] - layers: Arc>, + #[serde(with = "mutex_sedre")] + layers: Mutex, min_depth: usize, } @@ -239,6 +238,12 @@ fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: &'static Bytes32) new_layer } +impl Clone for Merkle { + fn clone(&self) -> Self { + Merkle::new_advanced(self.ty, self.layers.lock().data[0].clone(), self.min_depth) + } +} + impl Merkle { /// Creates a new Merkle tree with the given type and leaf hashes. /// The tree is built up to the minimum depth necessary to hold all the @@ -270,10 +275,10 @@ impl Merkle { layers.push(new_layer); layer_i += 1; } - let layers = Arc::new(Mutex::new(Layers { + let layers = Mutex::new(Layers { data: layers, dirt: dirty_indices, - })); + }); Merkle { ty, layers, @@ -435,11 +440,10 @@ impl PartialEq for Merkle { impl Eq for Merkle {} -pub mod arc_mutex_sedre { +pub mod mutex_sedre { use parking_lot::Mutex; - use std::sync::Arc; - pub fn serialize(data: &Arc>, serializer: S) -> Result + pub fn serialize(data: &Mutex, serializer: S) -> Result where S: serde::Serializer, T: serde::Serialize, @@ -447,12 +451,12 @@ pub mod arc_mutex_sedre { data.lock().serialize(serializer) } - pub fn deserialize<'de, D, T>(deserializer: D) -> Result>, D::Error> + pub fn deserialize<'de, D, T>(deserializer: D) -> Result, D::Error> where D: serde::Deserializer<'de>, T: serde::Deserialize<'de>, { - Ok(Arc::new(Mutex::new(T::deserialize(deserializer)?))) + Ok(Mutex::new(T::deserialize(deserializer)?)) } } @@ -566,6 +570,15 @@ fn emit_memory_zerohashes() { } } +#[test] +fn clone_is_separate() { + let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); + let m2 = merkle.clone(); + m2.resize(4).expect("resize failed"); + m2.set(3, Bytes32::from([2; 32])); + assert_ne!(merkle, m2); +} + #[test] fn serialization_roundtrip() { let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); From ef7313d8af33d93002ceb95334c461bbc43e8d71 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 22 May 2024 11:20:44 +0200 Subject: [PATCH 064/268] Make clone create completely independent layers structs. The default behavior of an Arc is to allow sharing between different threads and different instances. So, the derived behavior for cloning was to put the same references on the clone as on the orignal. But, we actually want separate clones of our merkle trees to be independent. That is, changing the data on the clone, should have no affect on the original (and vice versa.) The test added in this commit failed before the change and passes afer. --- arbitrator/prover/src/merkle.rs | 35 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 70884da096..be1eef8b69 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -32,7 +32,6 @@ use sha3::Keccak256; use std::{ collections::HashSet, convert::{TryFrom, TryInto}, - sync::Arc, }; #[cfg(feature = "rayon")] @@ -172,11 +171,11 @@ struct Layers { /// and passing a minimum depth. /// /// This structure does not contain the data itself, only the hashes. -#[derive(Debug, Clone, Default, Serialize, Deserialize)] +#[derive(Debug, Default, Serialize, Deserialize)] pub struct Merkle { ty: MerkleType, - #[serde(with = "arc_mutex_sedre")] - layers: Arc>, + #[serde(with = "mutex_sedre")] + layers: Mutex, min_depth: usize, } @@ -222,6 +221,12 @@ fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: &'static Bytes32) new_layer } +impl Clone for Merkle { + fn clone(&self) -> Self { + Merkle::new_advanced(self.ty, self.layers.lock().data[0].clone(), self.min_depth) + } +} + impl Merkle { /// Creates a new Merkle tree with the given type and leaf hashes. /// The tree is built up to the minimum depth necessary to hold all the @@ -253,10 +258,10 @@ impl Merkle { layers.push(new_layer); layer_i += 1; } - let layers = Arc::new(Mutex::new(Layers { + let layers = Mutex::new(Layers { data: layers, dirt: dirty_indices, - })); + }); Merkle { ty, layers, @@ -416,11 +421,10 @@ impl PartialEq for Merkle { impl Eq for Merkle {} -pub mod arc_mutex_sedre { +pub mod mutex_sedre { use parking_lot::Mutex; - use std::sync::Arc; - pub fn serialize(data: &Arc>, serializer: S) -> Result + pub fn serialize(data: &Mutex, serializer: S) -> Result where S: serde::Serializer, T: serde::Serialize, @@ -428,12 +432,12 @@ pub mod arc_mutex_sedre { data.lock().serialize(serializer) } - pub fn deserialize<'de, D, T>(deserializer: D) -> Result>, D::Error> + pub fn deserialize<'de, D, T>(deserializer: D) -> Result, D::Error> where D: serde::Deserializer<'de>, T: serde::Deserialize<'de>, { - Ok(Arc::new(Mutex::new(T::deserialize(deserializer)?))) + Ok(Mutex::new(T::deserialize(deserializer)?)) } } @@ -547,6 +551,15 @@ fn emit_memory_zerohashes() { } } +#[test] +fn clone_is_separate() { + let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); + let m2 = merkle.clone(); + m2.resize(4).expect("resize failed"); + m2.set(3, Bytes32::from([2; 32])); + assert_ne!(merkle, m2); +} + #[test] fn serialization_roundtrip() { let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); From 4306ec3e05a57950e7681d88316b4c29b1a53ce6 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 22 May 2024 13:22:00 +0200 Subject: [PATCH 065/268] Handle the empty leaves case. During a clone of an empty Merkle tree, there was an index out of bounds error. --- arbitrator/prover/src/merkle.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index be1eef8b69..005d3dae16 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -223,7 +223,12 @@ fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: &'static Bytes32) impl Clone for Merkle { fn clone(&self) -> Self { - Merkle::new_advanced(self.ty, self.layers.lock().data[0].clone(), self.min_depth) + let leaves = if self.layers.lock().data.is_empty() { + vec![] + } else { + self.layers.lock().data[0].clone() + }; + Merkle::new_advanced(self.ty, leaves, self.min_depth) } } From b075b20e3b99805fa3b12218ec8b341f9f203871 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Mon, 27 May 2024 16:14:48 +0200 Subject: [PATCH 066/268] Make clippy happy. --- arbitrator/bench/src/parse_input.rs | 6 +++--- arbitrator/bench/src/prepare.rs | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/arbitrator/bench/src/parse_input.rs b/arbitrator/bench/src/parse_input.rs index f04150ea22..decc67372a 100644 --- a/arbitrator/bench/src/parse_input.rs +++ b/arbitrator/bench/src/parse_input.rs @@ -24,8 +24,8 @@ mod prefixed_hex { D: Deserializer<'de>, { let s = String::deserialize(deserializer)?; - if s.starts_with("0x") { - hex::decode(&s[2..]).map_err(serde::de::Error::custom) + if let Some(s) = s.strip_prefix("0x") { + hex::decode(s).map_err(serde::de::Error::custom) } else { Err(serde::de::Error::custom("missing 0x prefix")) } @@ -71,6 +71,6 @@ pub struct FileData { impl FileData { pub fn from_reader(mut reader: R) -> io::Result { let data = serde_json::from_reader(&mut reader)?; - return Ok(data); + Ok(data) } } diff --git a/arbitrator/bench/src/prepare.rs b/arbitrator/bench/src/prepare.rs index aebc7ae895..668f5e1120 100644 --- a/arbitrator/bench/src/prepare.rs +++ b/arbitrator/bench/src/prepare.rs @@ -17,8 +17,7 @@ pub fn prepare_machine(preimages: PathBuf, machines: PathBuf) -> eyre::Result>>(); let preimage_resolver = move |_: u64, _: PreimageType, hash: Bytes32| -> Option { preimages From db2a1dfdb8cffb8e1f86160bfd092bd41e2dd080 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 4 Jun 2024 10:26:53 +0200 Subject: [PATCH 067/268] Update Cargo.lock --- arbitrator/Cargo.lock | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 45b2c551dd..1222576846 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -450,7 +450,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -856,7 +856,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] @@ -1899,6 +1899,15 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scopeguard" version = "1.2.0" From 8d074df86d199012b7ed7c1a5121b23730aea503 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 5 Jun 2024 16:49:40 +0200 Subject: [PATCH 068/268] Fix Clone for the Memory type. This was causing problems across with the CGo bindings. --- arbitrator/prover/src/memory.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 78b5ba7259..d5d0a0855d 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -10,13 +10,7 @@ use digest::Digest; use eyre::{bail, ErrReport, Result}; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use std::{ - borrow::Cow, - collections::HashSet, - convert::TryFrom, - ops::Deref, - sync::{Arc, Mutex}, -}; +use std::{borrow::Cow, collections::HashSet, convert::TryFrom, ops::Deref, sync::Mutex}; #[cfg(feature = "counters")] use std::sync::atomic::{AtomicUsize, Ordering}; @@ -70,14 +64,14 @@ impl TryFrom<&wasmparser::MemoryType> for MemoryType { } } -#[derive(Clone, Debug, Default, Serialize, Deserialize)] +#[derive(Debug, Default, Serialize, Deserialize)] pub struct Memory { buffer: Vec, #[serde(skip)] pub merkle: Option, pub max_size: u64, #[serde(skip)] - dirty_indices: Arc>>, + dirty_indices: Mutex>, } fn hash_leaf(bytes: [u8; Memory::LEAF_SIZE]) -> Bytes32 { @@ -116,6 +110,17 @@ impl PartialEq for Memory { } } +impl Clone for Memory { + fn clone(&self) -> Self { + Memory { + buffer: self.buffer.clone(), + merkle: self.merkle.clone(), + max_size: self.max_size, + dirty_indices: Mutex::new(self.dirty_indices.lock().unwrap().clone()), + } + } +} + impl Memory { pub const LEAF_SIZE: usize = 32; /// Only used when initializing a memory to determine its size @@ -129,7 +134,7 @@ impl Memory { buffer: vec![0u8; size], merkle: None, max_size, - dirty_indices: Arc::new(Mutex::new(HashSet::new())), + dirty_indices: Mutex::new(HashSet::new()), } } From 1974d33cc467b7c4568746bb4376c446c72fa2a2 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 6 Jun 2024 11:53:43 +0200 Subject: [PATCH 069/268] Remove race condition in merkelize. --- arbitrator/prover/src/memory.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index d5d0a0855d..441d25bd18 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -144,11 +144,12 @@ impl Memory { pub fn merkelize(&self) -> Cow<'_, Merkle> { if let Some(m) = &self.merkle { - for idx in self.dirty_indices.lock().unwrap().iter() { + let mut dirt = self.dirty_indices.lock().unwrap(); + for idx in dirt.iter() { let leaf_idx = idx / Self::LEAF_SIZE; m.set(leaf_idx, hash_leaf(self.get_leaf_data(leaf_idx))); } - self.dirty_indices.lock().unwrap().clear(); + dirt.clear(); return Cow::Borrowed(m); } // Round the size up to 8 byte long leaves, then round up to the next power of two number of leaves From fc5dd2adc5e80393bbcacfc28db43f02a78adb56 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 11 Jun 2024 10:25:56 +0200 Subject: [PATCH 070/268] Update Cargo.lock --- arbitrator/Cargo.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 0e0c8f5e82..5175b6b609 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -749,6 +749,7 @@ dependencies = [ "ident_case", "proc-macro2", "quote", + "strsim 0.11.1", "syn 2.0.66", ] @@ -2116,7 +2117,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.64", + "syn 2.0.66", ] [[package]] From b5adaedafed993caab25316f5daff1d3fa8afc0a Mon Sep 17 00:00:00 2001 From: tongjicoder Date: Fri, 14 Jun 2024 18:09:07 +0800 Subject: [PATCH 071/268] chore: make function comment match function name Signed-off-by: tongjicoder --- validator/server_arb/execution_run.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index 255d42ab16..4af5736ba6 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -19,7 +19,7 @@ type executionRun struct { close sync.Once } -// NewExecutionChallengeBackend creates a backend with the given arguments. +// NewExecutionRun creates a backend with the given arguments. // Note: machineCache may be nil, but if present, it must not have a restricted range. func NewExecutionRun( ctxIn context.Context, From 8471f77754723394e65e0077825bb76a6b2b1de8 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 19 Jun 2024 13:08:29 +0200 Subject: [PATCH 072/268] Address review feedback. --- arbitrator/bench/src/bin.rs | 1 - arbitrator/bench/src/prepare.rs | 6 --- arbitrator/prover/src/memory.rs | 13 ++++-- arbitrator/prover/src/merkle.rs | 71 +++++++++++++-------------------- 4 files changed, 37 insertions(+), 54 deletions(-) diff --git a/arbitrator/bench/src/bin.rs b/arbitrator/bench/src/bin.rs index 23930652c2..09ce670f05 100644 --- a/arbitrator/bench/src/bin.rs +++ b/arbitrator/bench/src/bin.rs @@ -76,7 +76,6 @@ fn main() -> eyre::Result<()> { MachineStatus::Errored => { println!("Errored"); break; - // bail!("Machine errored => position {}", machine.get_steps()) } MachineStatus::TooFar => { bail!("Machine too far => position {}", machine.get_steps()) diff --git a/arbitrator/bench/src/prepare.rs b/arbitrator/bench/src/prepare.rs index daf0f48f8f..1bdbf88144 100644 --- a/arbitrator/bench/src/prepare.rs +++ b/arbitrator/bench/src/prepare.rs @@ -36,7 +36,6 @@ pub fn prepare_machine( let preimage_resolver = Arc::new(Box::new(preimage_resolver)); let binary_path = Path::new(&machines); - // println!("Creating machine from binary_path"); let mut mach = Machine::new_from_wavm(binary_path, always_merkleize)?; let block_hash: [u8; 32] = data.start_state.block_hash.try_into().unwrap(); @@ -50,18 +49,13 @@ pub fn prepare_machine( u64_vals, }; - //println!("Setting global state"); mach.set_global_state(start_state); - // println!("After setting global state: {:?}", mach.get_global_state()); - // println!("Setting preimage resolver"); mach.set_preimage_resolver(preimage_resolver); - // println!("Adding sequencer inbox message"); let identifier = argument_data_to_inbox(0).unwrap(); mach.add_inbox_msg(identifier, data.batch_info.number, data.batch_info.data); - // println!("Adding delayed inbox message"); let identifier = argument_data_to_inbox(1).unwrap(); mach.add_inbox_msg(identifier, data.delayed_msg_nr, data.delayed_msg); diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index bba8e4124f..0fdb61411f 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -121,7 +121,10 @@ impl Memory { let size = leaf_hashes.len(); let m = Merkle::new_advanced(MerkleType::Memory, leaf_hashes, Self::MEMORY_LAYERS); if size < leaves { - m.resize(leaves).expect("Couldn't resize merkle tree"); + m.resize(leaves).expect(&format!( + "Couldn't resize merkle tree from {} to {}", + size, leaves + )); } Cow::Owned(m) } @@ -308,9 +311,11 @@ impl Memory { pub fn resize(&mut self, new_size: usize) { self.buffer.resize(new_size, 0); if let Some(merkle) = self.merkle.take() { - merkle - .resize(new_size) - .expect("Couldn't resize merkle tree"); + merkle.resize(new_size).expect(&format!( + "Couldn't resize merkle tree from {} to {}", + merkle.len(), + new_size + )); self.merkle = Some(merkle); } } diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 005d3dae16..9952f84631 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -44,50 +44,26 @@ use zerohashes::ZERO_HASHES; use self::zerohashes::EMPTY_HASH; #[cfg(feature = "counters")] -lazy_static! { - static ref NEW_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { - let mut map = HashMap::new(); - map.insert(&MerkleType::Empty, AtomicUsize::new(0)); - map.insert(&MerkleType::Value, AtomicUsize::new(0)); - map.insert(&MerkleType::Function, AtomicUsize::new(0)); - map.insert(&MerkleType::Instruction, AtomicUsize::new(0)); - map.insert(&MerkleType::Memory, AtomicUsize::new(0)); - map.insert(&MerkleType::Table, AtomicUsize::new(0)); - map.insert(&MerkleType::TableElement, AtomicUsize::new(0)); - map.insert(&MerkleType::Module, AtomicUsize::new(0)); - map +macro_rules! init_counters { + ($name:ident) => { + lazy_static! { + static ref $name: HashMap<&'static MerkleType, AtomicUsize> = { + let mut map = HashMap::new(); + $(map.insert(&MerkleType::$variant, AtomicUsize::new(0));)* + map + }; + } }; } + #[cfg(feature = "counters")] -lazy_static! { - static ref ROOT_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { - let mut map = HashMap::new(); - map.insert(&MerkleType::Empty, AtomicUsize::new(0)); - map.insert(&MerkleType::Value, AtomicUsize::new(0)); - map.insert(&MerkleType::Function, AtomicUsize::new(0)); - map.insert(&MerkleType::Instruction, AtomicUsize::new(0)); - map.insert(&MerkleType::Memory, AtomicUsize::new(0)); - map.insert(&MerkleType::Table, AtomicUsize::new(0)); - map.insert(&MerkleType::TableElement, AtomicUsize::new(0)); - map.insert(&MerkleType::Module, AtomicUsize::new(0)); - map - }; -} +init_counters!(NEW_COUNTERS); + #[cfg(feature = "counters")] -lazy_static! { - static ref SET_COUNTERS: HashMap<&'static MerkleType, AtomicUsize> = { - let mut map = HashMap::new(); - map.insert(&MerkleType::Empty, AtomicUsize::new(0)); - map.insert(&MerkleType::Value, AtomicUsize::new(0)); - map.insert(&MerkleType::Function, AtomicUsize::new(0)); - map.insert(&MerkleType::Instruction, AtomicUsize::new(0)); - map.insert(&MerkleType::Memory, AtomicUsize::new(0)); - map.insert(&MerkleType::Table, AtomicUsize::new(0)); - map.insert(&MerkleType::TableElement, AtomicUsize::new(0)); - map.insert(&MerkleType::Module, AtomicUsize::new(0)); - map - }; -} +init_counters!(ROOT_COUNTERS); + +#[cfg(feature = "counters")] +init_counters!(SET_COUNTERS); #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Sequence)] pub enum MerkleType { @@ -213,7 +189,7 @@ fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: &'static Bytes32) #[inline] #[cfg(not(feature = "rayon"))] -fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: &'static Bytes32) -> Vec { +fn new_layer(ty: MerkleType, layer: &[Bytes32], empty_hash: &'static Bytes32) -> Vec { let new_layer = layer .chunks(2) .map(|chunk| hash_node(ty, chunk[0], chunk.get(1).unwrap_or(empty_hash))) @@ -275,15 +251,23 @@ impl Merkle { } fn rehash(&self, layers: &mut Layers) { + // If nothing is dirty, then there's no need to rehash. if layers.dirt.is_empty() || layers.dirt[0].is_empty() { return; } + // Process dirty indices starting from layer 1 (layer 0 is the leaves). for layer_i in 1..layers.data.len() { let dirty_i = layer_i - 1; - let dirt = layers.dirt[dirty_i].clone(); + // Consume this layer's dirty indices. + let dirt = std::mem::take(&mut layers.dirt[dirty_i]); + // It is important to process the dirty indices in order because + // when the leaves grown since the last rehash, the new parent is + // simply pused to the end of the layer's data. for idx in dirt.iter().sorted() { let left_child_idx = idx << 1; let right_child_idx = left_child_idx + 1; + // The left child is guaranteed to exist, but the right one + // might not if the number of child nodes is odd. let left = layers.data[layer_i - 1][left_child_idx]; let right = layers.data[layer_i - 1] .get(right_child_idx) @@ -292,13 +276,14 @@ impl Merkle { if *idx < layers.data[layer_i].len() { layers.data[layer_i][*idx] = new_hash; } else { + // Push the new parent hash onto the end of the layer. layers.data[layer_i].push(new_hash); } + // Mark the node's parent as dirty unless it's the root. if layer_i < layers.data.len() - 1 { layers.dirt[dirty_i + 1].insert(idx >> 1); } } - layers.dirt[dirty_i].clear(); } } From b378cea1d23497ab4e8e78cb7e6ae21c905ef410 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 19 Jun 2024 13:45:23 +0200 Subject: [PATCH 073/268] Make clippy happier. --- arbitrator/prover/src/memory.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 0fdb61411f..c7aa2af794 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -121,10 +121,9 @@ impl Memory { let size = leaf_hashes.len(); let m = Merkle::new_advanced(MerkleType::Memory, leaf_hashes, Self::MEMORY_LAYERS); if size < leaves { - m.resize(leaves).expect(&format!( - "Couldn't resize merkle tree from {} to {}", - size, leaves - )); + m.resize(leaves).unwrap_or_else(|_| { + panic!("Couldn't resize merkle tree from {} to {}", size, leaves) + }); } Cow::Owned(m) } @@ -311,11 +310,13 @@ impl Memory { pub fn resize(&mut self, new_size: usize) { self.buffer.resize(new_size, 0); if let Some(merkle) = self.merkle.take() { - merkle.resize(new_size).expect(&format!( - "Couldn't resize merkle tree from {} to {}", - merkle.len(), - new_size - )); + merkle.resize(new_size).unwrap_or_else(|_| { + panic!( + "Couldn't resize merkle tree from {} to {}", + merkle.len(), + new_size + ) + }); self.merkle = Some(merkle); } } From 7f5f406b15ec1abfae80e0f3f38e89883fd4a5c5 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 26 Jun 2024 19:32:04 +0530 Subject: [PATCH 074/268] fast confirmation --- contracts | 2 +- staker/staker.go | 34 ++++++- system_tests/staker_test.go | 182 ++++++++++++++++++++++++++++++++++++ 3 files changed, 213 insertions(+), 5 deletions(-) diff --git a/contracts b/contracts index 7a41cd59cd..ccd2c2b5b3 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 7a41cd59cdf2eb01cf31c2351b8d1ff6fbf52178 +Subproject commit ccd2c2b5b3dbeaa93df3be20841322b54ab2b045 diff --git a/staker/staker.go b/staker/staker.go index da6413e122..ff0f00fee2 100644 --- a/staker/staker.go +++ b/staker/staker.go @@ -90,6 +90,7 @@ type L1ValidatorConfig struct { ExtraGas uint64 `koanf:"extra-gas" reload:"hot"` Dangerous DangerousConfig `koanf:"dangerous"` ParentChainWallet genericconf.WalletConfig `koanf:"parent-chain-wallet"` + EnableFastConfirmation bool `koanf:"enable-fast-confirmation"` strategy StakerStrategy gasRefunder common.Address @@ -156,6 +157,7 @@ var DefaultL1ValidatorConfig = L1ValidatorConfig{ ExtraGas: 50000, Dangerous: DefaultDangerousConfig, ParentChainWallet: DefaultValidatorL1WalletConfig, + EnableFastConfirmation: false, } var TestL1ValidatorConfig = L1ValidatorConfig{ @@ -176,6 +178,7 @@ var TestL1ValidatorConfig = L1ValidatorConfig{ ExtraGas: 50000, Dangerous: DefaultDangerousConfig, ParentChainWallet: DefaultValidatorL1WalletConfig, + EnableFastConfirmation: false, } var DefaultValidatorL1WalletConfig = genericconf.WalletConfig{ @@ -204,6 +207,7 @@ func L1ValidatorConfigAddOptions(prefix string, f *flag.FlagSet) { dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f, dataposter.DefaultDataPosterConfigForValidator) DangerousConfigAddOptions(prefix+".dangerous", f) genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultL1ValidatorConfig.ParentChainWallet.Pathname) + f.Bool(prefix+".enable-fast-confirmation", DefaultL1ValidatorConfig.EnableFastConfirmation, "enable fast confirmation") } type DangerousConfig struct { @@ -864,7 +868,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv if err != nil { return fmt.Errorf("error staking on new node: %w", err) } - return nil + return s.tryFastConfirmation(ctx, action.assertion.AfterState.GlobalState.BlockHash, action.assertion.AfterState.GlobalState.SendRoot) } // If we have no stake yet, we'll put one down @@ -886,7 +890,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv return fmt.Errorf("error placing new stake on new node: %w", err) } info.StakeExists = true - return nil + return s.tryFastConfirmation(ctx, action.assertion.AfterState.GlobalState.BlockHash, action.assertion.AfterState.GlobalState.SendRoot) case existingNodeAction: info.LatestStakedNode = action.number info.LatestStakedNodeHash = action.hash @@ -914,7 +918,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv if err != nil { return fmt.Errorf("error staking on existing node: %w", err) } - return nil + return s.tryFastConfirmationNodeNumber(ctx, action.number) } // If we have no stake yet, we'll put one down @@ -935,12 +939,34 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv return fmt.Errorf("error placing new stake on existing node: %w", err) } info.StakeExists = true - return nil + return s.tryFastConfirmationNodeNumber(ctx, action.number) default: panic("invalid action type") } } +func (s *Staker) tryFastConfirmationNodeNumber(ctx context.Context, number uint64) error { + if !s.config.EnableFastConfirmation { + return nil + } + nodeInfo, err := s.rollup.LookupNode(ctx, number) + if err != nil { + return err + } + return s.tryFastConfirmation(ctx, nodeInfo.AfterState().GlobalState.BlockHash, nodeInfo.AfterState().GlobalState.SendRoot) +} + +func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { + if !s.config.EnableFastConfirmation { + return nil + } + auth, err := s.builder.Auth(ctx) + if err != nil { + return err + } + _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot) + return err +} func (s *Staker) createConflict(ctx context.Context, info *StakerInfo) error { if info.CurrentChallenge != nil { return nil diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 4afe2e8ccd..14fcb49a9e 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -464,3 +464,185 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) func TestStakersCooperative(t *testing.T) { stakerTestImpl(t, false, false) } + +func TestFastConfirmation(t *testing.T) { + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + srv := externalsignertest.NewServer(t) + go func() { + if err := srv.Start(); err != nil { + log.Error("Failed to start external signer server:", err) + return + } + }() + var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs + + builder := NewNodeBuilder(ctx).DefaultConfig(t, true) + builder.L2Info = NewBlockChainTestInfo( + t, + types.NewArbitrumSigner(types.NewLondonSigner(builder.chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), + transferGas, + ) + + builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour + cleanup := builder.Build(t) + defer cleanup() + + addNewBatchPoster(ctx, t, builder, srv.Address) + + builder.L1.SendWaitTestTransactions(t, []*types.Transaction{ + builder.L1Info.PrepareTxTo("Faucet", &srv.Address, 30000, big.NewInt(1).Mul(big.NewInt(1e18), big.NewInt(1e18)), nil)}) + + l2node := builder.L2.ConsensusNode + execNode := builder.L2.ExecNode + + config := arbnode.ConfigDefaultL1Test() + config.Sequencer = false + config.DelayedSequencer.Enable = false + config.BatchPoster.Enable = false + builder.execConfig.Sequencer.Enable = false + + builder.BridgeBalance(t, "Faucet", big.NewInt(1).Mul(big.NewInt(params.Ether), big.NewInt(10000))) + + deployAuth := builder.L1Info.GetDefaultTransactOpts("RollupOwner", ctx) + + balance := big.NewInt(params.Ether) + balance.Mul(balance, big.NewInt(100)) + builder.L1.TransferBalance(t, "Faucet", "Validator", balance, builder.L1Info) + l1auth := builder.L1Info.GetDefaultTransactOpts("Validator", ctx) + + valWalletAddrPtr, err := validatorwallet.GetValidatorWalletContract(ctx, l2node.DeployInfo.ValidatorWalletCreator, 0, &l1auth, l2node.L1Reader, true) + Require(t, err) + valWalletAddr := *valWalletAddrPtr + valWalletAddrCheck, err := validatorwallet.GetValidatorWalletContract(ctx, l2node.DeployInfo.ValidatorWalletCreator, 0, &l1auth, l2node.L1Reader, true) + Require(t, err) + if valWalletAddr == *valWalletAddrCheck { + Require(t, err, "didn't cache validator wallet address", valWalletAddr.String(), "vs", valWalletAddrCheck.String()) + } + + rollup, err := rollupgen.NewRollupAdminLogic(l2node.DeployInfo.Rollup, builder.L1.Client) + Require(t, err) + + upgradeExecutor, err := upgrade_executorgen.NewUpgradeExecutor(l2node.DeployInfo.UpgradeExecutor, builder.L1.Client) + Require(t, err, "unable to bind upgrade executor") + rollupABI, err := abi.JSON(strings.NewReader(rollupgen.RollupAdminLogicABI)) + Require(t, err, "unable to parse rollup ABI") + + setValidatorCalldata, err := rollupABI.Pack("setValidator", []common.Address{valWalletAddr, srv.Address}, []bool{true, true}) + Require(t, err, "unable to generate setValidator calldata") + tx, err := upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setValidatorCalldata) + Require(t, err, "unable to set validators") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + setMinAssertPeriodCalldata, err := rollupABI.Pack("setMinimumAssertionPeriod", big.NewInt(1)) + Require(t, err, "unable to generate setMinimumAssertionPeriod calldata") + tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setMinAssertPeriodCalldata) + Require(t, err, "unable to set minimum assertion period") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + setAnyTrustFastConfirmerCalldata, err := rollupABI.Pack("setAnyTrustFastConfirmer", valWalletAddr) + Require(t, err, "unable to generate setAnyTrustFastConfirmer calldata") + tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setAnyTrustFastConfirmerCalldata) + Require(t, err, "unable to set anytrust fast confirmer") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + valConfig := staker.TestL1ValidatorConfig + valConfig.EnableFastConfirmation = true + parentChainID, err := builder.L1.Client.ChainID(ctx) + if err != nil { + t.Fatalf("Failed to get parent chain id: %v", err) + } + dp, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2node.ArbDB, storage.StakerPrefix), + l2node.L1Reader, + &l1auth, NewFetcherFromConfig(arbnode.ConfigDefaultL1NonSequencerTest()), + nil, + parentChainID, + ) + if err != nil { + t.Fatalf("Error creating validator dataposter: %v", err) + } + valWallet, err := validatorwallet.NewContract(dp, nil, l2node.DeployInfo.ValidatorWalletCreator, l2node.DeployInfo.Rollup, l2node.L1Reader, &l1auth, 0, func(common.Address) {}, func() uint64 { return valConfig.ExtraGas }) + Require(t, err) + valConfig.Strategy = "MakeNodes" + + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + blockValidatorConfig := staker.TestBlockValidatorConfig + + stateless, err := staker.NewStatelessBlockValidator( + l2node.InboxReader, + l2node.InboxTracker, + l2node.TxStreamer, + execNode, + l2node.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStack, + ) + Require(t, err) + err = stateless.Start(ctx) + Require(t, err) + stakerA, err := staker.NewStaker( + l2node.L1Reader, + valWallet, + bind.CallOpts{}, + valConfig, + nil, + stateless, + nil, + nil, + l2node.DeployInfo.ValidatorUtils, + nil, + ) + Require(t, err) + err = stakerA.Initialize(ctx) + if stakerA.Strategy() != staker.WatchtowerStrategy { + err = valWallet.Initialize(ctx) + Require(t, err) + } + Require(t, err) + cfg := arbnode.ConfigDefaultL1NonSequencerTest() + signerCfg, err := externalSignerTestCfg(srv.Address, srv.URL()) + if err != nil { + t.Fatalf("Error getting external signer config: %v", err) + } + cfg.Staker.DataPoster.ExternalSigner = *signerCfg + + builder.L2Info.GenerateAccount("BackgroundUser") + tx = builder.L2Info.PrepareTx("Faucet", "BackgroundUser", builder.L2Info.TransferGas, balance, nil) + err = builder.L2.Client.SendTransaction(ctx, tx) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + // Continually make L2 transactions in a background thread + backgroundTxsCtx, cancelBackgroundTxs := context.WithCancel(ctx) + backgroundTxsShutdownChan := make(chan struct{}) + defer (func() { + cancelBackgroundTxs() + <-backgroundTxsShutdownChan + })() + go (func() { + defer close(backgroundTxsShutdownChan) + err := makeBackgroundTxs(backgroundTxsCtx, builder) + if !errors.Is(err, context.Canceled) { + log.Warn("error making background txs", "err", err) + } + })() + + latestConfirmBeforeAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + tx, err = stakerA.Act(ctx) + Require(t, err) + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + latestConfirmAfterAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + if latestConfirmAfterAct <= latestConfirmBeforeAct { + Fatal(t, "staker A didn't advance the latest confirmed node") + } +} From aaaa297c1962750f7661484d6f3daaacb807aa9e Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 27 Jun 2024 18:31:18 +0530 Subject: [PATCH 075/268] fast confirmation with safe --- .gitmodules | 3 + contracts | 2 +- safe-smart-account | 1 + solgen/gen.go | 12 ++ staker/staker.go | 225 +++++++++++++++++++++++++++ system_tests/staker_test.go | 301 +++++++++++++++++++++++++++++++++++- 6 files changed, 541 insertions(+), 3 deletions(-) create mode 160000 safe-smart-account diff --git a/.gitmodules b/.gitmodules index d7b61d862b..d4d26282ae 100644 --- a/.gitmodules +++ b/.gitmodules @@ -32,3 +32,6 @@ [submodule "arbitrator/langs/bf"] path = arbitrator/langs/bf url = https://github.com/OffchainLabs/stylus-sdk-bf.git +[submodule "safe-smart-account"] + path = safe-smart-account + url = https://github.com/safe-global/safe-smart-account.git diff --git a/contracts b/contracts index ccd2c2b5b3..56ae8045eb 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit ccd2c2b5b3dbeaa93df3be20841322b54ab2b045 +Subproject commit 56ae8045eb511824474f675326d32716ca26326b diff --git a/safe-smart-account b/safe-smart-account new file mode 160000 index 0000000000..46f7c60ef4 --- /dev/null +++ b/safe-smart-account @@ -0,0 +1 @@ +Subproject commit 46f7c60ef4ba68cd2ed2bad8ab9f606fe9dab40f diff --git a/solgen/gen.go b/solgen/gen.go index 92511595d7..2ad71b0c79 100644 --- a/solgen/gen.go +++ b/solgen/gen.go @@ -73,6 +73,18 @@ func main() { log.Fatal(err) } + filePathsSafeSmartAccount, err := filepath.Glob(filepath.Join(parent, "safe-smart-account", "build", "artifacts", "contracts", "*", "*.sol", "*.json")) + if err != nil { + log.Fatal(err) + } + filePathsSafeSmartAccountOuter, err := filepath.Glob(filepath.Join(parent, "safe-smart-account", "build", "artifacts", "contracts", "*.sol", "*.json")) + if err != nil { + log.Fatal(err) + } + + filePaths = append(filePaths, filePathsSafeSmartAccount...) + filePaths = append(filePaths, filePathsSafeSmartAccountOuter...) + modules := make(map[string]*moduleInfo) for _, path := range filePaths { diff --git a/staker/staker.go b/staker/staker.go index ff0f00fee2..f031623a6d 100644 --- a/staker/staker.go +++ b/staker/staker.go @@ -9,9 +9,11 @@ import ( "fmt" "math/big" "runtime/debug" + "sort" "strings" "time" + "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -23,6 +25,8 @@ import ( "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/cmd/genericconf" + "github.com/offchainlabs/nitro/solgen/go/contractsgen" + "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/staker/txbuilder" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/arbmath" @@ -91,6 +95,7 @@ type L1ValidatorConfig struct { Dangerous DangerousConfig `koanf:"dangerous"` ParentChainWallet genericconf.WalletConfig `koanf:"parent-chain-wallet"` EnableFastConfirmation bool `koanf:"enable-fast-confirmation"` + FastConfirmSafeAddress string `koanf:"fast-confirm-safe-address"` strategy StakerStrategy gasRefunder common.Address @@ -158,6 +163,7 @@ var DefaultL1ValidatorConfig = L1ValidatorConfig{ Dangerous: DefaultDangerousConfig, ParentChainWallet: DefaultValidatorL1WalletConfig, EnableFastConfirmation: false, + FastConfirmSafeAddress: "", } var TestL1ValidatorConfig = L1ValidatorConfig{ @@ -179,6 +185,7 @@ var TestL1ValidatorConfig = L1ValidatorConfig{ Dangerous: DefaultDangerousConfig, ParentChainWallet: DefaultValidatorL1WalletConfig, EnableFastConfirmation: false, + FastConfirmSafeAddress: "", } var DefaultValidatorL1WalletConfig = genericconf.WalletConfig{ @@ -208,6 +215,7 @@ func L1ValidatorConfigAddOptions(prefix string, f *flag.FlagSet) { DangerousConfigAddOptions(prefix+".dangerous", f) genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultL1ValidatorConfig.ParentChainWallet.Pathname) f.Bool(prefix+".enable-fast-confirmation", DefaultL1ValidatorConfig.EnableFastConfirmation, "enable fast confirmation") + f.String(prefix+".fast-confirm-safe-address", DefaultL1ValidatorConfig.FastConfirmSafeAddress, "safe address for fast confirmation") } type DangerousConfig struct { @@ -254,6 +262,20 @@ type Staker struct { inboxReader InboxReaderInterface statelessBlockValidator *StatelessBlockValidator fatalErr chan<- error + fastConfirmSafe *FastConfirmSafe +} + +type FastConfirmSafe struct { + rollupAddress common.Address + safe *contractsgen.Safe + owners []common.Address + approvedHashesOwners map[common.Hash]map[common.Address]bool + threshold uint64 + fastConfirmNextNodeMethod abi.Method + builder *txbuilder.Builder + wallet ValidatorWalletInterface + gasRefunder common.Address + l1Reader *headerreader.HeaderReader } type ValidatorWalletInterface interface { @@ -303,6 +325,21 @@ func NewStaker( if config.StartValidationFromStaked && blockValidator != nil { stakedNotifiers = append(stakedNotifiers, blockValidator) } + var fastConfirmSafe *FastConfirmSafe + if config.EnableFastConfirmation && config.FastConfirmSafeAddress != "" { + fastConfirmSafe, err = NewFastConfirmSafe( + callOpts, + wallet.RollupAddress(), + common.HexToAddress(config.FastConfirmSafeAddress), + val.builder, + val.wallet, + config.gasRefunder, + l1Reader, + ) + if err != nil { + return nil, err + } + } return &Staker{ L1Validator: val, l1Reader: l1Reader, @@ -315,9 +352,59 @@ func NewStaker( inboxReader: statelessBlockValidator.inboxReader, statelessBlockValidator: statelessBlockValidator, fatalErr: fatalErr, + fastConfirmSafe: fastConfirmSafe, }, nil } +func NewFastConfirmSafe( + callOpts bind.CallOpts, + rollupAddress common.Address, + fastConfirmSafeAddress common.Address, + builder *txbuilder.Builder, + wallet ValidatorWalletInterface, + gasRefunder common.Address, + l1Reader *headerreader.HeaderReader, +) (*FastConfirmSafe, error) { + fastConfirmSafe := &FastConfirmSafe{ + builder: builder, + rollupAddress: rollupAddress, + wallet: wallet, + gasRefunder: gasRefunder, + l1Reader: l1Reader, + } + safe, err := contractsgen.NewSafe(fastConfirmSafeAddress, builder) + if err != nil { + return nil, err + } + fastConfirmSafe.safe = safe + owners, err := safe.GetOwners(&callOpts) + if err != nil { + return nil, err + } + + // This is needed because safe contract needs owners to be sorted. + sort.Slice(owners, func(i, j int) bool { + return owners[i].Cmp(owners[j]) < 0 + }) + fastConfirmSafe.owners = owners + threshold, err := safe.GetThreshold(&callOpts) + if err != nil { + return nil, err + } + fastConfirmSafe.threshold = threshold.Uint64() + fastConfirmSafe.approvedHashesOwners = make(map[common.Hash]map[common.Address]bool) + rollupUserLogicAbi, err := rollupgen.RollupUserLogicMetaData.GetAbi() + if err != nil { + return nil, err + } + fastConfirmNextNodeMethod, ok := rollupUserLogicAbi.Methods["fastConfirmNextNode"] + if !ok { + return nil, errors.New("RollupUserLogic ABI missing fastConfirmNextNode method") + } + fastConfirmSafe.fastConfirmNextNodeMethod = fastConfirmNextNodeMethod + return fastConfirmSafe, nil +} + func (s *Staker) Initialize(ctx context.Context) error { err := s.L1Validator.Initialize(ctx) if err != nil { @@ -960,6 +1047,9 @@ func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, if !s.config.EnableFastConfirmation { return nil } + if s.fastConfirmSafe != nil { + return s.fastConfirmSafe.tryFastConfirmation(ctx, blockHash, sendRoot) + } auth, err := s.builder.Auth(ctx) if err != nil { return err @@ -967,6 +1057,141 @@ func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot) return err } + +func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { + fastConfirmCallData, err := f.createFastConfirmCalldata(blockHash, sendRoot) + if err != nil { + return err + } + callOpts := &bind.CallOpts{Context: ctx} + // Current nonce of the safe. + nonce, err := f.safe.Nonce(callOpts) + if err != nil { + return err + } + // Hash of the safe transaction. + safeTxHash, err := f.safe.GetTransactionHash( + callOpts, + f.rollupAddress, + big.NewInt(0), + fastConfirmCallData, + 0, + big.NewInt(0), + big.NewInt(0), + big.NewInt(0), + common.Address{}, + common.Address{}, + nonce, + ) + if err != nil { + return err + } + arbTx, err := f.wallet.ExecuteTransactions(ctx, f.builder, f.gasRefunder) + if err != nil { + return err + } + if arbTx != nil { + _, err = f.l1Reader.WaitForTxApproval(ctx, arbTx) + if err == nil { + log.Info("successfully executed staker transaction", "hash", arbTx.Hash()) + } else { + return fmt.Errorf("error waiting for tx receipt: %w", err) + } + } + f.builder.ClearTransactions() + auth, err := f.builder.Auth(ctx) + if err != nil { + return err + } + _, err = f.safe.ApproveHash(auth, safeTxHash) + if err != nil { + return err + } + arbTx, err = f.wallet.ExecuteTransactions(ctx, f.builder, f.gasRefunder) + if err != nil { + return err + } + if arbTx != nil { + _, err = f.l1Reader.WaitForTxApproval(ctx, arbTx) + if err == nil { + log.Info("successfully executed staker transaction", "hash", arbTx.Hash()) + } else { + return fmt.Errorf("error waiting for tx receipt: %w", err) + } + } + f.builder.ClearTransactions() + if _, ok := f.approvedHashesOwners[safeTxHash]; !ok { + f.approvedHashesOwners[safeTxHash] = make(map[common.Address]bool) + } + return f.checkApprovedHashAndExecTransaction(ctx, fastConfirmCallData, safeTxHash) +} + +func (f *FastConfirmSafe) createFastConfirmCalldata( + blockHash common.Hash, sendRoot common.Hash, +) ([]byte, error) { + calldata, err := f.fastConfirmNextNodeMethod.Inputs.Pack( + blockHash, + sendRoot, + ) + if err != nil { + return nil, err + } + fullCalldata := append([]byte{}, f.fastConfirmNextNodeMethod.ID...) + fullCalldata = append(fullCalldata, calldata...) + return fullCalldata, nil +} + +func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Context, fastConfirmCallData []byte, safeTxHash [32]byte) error { + var signatures []byte + for _, owner := range f.owners { + if _, ok := f.approvedHashesOwners[safeTxHash][owner]; !ok { + iter, err := f.safe.FilterApproveHash(&bind.FilterOpts{Context: ctx}, [][32]byte{safeTxHash}, []common.Address{owner}) + if err != nil { + return err + } + for iter.Next() { + f.approvedHashesOwners[iter.Event.ApprovedHash][iter.Event.Owner] = true + } + } + // If the owner has approved the hash, we add the signature to the transaction. + // We add the signature in the format r, s, v. + // We set v to 1, as it is the only possible value for a approved hash. + // We set r to the owner's address. + // We set s to the empty hash. + // Refer to the Safe contract for more information. + if _, ok := f.approvedHashesOwners[safeTxHash][owner]; ok { + v := uint8(1) + r := common.BytesToHash(owner.Bytes()) + s := common.Hash{} + signatures = append(signatures, r.Bytes()...) + signatures = append(signatures, s.Bytes()...) + signatures = append(signatures, v) + } + } + if uint64(len(f.approvedHashesOwners[safeTxHash])) >= f.threshold { + auth, err := f.builder.Auth(ctx) + if err != nil { + return err + } + _, err = f.safe.ExecTransaction( + auth, + f.rollupAddress, + big.NewInt(0), + fastConfirmCallData, + 0, + big.NewInt(0), + big.NewInt(0), + big.NewInt(0), + common.Address{}, + common.Address{}, + signatures, + ) + if err != nil { + return err + } + } + return nil +} func (s *Staker) createConflict(ctx context.Context, info *StakerInfo) error { if info.CurrentChallenge != nil { return nil diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 14fcb49a9e..955ccc6e9f 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -29,7 +29,9 @@ import ( "github.com/offchainlabs/nitro/arbnode/dataposter/externalsignertest" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/arbos/l2pricing" + "github.com/offchainlabs/nitro/solgen/go/contractsgen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" + "github.com/offchainlabs/nitro/solgen/go/proxiesgen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" "github.com/offchainlabs/nitro/staker" @@ -638,11 +640,306 @@ func TestFastConfirmation(t *testing.T) { Require(t, err) tx, err = stakerA.Act(ctx) Require(t, err) - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) + if tx != nil { + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + } latestConfirmAfterAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) Require(t, err) if latestConfirmAfterAct <= latestConfirmBeforeAct { Fatal(t, "staker A didn't advance the latest confirmed node") } } + +func TestFastConfirmationWithSafe(t *testing.T) { + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + srv := externalsignertest.NewServer(t) + go func() { + if err := srv.Start(); err != nil { + log.Error("Failed to start external signer server:", err) + return + } + }() + var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs + + builder := NewNodeBuilder(ctx).DefaultConfig(t, true) + builder.L2Info = NewBlockChainTestInfo( + t, + types.NewArbitrumSigner(types.NewLondonSigner(builder.chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), + transferGas, + ) + + builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour + cleanupA := builder.Build(t) + defer cleanupA() + + addNewBatchPoster(ctx, t, builder, srv.Address) + + builder.L1.SendWaitTestTransactions(t, []*types.Transaction{ + builder.L1Info.PrepareTxTo("Faucet", &srv.Address, 30000, big.NewInt(1).Mul(big.NewInt(1e18), big.NewInt(1e18)), nil)}) + + l2nodeA := builder.L2.ConsensusNode + execNodeA := builder.L2.ExecNode + + config := arbnode.ConfigDefaultL1Test() + config.Sequencer = false + config.DelayedSequencer.Enable = false + config.BatchPoster.Enable = false + builder.execConfig.Sequencer.Enable = false + testClientB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: config}) + defer cleanupB() + + l2nodeB := testClientB.ConsensusNode + execNodeB := testClientB.ExecNode + + nodeAGenesis := execNodeA.Backend.APIBackend().CurrentHeader().Hash() + nodeBGenesis := execNodeB.Backend.APIBackend().CurrentHeader().Hash() + if nodeAGenesis != nodeBGenesis { + Fatal(t, "node A L2 genesis hash", nodeAGenesis, "!= node B L2 genesis hash", nodeBGenesis) + } + + builder.BridgeBalance(t, "Faucet", big.NewInt(1).Mul(big.NewInt(params.Ether), big.NewInt(10000))) + + deployAuth := builder.L1Info.GetDefaultTransactOpts("RollupOwner", ctx) + + balance := big.NewInt(params.Ether) + balance.Mul(balance, big.NewInt(100)) + builder.L1Info.GenerateAccount("ValidatorA") + builder.L1.TransferBalance(t, "Faucet", "ValidatorA", balance, builder.L1Info) + l1authA := builder.L1Info.GetDefaultTransactOpts("ValidatorA", ctx) + + builder.L1Info.GenerateAccount("ValidatorB") + builder.L1.TransferBalance(t, "Faucet", "ValidatorB", balance, builder.L1Info) + l1authB := builder.L1Info.GetDefaultTransactOpts("ValidatorB", ctx) + + valWalletAddrAPtr, err := validatorwallet.GetValidatorWalletContract(ctx, l2nodeA.DeployInfo.ValidatorWalletCreator, 0, &l1authA, l2nodeA.L1Reader, true) + Require(t, err) + valWalletAddrA := *valWalletAddrAPtr + valWalletAddrCheck, err := validatorwallet.GetValidatorWalletContract(ctx, l2nodeA.DeployInfo.ValidatorWalletCreator, 0, &l1authA, l2nodeA.L1Reader, true) + Require(t, err) + if valWalletAddrA == *valWalletAddrCheck { + Require(t, err, "didn't cache validator wallet address", valWalletAddrA.String(), "vs", valWalletAddrCheck.String()) + } + + rollup, err := rollupgen.NewRollupAdminLogic(l2nodeA.DeployInfo.Rollup, builder.L1.Client) + Require(t, err) + + upgradeExecutor, err := upgrade_executorgen.NewUpgradeExecutor(l2nodeA.DeployInfo.UpgradeExecutor, builder.L1.Client) + Require(t, err, "unable to bind upgrade executor") + rollupABI, err := abi.JSON(strings.NewReader(rollupgen.RollupAdminLogicABI)) + Require(t, err, "unable to parse rollup ABI") + + safeAddress := deploySafe(t, builder.L1, builder.L1.Client, deployAuth, []common.Address{valWalletAddrA, srv.Address}) + setValidatorCalldata, err := rollupABI.Pack("setValidator", []common.Address{valWalletAddrA, l1authB.From, srv.Address, safeAddress}, []bool{true, true, true, true}) + Require(t, err, "unable to generate setValidator calldata") + tx, err := upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setValidatorCalldata) + Require(t, err, "unable to set validators") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + setMinAssertPeriodCalldata, err := rollupABI.Pack("setMinimumAssertionPeriod", big.NewInt(1)) + Require(t, err, "unable to generate setMinimumAssertionPeriod calldata") + tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setMinAssertPeriodCalldata) + Require(t, err, "unable to set minimum assertion period") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + setAnyTrustFastConfirmerCalldata, err := rollupABI.Pack("setAnyTrustFastConfirmer", safeAddress) + Require(t, err, "unable to generate setAnyTrustFastConfirmer calldata") + tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setAnyTrustFastConfirmerCalldata) + Require(t, err, "unable to set anytrust fast confirmer") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + valConfig := staker.TestL1ValidatorConfig + valConfig.EnableFastConfirmation = true + valConfig.FastConfirmSafeAddress = safeAddress.String() + parentChainID, err := builder.L1.Client.ChainID(ctx) + if err != nil { + t.Fatalf("Failed to get parent chain id: %v", err) + } + dpA, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2nodeB.ArbDB, storage.StakerPrefix), + l2nodeA.L1Reader, + &l1authA, NewFetcherFromConfig(arbnode.ConfigDefaultL1NonSequencerTest()), + nil, + parentChainID, + ) + if err != nil { + t.Fatalf("Error creating validator dataposter: %v", err) + } + valWalletA, err := validatorwallet.NewContract(dpA, nil, l2nodeA.DeployInfo.ValidatorWalletCreator, l2nodeA.DeployInfo.Rollup, l2nodeA.L1Reader, &l1authA, 0, func(common.Address) {}, func() uint64 { return valConfig.ExtraGas }) + Require(t, err) + valConfig.Strategy = "MakeNodes" + + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + blockValidatorConfig := staker.TestBlockValidatorConfig + + statelessA, err := staker.NewStatelessBlockValidator( + l2nodeA.InboxReader, + l2nodeA.InboxTracker, + l2nodeA.TxStreamer, + execNodeA, + l2nodeA.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStack, + ) + Require(t, err) + err = statelessA.Start(ctx) + Require(t, err) + stakerA, err := staker.NewStaker( + l2nodeA.L1Reader, + valWalletA, + bind.CallOpts{}, + valConfig, + nil, + statelessA, + nil, + nil, + l2nodeA.DeployInfo.ValidatorUtils, + nil, + ) + Require(t, err) + err = stakerA.Initialize(ctx) + if stakerA.Strategy() != staker.WatchtowerStrategy { + err = valWalletA.Initialize(ctx) + Require(t, err) + } + Require(t, err) + cfg := arbnode.ConfigDefaultL1NonSequencerTest() + signerCfg, err := externalSignerTestCfg(srv.Address, srv.URL()) + if err != nil { + t.Fatalf("Error getting external signer config: %v", err) + } + cfg.Staker.DataPoster.ExternalSigner = *signerCfg + dpB, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2nodeB.ArbDB, storage.StakerPrefix), + l2nodeB.L1Reader, + &l1authB, NewFetcherFromConfig(cfg), + nil, + parentChainID, + ) + if err != nil { + t.Fatalf("Error creating validator dataposter: %v", err) + } + valWalletB, err := validatorwallet.NewEOA(dpB, l2nodeB.DeployInfo.Rollup, l2nodeB.L1Reader.Client(), func() uint64 { return 0 }) + Require(t, err) + valConfig.Strategy = "MakeNodes" + statelessB, err := staker.NewStatelessBlockValidator( + l2nodeB.InboxReader, + l2nodeB.InboxTracker, + l2nodeB.TxStreamer, + execNodeB, + l2nodeB.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStack, + ) + Require(t, err) + err = statelessB.Start(ctx) + Require(t, err) + stakerB, err := staker.NewStaker( + l2nodeB.L1Reader, + valWalletB, + bind.CallOpts{}, + valConfig, + nil, + statelessB, + nil, + nil, + l2nodeB.DeployInfo.ValidatorUtils, + nil, + ) + Require(t, err) + err = stakerB.Initialize(ctx) + Require(t, err) + if stakerB.Strategy() != staker.WatchtowerStrategy { + err = valWalletB.Initialize(ctx) + Require(t, err) + } + + builder.L2Info.GenerateAccount("BackgroundUser") + tx = builder.L2Info.PrepareTx("Faucet", "BackgroundUser", builder.L2Info.TransferGas, balance, nil) + err = builder.L2.Client.SendTransaction(ctx, tx) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + // Continually make L2 transactions in a background thread + backgroundTxsCtx, cancelBackgroundTxs := context.WithCancel(ctx) + backgroundTxsShutdownChan := make(chan struct{}) + defer (func() { + cancelBackgroundTxs() + <-backgroundTxsShutdownChan + })() + go (func() { + defer close(backgroundTxsShutdownChan) + err := makeBackgroundTxs(backgroundTxsCtx, builder) + if !errors.Is(err, context.Canceled) { + log.Warn("error making background txs", "err", err) + } + })() + + latestConfirmBeforeAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + tx, err = stakerA.Act(ctx) + Require(t, err) + if tx != nil { + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + } + latestConfirmAfterStakerAAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + if latestConfirmAfterStakerAAct != latestConfirmBeforeAct { + Fatal(t, "staker A alone advanced the latest confirmed node", latestConfirmAfterStakerAAct, "when it shouldn't have") + } + for j := 0; j < 5; j++ { + builder.L1.TransferBalance(t, "Faucet", "Faucet", common.Big0, builder.L1Info) + } + tx, err = stakerB.Act(ctx) + Require(t, err) + if tx != nil { + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + } + latestConfirmAfterStakerBAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + if latestConfirmAfterStakerBAct <= latestConfirmBeforeAct { + Fatal(t, "staker A and B together didn't advance the latest confirmed node") + } +} + +func deploySafe(t *testing.T, l1 *TestClient, backend bind.ContractBackend, deployAuth bind.TransactOpts, owners []common.Address) common.Address { + safeAddress, tx, _, err := contractsgen.DeploySafeL2(&deployAuth, backend) + Require(t, err) + _, err = l1.EnsureTxSucceeded(tx) + Require(t, err) + safeProxyAddress, tx, _, err := proxiesgen.DeploySafeProxy(&deployAuth, backend, safeAddress) + Require(t, err) + _, err = l1.EnsureTxSucceeded(tx) + Require(t, err) + var safe *contractsgen.Safe + safe, err = contractsgen.NewSafe(safeProxyAddress, backend) + Require(t, err) + _, err = l1.EnsureTxSucceeded(tx) + Require(t, err) + tx, err = safe.Setup( + &deployAuth, + owners, + big.NewInt(2), + common.Address{}, + nil, + common.Address{}, + common.Address{}, + big.NewInt(0), + common.Address{}, + ) + Require(t, err) + _, err = l1.EnsureTxSucceeded(tx) + Require(t, err) + return safeProxyAddress +} From 97a3dbad253a36ae6babce7271699cacdc00163c Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 27 Jun 2024 18:43:51 +0530 Subject: [PATCH 076/268] fix makefile --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 53b89c8d72..c924fddeb5 100644 --- a/Makefile +++ b/Makefile @@ -494,11 +494,13 @@ contracts/test/prover/proofs/%.json: $(arbitrator_cases)/%.wasm $(prover_bin) @touch $@ .make/solidity: $(DEP_PREDICATE) contracts/src/*/*.sol .make/yarndeps $(ORDER_ONLY_PREDICATE) .make + (cd safe-smart-account && npm run build) yarn --cwd contracts build yarn --cwd contracts build:forge:yul @touch $@ .make/yarndeps: $(DEP_PREDICATE) contracts/package.json contracts/yarn.lock $(ORDER_ONLY_PREDICATE) .make + (cd safe-smart-account && npm i) yarn --cwd contracts install @touch $@ From 7a675c158efc561164deae76373559202e00b3b3 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 27 Jun 2024 18:55:44 +0530 Subject: [PATCH 077/268] fix docker --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 2863b76dd1..75a4a3470e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,7 @@ WORKDIR /workspace COPY contracts/package.json contracts/yarn.lock contracts/ RUN cd contracts && yarn install COPY contracts contracts/ +COPY safe-smart-account safe-smart-account/ COPY Makefile . RUN . ~/.bashrc && NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity From 32bb178a9bc2512b086a49187f1c95359d614d6f Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 27 Jun 2024 19:06:50 +0530 Subject: [PATCH 078/268] fix docker --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 75a4a3470e..45ac32e18e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,7 @@ WORKDIR /workspace COPY contracts/package.json contracts/yarn.lock contracts/ RUN cd contracts && yarn install COPY contracts contracts/ +RUN cd safe-smart-account && npm i && npm run build COPY safe-smart-account safe-smart-account/ COPY Makefile . RUN . ~/.bashrc && NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity From da7f1769ae2eca854ef0271f4bb947a79e717e9a Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 27 Jun 2024 19:16:46 +0530 Subject: [PATCH 079/268] fix docker --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 45ac32e18e..72581029a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,8 +32,8 @@ WORKDIR /workspace COPY contracts/package.json contracts/yarn.lock contracts/ RUN cd contracts && yarn install COPY contracts contracts/ -RUN cd safe-smart-account && npm i && npm run build COPY safe-smart-account safe-smart-account/ +RUN cd safe-smart-account && npm i && npm run build COPY Makefile . RUN . ~/.bashrc && NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity From c0ef5f186f05a46433f1ee40e49567d3a00e3ac8 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 27 Jun 2024 19:37:52 +0530 Subject: [PATCH 080/268] fix docker --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 72581029a9..d2b5dbc209 100644 --- a/Dockerfile +++ b/Dockerfile @@ -227,6 +227,7 @@ COPY . ./ COPY --from=contracts-builder workspace/contracts/build/ contracts/build/ COPY --from=contracts-builder workspace/contracts/out/ contracts/out/ COPY --from=contracts-builder workspace/contracts/node_modules/@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json contracts/node_modules/@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/ +COPY --from=contracts-builder workspace/safe-smart-account/build/ workspace/safe-smart-account/build/ COPY --from=contracts-builder workspace/.make/ .make/ COPY --from=prover-header-export / target/ COPY --from=brotli-library-export / target/ From c8797fa770e6a869066e2cc03a2f0477a577aa82 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 27 Jun 2024 20:06:40 +0530 Subject: [PATCH 081/268] fix makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c924fddeb5..3635eefaf2 100644 --- a/Makefile +++ b/Makefile @@ -493,7 +493,7 @@ contracts/test/prover/proofs/%.json: $(arbitrator_cases)/%.wasm $(prover_bin) go run solgen/gen.go @touch $@ -.make/solidity: $(DEP_PREDICATE) contracts/src/*/*.sol .make/yarndeps $(ORDER_ONLY_PREDICATE) .make +.make/solidity: $(DEP_PREDICATE) safe-smart-account/contracts/*/*.sol safe-smart-account/contracts/*.sol contracts/src/*/*.sol .make/yarndeps $(ORDER_ONLY_PREDICATE) .make (cd safe-smart-account && npm run build) yarn --cwd contracts build yarn --cwd contracts build:forge:yul From b08928dcc1877fda9e55235fd8fc899b6948d67a Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 28 Jun 2024 18:50:51 +0530 Subject: [PATCH 082/268] Skip TestSequencerPriceAdjustsFrom* on local builds --- .github/workflows/ci.yml | 2 +- system_tests/fees_test.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d97b5bfd5..c2ee39a6d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,7 @@ jobs: if: matrix.test-mode == 'defaults' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 -tags=feestest > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") - name: run tests with race detection if: matrix.test-mode == 'race' diff --git a/system_tests/fees_test.go b/system_tests/fees_test.go index 4d8fbf43fd..2a53e42a23 100644 --- a/system_tests/fees_test.go +++ b/system_tests/fees_test.go @@ -2,8 +2,10 @@ // For license information, see https://github.com/nitro/blob/master/LICENSE // these tests seems to consume too much memory with race detection -//go:build !race -// +build !race +// Test randomly fails with L1 gas price estimate should tend toward the basefee +// so skipping locally, but running on CI +//go:build !race && feestest +// +build !race,feestest package arbtest From 21bf88cfa8a7f891c7d4742b6430abaec5ba8820 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 28 Jun 2024 18:49:18 +0200 Subject: [PATCH 083/268] Inline cloning the layers into a new Merkle. This was a suggestion from Lee to keep from taking the lock twice. --- arbitrator/prover/src/merkle.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 9952f84631..28b3df5810 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -199,11 +199,7 @@ fn new_layer(ty: MerkleType, layer: &[Bytes32], empty_hash: &'static Bytes32) -> impl Clone for Merkle { fn clone(&self) -> Self { - let leaves = if self.layers.lock().data.is_empty() { - vec![] - } else { - self.layers.lock().data[0].clone() - }; + let leaves = self.layers.lock().data.get(0).cloned().unwrap_or_default(); Merkle::new_advanced(self.ty, leaves, self.min_depth) } } From 3afb90a922bd39a1cdbf82e21f74f9b90f601635 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 2 Jul 2024 22:45:33 +0200 Subject: [PATCH 084/268] Divide the bytes of memory by the leaf size. Without this we end up with Merkle trees that are 32 times larger than they need to be. --- arbitrator/prover/src/memory.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index c7aa2af794..9443d87667 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -310,13 +310,15 @@ impl Memory { pub fn resize(&mut self, new_size: usize) { self.buffer.resize(new_size, 0); if let Some(merkle) = self.merkle.take() { - merkle.resize(new_size).unwrap_or_else(|_| { - panic!( - "Couldn't resize merkle tree from {} to {}", - merkle.len(), - new_size - ) - }); + merkle + .resize(new_size / Self::LEAF_SIZE) + .unwrap_or_else(|_| { + panic!( + "Couldn't resize merkle tree from {} to {}", + merkle.len(), + new_size + ) + }); self.merkle = Some(merkle); } } From fe8c159eaf4fbf2e80dc1b234739ebd49991829c Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 2 Jul 2024 23:16:26 +0200 Subject: [PATCH 085/268] Make clippy happy. --- arbitrator/prover/src/merkle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 241828f1e9..c58d31b1b1 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -204,7 +204,7 @@ fn new_layer(ty: MerkleType, layer: &[Bytes32], empty_hash: &'static Bytes32) -> impl Clone for Merkle { fn clone(&self) -> Self { - let leaves = self.layers.lock().data.get(0).cloned().unwrap_or_default(); + let leaves = self.layers.lock().data.first().cloned().unwrap_or_default(); Merkle::new_advanced(self.ty, leaves, self.min_depth) } } From 2acfea2f839131e75bafd7dbd2fd2c606c6e6c4f Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 2 Jul 2024 23:24:03 +0200 Subject: [PATCH 086/268] Make clippy happy. --- arbitrator/prover/src/merkle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 28b3df5810..595bf67d69 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -199,7 +199,7 @@ fn new_layer(ty: MerkleType, layer: &[Bytes32], empty_hash: &'static Bytes32) -> impl Clone for Merkle { fn clone(&self) -> Self { - let leaves = self.layers.lock().data.get(0).cloned().unwrap_or_default(); + let leaves = self.layers.lock().data.first().cloned().unwrap_or_default(); Merkle::new_advanced(self.ty, leaves, self.min_depth) } } From b66830638e0ca69e7d7a245ce894e87a829208f0 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 8 Jul 2024 17:09:55 +0530 Subject: [PATCH 087/268] fix contracts --- contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts b/contracts index 56ae8045eb..61204dd455 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 56ae8045eb511824474f675326d32716ca26326b +Subproject commit 61204dd455966cb678192427a07aa9795ff91c14 From f66590c1575a7f83bfd69503062c52c5ba48b746 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 8 Jul 2024 18:03:14 +0530 Subject: [PATCH 088/268] cherry pick fast confrimation commits --- contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts b/contracts index 61204dd455..448e30d6de 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 61204dd455966cb678192427a07aa9795ff91c14 +Subproject commit 448e30d6de0eda9efd6a4c7c2311ec0b89f5cb60 From ca9d8690cd673c4dfbd83deb280175d1a4bca3dc Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 8 Jul 2024 19:25:45 +0530 Subject: [PATCH 089/268] fix docker --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e003bb493b..6194581546 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,7 @@ COPY contracts/package.json contracts/yarn.lock contracts/ RUN cd contracts && yarn install COPY contracts contracts/ COPY safe-smart-account safe-smart-account/ -RUN cd safe-smart-account && npm i && npm run build +RUN cd safe-smart-account && npm i COPY Makefile . RUN . ~/.bashrc && NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity @@ -227,7 +227,7 @@ COPY . ./ COPY --from=contracts-builder workspace/contracts/build/ contracts/build/ COPY --from=contracts-builder workspace/contracts/out/ contracts/out/ COPY --from=contracts-builder workspace/contracts/node_modules/@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/UpgradeExecutor.json contracts/node_modules/@offchainlabs/upgrade-executor/build/contracts/src/UpgradeExecutor.sol/ -COPY --from=contracts-builder workspace/safe-smart-account/build/ workspace/safe-smart-account/build/ +COPY --from=contracts-builder workspace/safe-smart-account/build/ safe-smart-account/build/ COPY --from=contracts-builder workspace/.make/ .make/ COPY --from=prover-header-export / target/ COPY --from=brotli-library-export / target/ From 5e2881535526c8cf14a33336f6bc82b242c20e6a Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 8 Jul 2024 20:29:40 +0530 Subject: [PATCH 090/268] fix --- .dockerignore | 1 + Dockerfile | 1 + 2 files changed, 2 insertions(+) diff --git a/.dockerignore b/.dockerignore index e142afd073..21fe19b1fc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,6 +9,7 @@ go-ethereum/tests **/*.yml contracts/build contracts/cache/ +safe-smart-account/ solgen/go **/node_modules diff --git a/Dockerfile b/Dockerfile index 6194581546..6d3662a455 100644 --- a/Dockerfile +++ b/Dockerfile @@ -84,6 +84,7 @@ COPY ./wavmio ./wavmio COPY ./zeroheavy ./zeroheavy COPY ./contracts/src/precompiles/ ./contracts/src/precompiles/ COPY ./contracts/package.json ./contracts/yarn.lock ./contracts/ +COPY ./safe-smart-account ./safe-smart-account COPY ./solgen/gen.go ./solgen/ COPY ./fastcache ./fastcache COPY ./go-ethereum ./go-ethereum From a736fd81199ff8e78180663b834291ea6252a1a7 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 8 Jul 2024 20:32:25 +0530 Subject: [PATCH 091/268] fix --- .dockerignore | 2 +- Dockerfile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 21fe19b1fc..51424900e8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,7 +9,7 @@ go-ethereum/tests **/*.yml contracts/build contracts/cache/ -safe-smart-account/ +safe-smart-account/build/ solgen/go **/node_modules diff --git a/Dockerfile b/Dockerfile index 6d3662a455..f58b46fff7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -182,6 +182,7 @@ COPY ./Makefile ./ COPY ./arbitrator ./arbitrator COPY ./solgen ./solgen COPY ./contracts ./contracts +COPY ./safe-smart-account ./safe-smart-account RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-replay-env FROM debian:bookworm-slim as machine-versions From 89227b14f0e02c1773b9d5e742a39f3ede439a0f Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 9 Jul 2024 15:57:10 +0530 Subject: [PATCH 092/268] update test --- system_tests/staker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 955ccc6e9f..1ae2d07610 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -828,7 +828,7 @@ func TestFastConfirmationWithSafe(t *testing.T) { } valWalletB, err := validatorwallet.NewEOA(dpB, l2nodeB.DeployInfo.Rollup, l2nodeB.L1Reader.Client(), func() uint64 { return 0 }) Require(t, err) - valConfig.Strategy = "MakeNodes" + valConfig.Strategy = "stakelatest" statelessB, err := staker.NewStatelessBlockValidator( l2nodeB.InboxReader, l2nodeB.InboxTracker, From 08320f68f58c060c358748b928cfd22bf0e1d135 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 9 Jul 2024 20:38:25 +0530 Subject: [PATCH 093/268] pin safe module to 192c7dc --- safe-smart-account | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/safe-smart-account b/safe-smart-account index 46f7c60ef4..192c7dc672 160000 --- a/safe-smart-account +++ b/safe-smart-account @@ -1 +1 @@ -Subproject commit 46f7c60ef4ba68cd2ed2bad8ab9f606fe9dab40f +Subproject commit 192c7dc67290940fcbc75165522bb86a37187069 From bc279c2808b17c8ef940f9e4b3617c19e533a4eb Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Tue, 9 Jul 2024 21:02:18 +0530 Subject: [PATCH 094/268] fix ci --- Dockerfile | 2 +- Makefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 37013d6d73..89f1b07da4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,7 @@ COPY contracts/package.json contracts/yarn.lock contracts/ RUN cd contracts && yarn install COPY contracts contracts/ COPY safe-smart-account safe-smart-account/ -RUN cd safe-smart-account && npm i +RUN cd safe-smart-account && yarn install COPY Makefile . RUN . ~/.bashrc && NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-solidity diff --git a/Makefile b/Makefile index 931d504996..b0d8116c97 100644 --- a/Makefile +++ b/Makefile @@ -495,13 +495,13 @@ contracts/test/prover/proofs/%.json: $(arbitrator_cases)/%.wasm $(prover_bin) @touch $@ .make/solidity: $(DEP_PREDICATE) safe-smart-account/contracts/*/*.sol safe-smart-account/contracts/*.sol contracts/src/*/*.sol .make/yarndeps $(ORDER_ONLY_PREDICATE) .make - (cd safe-smart-account && npm run build) + yarn --cwd safe-smart-account build yarn --cwd contracts build yarn --cwd contracts build:forge:yul @touch $@ .make/yarndeps: $(DEP_PREDICATE) contracts/package.json contracts/yarn.lock $(ORDER_ONLY_PREDICATE) .make - (cd safe-smart-account && npm i) + yarn --cwd safe-smart-account install yarn --cwd contracts install @touch $@ From 29b51d2abce6521680e76b31f29e3366e954315a Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Wed, 10 Jul 2024 00:25:13 +0530 Subject: [PATCH 095/268] fix --- staker/staker.go | 4 ++-- system_tests/staker_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/staker/staker.go b/staker/staker.go index f031623a6d..51647f343f 100644 --- a/staker/staker.go +++ b/staker/staker.go @@ -937,7 +937,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv s.bringActiveUntilNode = info.LatestStakedNode + 1 } info.CanProgress = false - return nil + return s.tryFastConfirmation(ctx, action.assertion.AfterState.GlobalState.BlockHash, action.assertion.AfterState.GlobalState.SendRoot) } // Details are already logged with more details in generateNodeAction @@ -992,7 +992,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv hash: action.hash, } } - return nil + return s.tryFastConfirmationNodeNumber(ctx, action.number) } log.Info("staking on existing node", "node", action.number) // We'll return early if we already havea stake diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 1ae2d07610..5a1cb57fc0 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -828,7 +828,7 @@ func TestFastConfirmationWithSafe(t *testing.T) { } valWalletB, err := validatorwallet.NewEOA(dpB, l2nodeB.DeployInfo.Rollup, l2nodeB.L1Reader.Client(), func() uint64 { return 0 }) Require(t, err) - valConfig.Strategy = "stakelatest" + valConfig.Strategy = "watchtower" statelessB, err := staker.NewStatelessBlockValidator( l2nodeB.InboxReader, l2nodeB.InboxTracker, From 73be2edc259a64d3b0d8f08ec95afd89caf8eb3f Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 11 Jul 2024 10:59:46 +0530 Subject: [PATCH 096/268] Changes based on PR comments --- .github/workflows/ci.yml | 2 +- system_tests/fees_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02ef915f16..7fea04de4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,7 @@ jobs: if: matrix.test-mode == 'defaults' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 -tags=feestest > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 -tags=cionly > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") - name: run tests with race detection if: matrix.test-mode == 'race' diff --git a/system_tests/fees_test.go b/system_tests/fees_test.go index 2a53e42a23..ccca82e009 100644 --- a/system_tests/fees_test.go +++ b/system_tests/fees_test.go @@ -4,8 +4,8 @@ // these tests seems to consume too much memory with race detection // Test randomly fails with L1 gas price estimate should tend toward the basefee // so skipping locally, but running on CI -//go:build !race && feestest -// +build !race,feestest +//go:build !race && cionly +// +build !race,cionly package arbtest From 9b1faa22de915a41db2acd93d33a0368806f30c3 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Wed, 10 Jul 2024 13:03:08 -0300 Subject: [PATCH 097/268] Add TestWasmRecreateWithDelegatecall Test that the given Stylus program will be lazily recreated after being called by a Solidity contract with a delegate call. This change modifies the existing recreation test so both tests can share most of the code. --- contracts | 2 +- system_tests/program_test.go | 70 ++++++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/contracts b/contracts index 61204dd455..9c1d3010e8 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 61204dd455966cb678192427a07aa9795ff91c14 +Subproject commit 9c1d3010e85e920252798077b83b48c6beed26e4 diff --git a/system_tests/program_test.go b/system_tests/program_test.go index b05589a1bf..0164218bad 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1668,20 +1668,12 @@ func formatTime(duration time.Duration) string { return fmt.Sprintf("%.2f%s", span, units[unit]) } -func TestWasmRecreate(t *testing.T) { - builder, auth, cleanup := setupProgramTest(t, true) +func testWasmRecreate(t *testing.T, builder *NodeBuilder, storeTx *types.Transaction, loadTx *types.Transaction, want []byte) { ctx := builder.ctx l2info := builder.L2Info l2client := builder.L2.Client - defer cleanup() - - storage := deployWasm(t, ctx, auth, l2client, rustFile("storage")) - - zero := common.Hash{} - val := common.HexToHash("0x121233445566") // do an onchain call - store value - storeTx := l2info.PrepareTxTo("Owner", &storage, l2info.TransferGas, nil, argsForStorageWrite(zero, val)) Require(t, l2client.SendTransaction(ctx, storeTx)) _, err := EnsureTxSucceeded(ctx, l2client, storeTx) Require(t, err) @@ -1694,11 +1686,10 @@ func TestWasmRecreate(t *testing.T) { Require(t, err) // make sure reading 2nd value succeeds from 2nd node - loadTx := l2info.PrepareTxTo("Owner", &storage, l2info.TransferGas, nil, argsForStorageRead(zero)) result, err := arbutil.SendTxAsCall(ctx, nodeB.Client, loadTx, l2info.GetAddress("Owner"), nil, true) Require(t, err) - if common.BytesToHash(result) != val { - Fatal(t, "got wrong value") + if !bytes.Equal(result, want) { + t.Fatalf("got wrong value, got %x, want %x", result, want) } // close nodeB cleanupB() @@ -1723,8 +1714,8 @@ func TestWasmRecreate(t *testing.T) { // test nodeB - answers eth_call (requires reloading wasm) result, err = arbutil.SendTxAsCall(ctx, nodeB.Client, loadTx, l2info.GetAddress("Owner"), nil, true) Require(t, err) - if common.BytesToHash(result) != val { - Fatal(t, "got wrong value") + if !bytes.Equal(result, want) { + t.Fatalf("got wrong value, got %x, want %x", result, want) } // send new tx (requires wasm) and check nodeB sees it as well @@ -1743,7 +1734,58 @@ func TestWasmRecreate(t *testing.T) { Fatal(t, "not contents found before delete") } os.RemoveAll(wasmPath) +} + +func TestWasmRecreate(t *testing.T) { + builder, auth, cleanup := setupProgramTest(t, true) + ctx := builder.ctx + l2info := builder.L2Info + l2client := builder.L2.Client + defer cleanup() + + storage := deployWasm(t, ctx, auth, l2client, rustFile("storage")) + + zero := common.Hash{} + val := common.HexToHash("0x121233445566") + + storeTx := l2info.PrepareTxTo("Owner", &storage, l2info.TransferGas, nil, argsForStorageWrite(zero, val)) + loadTx := l2info.PrepareTxTo("Owner", &storage, l2info.TransferGas, nil, argsForStorageRead(zero)) + + testWasmRecreate(t, builder, storeTx, loadTx, val[:]) +} + +func TestWasmRecreateWithDelegatecall(t *testing.T) { + builder, auth, cleanup := setupProgramTest(t, true) + ctx := builder.ctx + l2info := builder.L2Info + l2client := builder.L2.Client + defer cleanup() + + storage := deployWasm(t, ctx, auth, l2client, rustFile("storage")) + + zero := common.Hash{} + val := common.HexToHash("0x121233445566") + + // deploy mock that contains the delegatecall method + mock, tx, _, err := mocksgen.DeployProgramTest(&auth, l2client) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, l2client, tx) + Require(t, err) + mockAbi, err := mocksgen.ProgramTestMetaData.GetAbi() + Require(t, err) + + data, err := mockAbi.Pack("delegatecallProgram", storage, argsForStorageWrite(zero, val)) + Require(t, err) + storeTx := l2info.PrepareTxTo("Owner", &mock, l2info.TransferGas, nil, data) + + data, err = mockAbi.Pack("delegatecallProgram", storage, argsForStorageRead(zero)) + Require(t, err) + loadTx := l2info.PrepareTxTo("Owner", &mock, l2info.TransferGas, nil, data) + + want, err := mockAbi.Methods["delegatecallProgram"].Outputs.Pack(val[:]) + Require(t, err) + testWasmRecreate(t, builder, storeTx, loadTx, want) } // createMapFromDb is used in verifying if wasm store rebuilding works From 228d1160f15b10bef7736183c911b958175f8f89 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Fri, 12 Jul 2024 14:29:01 -0300 Subject: [PATCH 098/268] Revert contracts submodule change --- contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts b/contracts index 9c1d3010e8..61204dd455 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 9c1d3010e85e920252798077b83b48c6beed26e4 +Subproject commit 61204dd455966cb678192427a07aa9795ff91c14 From d3b8732f7e2143e32d44271f08235a52be7f82ab Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Fri, 12 Jul 2024 15:01:41 -0300 Subject: [PATCH 099/268] Use multicall Stylus contract to delegate call --- system_tests/program_test.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 0164218bad..b748739cdc 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1762,30 +1762,18 @@ func TestWasmRecreateWithDelegatecall(t *testing.T) { defer cleanup() storage := deployWasm(t, ctx, auth, l2client, rustFile("storage")) + multicall := deployWasm(t, ctx, auth, l2client, rustFile("multicall")) zero := common.Hash{} val := common.HexToHash("0x121233445566") - // deploy mock that contains the delegatecall method - mock, tx, _, err := mocksgen.DeployProgramTest(&auth, l2client) - Require(t, err) - _, err = EnsureTxSucceeded(ctx, l2client, tx) - Require(t, err) - mockAbi, err := mocksgen.ProgramTestMetaData.GetAbi() - Require(t, err) - - data, err := mockAbi.Pack("delegatecallProgram", storage, argsForStorageWrite(zero, val)) - Require(t, err) - storeTx := l2info.PrepareTxTo("Owner", &mock, l2info.TransferGas, nil, data) + data := argsForMulticall(vm.DELEGATECALL, storage, big.NewInt(0), argsForStorageWrite(zero, val)) + storeTx := l2info.PrepareTxTo("Owner", &multicall, l2info.TransferGas, nil, data) - data, err = mockAbi.Pack("delegatecallProgram", storage, argsForStorageRead(zero)) - Require(t, err) - loadTx := l2info.PrepareTxTo("Owner", &mock, l2info.TransferGas, nil, data) + data = argsForMulticall(vm.DELEGATECALL, storage, big.NewInt(0), argsForStorageRead(zero)) + loadTx := l2info.PrepareTxTo("Owner", &multicall, l2info.TransferGas, nil, data) - want, err := mockAbi.Methods["delegatecallProgram"].Outputs.Pack(val[:]) - Require(t, err) - - testWasmRecreate(t, builder, storeTx, loadTx, want) + testWasmRecreate(t, builder, storeTx, loadTx, val[:]) } // createMapFromDb is used in verifying if wasm store rebuilding works From 5b3e89da67f114bf00b4d9790c0fe638865144a2 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Thu, 11 Jul 2024 18:13:56 -0600 Subject: [PATCH 100/268] add metrics to block validator --- staker/block_validator.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index 94ee907da5..e80670b16f 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -35,6 +35,8 @@ var ( validatorValidValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/valid", nil) validatorFailedValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/failed", nil) validatorMsgCountCurrentBatch = metrics.NewRegisteredGauge("arb/validator/msg_count_current_batch", nil) + validatorMsgCountCreatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_created", nil) + validatorMsgCountRecordSentGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_record_sent", nil) validatorMsgCountValidatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_validated", nil) ) @@ -283,8 +285,9 @@ func NewBlockValidator( return ret, nil } -func atomicStorePos(addr *uint64, val arbutil.MessageIndex) { +func atomicStorePos(addr *uint64, val arbutil.MessageIndex, metr metrics.Gauge) { atomic.StoreUint64(addr, uint64(val)) + metr.Update(int64(val)) } func atomicLoadPos(addr *uint64) arbutil.MessageIndex { @@ -588,7 +591,7 @@ func (v *BlockValidator) createNextValidationEntry(ctx context.Context) (bool, e v.validations.Store(pos, status) v.nextCreateStartGS = endGS v.nextCreatePrevDelayed = msg.DelayedMessagesRead - atomicStorePos(&v.createdA, pos+1) + atomicStorePos(&v.createdA, pos+1, validatorMsgCountCreatedGauge) log.Trace("create validation entry: created", "pos", pos) return true, nil } @@ -667,7 +670,7 @@ func (v *BlockValidator) sendNextRecordRequests(ctx context.Context) (bool, erro return false, err } pos += 1 - atomicStorePos(&v.recordSentA, pos) + atomicStorePos(&v.recordSentA, pos, validatorMsgCountRecordSentGauge) log.Trace("next record request: sent", "pos", pos) } @@ -778,11 +781,10 @@ validationsLoop: log.Error("failed writing new validated to database", "pos", pos, "err", err) } go v.recorder.MarkValid(pos, v.lastValidGS.BlockHash) - atomicStorePos(&v.validatedA, pos+1) + atomicStorePos(&v.validatedA, pos+1, validatorMsgCountValidatedGauge) v.validations.Delete(pos) nonBlockingTrigger(v.createNodesChan) nonBlockingTrigger(v.sendRecordChan) - validatorMsgCountValidatedGauge.Update(int64(pos + 1)) if v.testingProgressMadeChan != nil { nonBlockingTrigger(v.testingProgressMadeChan) } @@ -1222,9 +1224,9 @@ func (v *BlockValidator) checkValidatedGSCaughtUp() (bool, error) { v.nextCreateBatchReread = true v.nextCreateStartGS = v.lastValidGS v.nextCreatePrevDelayed = msg.DelayedMessagesRead - atomicStorePos(&v.createdA, count) - atomicStorePos(&v.recordSentA, count) - atomicStorePos(&v.validatedA, count) + atomicStorePos(&v.createdA, count, validatorMsgCountCreatedGauge) + atomicStorePos(&v.recordSentA, count, validatorMsgCountRecordSentGauge) + atomicStorePos(&v.validatedA, count, validatorMsgCountValidatedGauge) validatorMsgCountValidatedGauge.Update(int64(count)) v.chainCaughtUp = true return true, nil From 23fe471656f18bdf85d89b9f0ab739300a75bf4e Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Thu, 11 Jul 2024 19:32:10 -0600 Subject: [PATCH 101/268] redis: avoid redundent error print --- pubsub/common.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pubsub/common.go b/pubsub/common.go index 9f05304e46..65e996c68d 100644 --- a/pubsub/common.go +++ b/pubsub/common.go @@ -3,7 +3,6 @@ package pubsub import ( "context" - "github.com/ethereum/go-ethereum/log" "github.com/go-redis/redis/v8" ) @@ -22,7 +21,6 @@ func CreateStream(ctx context.Context, streamName string, client redis.Universal func StreamExists(ctx context.Context, streamName string, client redis.UniversalClient) bool { got, err := client.Do(ctx, "XINFO", "STREAM", streamName).Result() if err != nil { - log.Error("Reading redis streams", "error", err) return false } return got != nil From 3b36d2e1abdc1ebac9fcf862c0ef7c56ed05cbf7 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 12 Jul 2024 15:10:55 -0600 Subject: [PATCH 102/268] redisproducer: trim, don't claim if not reproducing --- pubsub/producer.go | 164 +++++++++++++++++++++++++++++------------- pubsub/pubsub_test.go | 113 ++++++++++++----------------- 2 files changed, 158 insertions(+), 119 deletions(-) diff --git a/pubsub/producer.go b/pubsub/producer.go index 074670ca0f..a81da13d78 100644 --- a/pubsub/producer.go +++ b/pubsub/producer.go @@ -13,6 +13,9 @@ import ( "encoding/json" "errors" "fmt" + "math" + "strconv" + "strings" "sync" "time" @@ -69,7 +72,7 @@ var DefaultProducerConfig = ProducerConfig{ } var TestProducerConfig = ProducerConfig{ - EnableReproduce: true, + EnableReproduce: false, CheckPendingInterval: 10 * time.Millisecond, KeepAliveTimeout: 100 * time.Millisecond, CheckResultInterval: 5 * time.Millisecond, @@ -99,13 +102,13 @@ func NewProducer[Request any, Response any](client redis.UniversalClient, stream }, nil } -func (p *Producer[Request, Response]) errorPromisesFor(msgs []*Message[Request]) { +func (p *Producer[Request, Response]) errorPromisesFor(msgIds []string) { p.promisesLock.Lock() defer p.promisesLock.Unlock() - for _, msg := range msgs { - if promise, found := p.promises[msg.ID]; found { + for _, msg := range msgIds { + if promise, found := p.promises[msg]; found { promise.ProduceError(fmt.Errorf("internal error, consumer died while serving the request")) - delete(p.promises, msg.ID) + delete(p.promises, msg) } } } @@ -113,20 +116,55 @@ func (p *Producer[Request, Response]) errorPromisesFor(msgs []*Message[Request]) // checkAndReproduce reproduce pending messages that were sent to consumers // that are currently inactive. func (p *Producer[Request, Response]) checkAndReproduce(ctx context.Context) time.Duration { - msgs, err := p.checkPending(ctx) + staleIds, err := p.checkPending(ctx) if err != nil { log.Error("Checking pending messages", "error", err) return p.cfg.CheckPendingInterval } - if len(msgs) == 0 { + if len(staleIds) == 0 { return p.cfg.CheckPendingInterval } - if !p.cfg.EnableReproduce { - p.errorPromisesFor(msgs) - return p.cfg.CheckPendingInterval + if p.cfg.EnableReproduce { + err = p.reproduceIds(ctx, staleIds) + if err != nil { + log.Warn("filed reproducing messages", "err", err) + } + } else { + p.errorPromisesFor(staleIds) + } + return p.cfg.CheckPendingInterval +} + +func (p *Producer[Request, Response]) reproduceIds(ctx context.Context, staleIds []string) error { + log.Info("Attempting to claim", "messages", staleIds) + claimedMsgs, err := p.client.XClaim(ctx, &redis.XClaimArgs{ + Stream: p.redisStream, + Group: p.redisGroup, + Consumer: p.id, + MinIdle: p.cfg.KeepAliveTimeout, + Messages: staleIds, + }).Result() + if err != nil { + return fmt.Errorf("claiming ownership on messages: %v, error: %w", staleIds, err) + } + var messages []*Message[Request] + for _, msg := range claimedMsgs { + data, ok := (msg.Values[messageKey]).(string) + if !ok { + return fmt.Errorf("casting request: %v to bytes", msg.Values[messageKey]) + } + var req Request + if err := json.Unmarshal([]byte(data), &req); err != nil { + return fmt.Errorf("marshaling value: %v, error: %w", msg.Values[messageKey], err) + } + messages = append(messages, &Message[Request]{ + ID: msg.ID, + Value: req, + }) } + acked := make(map[string]Request) - for _, msg := range msgs { + for _, msg := range messages { if _, err := p.client.XAck(ctx, p.redisStream, p.redisGroup, msg.ID).Result(); err != nil { log.Error("ACKing message", "error", err) continue @@ -140,29 +178,81 @@ func (p *Producer[Request, Response]) checkAndReproduce(ctx context.Context) tim log.Error("Re-inserting pending messages with inactive consumers", "error", err) } } - return p.cfg.CheckPendingInterval + return nil +} + +func setMinIdInt(min *[2]uint64, id string) error { + idParts := strings.Split(id, "-") + if len(idParts) != 2 { + return errors.New("invalid i.d") + } + idTimeStamp, err := strconv.Atoi(idParts[0]) + if err != nil { + return fmt.Errorf("invalid i.d ts: %w", err) + } + if uint64(idTimeStamp) > min[0] { + return nil + } + idSerial, err := strconv.Atoi(idParts[1]) + if err != nil { + return fmt.Errorf("invalid i.d serial: %w", err) + } + if uint64(idTimeStamp) < min[0] { + min[0] = uint64(idTimeStamp) + min[1] = uint64(idSerial) + return nil + } + // idTimeStamp == min[0] + if uint64(idSerial) < min[1] { + min[1] = uint64(idSerial) + } + return nil } // checkResponses checks iteratively whether response for the promise is ready. func (p *Producer[Request, Response]) checkResponses(ctx context.Context) time.Duration { + minIdInt := [2]uint64{math.MaxUint64, math.MaxUint64} p.promisesLock.Lock() defer p.promisesLock.Unlock() + responded := 0 + errored := 0 for id, promise := range p.promises { + if ctx.Err() != nil { + return 0 + } res, err := p.client.Get(ctx, id).Result() if err != nil { - if errors.Is(err, redis.Nil) { - continue + errSetId := setMinIdInt(&minIdInt, id) + if errSetId != nil { + log.Error("error setting minId", "err", err) + return p.cfg.CheckResultInterval } - log.Error("Error reading value in redis", "key", id, "error", err) + if !errors.Is(err, redis.Nil) { + log.Error("Error reading value in redis", "key", id, "error", err) + } + continue } var resp Response if err := json.Unmarshal([]byte(res), &resp); err != nil { + promise.ProduceError(fmt.Errorf("error unmarshalling: %w", err)) log.Error("Error unmarshaling", "value", res, "error", err) - continue + errored++ + } else { + promise.Produce(resp) + responded++ } - promise.Produce(resp) delete(p.promises, id) } + var trimmed int64 + var trimErr error + minId := "+" + if minIdInt[0] < math.MaxUint64 { + minId = fmt.Sprintf("%d-%d", minIdInt[0], minIdInt[1]) + trimmed, trimErr = p.client.XTrimMinID(ctx, p.redisStream, minId).Result() + } else { + trimmed, trimErr = p.client.XTrimMaxLen(ctx, p.redisStream, 0).Result() + } + log.Trace("trimming", "id", minId, "trimmed", trimmed, "responded", responded, "errored", errored, "trim-err", trimErr) return p.cfg.CheckResultInterval } @@ -184,6 +274,10 @@ func (p *Producer[Request, Response]) reproduce(ctx context.Context, value Reque if err != nil { return nil, fmt.Errorf("marshaling value: %w", err) } + // catching the promiseLock before we sendXadd makes sure promise ids will + // be always ascending + p.promisesLock.Lock() + defer p.promisesLock.Unlock() id, err := p.client.XAdd(ctx, &redis.XAddArgs{ Stream: p.redisStream, Values: map[string]any{messageKey: val}, @@ -191,8 +285,6 @@ func (p *Producer[Request, Response]) reproduce(ctx context.Context, value Reque if err != nil { return nil, fmt.Errorf("adding values to redis: %w", err) } - p.promisesLock.Lock() - defer p.promisesLock.Unlock() promise := p.promises[oldKey] if oldKey != "" && promise == nil { // This will happen if the old consumer became inactive but then ack_d @@ -232,7 +324,7 @@ func (p *Producer[Request, Response]) havePromiseFor(messageID string) bool { return found } -func (p *Producer[Request, Response]) checkPending(ctx context.Context) ([]*Message[Request], error) { +func (p *Producer[Request, Response]) checkPending(ctx context.Context) ([]string, error) { pendingMessages, err := p.client.XPendingExt(ctx, &redis.XPendingExtArgs{ Stream: p.redisStream, Group: p.redisGroup, @@ -265,35 +357,5 @@ func (p *Producer[Request, Response]) checkPending(ctx context.Context) ([]*Mess } ids = append(ids, msg.ID) } - if len(ids) == 0 { - log.Trace("There are no pending messages with inactive consumers") - return nil, nil - } - log.Info("Attempting to claim", "messages", ids) - claimedMsgs, err := p.client.XClaim(ctx, &redis.XClaimArgs{ - Stream: p.redisStream, - Group: p.redisGroup, - Consumer: p.id, - MinIdle: p.cfg.KeepAliveTimeout, - Messages: ids, - }).Result() - if err != nil { - return nil, fmt.Errorf("claiming ownership on messages: %v, error: %w", ids, err) - } - var res []*Message[Request] - for _, msg := range claimedMsgs { - data, ok := (msg.Values[messageKey]).(string) - if !ok { - return nil, fmt.Errorf("casting request: %v to bytes", msg.Values[messageKey]) - } - var req Request - if err := json.Unmarshal([]byte(data), &req); err != nil { - return nil, fmt.Errorf("marshaling value: %v, error: %w", msg.Values[messageKey], err) - } - res = append(res, &Message[Request]{ - ID: msg.ID, - Value: req, - }) - } - return res, nil + return ids, nil } diff --git a/pubsub/pubsub_test.go b/pubsub/pubsub_test.go index 72504602e3..50e88f1bb2 100644 --- a/pubsub/pubsub_test.go +++ b/pubsub/pubsub_test.go @@ -49,10 +49,12 @@ type configOpt interface { apply(consCfg *ConsumerConfig, prodCfg *ProducerConfig) } -type disableReproduce struct{} +type withReproduce struct { + reproduce bool +} -func (e *disableReproduce) apply(_ *ConsumerConfig, prodCfg *ProducerConfig) { - prodCfg.EnableReproduce = false +func (e *withReproduce) apply(_ *ConsumerConfig, prodCfg *ProducerConfig) { + prodCfg.EnableReproduce = e.reproduce } func producerCfg() *ProducerConfig { @@ -71,7 +73,7 @@ func consumerCfg() *ConsumerConfig { } } -func newProducerConsumers(ctx context.Context, t *testing.T, opts ...configOpt) (*Producer[testRequest, testResponse], []*Consumer[testRequest, testResponse]) { +func newProducerConsumers(ctx context.Context, t *testing.T, opts ...configOpt) (redis.UniversalClient, string, *Producer[testRequest, testResponse], []*Consumer[testRequest, testResponse]) { t.Helper() redisClient, err := redisutil.RedisClientFromURL(redisutil.CreateTestRedis(ctx, t)) if err != nil { @@ -107,7 +109,7 @@ func newProducerConsumers(ctx context.Context, t *testing.T, opts ...configOpt) log.Debug("Error deleting heartbeat keys", "error", err) } }) - return producer, consumers + return redisClient, streamName, producer, consumers } func messagesMaps(n int) []map[string]string { @@ -118,10 +120,14 @@ func messagesMaps(n int) []map[string]string { return ret } +func msgForIndex(idx int) string { + return fmt.Sprintf("msg: %d", idx) +} + func wantMessages(n int) []string { var ret []string for i := 0; i < n; i++ { - ret = append(ret, fmt.Sprintf("msg: %d", i)) + ret = append(ret, msgForIndex(i)) } sort.Strings(ret) return ret @@ -148,26 +154,25 @@ func produceMessages(ctx context.Context, msgs []string, producer *Producer[test return promises, nil } -func awaitResponses(ctx context.Context, promises []*containers.Promise[testResponse]) ([]string, error) { +func awaitResponses(ctx context.Context, promises []*containers.Promise[testResponse]) ([]string, []int) { var ( responses []string - errs []error + errs []int ) - for _, p := range promises { + for idx, p := range promises { res, err := p.Await(ctx) if err != nil { - errs = append(errs, err) + errs = append(errs, idx) continue } responses = append(responses, res.Response) } - return responses, errors.Join(errs...) + return responses, errs } // consume messages from every consumer except stopped ones. -func consume(ctx context.Context, t *testing.T, consumers []*Consumer[testRequest, testResponse]) ([]map[string]string, [][]string) { +func consume(ctx context.Context, t *testing.T, consumers []*Consumer[testRequest, testResponse], gotMessages []map[string]string) [][]string { t.Helper() - gotMessages := messagesMaps(consumersCount) wantResponses := make([][]string, consumersCount) for idx := 0; idx < consumersCount; idx++ { if consumers[idx].Stopped() { @@ -199,7 +204,7 @@ func consume(ctx context.Context, t *testing.T, consumers []*Consumer[testReques } }) } - return gotMessages, wantResponses + return wantResponses } func TestRedisProduce(t *testing.T) { @@ -208,43 +213,56 @@ func TestRedisProduce(t *testing.T) { for _, tc := range []struct { name string killConsumers bool + autoRecover bool }{ { name: "all consumers are active", killConsumers: false, + autoRecover: false, }, { name: "some consumers killed, others should take over their work", killConsumers: true, + autoRecover: true, + }, + { + name: "some consumers killed, should return failure", + killConsumers: true, + autoRecover: false, }, } { t.Run(tc.name, func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - producer, consumers := newProducerConsumers(ctx, t) + redisClient, streamName, producer, consumers := newProducerConsumers(ctx, t, &withReproduce{tc.autoRecover}) producer.Start(ctx) wantMsgs := wantMessages(messagesCount) promises, err := produceMessages(ctx, wantMsgs, producer) if err != nil { t.Fatalf("Error producing messages: %v", err) } + gotMessages := messagesMaps(len(consumers)) if tc.killConsumers { // Consumer messages in every third consumer but don't ack them to check // that other consumers will claim ownership on those messages. for i := 0; i < len(consumers); i += 3 { consumers[i].Start(ctx) - if _, err := consumers[i].Consume(ctx); err != nil { + req, err := consumers[i].Consume(ctx) + if err != nil { t.Errorf("Error consuming message: %v", err) } + if !tc.autoRecover { + gotMessages[i][req.ID] = req.Value.Request + } consumers[i].StopAndWait() } } time.Sleep(time.Second) - gotMessages, wantResponses := consume(ctx, t, consumers) - gotResponses, err := awaitResponses(ctx, promises) - if err != nil { - t.Fatalf("Error awaiting responses: %v", err) + wantResponses := consume(ctx, t, consumers, gotMessages) + gotResponses, errIndexes := awaitResponses(ctx, promises) + if len(errIndexes) != 0 && tc.autoRecover { + t.Fatalf("Error awaiting responses: %v", errIndexes) } producer.StopAndWait() for _, c := range consumers { @@ -254,7 +272,6 @@ func TestRedisProduce(t *testing.T) { if err != nil { t.Fatalf("mergeMaps() unexpected error: %v", err) } - if diff := cmp.Diff(wantMsgs, got); diff != "" { t.Errorf("Unexpected diff (-want +got):\n%s\n", diff) } @@ -266,57 +283,17 @@ func TestRedisProduce(t *testing.T) { if cnt := producer.promisesLen(); cnt != 0 { t.Errorf("Producer still has %d unfullfilled promises", cnt) } + msgs, err := redisClient.XRange(ctx, streamName, "-", "+").Result() + if err != nil { + t.Errorf("XRange failed: %v", err) + } + if len(msgs) != 0 { + t.Errorf("redis still has %v messages", len(msgs)) + } }) } } -func TestRedisReproduceDisabled(t *testing.T) { - t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - producer, consumers := newProducerConsumers(ctx, t, &disableReproduce{}) - producer.Start(ctx) - wantMsgs := wantMessages(messagesCount) - promises, err := produceMessages(ctx, wantMsgs, producer) - if err != nil { - t.Fatalf("Error producing messages: %v", err) - } - - // Consumer messages in every third consumer but don't ack them to check - // that other consumers will claim ownership on those messages. - for i := 0; i < len(consumers); i += 3 { - consumers[i].Start(ctx) - if _, err := consumers[i].Consume(ctx); err != nil { - t.Errorf("Error consuming message: %v", err) - } - consumers[i].StopAndWait() - } - - gotMessages, _ := consume(ctx, t, consumers) - gotResponses, err := awaitResponses(ctx, promises) - if err == nil { - t.Fatalf("All promises were fullfilled with reproduce disabled and some consumers killed") - } - producer.StopAndWait() - for _, c := range consumers { - c.StopWaiter.StopAndWait() - } - got, err := mergeValues(gotMessages) - if err != nil { - t.Fatalf("mergeMaps() unexpected error: %v", err) - } - wantMsgCnt := messagesCount - ((consumersCount + 2) / 3) - if len(got) != wantMsgCnt { - t.Fatalf("Got: %d messages, want %d", len(got), wantMsgCnt) - } - if len(gotResponses) != wantMsgCnt { - t.Errorf("Got %d responses want: %d\n", len(gotResponses), wantMsgCnt) - } - if cnt := producer.promisesLen(); cnt != 0 { - t.Errorf("Producer still has %d unfullfilled promises", cnt) - } -} - // mergeValues merges maps from the slice and returns their values. // Returns and error if there exists duplicate key. func mergeValues(messages []map[string]string) ([]string, error) { From 7afc0db030b0c94fd5eb30e0b6bb079e016d6b9f Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 12 Jul 2024 15:30:02 -0600 Subject: [PATCH 103/268] validation client and server: allow prefix off by default, this will allow multiple streams to use the same redis --- system_tests/common_test.go | 4 ++-- validator/client/redis/producer.go | 27 ++++++++++++++------------- validator/server_api/json.go | 4 ++-- validator/valnode/redis/consumer.go | 6 +++++- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 16d6b2f131..1a11abf89b 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -624,12 +624,12 @@ func AddDefaultValNode(t *testing.T, ctx context.Context, nodeConfig *arbnode.Co conf.Wasm.RootPath = wasmRootDir // Enable redis streams when URL is specified if redisURL != "" { - conf.Arbitrator.RedisValidationServerConfig = rediscons.DefaultValidationServerConfig + conf.Arbitrator.RedisValidationServerConfig = rediscons.TestValidationServerConfig redisClient, err := redisutil.RedisClientFromURL(redisURL) if err != nil { t.Fatalf("Error creating redis coordinator: %v", err) } - redisStream := server_api.RedisStreamForRoot(currentRootModule(t)) + redisStream := server_api.RedisStreamForRoot(rediscons.TestValidationServerConfig.StreamPrefix, currentRootModule(t)) createRedisGroup(ctx, t, redisStream, redisClient) conf.Arbitrator.RedisValidationServerConfig.RedisURL = redisURL t.Cleanup(func() { destroyRedisGroup(ctx, t, redisStream, redisClient) }) diff --git a/validator/client/redis/producer.go b/validator/client/redis/producer.go index 4aa4031350..fad64489b0 100644 --- a/validator/client/redis/producer.go +++ b/validator/client/redis/producer.go @@ -20,6 +20,7 @@ import ( type ValidationClientConfig struct { Name string `koanf:"name"` + StreamPrefix string `koanf:"stream-prefix"` Room int32 `koanf:"room"` RedisURL string `koanf:"redis-url"` ProducerConfig pubsub.ProducerConfig `koanf:"producer-config"` @@ -42,6 +43,7 @@ var TestValidationClientConfig = ValidationClientConfig{ Name: "test redis validation client", Room: 2, RedisURL: "", + StreamPrefix: "test-", ProducerConfig: pubsub.TestProducerConfig, CreateStreams: false, } @@ -50,6 +52,7 @@ func ValidationClientConfigAddOptions(prefix string, f *pflag.FlagSet) { f.String(prefix+".name", DefaultValidationClientConfig.Name, "validation client name") f.Int32(prefix+".room", DefaultValidationClientConfig.Room, "validation client room") f.String(prefix+".redis-url", DefaultValidationClientConfig.RedisURL, "redis url") + f.String(prefix+".stream-prefix", DefaultValidationClientConfig.StreamPrefix, "prefix for stream name") pubsub.ProducerAddConfigAddOptions(prefix+".producer-config", f) f.Bool(prefix+".create-streams", DefaultValidationClientConfig.CreateStreams, "create redis streams if it does not exist") } @@ -57,14 +60,14 @@ func ValidationClientConfigAddOptions(prefix string, f *pflag.FlagSet) { // ValidationClient implements validation client through redis streams. type ValidationClient struct { stopwaiter.StopWaiter - name string - room int32 + config *ValidationClientConfig + name string + room int32 // producers stores moduleRoot to producer mapping. producers map[common.Hash]*pubsub.Producer[*validator.ValidationInput, validator.GoGlobalState] producerConfig pubsub.ProducerConfig redisClient redis.UniversalClient moduleRoots []common.Hash - createStreams bool } func NewValidationClient(cfg *ValidationClientConfig) (*ValidationClient, error) { @@ -76,19 +79,17 @@ func NewValidationClient(cfg *ValidationClientConfig) (*ValidationClient, error) return nil, err } return &ValidationClient{ - name: cfg.Name, - room: cfg.Room, - producers: make(map[common.Hash]*pubsub.Producer[*validator.ValidationInput, validator.GoGlobalState]), - producerConfig: cfg.ProducerConfig, - redisClient: redisClient, - createStreams: cfg.CreateStreams, + config: cfg, + room: cfg.Room, + producers: make(map[common.Hash]*pubsub.Producer[*validator.ValidationInput, validator.GoGlobalState]), + redisClient: redisClient, }, nil } func (c *ValidationClient) Initialize(ctx context.Context, moduleRoots []common.Hash) error { for _, mr := range moduleRoots { - if c.createStreams { - if err := pubsub.CreateStream(ctx, server_api.RedisStreamForRoot(mr), c.redisClient); err != nil { + if c.config.CreateStreams { + if err := pubsub.CreateStream(ctx, server_api.RedisStreamForRoot(c.config.StreamPrefix, mr), c.redisClient); err != nil { return fmt.Errorf("creating redis stream: %w", err) } } @@ -97,7 +98,7 @@ func (c *ValidationClient) Initialize(ctx context.Context, moduleRoots []common. continue } p, err := pubsub.NewProducer[*validator.ValidationInput, validator.GoGlobalState]( - c.redisClient, server_api.RedisStreamForRoot(mr), &c.producerConfig) + c.redisClient, server_api.RedisStreamForRoot(c.config.StreamPrefix, mr), &c.producerConfig) if err != nil { log.Warn("failed init redis for %v: %w", mr, err) continue @@ -152,5 +153,5 @@ func (c *ValidationClient) Name() string { } func (c *ValidationClient) Room() int { - return int(c.room) + return int(atomic.LoadInt32(&c.room)) } diff --git a/validator/server_api/json.go b/validator/server_api/json.go index 3dd817d5ae..dd646e1aa1 100644 --- a/validator/server_api/json.go +++ b/validator/server_api/json.go @@ -45,8 +45,8 @@ func MachineStepResultFromJson(resultJson *MachineStepResultJson) (*validator.Ma }, nil } -func RedisStreamForRoot(moduleRoot common.Hash) string { - return fmt.Sprintf("stream:%s", moduleRoot.Hex()) +func RedisStreamForRoot(prefix string, moduleRoot common.Hash) string { + return fmt.Sprintf("%sstream:%s", prefix, moduleRoot.Hex()) } type Request struct { diff --git a/validator/valnode/redis/consumer.go b/validator/valnode/redis/consumer.go index 84f597c095..fb7db1e870 100644 --- a/validator/valnode/redis/consumer.go +++ b/validator/valnode/redis/consumer.go @@ -37,7 +37,7 @@ func NewValidationServer(cfg *ValidationServerConfig, spawner validator.Validati consumers := make(map[common.Hash]*pubsub.Consumer[*validator.ValidationInput, validator.GoGlobalState]) for _, hash := range cfg.ModuleRoots { mr := common.HexToHash(hash) - c, err := pubsub.NewConsumer[*validator.ValidationInput, validator.GoGlobalState](redisClient, server_api.RedisStreamForRoot(mr), &cfg.ConsumerConfig) + c, err := pubsub.NewConsumer[*validator.ValidationInput, validator.GoGlobalState](redisClient, server_api.RedisStreamForRoot(cfg.StreamPrefix, mr), &cfg.ConsumerConfig) if err != nil { return nil, fmt.Errorf("creating consumer for validation: %w", err) } @@ -130,10 +130,12 @@ type ValidationServerConfig struct { ModuleRoots []string `koanf:"module-roots"` // Timeout on polling for existence of each redis stream. StreamTimeout time.Duration `koanf:"stream-timeout"` + StreamPrefix string `koanf:"stream-prefix"` } var DefaultValidationServerConfig = ValidationServerConfig{ RedisURL: "", + StreamPrefix: "", ConsumerConfig: pubsub.DefaultConsumerConfig, ModuleRoots: []string{}, StreamTimeout: 10 * time.Minute, @@ -141,6 +143,7 @@ var DefaultValidationServerConfig = ValidationServerConfig{ var TestValidationServerConfig = ValidationServerConfig{ RedisURL: "", + StreamPrefix: "test-", ConsumerConfig: pubsub.TestConsumerConfig, ModuleRoots: []string{}, StreamTimeout: time.Minute, @@ -150,6 +153,7 @@ func ValidationServerConfigAddOptions(prefix string, f *pflag.FlagSet) { pubsub.ConsumerConfigAddOptions(prefix+".consumer-config", f) f.StringSlice(prefix+".module-roots", nil, "Supported module root hashes") f.String(prefix+".redis-url", DefaultValidationServerConfig.RedisURL, "url of redis server") + f.String(prefix+".stream-prefix", DefaultValidationServerConfig.StreamPrefix, "prefix for stream name") f.Duration(prefix+".stream-timeout", DefaultValidationServerConfig.StreamTimeout, "Timeout on polling for existence of redis streams") } From 06902576d1c9c0d776b3b788bdaf074e8c9bfdfc Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 12 Jul 2024 17:21:14 -0600 Subject: [PATCH 104/268] producer: parse directl to uint64 --- pubsub/producer.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pubsub/producer.go b/pubsub/producer.go index a81da13d78..d8e72d4809 100644 --- a/pubsub/producer.go +++ b/pubsub/producer.go @@ -186,25 +186,25 @@ func setMinIdInt(min *[2]uint64, id string) error { if len(idParts) != 2 { return errors.New("invalid i.d") } - idTimeStamp, err := strconv.Atoi(idParts[0]) + idTimeStamp, err := strconv.ParseUint(idParts[0], 10, 64) if err != nil { return fmt.Errorf("invalid i.d ts: %w", err) } - if uint64(idTimeStamp) > min[0] { + if idTimeStamp > min[0] { return nil } - idSerial, err := strconv.Atoi(idParts[1]) + idSerial, err := strconv.ParseUint(idParts[1], 10, 64) if err != nil { return fmt.Errorf("invalid i.d serial: %w", err) } - if uint64(idTimeStamp) < min[0] { - min[0] = uint64(idTimeStamp) - min[1] = uint64(idSerial) + if idTimeStamp < min[0] { + min[0] = idTimeStamp + min[1] = idSerial return nil } // idTimeStamp == min[0] - if uint64(idSerial) < min[1] { - min[1] = uint64(idSerial) + if idSerial < min[1] { + min[1] = idSerial } return nil } From c96a07e1d5de74768e287d9a994c9fb84e072a2c Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 15:46:08 +0530 Subject: [PATCH 105/268] Merge v1.13.13 --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index e35bf9cdd3..90b36cf0b8 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit e35bf9cdd3d02034ac1be34a479d101f12012ba6 +Subproject commit 90b36cf0b87b96e0a74acf91d9603b341d8165d4 From df164cd61630de5e483fee1e5fbca6aa8c2f34f0 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 15:48:52 +0530 Subject: [PATCH 106/268] update module --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 90b36cf0b8..7c6e05f753 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 90b36cf0b87b96e0a74acf91d9603b341d8165d4 +Subproject commit 7c6e05f75337d59562a6e2b8e1bdf1e445ad14fb From 47bfc4c1c60840bd3516ab0aeee731759801f798 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 16:09:04 +0530 Subject: [PATCH 107/268] update import --- cmd/staterecovery/staterecovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/staterecovery/staterecovery.go b/cmd/staterecovery/staterecovery.go index 58ad06ad14..a7de58b2c9 100644 --- a/cmd/staterecovery/staterecovery.go +++ b/cmd/staterecovery/staterecovery.go @@ -10,7 +10,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/trie" - "github.com/ethereum/go-ethereum/trie/triedb/hashdb" + "github.com/ethereum/go-ethereum/triedb/hashdb" ) func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheConfig *core.CacheConfig, startBlock uint64) error { From 3942bc500dcd61a110332cbc08fb59614c98b818 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 17:03:36 +0530 Subject: [PATCH 108/268] fix --- cmd/staterecovery/staterecovery.go | 4 ++-- go.mod | 4 ++-- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/staterecovery/staterecovery.go b/cmd/staterecovery/staterecovery.go index a7de58b2c9..19ed51ef2d 100644 --- a/cmd/staterecovery/staterecovery.go +++ b/cmd/staterecovery/staterecovery.go @@ -9,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/hashdb" ) @@ -32,7 +32,7 @@ func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheCon } hashConfig := *hashdb.Defaults hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024 - trieConfig := &trie.Config{ + trieConfig := &triedb.Config{ Preimages: false, HashDB: &hashConfig, } diff --git a/go.mod b/go.mod index 00cee1a99a..d0c8d5e719 100644 --- a/go.mod +++ b/go.mod @@ -118,7 +118,7 @@ require ( github.com/graph-gophers/graphql-go v1.3.0 // indirect github.com/h2non/filetype v1.0.6 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect - github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect + github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/huin/goupnp v1.3.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect @@ -162,7 +162,7 @@ require ( go.opencensus.io v0.22.5 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/sync v0.5.0 golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/protobuf v1.30.0 // indirect diff --git a/go.sum b/go.sum index 8676c270c4..ff4726b22f 100644 --- a/go.sum +++ b/go.sum @@ -420,8 +420,8 @@ github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoI github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw= -github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= From 74da3216fa1430c74e617a6498a83e728f2943df Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 17:22:47 +0530 Subject: [PATCH 109/268] fix --- system_tests/test_info.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/system_tests/test_info.go b/system_tests/test_info.go index 764a8ae396..ee84564bdc 100644 --- a/system_tests/test_info.go +++ b/system_tests/test_info.go @@ -16,7 +16,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" @@ -110,8 +109,8 @@ func (b *BlockchainTestInfo) GenerateGenesisAccount(name string, balance *big.In }) } -func (b *BlockchainTestInfo) GetGenesisAlloc() core.GenesisAlloc { - alloc := make(core.GenesisAlloc) +func (b *BlockchainTestInfo) GetGenesisAlloc() types.GenesisAlloc { + alloc := make(types.GenesisAlloc) for _, info := range b.ArbInitData.Accounts { var contractCode []byte contractStorage := make(map[common.Hash]common.Hash) @@ -121,7 +120,7 @@ func (b *BlockchainTestInfo) GetGenesisAlloc() core.GenesisAlloc { contractStorage[k] = v } } - alloc[info.Addr] = core.GenesisAccount{ + alloc[info.Addr] = types.Account{ Balance: new(big.Int).Set(info.EthBalance), Nonce: info.Nonce, Code: contractCode, From 61d565258abcbeefdee2c988909786132253e4fc Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 15 Jul 2024 18:17:44 -0600 Subject: [PATCH 110/268] log unexpected errors in StreamExists --- pubsub/common.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pubsub/common.go b/pubsub/common.go index 65e996c68d..d7f041af15 100644 --- a/pubsub/common.go +++ b/pubsub/common.go @@ -2,7 +2,9 @@ package pubsub import ( "context" + "strings" + "github.com/ethereum/go-ethereum/log" "github.com/go-redis/redis/v8" ) @@ -21,6 +23,9 @@ func CreateStream(ctx context.Context, streamName string, client redis.Universal func StreamExists(ctx context.Context, streamName string, client redis.UniversalClient) bool { got, err := client.Do(ctx, "XINFO", "STREAM", streamName).Result() if err != nil { + if !strings.Contains(err.Error(), "no such key") { + log.Error("redis error", "err", err, "searching stream", streamName) + } return false } return got != nil From 6a99eb40c50a84b164574cf80630a2fc9a38929a Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 15 Jul 2024 19:59:08 -0600 Subject: [PATCH 111/268] redis pubsub: addressing comments --- pubsub/producer.go | 32 ++++++++++-------------------- validator/client/redis/producer.go | 15 +++++--------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/pubsub/producer.go b/pubsub/producer.go index d8e72d4809..197c8c41f0 100644 --- a/pubsub/producer.go +++ b/pubsub/producer.go @@ -147,35 +147,24 @@ func (p *Producer[Request, Response]) reproduceIds(ctx context.Context, staleIds if err != nil { return fmt.Errorf("claiming ownership on messages: %v, error: %w", staleIds, err) } - var messages []*Message[Request] for _, msg := range claimedMsgs { data, ok := (msg.Values[messageKey]).(string) if !ok { - return fmt.Errorf("casting request: %v to bytes", msg.Values[messageKey]) + log.Error("redis producer reproduce: message not string", "id", msg.ID, "value", msg.Values[messageKey]) + continue } var req Request if err := json.Unmarshal([]byte(data), &req); err != nil { - return fmt.Errorf("marshaling value: %v, error: %w", msg.Values[messageKey], err) + log.Error("redis producer reproduce: message not a request", "id", msg.ID, "err", err, "value", msg.Values[messageKey]) + continue } - messages = append(messages, &Message[Request]{ - ID: msg.ID, - Value: req, - }) - } - - acked := make(map[string]Request) - for _, msg := range messages { if _, err := p.client.XAck(ctx, p.redisStream, p.redisGroup, msg.ID).Result(); err != nil { - log.Error("ACKing message", "error", err) + log.Error("redis producer reproduce: could not ACK", "id", msg.ID, "err", err) continue } - acked[msg.ID] = msg.Value - } - for k, v := range acked { // Only re-insert messages that were removed the the pending list first. - _, err := p.reproduce(ctx, v, k) - if err != nil { - log.Error("Re-inserting pending messages with inactive consumers", "error", err) + if _, err := p.reproduce(ctx, req, msg.ID); err != nil { + log.Error("redis producer reproduce: error", "err", err) } } return nil @@ -184,18 +173,18 @@ func (p *Producer[Request, Response]) reproduceIds(ctx context.Context, staleIds func setMinIdInt(min *[2]uint64, id string) error { idParts := strings.Split(id, "-") if len(idParts) != 2 { - return errors.New("invalid i.d") + return fmt.Errorf("invalid i.d: %v", id) } idTimeStamp, err := strconv.ParseUint(idParts[0], 10, 64) if err != nil { - return fmt.Errorf("invalid i.d ts: %w", err) + return fmt.Errorf("invalid i.d: %v err: %w", id, err) } if idTimeStamp > min[0] { return nil } idSerial, err := strconv.ParseUint(idParts[1], 10, 64) if err != nil { - return fmt.Errorf("invalid i.d serial: %w", err) + return fmt.Errorf("invalid i.d serial: %v err: %w", id, err) } if idTimeStamp < min[0] { min[0] = idTimeStamp @@ -324,6 +313,7 @@ func (p *Producer[Request, Response]) havePromiseFor(messageID string) bool { return found } +// returns ids of pending messages that's worker doesn't appear alive func (p *Producer[Request, Response]) checkPending(ctx context.Context) ([]string, error) { pendingMessages, err := p.client.XPendingExt(ctx, &redis.XPendingExtArgs{ Stream: p.redisStream, diff --git a/validator/client/redis/producer.go b/validator/client/redis/producer.go index fad64489b0..43dc541276 100644 --- a/validator/client/redis/producer.go +++ b/validator/client/redis/producer.go @@ -61,13 +61,11 @@ func ValidationClientConfigAddOptions(prefix string, f *pflag.FlagSet) { type ValidationClient struct { stopwaiter.StopWaiter config *ValidationClientConfig - name string room int32 // producers stores moduleRoot to producer mapping. - producers map[common.Hash]*pubsub.Producer[*validator.ValidationInput, validator.GoGlobalState] - producerConfig pubsub.ProducerConfig - redisClient redis.UniversalClient - moduleRoots []common.Hash + producers map[common.Hash]*pubsub.Producer[*validator.ValidationInput, validator.GoGlobalState] + redisClient redis.UniversalClient + moduleRoots []common.Hash } func NewValidationClient(cfg *ValidationClientConfig) (*ValidationClient, error) { @@ -98,7 +96,7 @@ func (c *ValidationClient) Initialize(ctx context.Context, moduleRoots []common. continue } p, err := pubsub.NewProducer[*validator.ValidationInput, validator.GoGlobalState]( - c.redisClient, server_api.RedisStreamForRoot(c.config.StreamPrefix, mr), &c.producerConfig) + c.redisClient, server_api.RedisStreamForRoot(c.config.StreamPrefix, mr), &c.config.ProducerConfig) if err != nil { log.Warn("failed init redis for %v: %w", mr, err) continue @@ -146,10 +144,7 @@ func (c *ValidationClient) Stop() { } func (c *ValidationClient) Name() string { - if c.Started() { - return c.name - } - return "(not started)" + return c.config.Name } func (c *ValidationClient) Room() int { From 9d8c60ff37d3598562a5f5b80dff79e402ac7459 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 15 Jul 2024 19:59:36 -0600 Subject: [PATCH 112/268] redis consumer: checkPendingItems --- pubsub/producer.go | 9 ++++++++- pubsub/pubsub_test.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pubsub/producer.go b/pubsub/producer.go index 197c8c41f0..09a32f0e28 100644 --- a/pubsub/producer.go +++ b/pubsub/producer.go @@ -62,6 +62,7 @@ type ProducerConfig struct { KeepAliveTimeout time.Duration `koanf:"keepalive-timeout"` // Interval duration for checking the result set by consumers. CheckResultInterval time.Duration `koanf:"check-result-interval"` + CheckPendingItems int64 `koanf:"check-pending-items"` } var DefaultProducerConfig = ProducerConfig{ @@ -69,6 +70,7 @@ var DefaultProducerConfig = ProducerConfig{ CheckPendingInterval: time.Second, KeepAliveTimeout: 5 * time.Minute, CheckResultInterval: 5 * time.Second, + CheckPendingItems: 256, } var TestProducerConfig = ProducerConfig{ @@ -76,6 +78,7 @@ var TestProducerConfig = ProducerConfig{ CheckPendingInterval: 10 * time.Millisecond, KeepAliveTimeout: 100 * time.Millisecond, CheckResultInterval: 5 * time.Millisecond, + CheckPendingItems: 256, } func ProducerAddConfigAddOptions(prefix string, f *pflag.FlagSet) { @@ -83,6 +86,7 @@ func ProducerAddConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Duration(prefix+".check-pending-interval", DefaultProducerConfig.CheckPendingInterval, "interval in which producer checks pending messages whether consumer processing them is inactive") f.Duration(prefix+".check-result-interval", DefaultProducerConfig.CheckResultInterval, "interval in which producer checks pending messages whether consumer processing them is inactive") f.Duration(prefix+".keepalive-timeout", DefaultProducerConfig.KeepAliveTimeout, "timeout after which consumer is considered inactive if heartbeat wasn't performed") + f.Int64(prefix+".check-pending-items", DefaultProducerConfig.CheckPendingItems, "items to screen during check-pending") } func NewProducer[Request any, Response any](client redis.UniversalClient, streamName string, cfg *ProducerConfig) (*Producer[Request, Response], error) { @@ -320,7 +324,7 @@ func (p *Producer[Request, Response]) checkPending(ctx context.Context) ([]strin Group: p.redisGroup, Start: "-", End: "+", - Count: 100, + Count: p.cfg.CheckPendingItems, }).Result() if err != nil && !errors.Is(err, redis.Nil) { @@ -329,6 +333,9 @@ func (p *Producer[Request, Response]) checkPending(ctx context.Context) ([]strin if len(pendingMessages) == 0 { return nil, nil } + if len(pendingMessages) >= int(p.cfg.CheckPendingItems) { + log.Warn("redis producer: many pending items found", "stream", p.redisStream, "check-pending-items", p.cfg.CheckPendingItems) + } // IDs of the pending messages with inactive consumers. var ids []string active := make(map[string]bool) diff --git a/pubsub/pubsub_test.go b/pubsub/pubsub_test.go index 50e88f1bb2..a3140e32ac 100644 --- a/pubsub/pubsub_test.go +++ b/pubsub/pubsub_test.go @@ -63,6 +63,7 @@ func producerCfg() *ProducerConfig { CheckPendingInterval: TestProducerConfig.CheckPendingInterval, KeepAliveTimeout: TestProducerConfig.KeepAliveTimeout, CheckResultInterval: TestProducerConfig.CheckResultInterval, + CheckPendingItems: TestProducerConfig.CheckPendingItems, } } From 644fa77f29fe28f0ca3c5944e8c7cd4d810dd842 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 15 Jul 2024 20:22:43 -0600 Subject: [PATCH 113/268] producer - don't error if got unexpected late response --- pubsub/producer.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubsub/producer.go b/pubsub/producer.go index 09a32f0e28..2b1cdb5e3f 100644 --- a/pubsub/producer.go +++ b/pubsub/producer.go @@ -282,7 +282,8 @@ func (p *Producer[Request, Response]) reproduce(ctx context.Context, value Reque if oldKey != "" && promise == nil { // This will happen if the old consumer became inactive but then ack_d // the message afterwards. - return nil, fmt.Errorf("error reproducing the message, could not find existing one") + // don't error + log.Warn("tried reproducing a message but it wasn't found - probably got response", "oldKey", oldKey) } if oldKey == "" || promise == nil { pr := containers.NewPromise[Response](nil) From 96f5642e64cfefb17b1f62c9956d934bf2410747 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 09:49:01 +0200 Subject: [PATCH 114/268] Remove the new_direct method from Bytes32 This is completely superfluous. It is sufficient to just call `Bytes32(arr)`. --- arbitrator/arbutil/src/types.rs | 6 - arbitrator/prover/src/merkle.rs | 2 +- arbitrator/prover/src/merkle/zerohashes.rs | 898 ++++++++++----------- 3 files changed, 450 insertions(+), 456 deletions(-) diff --git a/arbitrator/arbutil/src/types.rs b/arbitrator/arbutil/src/types.rs index 9c6eaff1e8..6cf1d6cdf7 100644 --- a/arbitrator/arbutil/src/types.rs +++ b/arbitrator/arbutil/src/types.rs @@ -27,12 +27,6 @@ pub enum PreimageType { #[repr(C)] pub struct Bytes32(pub [u8; 32]); -impl Bytes32 { - pub const fn new_direct(x: [u8; 32]) -> Self { - Self(x) - } -} - impl Deref for Bytes32 { type Target = [u8; 32]; diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index c58d31b1b1..3e50dbd1a9 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -526,7 +526,7 @@ fn correct_capacity() { #[ignore = "This is just used for generating the zero hashes for the memory merkle trees."] fn emit_memory_zerohashes() { // The following code was generated from the empty_leaf_hash() test in the memory package. - let mut empty_node = Bytes32::new_direct([ + let mut empty_node = Bytes32([ 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, 186, 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, ]) diff --git a/arbitrator/prover/src/merkle/zerohashes.rs b/arbitrator/prover/src/merkle/zerohashes.rs index 1eef9b8557..a4724a609d 100644 --- a/arbitrator/prover/src/merkle/zerohashes.rs +++ b/arbitrator/prover/src/merkle/zerohashes.rs @@ -1,777 +1,777 @@ use arbutil::Bytes32; const VALUE_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([ + Bytes32([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]), - Bytes32::new_direct([ + Bytes32([ 119, 47, 167, 222, 218, 156, 26, 105, 57, 248, 170, 182, 183, 151, 18, 150, 142, 70, 138, 253, 54, 123, 132, 86, 170, 76, 157, 52, 113, 138, 253, 254, ]), - Bytes32::new_direct([ + Bytes32([ 8, 117, 27, 211, 196, 42, 6, 98, 185, 88, 231, 145, 14, 3, 207, 145, 158, 255, 69, 52, 198, 196, 148, 154, 59, 94, 229, 157, 93, 51, 200, 69, ]), - Bytes32::new_direct([ + Bytes32([ 247, 208, 196, 206, 204, 168, 129, 100, 238, 95, 52, 26, 132, 138, 233, 149, 196, 72, 179, 226, 60, 114, 27, 94, 173, 189, 197, 100, 163, 232, 180, 63, ]), - Bytes32::new_direct([ + Bytes32([ 178, 100, 198, 112, 40, 33, 187, 175, 130, 245, 59, 210, 133, 234, 158, 158, 133, 64, 213, 72, 222, 157, 216, 42, 210, 134, 36, 13, 211, 156, 163, 211, ]), - Bytes32::new_direct([ + Bytes32([ 203, 127, 32, 130, 225, 40, 219, 15, 35, 236, 47, 201, 161, 48, 53, 145, 134, 169, 109, 29, 26, 29, 178, 201, 118, 217, 57, 165, 116, 172, 232, 4, ]), - Bytes32::new_direct([ + Bytes32([ 209, 109, 33, 102, 227, 251, 133, 224, 170, 130, 65, 90, 185, 209, 146, 77, 244, 145, 181, 206, 159, 70, 209, 64, 241, 19, 149, 223, 138, 31, 163, 61, ]), - Bytes32::new_direct([ + Bytes32([ 145, 168, 124, 48, 254, 12, 34, 41, 4, 213, 245, 86, 61, 29, 177, 192, 67, 165, 237, 236, 87, 126, 193, 191, 15, 126, 104, 173, 165, 186, 1, 107, ]), - Bytes32::new_direct([ + Bytes32([ 235, 161, 247, 143, 69, 95, 210, 40, 243, 76, 102, 29, 118, 86, 180, 54, 81, 144, 103, 54, 202, 164, 81, 83, 180, 90, 154, 184, 54, 28, 7, 220, ]), - Bytes32::new_direct([ + Bytes32([ 203, 62, 12, 83, 35, 122, 214, 199, 125, 61, 236, 8, 253, 64, 145, 34, 127, 116, 217, 118, 245, 107, 15, 81, 9, 7, 31, 154, 89, 28, 123, 132, ]), - Bytes32::new_direct([ + Bytes32([ 222, 94, 234, 109, 142, 74, 142, 176, 248, 3, 172, 30, 204, 138, 241, 195, 121, 232, 104, 219, 32, 54, 240, 77, 125, 247, 70, 137, 80, 46, 221, 247, ]), - Bytes32::new_direct([ + Bytes32([ 162, 122, 237, 101, 178, 31, 12, 62, 50, 133, 242, 82, 111, 215, 166, 136, 138, 185, 72, 220, 163, 58, 58, 97, 6, 97, 167, 114, 179, 227, 19, 170, ]), - Bytes32::new_direct([ + Bytes32([ 67, 251, 144, 11, 175, 194, 149, 65, 173, 179, 69, 140, 213, 191, 133, 59, 81, 175, 161, 115, 252, 125, 232, 150, 52, 241, 102, 164, 122, 32, 70, 229, ]), - Bytes32::new_direct([ + Bytes32([ 249, 161, 115, 93, 215, 247, 145, 182, 75, 191, 48, 38, 123, 220, 232, 47, 246, 46, 81, 164, 98, 41, 141, 249, 137, 173, 93, 213, 96, 15, 151, 245, ]), - Bytes32::new_direct([ + Bytes32([ 222, 93, 144, 194, 107, 42, 144, 4, 242, 153, 203, 176, 146, 242, 94, 72, 9, 222, 194, 2, 73, 200, 167, 147, 106, 9, 67, 73, 59, 127, 174, 178, ]), - Bytes32::new_direct([ + Bytes32([ 56, 228, 248, 59, 153, 215, 120, 224, 111, 48, 159, 82, 171, 227, 93, 214, 208, 151, 78, 67, 112, 31, 218, 94, 219, 3, 79, 250, 227, 24, 222, 207, ]), - Bytes32::new_direct([ + Bytes32([ 26, 171, 68, 22, 162, 195, 65, 97, 219, 55, 51, 46, 178, 6, 247, 65, 123, 219, 128, 86, 193, 3, 253, 0, 239, 228, 187, 94, 184, 240, 67, 11, ]), - Bytes32::new_direct([ + Bytes32([ 250, 36, 5, 131, 94, 0, 99, 187, 112, 155, 252, 52, 68, 236, 185, 152, 93, 239, 0, 185, 101, 101, 182, 92, 112, 5, 67, 55, 121, 203, 100, 245, ]), - Bytes32::new_direct([ + Bytes32([ 208, 57, 149, 71, 227, 213, 246, 213, 175, 88, 95, 238, 93, 122, 168, 223, 149, 84, 30, 89, 98, 228, 113, 72, 90, 48, 112, 171, 231, 67, 113, 216, ]), - Bytes32::new_direct([ + Bytes32([ 125, 48, 157, 119, 154, 38, 14, 211, 223, 68, 87, 187, 159, 126, 234, 72, 84, 60, 236, 237, 227, 130, 87, 43, 217, 105, 81, 196, 159, 238, 240, 10, ]), - Bytes32::new_direct([ + Bytes32([ 141, 217, 59, 213, 245, 231, 7, 85, 178, 197, 115, 188, 31, 49, 126, 237, 83, 199, 56, 196, 133, 169, 239, 218, 90, 131, 178, 70, 126, 132, 114, 186, ]), - Bytes32::new_direct([ + Bytes32([ 18, 2, 140, 12, 121, 238, 8, 160, 7, 208, 89, 194, 105, 136, 211, 58, 179, 200, 226, 138, 186, 242, 4, 237, 18, 113, 131, 135, 31, 222, 28, 195, ]), - Bytes32::new_direct([ + Bytes32([ 156, 222, 183, 39, 119, 110, 130, 60, 33, 221, 36, 39, 223, 155, 33, 2, 71, 32, 209, 25, 194, 172, 209, 1, 40, 105, 235, 140, 160, 18, 63, 168, ]), - Bytes32::new_direct([ + Bytes32([ 211, 210, 123, 27, 217, 111, 97, 42, 167, 191, 112, 239, 66, 42, 199, 131, 124, 213, 89, 56, 92, 245, 166, 238, 185, 42, 48, 2, 113, 255, 156, 7, ]), - Bytes32::new_direct([ + Bytes32([ 66, 255, 87, 69, 86, 6, 54, 162, 162, 5, 93, 138, 194, 194, 151, 195, 57, 155, 58, 17, 21, 149, 77, 2, 134, 107, 125, 54, 220, 247, 160, 209, ]), - Bytes32::new_direct([ + Bytes32([ 169, 216, 13, 41, 251, 216, 191, 87, 91, 55, 236, 6, 242, 103, 98, 209, 46, 202, 29, 55, 2, 50, 233, 76, 107, 92, 82, 156, 113, 226, 78, 211, ]), - Bytes32::new_direct([ + Bytes32([ 88, 189, 113, 129, 119, 11, 141, 60, 128, 134, 113, 107, 7, 186, 81, 200, 14, 76, 197, 14, 96, 19, 247, 220, 95, 62, 81, 153, 61, 231, 26, 86, ]), - Bytes32::new_direct([ + Bytes32([ 41, 214, 41, 96, 151, 11, 231, 7, 203, 70, 242, 156, 247, 133, 49, 223, 254, 164, 202, 154, 188, 104, 124, 120, 225, 229, 148, 203, 141, 218, 228, 56, ]), - Bytes32::new_direct([ + Bytes32([ 181, 157, 136, 110, 158, 152, 105, 61, 125, 220, 32, 180, 53, 115, 155, 189, 91, 152, 96, 172, 7, 121, 65, 143, 82, 180, 3, 69, 118, 219, 31, 244, ]), - Bytes32::new_direct([ + Bytes32([ 29, 12, 159, 30, 12, 37, 126, 102, 218, 149, 67, 116, 182, 125, 134, 208, 184, 199, 181, 191, 87, 144, 48, 150, 87, 67, 222, 218, 254, 118, 12, 160, ]), - Bytes32::new_direct([ + Bytes32([ 193, 249, 209, 245, 102, 95, 15, 55, 160, 156, 203, 160, 49, 198, 203, 30, 99, 172, 89, 92, 235, 89, 131, 205, 53, 254, 219, 168, 202, 195, 10, 242, ]), - Bytes32::new_direct([ + Bytes32([ 131, 64, 102, 7, 226, 96, 60, 111, 221, 120, 41, 86, 239, 157, 121, 38, 57, 244, 221, 55, 32, 237, 13, 20, 244, 238, 133, 189, 89, 118, 204, 247, ]), - Bytes32::new_direct([ + Bytes32([ 239, 211, 89, 185, 191, 211, 243, 207, 134, 159, 59, 19, 87, 254, 115, 27, 152, 156, 120, 226, 39, 63, 155, 51, 77, 130, 162, 63, 16, 43, 112, 121, ]), - Bytes32::new_direct([ + Bytes32([ 10, 146, 190, 23, 235, 67, 23, 169, 33, 140, 54, 209, 129, 176, 29, 218, 40, 55, 13, 80, 57, 68, 92, 97, 44, 82, 209, 240, 207, 214, 22, 119, ]), - Bytes32::new_direct([ + Bytes32([ 59, 161, 125, 95, 7, 155, 141, 55, 253, 106, 238, 72, 109, 158, 201, 200, 236, 157, 227, 178, 176, 47, 166, 84, 87, 111, 25, 133, 194, 55, 244, 254, ]), - Bytes32::new_direct([ + Bytes32([ 8, 134, 213, 182, 108, 15, 225, 138, 152, 138, 132, 240, 27, 80, 231, 117, 194, 157, 205, 20, 110, 239, 166, 37, 50, 46, 213, 165, 216, 101, 245, 98, ]), - Bytes32::new_direct([ + Bytes32([ 137, 57, 186, 173, 198, 113, 221, 42, 0, 211, 127, 200, 128, 7, 112, 97, 75, 155, 152, 224, 71, 220, 16, 124, 32, 50, 30, 48, 251, 132, 120, 147, ]), - Bytes32::new_direct([ + Bytes32([ 201, 8, 226, 108, 147, 192, 3, 240, 168, 237, 131, 47, 150, 51, 251, 126, 23, 182, 223, 99, 162, 167, 248, 248, 233, 8, 121, 99, 71, 212, 120, 251, ]), - Bytes32::new_direct([ + Bytes32([ 140, 30, 196, 244, 166, 80, 95, 116, 140, 218, 94, 20, 236, 233, 241, 129, 175, 187, 110, 88, 174, 173, 152, 203, 67, 75, 51, 232, 225, 6, 17, 134, ]), - Bytes32::new_direct([ + Bytes32([ 92, 132, 115, 164, 66, 159, 201, 147, 233, 228, 16, 95, 81, 233, 129, 254, 155, 148, 38, 239, 186, 40, 118, 104, 144, 134, 17, 46, 99, 150, 211, 9, ]), - Bytes32::new_direct([ + Bytes32([ 81, 73, 72, 117, 215, 159, 240, 86, 136, 196, 69, 201, 149, 208, 48, 245, 105, 153, 97, 107, 221, 85, 49, 121, 197, 129, 32, 140, 206, 231, 120, 123, ]), - Bytes32::new_direct([ + Bytes32([ 0, 203, 34, 135, 242, 129, 113, 204, 198, 134, 219, 134, 187, 240, 235, 59, 44, 163, 180, 83, 174, 40, 66, 141, 95, 99, 71, 221, 186, 216, 37, 250, ]), - Bytes32::new_direct([ + Bytes32([ 225, 181, 151, 12, 26, 209, 127, 99, 248, 177, 126, 113, 215, 220, 252, 89, 149, 123, 19, 65, 89, 122, 180, 169, 195, 87, 147, 9, 196, 31, 203, 178, ]), - Bytes32::new_direct([ + Bytes32([ 125, 81, 154, 100, 204, 138, 194, 248, 156, 95, 119, 58, 60, 221, 150, 248, 216, 19, 123, 15, 198, 108, 228, 228, 224, 122, 16, 249, 223, 84, 117, 89, ]), - Bytes32::new_direct([ + Bytes32([ 99, 153, 60, 217, 168, 254, 244, 149, 214, 115, 250, 90, 117, 112, 66, 163, 143, 207, 121, 70, 108, 92, 2, 47, 56, 109, 56, 207, 152, 27, 196, 141, ]), - Bytes32::new_direct([ + Bytes32([ 99, 251, 124, 97, 158, 155, 101, 251, 98, 124, 239, 73, 50, 50, 173, 142, 39, 208, 167, 53, 5, 151, 85, 239, 25, 77, 36, 52, 141, 225, 66, 186, ]), - Bytes32::new_direct([ + Bytes32([ 235, 44, 31, 180, 197, 243, 114, 60, 199, 242, 167, 21, 206, 27, 116, 165, 18, 76, 162, 163, 14, 91, 109, 104, 118, 51, 33, 172, 9, 165, 214, 38, ]), - Bytes32::new_direct([ + Bytes32([ 188, 4, 5, 50, 169, 70, 231, 90, 220, 90, 226, 214, 89, 19, 159, 207, 201, 80, 241, 214, 32, 240, 63, 74, 6, 251, 177, 182, 236, 19, 156, 92, ]), - Bytes32::new_direct([ + Bytes32([ 128, 150, 66, 27, 197, 229, 103, 137, 175, 252, 19, 131, 213, 63, 112, 172, 182, 255, 235, 246, 226, 37, 25, 180, 24, 38, 35, 138, 207, 149, 186, 175, ]), - Bytes32::new_direct([ + Bytes32([ 5, 123, 231, 106, 12, 171, 157, 189, 58, 109, 144, 7, 38, 97, 4, 148, 1, 138, 124, 123, 2, 202, 108, 221, 194, 160, 53, 73, 115, 36, 231, 142, ]), - Bytes32::new_direct([ + Bytes32([ 160, 157, 243, 224, 214, 120, 59, 206, 24, 30, 231, 209, 123, 227, 15, 221, 86, 30, 128, 117, 210, 109, 132, 117, 204, 87, 243, 213, 231, 224, 91, 75, ]), - Bytes32::new_direct([ + Bytes32([ 74, 238, 110, 147, 63, 110, 246, 102, 252, 212, 120, 225, 124, 218, 145, 204, 129, 63, 13, 34, 1, 0, 15, 9, 27, 221, 39, 199, 24, 231, 9, 38, ]), - Bytes32::new_direct([ + Bytes32([ 194, 20, 160, 161, 90, 2, 118, 75, 103, 228, 51, 42, 191, 220, 63, 150, 140, 32, 85, 172, 218, 29, 251, 31, 99, 96, 98, 46, 130, 157, 201, 61, ]), - Bytes32::new_direct([ + Bytes32([ 88, 123, 95, 139, 94, 66, 69, 27, 223, 223, 216, 130, 99, 210, 130, 54, 248, 35, 226, 252, 151, 238, 7, 175, 12, 97, 188, 43, 233, 129, 82, 222, ]), - Bytes32::new_direct([ + Bytes32([ 179, 248, 157, 243, 50, 157, 172, 17, 139, 10, 245, 208, 241, 210, 67, 199, 135, 233, 234, 39, 127, 38, 54, 39, 40, 159, 94, 122, 36, 221, 180, 195, ]), - Bytes32::new_direct([ + Bytes32([ 190, 185, 147, 237, 82, 32, 165, 236, 252, 183, 173, 181, 68, 44, 216, 20, 110, 243, 158, 213, 88, 209, 218, 207, 244, 241, 121, 239, 136, 167, 245, 155, ]), - Bytes32::new_direct([ + Bytes32([ 114, 131, 254, 248, 183, 0, 175, 217, 194, 58, 178, 238, 250, 119, 158, 205, 19, 74, 94, 35, 100, 175, 114, 55, 186, 192, 239, 126, 42, 86, 60, 119, ]), - Bytes32::new_direct([ + Bytes32([ 1, 253, 107, 150, 25, 240, 27, 172, 252, 185, 151, 152, 107, 105, 164, 230, 221, 242, 7, 166, 142, 53, 237, 83, 19, 30, 81, 149, 150, 39, 123, 220, ]), - Bytes32::new_direct([ + Bytes32([ 57, 240, 92, 232, 26, 238, 69, 252, 110, 171, 164, 109, 199, 73, 110, 49, 11, 253, 109, 69, 155, 26, 84, 52, 155, 204, 115, 99, 90, 38, 247, 167, ]), - Bytes32::new_direct([ + Bytes32([ 46, 87, 146, 25, 215, 40, 208, 78, 73, 60, 35, 19, 194, 41, 34, 186, 215, 131, 205, 29, 107, 100, 95, 169, 45, 1, 242, 115, 30, 226, 93, 48, ]), - Bytes32::new_direct([ + Bytes32([ 95, 183, 66, 0, 196, 173, 44, 27, 175, 151, 17, 0, 159, 168, 123, 236, 124, 198, 85, 181, 118, 89, 21, 52, 169, 104, 178, 111, 120, 173, 94, 109, ]), - Bytes32::new_direct([ + Bytes32([ 13, 111, 162, 25, 133, 108, 250, 75, 197, 221, 19, 160, 147, 36, 130, 70, 224, 39, 134, 144, 149, 166, 187, 96, 155, 154, 123, 90, 241, 154, 44, 102, ]), - Bytes32::new_direct([ + Bytes32([ 95, 171, 183, 135, 121, 205, 161, 160, 212, 226, 64, 232, 180, 166, 176, 95, 51, 96, 110, 20, 76, 143, 47, 96, 197, 132, 210, 109, 174, 132, 13, 95, ]), - Bytes32::new_direct([ + Bytes32([ 66, 51, 176, 1, 106, 199, 192, 16, 106, 180, 212, 53, 72, 121, 218, 148, 77, 26, 15, 244, 124, 131, 88, 84, 147, 211, 254, 156, 187, 91, 193, 120, ]), ]; const FUNCTION_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([ + Bytes32([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]), - Bytes32::new_direct([ + Bytes32([ 239, 247, 49, 255, 201, 159, 228, 149, 22, 115, 41, 139, 56, 117, 149, 46, 67, 155, 98, 70, 216, 225, 85, 100, 113, 242, 144, 167, 97, 238, 117, 207, ]), - Bytes32::new_direct([ + Bytes32([ 46, 87, 136, 101, 122, 12, 6, 120, 39, 121, 167, 193, 66, 146, 150, 1, 90, 240, 97, 225, 179, 150, 197, 127, 56, 214, 116, 24, 180, 109, 96, 51, ]), - Bytes32::new_direct([ + Bytes32([ 54, 125, 90, 195, 243, 1, 115, 18, 251, 68, 203, 216, 48, 156, 216, 200, 215, 250, 80, 152, 203, 58, 245, 128, 70, 112, 221, 104, 34, 125, 234, 138, ]), - Bytes32::new_direct([ + Bytes32([ 103, 99, 44, 86, 57, 0, 102, 201, 99, 214, 249, 24, 45, 112, 234, 183, 225, 196, 9, 162, 168, 33, 121, 118, 93, 184, 14, 70, 148, 135, 211, 214, ]), - Bytes32::new_direct([ + Bytes32([ 69, 7, 89, 47, 41, 94, 148, 139, 67, 197, 99, 98, 100, 63, 25, 230, 100, 118, 213, 25, 28, 129, 5, 39, 69, 89, 71, 21, 102, 84, 101, 175, ]), - Bytes32::new_direct([ + Bytes32([ 232, 195, 82, 123, 189, 200, 139, 61, 179, 141, 208, 69, 102, 58, 127, 66, 69, 127, 7, 179, 108, 128, 253, 154, 207, 254, 201, 18, 192, 241, 99, 208, ]), - Bytes32::new_direct([ + Bytes32([ 138, 25, 185, 215, 159, 159, 214, 251, 161, 103, 180, 78, 209, 215, 131, 132, 134, 180, 177, 37, 79, 219, 19, 93, 45, 30, 53, 125, 142, 194, 114, 34, ]), - Bytes32::new_direct([ + Bytes32([ 185, 24, 200, 28, 68, 7, 118, 226, 65, 240, 85, 120, 123, 174, 239, 85, 247, 210, 104, 247, 20, 229, 41, 91, 242, 5, 2, 121, 132, 69, 43, 33, ]), - Bytes32::new_direct([ + Bytes32([ 78, 191, 92, 97, 205, 120, 114, 216, 112, 101, 44, 98, 148, 2, 112, 221, 168, 199, 254, 55, 160, 116, 116, 105, 109, 227, 130, 219, 194, 32, 209, 196, ]), - Bytes32::new_direct([ + Bytes32([ 177, 203, 26, 1, 216, 115, 242, 158, 202, 107, 60, 221, 81, 167, 8, 233, 247, 235, 49, 54, 45, 133, 202, 193, 34, 158, 205, 29, 232, 245, 195, 194, ]), - Bytes32::new_direct([ + Bytes32([ 193, 118, 182, 153, 10, 237, 67, 229, 136, 193, 253, 250, 46, 125, 141, 22, 107, 168, 74, 130, 60, 193, 194, 196, 249, 129, 153, 82, 162, 143, 188, 42, ]), - Bytes32::new_direct([ + Bytes32([ 239, 57, 105, 90, 116, 61, 160, 214, 55, 191, 17, 228, 44, 149, 103, 180, 229, 4, 175, 240, 209, 231, 141, 95, 109, 195, 78, 142, 122, 177, 227, 20, ]), - Bytes32::new_direct([ + Bytes32([ 153, 247, 105, 126, 178, 44, 190, 57, 12, 63, 169, 27, 206, 19, 151, 38, 33, 83, 35, 3, 177, 97, 36, 182, 37, 78, 150, 243, 222, 32, 180, 148, ]), - Bytes32::new_direct([ + Bytes32([ 29, 109, 110, 167, 27, 136, 235, 226, 147, 175, 241, 236, 138, 135, 163, 200, 21, 94, 220, 238, 23, 84, 46, 14, 44, 100, 47, 131, 134, 43, 98, 173, ]), - Bytes32::new_direct([ + Bytes32([ 73, 241, 108, 102, 184, 200, 64, 80, 58, 162, 29, 211, 173, 150, 6, 195, 2, 137, 246, 51, 155, 132, 41, 255, 21, 71, 74, 143, 197, 180, 217, 159, ]), - Bytes32::new_direct([ + Bytes32([ 109, 189, 226, 33, 70, 157, 161, 166, 223, 31, 224, 221, 37, 112, 27, 215, 163, 250, 217, 155, 168, 121, 119, 232, 100, 177, 104, 210, 10, 118, 215, 0, ]), - Bytes32::new_direct([ + Bytes32([ 175, 156, 32, 156, 238, 82, 62, 25, 96, 251, 146, 24, 13, 2, 115, 174, 163, 50, 14, 251, 196, 173, 5, 87, 171, 228, 191, 9, 90, 84, 156, 63, ]), - Bytes32::new_direct([ + Bytes32([ 244, 161, 238, 217, 14, 60, 162, 139, 34, 84, 68, 121, 213, 11, 230, 95, 57, 221, 174, 107, 103, 105, 76, 137, 58, 247, 65, 209, 167, 63, 96, 212, ]), - Bytes32::new_direct([ + Bytes32([ 31, 177, 221, 130, 152, 92, 190, 4, 59, 90, 122, 63, 128, 180, 140, 201, 75, 239, 200, 151, 94, 65, 36, 227, 21, 250, 10, 253, 26, 114, 238, 188, ]), - Bytes32::new_direct([ + Bytes32([ 48, 216, 87, 30, 113, 214, 69, 1, 9, 112, 244, 232, 127, 55, 43, 162, 156, 83, 235, 199, 126, 132, 241, 106, 65, 209, 240, 32, 11, 179, 219, 135, ]), - Bytes32::new_direct([ + Bytes32([ 20, 55, 225, 132, 0, 219, 175, 17, 235, 73, 236, 16, 24, 227, 250, 155, 32, 83, 234, 123, 191, 209, 157, 133, 215, 202, 3, 221, 135, 223, 221, 90, ]), - Bytes32::new_direct([ + Bytes32([ 113, 185, 118, 164, 139, 219, 203, 140, 245, 123, 21, 186, 102, 22, 54, 14, 19, 230, 223, 120, 211, 114, 203, 77, 173, 214, 61, 80, 151, 10, 2, 205, ]), - Bytes32::new_direct([ + Bytes32([ 50, 20, 214, 105, 232, 5, 9, 101, 16, 72, 46, 139, 177, 188, 25, 93, 14, 57, 60, 168, 49, 147, 134, 5, 62, 181, 120, 75, 193, 229, 107, 67, ]), - Bytes32::new_direct([ + Bytes32([ 92, 167, 117, 18, 186, 193, 28, 56, 86, 25, 75, 64, 1, 8, 126, 212, 56, 163, 157, 242, 34, 73, 65, 58, 187, 2, 112, 58, 225, 229, 113, 58, ]), - Bytes32::new_direct([ + Bytes32([ 173, 139, 156, 215, 250, 231, 15, 123, 8, 5, 98, 192, 164, 48, 106, 203, 152, 189, 118, 120, 245, 221, 214, 26, 79, 39, 148, 232, 217, 88, 34, 246, ]), - Bytes32::new_direct([ + Bytes32([ 8, 207, 11, 196, 253, 51, 182, 90, 62, 110, 125, 142, 209, 154, 5, 203, 252, 62, 117, 215, 226, 136, 140, 201, 227, 210, 71, 34, 113, 160, 42, 68, ]), - Bytes32::new_direct([ + Bytes32([ 108, 135, 226, 117, 179, 142, 93, 181, 20, 186, 189, 217, 49, 154, 66, 244, 180, 170, 122, 233, 153, 214, 104, 71, 44, 57, 103, 240, 97, 80, 170, 198, ]), - Bytes32::new_direct([ + Bytes32([ 123, 168, 184, 254, 241, 78, 23, 91, 32, 77, 218, 176, 179, 189, 61, 162, 114, 158, 212, 7, 201, 15, 58, 4, 161, 211, 188, 156, 190, 2, 20, 183, ]), - Bytes32::new_direct([ + Bytes32([ 60, 170, 86, 130, 38, 170, 202, 88, 97, 206, 67, 69, 140, 122, 201, 38, 70, 229, 144, 202, 146, 10, 146, 148, 21, 247, 119, 196, 150, 223, 110, 67, ]), - Bytes32::new_direct([ + Bytes32([ 102, 154, 215, 132, 143, 248, 151, 101, 101, 253, 80, 211, 254, 64, 179, 73, 96, 132, 144, 216, 225, 130, 48, 56, 14, 39, 97, 223, 134, 10, 124, 138, ]), - Bytes32::new_direct([ + Bytes32([ 197, 131, 194, 166, 168, 160, 24, 116, 47, 120, 89, 3, 44, 154, 83, 250, 142, 64, 77, 63, 15, 60, 97, 100, 150, 39, 227, 139, 42, 146, 146, 104, ]), - Bytes32::new_direct([ + Bytes32([ 7, 160, 246, 93, 64, 79, 76, 208, 66, 80, 60, 123, 13, 51, 115, 251, 196, 209, 145, 106, 61, 105, 136, 58, 7, 129, 142, 203, 205, 69, 45, 203, ]), - Bytes32::new_direct([ + Bytes32([ 64, 162, 48, 187, 213, 182, 41, 85, 62, 148, 26, 161, 227, 108, 173, 249, 195, 106, 203, 18, 28, 59, 184, 85, 249, 16, 224, 222, 114, 200, 99, 22, ]), - Bytes32::new_direct([ + Bytes32([ 246, 194, 74, 122, 165, 216, 211, 144, 101, 143, 134, 9, 53, 229, 197, 227, 121, 248, 89, 169, 48, 220, 104, 216, 117, 118, 36, 234, 108, 135, 81, 162, ]), - Bytes32::new_direct([ + Bytes32([ 232, 59, 196, 2, 103, 242, 44, 129, 41, 231, 226, 115, 238, 151, 166, 210, 158, 110, 43, 45, 86, 163, 127, 8, 162, 81, 131, 145, 165, 252, 170, 12, ]), - Bytes32::new_direct([ + Bytes32([ 204, 88, 102, 180, 241, 148, 27, 183, 223, 71, 157, 119, 155, 31, 102, 239, 4, 83, 204, 246, 38, 228, 234, 20, 97, 233, 203, 149, 186, 67, 143, 51, ]), - Bytes32::new_direct([ + Bytes32([ 246, 170, 233, 8, 202, 38, 67, 219, 175, 13, 250, 174, 98, 36, 84, 166, 6, 75, 27, 43, 62, 128, 106, 23, 163, 191, 86, 115, 164, 50, 127, 151, ]), - Bytes32::new_direct([ + Bytes32([ 204, 72, 199, 57, 106, 136, 244, 66, 217, 155, 183, 211, 166, 71, 140, 211, 210, 181, 178, 218, 204, 91, 200, 204, 153, 60, 22, 32, 24, 153, 131, 31, ]), - Bytes32::new_direct([ + Bytes32([ 204, 193, 13, 167, 214, 136, 121, 99, 198, 137, 11, 223, 85, 40, 167, 126, 153, 80, 187, 35, 226, 31, 226, 42, 9, 175, 31, 206, 119, 67, 153, 39, ]), - Bytes32::new_direct([ + Bytes32([ 63, 82, 16, 182, 255, 45, 123, 220, 252, 52, 199, 222, 76, 172, 123, 232, 133, 182, 143, 202, 223, 161, 203, 91, 239, 225, 123, 184, 231, 53, 19, 253, ]), - Bytes32::new_direct([ + Bytes32([ 5, 13, 255, 217, 70, 105, 205, 70, 41, 25, 44, 3, 245, 136, 16, 255, 101, 61, 189, 225, 142, 201, 210, 226, 9, 237, 171, 109, 63, 204, 204, 139, ]), - Bytes32::new_direct([ + Bytes32([ 161, 218, 126, 252, 32, 196, 32, 105, 98, 13, 201, 117, 64, 37, 232, 32, 159, 106, 48, 121, 250, 139, 219, 137, 129, 3, 83, 194, 102, 251, 148, 71, ]), - Bytes32::new_direct([ + Bytes32([ 72, 17, 9, 21, 142, 89, 135, 91, 81, 155, 72, 247, 56, 232, 136, 57, 251, 182, 211, 35, 207, 169, 87, 123, 31, 222, 72, 85, 212, 92, 159, 171, ]), - Bytes32::new_direct([ + Bytes32([ 193, 253, 238, 224, 198, 216, 154, 52, 59, 87, 183, 80, 242, 162, 238, 7, 218, 195, 253, 210, 92, 116, 43, 181, 109, 40, 74, 38, 154, 211, 102, 173, ]), - Bytes32::new_direct([ + Bytes32([ 193, 88, 249, 81, 11, 128, 242, 239, 220, 1, 237, 199, 235, 12, 153, 73, 145, 158, 15, 111, 108, 244, 19, 51, 159, 206, 66, 25, 147, 215, 157, 165, ]), - Bytes32::new_direct([ + Bytes32([ 195, 90, 0, 163, 8, 199, 55, 59, 47, 117, 186, 204, 5, 42, 205, 164, 239, 233, 203, 210, 69, 205, 244, 152, 113, 184, 206, 110, 101, 197, 120, 101, ]), - Bytes32::new_direct([ + Bytes32([ 114, 169, 222, 11, 169, 15, 123, 245, 42, 25, 120, 198, 66, 140, 125, 123, 201, 107, 3, 50, 245, 226, 52, 46, 162, 44, 134, 157, 226, 11, 115, 186, ]), - Bytes32::new_direct([ + Bytes32([ 6, 47, 131, 89, 216, 138, 92, 250, 126, 232, 238, 50, 181, 78, 69, 115, 227, 25, 49, 50, 116, 138, 47, 61, 179, 75, 121, 124, 127, 106, 228, 178, ]), - Bytes32::new_direct([ + Bytes32([ 152, 253, 228, 228, 120, 255, 82, 66, 24, 145, 159, 223, 39, 185, 81, 201, 81, 110, 47, 57, 105, 128, 8, 42, 130, 119, 92, 7, 14, 247, 137, 135, ]), - Bytes32::new_direct([ + Bytes32([ 162, 28, 11, 245, 48, 21, 8, 137, 161, 131, 84, 18, 129, 70, 197, 122, 165, 39, 71, 213, 142, 115, 159, 52, 46, 213, 81, 10, 217, 212, 74, 20, ]), - Bytes32::new_direct([ + Bytes32([ 129, 250, 71, 119, 46, 25, 220, 212, 143, 120, 0, 101, 85, 101, 109, 107, 142, 20, 107, 174, 39, 134, 128, 244, 237, 155, 190, 19, 110, 10, 240, 94, ]), - Bytes32::new_direct([ + Bytes32([ 90, 70, 190, 48, 191, 45, 227, 17, 185, 162, 159, 12, 18, 94, 186, 251, 252, 238, 95, 174, 253, 99, 194, 204, 5, 178, 117, 139, 50, 154, 93, 170, ]), - Bytes32::new_direct([ + Bytes32([ 201, 8, 48, 126, 70, 22, 83, 82, 229, 84, 168, 86, 100, 169, 227, 175, 196, 154, 217, 150, 2, 36, 1, 100, 48, 216, 141, 205, 113, 148, 109, 126, ]), - Bytes32::new_direct([ + Bytes32([ 16, 182, 10, 119, 255, 70, 127, 242, 64, 68, 67, 44, 52, 195, 63, 185, 227, 97, 138, 244, 53, 246, 110, 99, 41, 176, 146, 206, 81, 168, 66, 140, ]), - Bytes32::new_direct([ + Bytes32([ 95, 9, 211, 227, 219, 119, 221, 132, 248, 92, 236, 190, 110, 227, 153, 109, 103, 63, 121, 221, 165, 212, 20, 141, 33, 95, 52, 157, 69, 76, 2, 70, ]), - Bytes32::new_direct([ + Bytes32([ 216, 138, 115, 198, 102, 135, 226, 247, 235, 185, 206, 147, 130, 9, 48, 166, 92, 22, 41, 158, 169, 52, 233, 1, 60, 229, 165, 208, 60, 161, 194, 166, ]), - Bytes32::new_direct([ + Bytes32([ 129, 241, 87, 138, 103, 241, 79, 26, 52, 35, 125, 237, 54, 147, 253, 137, 101, 146, 235, 127, 124, 113, 60, 203, 181, 4, 250, 12, 72, 27, 24, 7, ]), - Bytes32::new_direct([ + Bytes32([ 52, 120, 68, 97, 147, 229, 251, 178, 161, 233, 142, 136, 38, 40, 85, 46, 121, 156, 115, 186, 72, 95, 128, 43, 252, 176, 176, 51, 113, 83, 154, 232, ]), - Bytes32::new_direct([ + Bytes32([ 227, 11, 188, 57, 98, 160, 248, 247, 112, 49, 247, 92, 94, 224, 135, 182, 211, 230, 69, 185, 138, 154, 141, 157, 18, 34, 138, 236, 67, 243, 26, 132, ]), - Bytes32::new_direct([ + Bytes32([ 61, 246, 31, 52, 44, 146, 190, 215, 214, 105, 253, 86, 172, 174, 140, 112, 30, 154, 82, 173, 62, 199, 157, 180, 255, 104, 73, 136, 163, 79, 210, 252, ]), - Bytes32::new_direct([ + Bytes32([ 200, 155, 200, 87, 142, 123, 62, 176, 250, 44, 18, 238, 229, 121, 125, 109, 102, 173, 60, 203, 88, 65, 33, 122, 22, 111, 157, 143, 164, 7, 214, 26, ]), - Bytes32::new_direct([ + Bytes32([ 179, 76, 168, 179, 139, 86, 151, 173, 26, 70, 236, 116, 202, 123, 63, 80, 106, 208, 63, 138, 179, 225, 114, 64, 48, 34, 78, 124, 132, 210, 224, 190, ]), - Bytes32::new_direct([ + Bytes32([ 138, 116, 89, 240, 28, 79, 42, 149, 199, 118, 149, 49, 146, 212, 104, 62, 17, 137, 138, 223, 225, 187, 152, 43, 134, 60, 95, 55, 175, 128, 95, 144, ]), ]; const INSTRUCTION_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([ + Bytes32([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]), - Bytes32::new_direct([ + Bytes32([ 248, 140, 83, 29, 241, 220, 66, 40, 126, 248, 5, 153, 77, 179, 26, 64, 221, 108, 205, 162, 173, 52, 179, 140, 202, 105, 0, 170, 166, 130, 120, 176, ]), - Bytes32::new_direct([ + Bytes32([ 35, 74, 103, 235, 245, 71, 66, 212, 99, 147, 15, 200, 1, 237, 95, 163, 10, 146, 122, 251, 243, 239, 93, 186, 46, 74, 206, 130, 63, 17, 199, 80, ]), - Bytes32::new_direct([ + Bytes32([ 113, 169, 40, 37, 169, 205, 28, 78, 37, 104, 52, 28, 29, 222, 39, 32, 208, 183, 215, 38, 255, 69, 87, 70, 174, 113, 221, 183, 206, 62, 192, 118, ]), - Bytes32::new_direct([ + Bytes32([ 1, 148, 183, 39, 234, 23, 138, 182, 169, 58, 52, 158, 248, 212, 186, 127, 60, 42, 25, 210, 20, 170, 182, 139, 20, 185, 196, 85, 241, 214, 181, 64, ]), - Bytes32::new_direct([ + Bytes32([ 241, 14, 59, 8, 168, 222, 232, 125, 149, 227, 125, 41, 223, 198, 88, 135, 54, 146, 140, 212, 164, 76, 239, 106, 10, 20, 67, 180, 24, 159, 174, 99, ]), - Bytes32::new_direct([ + Bytes32([ 117, 111, 220, 19, 204, 227, 211, 18, 61, 239, 179, 46, 142, 75, 67, 98, 159, 221, 205, 158, 125, 42, 221, 227, 148, 162, 193, 229, 147, 70, 214, 127, ]), - Bytes32::new_direct([ + Bytes32([ 20, 72, 211, 188, 38, 126, 166, 75, 54, 22, 225, 21, 113, 155, 167, 89, 161, 6, 37, 78, 227, 211, 219, 141, 161, 199, 151, 122, 81, 45, 159, 187, ]), - Bytes32::new_direct([ + Bytes32([ 69, 198, 100, 170, 106, 174, 208, 152, 152, 121, 118, 66, 111, 89, 131, 14, 159, 115, 142, 200, 205, 173, 89, 77, 68, 234, 5, 171, 105, 248, 199, 83, ]), - Bytes32::new_direct([ + Bytes32([ 17, 1, 220, 13, 154, 194, 88, 60, 253, 223, 149, 35, 44, 184, 107, 141, 205, 177, 185, 32, 22, 99, 212, 96, 194, 91, 255, 179, 121, 153, 254, 40, ]), - Bytes32::new_direct([ + Bytes32([ 222, 247, 186, 138, 222, 183, 135, 183, 170, 79, 182, 23, 69, 89, 70, 68, 88, 87, 235, 22, 178, 134, 114, 220, 249, 153, 70, 71, 229, 139, 10, 190, ]), - Bytes32::new_direct([ + Bytes32([ 183, 77, 65, 51, 207, 78, 55, 149, 222, 3, 100, 82, 232, 230, 21, 115, 249, 177, 36, 89, 12, 41, 70, 31, 199, 254, 213, 3, 184, 2, 85, 137, ]), - Bytes32::new_direct([ + Bytes32([ 82, 15, 215, 135, 95, 18, 143, 49, 239, 237, 6, 15, 213, 113, 153, 49, 149, 54, 50, 139, 100, 192, 128, 226, 168, 9, 120, 167, 157, 42, 45, 19, ]), - Bytes32::new_direct([ + Bytes32([ 70, 32, 130, 243, 186, 144, 224, 217, 130, 222, 175, 221, 218, 190, 179, 222, 217, 115, 70, 160, 141, 231, 221, 96, 2, 173, 27, 17, 158, 66, 180, 58, ]), - Bytes32::new_direct([ + Bytes32([ 76, 243, 65, 235, 12, 31, 48, 195, 62, 176, 202, 57, 99, 80, 237, 222, 138, 199, 124, 251, 143, 243, 205, 226, 18, 164, 67, 64, 68, 238, 53, 71, ]), - Bytes32::new_direct([ + Bytes32([ 70, 52, 254, 193, 211, 92, 63, 238, 92, 2, 160, 29, 154, 25, 221, 136, 2, 49, 96, 27, 15, 152, 238, 57, 241, 253, 32, 131, 73, 38, 229, 243, ]), - Bytes32::new_direct([ + Bytes32([ 214, 162, 82, 44, 146, 145, 61, 77, 36, 3, 131, 81, 217, 39, 127, 81, 66, 82, 172, 230, 246, 3, 243, 217, 210, 38, 201, 109, 240, 143, 253, 79, ]), - Bytes32::new_direct([ + Bytes32([ 127, 18, 198, 116, 112, 141, 16, 39, 115, 118, 37, 208, 118, 119, 147, 46, 196, 124, 19, 196, 34, 183, 172, 157, 18, 91, 4, 210, 77, 195, 220, 59, ]), - Bytes32::new_direct([ + Bytes32([ 87, 54, 42, 60, 39, 223, 84, 148, 158, 230, 70, 53, 191, 1, 108, 103, 139, 111, 58, 220, 114, 46, 46, 110, 20, 211, 84, 1, 173, 104, 175, 191, ]), - Bytes32::new_direct([ + Bytes32([ 182, 147, 66, 127, 229, 144, 125, 93, 84, 220, 116, 107, 51, 13, 24, 161, 68, 172, 165, 50, 12, 198, 229, 173, 49, 26, 114, 159, 84, 190, 6, 42, ]), - Bytes32::new_direct([ + Bytes32([ 183, 20, 36, 145, 76, 36, 61, 136, 224, 139, 89, 23, 124, 29, 210, 137, 1, 160, 22, 128, 48, 242, 234, 85, 84, 24, 206, 49, 143, 185, 237, 110, ]), - Bytes32::new_direct([ + Bytes32([ 38, 19, 77, 150, 92, 129, 177, 155, 139, 162, 90, 91, 231, 146, 216, 21, 54, 152, 18, 5, 98, 21, 67, 160, 154, 113, 175, 65, 214, 78, 19, 97, ]), - Bytes32::new_direct([ + Bytes32([ 163, 236, 47, 120, 121, 17, 217, 4, 200, 247, 206, 178, 211, 212, 163, 48, 38, 172, 111, 123, 75, 221, 63, 117, 42, 3, 252, 233, 104, 13, 210, 203, ]), - Bytes32::new_direct([ + Bytes32([ 127, 106, 132, 246, 28, 129, 245, 83, 159, 109, 196, 219, 68, 81, 230, 77, 254, 166, 55, 73, 169, 179, 93, 97, 117, 176, 53, 74, 121, 238, 184, 240, ]), - Bytes32::new_direct([ + Bytes32([ 255, 23, 108, 186, 145, 182, 196, 67, 163, 95, 173, 17, 67, 239, 199, 189, 145, 153, 120, 152, 159, 126, 255, 39, 55, 178, 230, 173, 91, 165, 229, 106, ]), - Bytes32::new_direct([ + Bytes32([ 184, 156, 20, 114, 222, 219, 89, 218, 102, 62, 130, 200, 179, 237, 32, 237, 127, 75, 251, 163, 160, 2, 221, 34, 166, 30, 172, 97, 115, 137, 179, 175, ]), - Bytes32::new_direct([ + Bytes32([ 244, 165, 127, 27, 66, 22, 38, 243, 235, 107, 30, 181, 31, 193, 210, 174, 254, 129, 39, 71, 59, 117, 186, 37, 217, 129, 138, 23, 146, 114, 96, 78, ]), - Bytes32::new_direct([ + Bytes32([ 27, 57, 244, 93, 208, 90, 64, 181, 161, 110, 161, 188, 62, 180, 46, 103, 136, 233, 63, 1, 243, 202, 236, 206, 173, 45, 45, 218, 238, 184, 83, 121, ]), - Bytes32::new_direct([ + Bytes32([ 138, 185, 33, 206, 120, 214, 246, 27, 100, 91, 106, 213, 60, 177, 39, 182, 149, 204, 11, 225, 254, 5, 87, 9, 19, 186, 166, 210, 33, 67, 146, 37, ]), - Bytes32::new_direct([ + Bytes32([ 243, 161, 7, 52, 35, 240, 227, 144, 29, 50, 232, 3, 101, 174, 192, 139, 89, 75, 204, 245, 173, 55, 139, 76, 126, 19, 142, 18, 230, 57, 219, 227, ]), - Bytes32::new_direct([ + Bytes32([ 97, 73, 36, 70, 120, 55, 49, 114, 107, 193, 66, 219, 47, 122, 201, 194, 52, 142, 12, 163, 108, 2, 107, 58, 185, 251, 168, 146, 57, 189, 150, 134, ]), - Bytes32::new_direct([ + Bytes32([ 11, 215, 29, 229, 151, 208, 62, 1, 172, 253, 253, 156, 177, 31, 117, 214, 161, 192, 68, 255, 140, 131, 66, 23, 247, 161, 107, 98, 199, 57, 123, 110, ]), - Bytes32::new_direct([ + Bytes32([ 41, 166, 54, 134, 242, 64, 153, 167, 5, 230, 226, 128, 71, 10, 251, 160, 19, 187, 70, 4, 95, 98, 77, 233, 181, 24, 11, 239, 142, 152, 229, 215, ]), - Bytes32::new_direct([ + Bytes32([ 221, 220, 68, 168, 143, 124, 235, 77, 241, 190, 214, 6, 102, 40, 32, 245, 131, 114, 170, 151, 134, 49, 79, 57, 242, 124, 85, 172, 83, 81, 68, 99, ]), - Bytes32::new_direct([ + Bytes32([ 142, 200, 102, 97, 170, 43, 14, 11, 139, 207, 150, 163, 99, 103, 2, 46, 44, 63, 109, 61, 62, 64, 199, 104, 36, 194, 155, 232, 139, 250, 97, 224, ]), - Bytes32::new_direct([ + Bytes32([ 162, 15, 26, 217, 96, 195, 70, 196, 253, 70, 127, 156, 39, 120, 120, 232, 197, 154, 192, 147, 104, 33, 104, 189, 120, 160, 36, 129, 208, 237, 128, 23, ]), - Bytes32::new_direct([ + Bytes32([ 42, 228, 74, 47, 20, 55, 197, 252, 173, 70, 178, 8, 2, 43, 97, 238, 155, 124, 87, 225, 217, 6, 103, 134, 136, 235, 193, 175, 33, 228, 219, 217, ]), - Bytes32::new_direct([ + Bytes32([ 219, 143, 25, 70, 78, 155, 119, 63, 126, 20, 158, 54, 27, 181, 104, 184, 74, 192, 75, 157, 42, 204, 45, 122, 25, 248, 247, 24, 225, 207, 51, 251, ]), - Bytes32::new_direct([ + Bytes32([ 151, 253, 36, 33, 104, 222, 126, 234, 112, 74, 59, 94, 239, 58, 36, 114, 90, 195, 208, 46, 250, 138, 165, 200, 178, 54, 238, 154, 219, 238, 6, 183, ]), - Bytes32::new_direct([ + Bytes32([ 205, 57, 187, 174, 221, 9, 164, 77, 76, 143, 54, 212, 115, 196, 67, 182, 200, 147, 78, 194, 245, 92, 173, 114, 180, 160, 168, 5, 200, 82, 217, 64, ]), - Bytes32::new_direct([ + Bytes32([ 211, 104, 62, 114, 157, 56, 254, 26, 32, 168, 208, 248, 62, 195, 142, 68, 53, 13, 7, 36, 216, 5, 127, 153, 97, 88, 222, 206, 91, 42, 14, 114, ]), - Bytes32::new_direct([ + Bytes32([ 203, 158, 225, 200, 62, 223, 202, 52, 207, 179, 250, 236, 29, 144, 181, 31, 87, 192, 203, 66, 56, 39, 123, 25, 123, 157, 196, 161, 34, 245, 22, 130, ]), - Bytes32::new_direct([ + Bytes32([ 147, 247, 233, 96, 190, 104, 227, 251, 99, 2, 16, 8, 77, 119, 1, 97, 243, 78, 103, 46, 24, 228, 217, 65, 219, 238, 135, 18, 164, 219, 132, 39, ]), - Bytes32::new_direct([ + Bytes32([ 239, 153, 72, 139, 52, 60, 171, 44, 72, 218, 138, 124, 45, 30, 143, 122, 147, 158, 12, 62, 213, 151, 217, 217, 212, 51, 110, 75, 122, 67, 134, 80, ]), - Bytes32::new_direct([ + Bytes32([ 46, 47, 130, 237, 178, 232, 239, 217, 165, 114, 255, 202, 132, 214, 18, 8, 72, 8, 255, 0, 162, 82, 5, 228, 141, 201, 70, 135, 255, 21, 220, 3, ]), - Bytes32::new_direct([ + Bytes32([ 21, 11, 196, 5, 215, 241, 194, 200, 198, 129, 133, 244, 204, 47, 131, 70, 138, 38, 107, 39, 211, 243, 72, 72, 34, 145, 35, 42, 14, 69, 218, 227, ]), - Bytes32::new_direct([ + Bytes32([ 73, 103, 117, 195, 67, 126, 242, 57, 232, 74, 142, 64, 169, 248, 113, 69, 110, 103, 127, 185, 177, 51, 212, 178, 48, 183, 247, 44, 246, 69, 35, 208, ]), - Bytes32::new_direct([ + Bytes32([ 125, 8, 83, 22, 215, 82, 179, 234, 169, 227, 213, 39, 170, 164, 195, 187, 63, 38, 59, 146, 144, 101, 38, 0, 110, 212, 202, 20, 245, 105, 187, 201, ]), - Bytes32::new_direct([ + Bytes32([ 186, 231, 186, 148, 68, 208, 226, 170, 120, 80, 68, 79, 23, 41, 51, 205, 240, 201, 10, 16, 24, 38, 137, 151, 7, 102, 92, 244, 3, 194, 228, 229, ]), - Bytes32::new_direct([ + Bytes32([ 46, 8, 51, 150, 63, 114, 126, 210, 30, 130, 76, 142, 13, 149, 14, 0, 205, 199, 48, 90, 86, 75, 151, 135, 164, 224, 129, 77, 174, 194, 212, 112, ]), - Bytes32::new_direct([ + Bytes32([ 150, 239, 42, 111, 3, 112, 25, 168, 179, 36, 106, 73, 212, 188, 215, 79, 180, 142, 191, 29, 219, 12, 244, 74, 254, 205, 160, 54, 68, 144, 81, 207, ]), - Bytes32::new_direct([ + Bytes32([ 23, 164, 189, 201, 250, 65, 212, 148, 132, 125, 94, 209, 115, 123, 29, 66, 3, 172, 57, 58, 46, 191, 96, 7, 212, 25, 226, 79, 120, 68, 202, 210, ]), - Bytes32::new_direct([ + Bytes32([ 252, 13, 137, 225, 208, 6, 84, 75, 97, 32, 177, 156, 248, 191, 113, 97, 254, 122, 86, 194, 3, 103, 219, 74, 227, 160, 231, 202, 13, 126, 46, 255, ]), - Bytes32::new_direct([ + Bytes32([ 70, 35, 27, 128, 17, 79, 226, 131, 144, 118, 248, 125, 188, 110, 20, 15, 255, 73, 205, 69, 0, 227, 26, 66, 39, 61, 191, 224, 239, 234, 83, 170, ]), - Bytes32::new_direct([ + Bytes32([ 129, 52, 148, 121, 230, 84, 28, 112, 75, 68, 181, 197, 80, 227, 107, 22, 60, 118, 81, 209, 198, 125, 233, 190, 84, 189, 18, 25, 72, 143, 2, 190, ]), - Bytes32::new_direct([ + Bytes32([ 244, 237, 81, 131, 251, 35, 56, 158, 229, 102, 150, 122, 213, 206, 119, 38, 54, 238, 158, 159, 1, 214, 31, 147, 245, 9, 172, 247, 156, 115, 209, 140, ]), - Bytes32::new_direct([ + Bytes32([ 47, 5, 174, 62, 80, 172, 77, 111, 136, 114, 188, 85, 249, 157, 182, 175, 187, 207, 29, 43, 152, 88, 130, 156, 138, 30, 188, 51, 82, 105, 145, 161, ]), - Bytes32::new_direct([ + Bytes32([ 102, 2, 197, 195, 206, 149, 53, 224, 61, 219, 163, 246, 208, 218, 140, 47, 16, 42, 196, 20, 145, 158, 101, 31, 225, 135, 49, 68, 95, 5, 228, 92, ]), - Bytes32::new_direct([ + Bytes32([ 78, 136, 176, 216, 253, 15, 136, 48, 162, 5, 57, 120, 93, 222, 179, 174, 129, 40, 8, 63, 18, 102, 97, 41, 58, 214, 1, 52, 58, 126, 186, 146, ]), - Bytes32::new_direct([ + Bytes32([ 145, 56, 231, 59, 247, 191, 104, 137, 240, 113, 32, 245, 235, 129, 255, 54, 99, 176, 109, 175, 107, 232, 201, 235, 95, 104, 54, 67, 252, 184, 200, 54, ]), - Bytes32::new_direct([ + Bytes32([ 181, 3, 229, 152, 113, 182, 55, 93, 138, 137, 21, 67, 27, 204, 96, 69, 72, 247, 237, 216, 28, 36, 115, 185, 111, 149, 224, 69, 66, 121, 188, 228, ]), - Bytes32::new_direct([ + Bytes32([ 212, 25, 201, 68, 187, 25, 10, 96, 40, 88, 100, 216, 145, 200, 26, 203, 220, 14, 14, 11, 190, 62, 143, 137, 53, 208, 233, 158, 37, 34, 8, 15, ]), - Bytes32::new_direct([ + Bytes32([ 80, 101, 192, 136, 203, 90, 189, 204, 181, 36, 28, 107, 220, 69, 119, 99, 145, 227, 198, 55, 37, 237, 212, 114, 31, 27, 19, 90, 231, 143, 87, 149, ]), - Bytes32::new_direct([ + Bytes32([ 248, 97, 168, 33, 15, 230, 128, 82, 157, 26, 186, 89, 200, 7, 101, 210, 117, 111, 75, 233, 244, 187, 1, 180, 30, 220, 15, 21, 203, 5, 243, 223, ]), @@ -779,1042 +779,1042 @@ const INSTRUCTION_HASHES: &[Bytes32; 64] = &[ /// These have been pre-calculated to match the current implementation of Memory::hash_leaf. const MEMORY_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([ + Bytes32([ 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, 186, 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, ]), - Bytes32::new_direct([ + Bytes32([ 190, 70, 141, 125, 34, 236, 162, 217, 92, 130, 99, 237, 252, 176, 62, 93, 182, 71, 180, 204, 178, 127, 225, 18, 119, 68, 89, 244, 245, 143, 151, 9, ]), - Bytes32::new_direct([ + Bytes32([ 9, 87, 12, 3, 155, 102, 114, 211, 160, 40, 161, 7, 3, 192, 11, 145, 241, 17, 215, 209, 18, 230, 221, 198, 189, 52, 34, 224, 245, 121, 253, 194, ]), - Bytes32::new_direct([ + Bytes32([ 10, 61, 178, 250, 4, 50, 245, 174, 54, 189, 184, 161, 208, 164, 55, 145, 70, 4, 81, 28, 129, 97, 216, 23, 41, 192, 91, 97, 9, 83, 1, 215, ]), - Bytes32::new_direct([ + Bytes32([ 244, 167, 192, 124, 155, 131, 227, 49, 180, 187, 181, 23, 114, 255, 114, 237, 129, 149, 159, 244, 63, 138, 0, 237, 37, 38, 159, 106, 4, 153, 119, 255, ]), - Bytes32::new_direct([ + Bytes32([ 63, 174, 225, 251, 118, 10, 96, 200, 132, 107, 27, 128, 250, 62, 47, 221, 227, 241, 107, 254, 3, 171, 26, 81, 199, 162, 154, 249, 154, 72, 185, 196, ]), - Bytes32::new_direct([ + Bytes32([ 89, 112, 167, 92, 33, 192, 100, 158, 137, 92, 61, 197, 73, 216, 188, 164, 72, 37, 5, 0, 161, 144, 254, 18, 10, 4, 248, 174, 26, 5, 149, 142, ]), - Bytes32::new_direct([ + Bytes32([ 202, 243, 125, 81, 15, 253, 233, 83, 91, 186, 151, 205, 84, 225, 16, 241, 42, 27, 7, 15, 143, 128, 189, 233, 206, 106, 21, 7, 96, 167, 149, 2, ]), - Bytes32::new_direct([ + Bytes32([ 155, 19, 224, 94, 41, 7, 172, 244, 76, 43, 181, 160, 220, 80, 64, 0, 140, 33, 238, 79, 87, 43, 40, 34, 162, 57, 122, 232, 216, 48, 64, 114, ]), - Bytes32::new_direct([ + Bytes32([ 64, 199, 52, 187, 21, 58, 215, 47, 174, 163, 203, 89, 35, 199, 187, 86, 137, 145, 236, 145, 66, 21, 218, 151, 88, 61, 109, 238, 61, 58, 215, 247, ]), - Bytes32::new_direct([ + Bytes32([ 197, 59, 74, 219, 191, 151, 46, 252, 54, 248, 228, 94, 22, 143, 69, 197, 114, 247, 37, 212, 243, 158, 179, 192, 205, 50, 50, 36, 40, 130, 115, 247, ]), - Bytes32::new_direct([ + Bytes32([ 168, 115, 30, 246, 210, 241, 88, 129, 115, 193, 107, 199, 199, 35, 118, 28, 145, 183, 82, 101, 162, 52, 67, 147, 208, 234, 115, 58, 40, 124, 16, 79, ]), - Bytes32::new_direct([ + Bytes32([ 253, 6, 238, 29, 37, 160, 45, 23, 26, 114, 137, 254, 44, 68, 147, 33, 212, 149, 16, 188, 28, 174, 189, 22, 12, 228, 99, 101, 60, 248, 174, 34, ]), - Bytes32::new_direct([ + Bytes32([ 0, 89, 208, 120, 115, 63, 79, 9, 29, 16, 81, 231, 78, 251, 117, 98, 172, 207, 54, 97, 38, 72, 37, 110, 102, 207, 38, 198, 165, 157, 208, 6, ]), - Bytes32::new_direct([ + Bytes32([ 193, 144, 83, 148, 50, 15, 138, 224, 145, 12, 222, 94, 88, 91, 151, 74, 180, 47, 102, 38, 244, 38, 251, 13, 230, 130, 141, 133, 10, 194, 108, 211, ]), - Bytes32::new_direct([ + Bytes32([ 182, 202, 171, 144, 153, 127, 43, 239, 77, 89, 56, 144, 39, 180, 30, 164, 1, 120, 105, 55, 21, 17, 147, 96, 185, 219, 67, 146, 86, 42, 44, 117, ]), - Bytes32::new_direct([ + Bytes32([ 240, 76, 90, 37, 238, 134, 53, 105, 125, 238, 19, 80, 162, 60, 63, 104, 193, 201, 233, 10, 246, 175, 15, 167, 239, 50, 201, 138, 153, 127, 40, 247, ]), - Bytes32::new_direct([ + Bytes32([ 127, 96, 10, 125, 139, 9, 213, 13, 60, 75, 10, 85, 88, 169, 180, 24, 18, 171, 157, 161, 252, 181, 178, 191, 227, 200, 140, 72, 205, 231, 67, 34, ]), - Bytes32::new_direct([ + Bytes32([ 8, 81, 79, 192, 81, 171, 28, 73, 80, 93, 207, 58, 0, 192, 109, 40, 59, 227, 148, 172, 144, 146, 237, 103, 47, 77, 112, 155, 215, 125, 49, 205, ]), - Bytes32::new_direct([ + Bytes32([ 181, 244, 223, 157, 69, 161, 149, 150, 31, 65, 52, 113, 11, 233, 51, 145, 135, 161, 34, 114, 133, 86, 133, 255, 161, 176, 170, 255, 21, 163, 146, 79, ]), - Bytes32::new_direct([ + Bytes32([ 251, 112, 107, 186, 121, 118, 206, 118, 164, 136, 208, 159, 220, 188, 218, 111, 190, 44, 16, 16, 251, 116, 206, 236, 111, 184, 20, 247, 252, 129, 200, 164, ]), - Bytes32::new_direct([ + Bytes32([ 101, 111, 124, 218, 143, 90, 110, 65, 52, 118, 81, 72, 234, 164, 106, 84, 54, 136, 212, 192, 46, 87, 56, 241, 227, 38, 37, 101, 250, 134, 254, 144, ]), - Bytes32::new_direct([ + Bytes32([ 209, 232, 185, 167, 159, 116, 4, 11, 114, 98, 71, 225, 233, 246, 135, 173, 175, 126, 125, 101, 16, 27, 254, 198, 79, 21, 181, 120, 50, 139, 76, 4, ]), - Bytes32::new_direct([ + Bytes32([ 30, 122, 82, 142, 43, 26, 170, 27, 0, 177, 218, 106, 39, 13, 154, 151, 92, 47, 144, 113, 173, 242, 169, 89, 230, 135, 188, 190, 57, 170, 66, 220, ]), - Bytes32::new_direct([ + Bytes32([ 39, 137, 200, 154, 57, 148, 82, 232, 82, 214, 232, 251, 187, 13, 253, 222, 184, 161, 144, 231, 67, 116, 160, 231, 214, 47, 228, 88, 146, 14, 244, 108, ]), - Bytes32::new_direct([ + Bytes32([ 122, 9, 214, 205, 84, 161, 177, 137, 68, 9, 178, 177, 141, 219, 162, 109, 116, 124, 124, 56, 189, 139, 28, 220, 98, 165, 217, 156, 157, 148, 43, 232, ]), - Bytes32::new_direct([ + Bytes32([ 83, 209, 1, 98, 176, 225, 170, 233, 144, 110, 148, 135, 159, 243, 202, 14, 201, 243, 218, 255, 75, 90, 222, 25, 141, 148, 128, 132, 101, 8, 178, 180, ]), - Bytes32::new_direct([ + Bytes32([ 93, 131, 135, 74, 118, 43, 37, 103, 218, 116, 47, 5, 212, 230, 133, 11, 76, 199, 46, 91, 17, 222, 122, 114, 166, 228, 113, 213, 31, 5, 32, 164, ]), - Bytes32::new_direct([ + Bytes32([ 230, 49, 245, 147, 146, 113, 214, 229, 67, 34, 234, 170, 14, 37, 33, 105, 12, 192, 127, 177, 195, 70, 29, 44, 232, 191, 3, 56, 70, 40, 70, 69, ]), - Bytes32::new_direct([ + Bytes32([ 64, 48, 103, 64, 135, 164, 51, 233, 201, 62, 5, 28, 35, 183, 178, 104, 54, 238, 0, 58, 215, 157, 29, 149, 57, 23, 224, 247, 85, 104, 240, 113, ]), - Bytes32::new_direct([ + Bytes32([ 12, 156, 88, 246, 58, 5, 82, 65, 113, 178, 127, 112, 138, 170, 91, 11, 79, 54, 122, 65, 87, 104, 104, 93, 134, 176, 56, 5, 139, 142, 73, 54, ]), - Bytes32::new_direct([ + Bytes32([ 92, 41, 81, 165, 165, 210, 34, 91, 127, 46, 250, 148, 104, 192, 211, 77, 108, 49, 111, 57, 161, 242, 142, 46, 100, 47, 24, 24, 51, 219, 92, 186, ]), - Bytes32::new_direct([ + Bytes32([ 201, 120, 116, 179, 124, 183, 117, 97, 200, 35, 138, 235, 77, 177, 138, 42, 47, 58, 69, 188, 70, 2, 71, 95, 51, 233, 69, 14, 22, 24, 195, 153, ]), - Bytes32::new_direct([ + Bytes32([ 249, 189, 13, 189, 45, 69, 100, 141, 50, 145, 24, 54, 91, 45, 125, 223, 181, 222, 63, 49, 66, 49, 106, 175, 55, 85, 112, 25, 69, 187, 44, 171, ]), - Bytes32::new_direct([ + Bytes32([ 86, 114, 135, 219, 78, 73, 34, 205, 239, 144, 56, 231, 164, 101, 129, 115, 51, 167, 158, 96, 1, 241, 178, 216, 54, 84, 97, 185, 200, 239, 215, 7, ]), - Bytes32::new_direct([ + Bytes32([ 35, 232, 131, 249, 70, 6, 185, 10, 58, 53, 72, 254, 74, 166, 76, 41, 122, 234, 77, 61, 16, 39, 26, 66, 102, 78, 102, 159, 55, 113, 195, 19, ]), - Bytes32::new_direct([ + Bytes32([ 204, 120, 229, 250, 86, 164, 18, 58, 82, 11, 112, 225, 76, 253, 63, 35, 245, 72, 81, 254, 193, 182, 255, 159, 200, 120, 135, 60, 253, 180, 185, 112, ]), - Bytes32::new_direct([ + Bytes32([ 35, 194, 73, 72, 85, 35, 3, 215, 21, 38, 67, 254, 195, 250, 173, 177, 156, 70, 47, 13, 178, 120, 227, 214, 92, 71, 181, 40, 213, 43, 193, 147, ]), - Bytes32::new_direct([ + Bytes32([ 148, 91, 40, 131, 45, 85, 232, 203, 101, 47, 189, 225, 128, 118, 138, 12, 83, 98, 227, 166, 192, 69, 188, 19, 84, 13, 162, 250, 65, 209, 47, 191, ]), - Bytes32::new_direct([ + Bytes32([ 100, 36, 35, 232, 157, 164, 39, 175, 77, 211, 19, 26, 20, 226, 226, 255, 121, 134, 19, 46, 185, 213, 2, 4, 6, 92, 47, 239, 206, 240, 225, 58, ]), - Bytes32::new_direct([ + Bytes32([ 121, 36, 6, 138, 185, 33, 130, 28, 55, 238, 127, 203, 99, 32, 56, 245, 237, 135, 207, 190, 72, 243, 137, 32, 218, 103, 150, 171, 3, 246, 48, 225, ]), - Bytes32::new_direct([ + Bytes32([ 233, 56, 238, 34, 238, 134, 69, 104, 220, 255, 47, 202, 241, 144, 207, 249, 107, 153, 38, 120, 101, 12, 177, 64, 151, 114, 146, 6, 227, 159, 40, 107, ]), - Bytes32::new_direct([ + Bytes32([ 237, 115, 194, 93, 160, 113, 23, 120, 250, 186, 21, 163, 155, 20, 179, 177, 55, 20, 24, 89, 77, 113, 163, 0, 176, 130, 228, 133, 239, 122, 177, 65, ]), - Bytes32::new_direct([ + Bytes32([ 108, 150, 128, 44, 189, 57, 148, 254, 56, 134, 118, 165, 95, 15, 168, 179, 162, 252, 169, 58, 223, 20, 38, 221, 25, 138, 101, 131, 32, 8, 2, 58, ]), - Bytes32::new_direct([ + Bytes32([ 154, 13, 160, 129, 192, 79, 86, 40, 135, 113, 123, 38, 53, 254, 62, 94, 255, 14, 119, 4, 102, 168, 200, 191, 112, 245, 29, 200, 164, 155, 141, 139, ]), - Bytes32::new_direct([ + Bytes32([ 238, 189, 209, 174, 202, 251, 240, 99, 133, 44, 221, 34, 17, 88, 220, 143, 188, 160, 235, 121, 167, 96, 106, 249, 213, 176, 31, 84, 26, 144, 201, 89, ]), - Bytes32::new_direct([ + Bytes32([ 178, 186, 146, 221, 228, 41, 150, 76, 220, 216, 144, 64, 108, 178, 242, 120, 153, 191, 212, 37, 114, 21, 30, 117, 45, 238, 46, 19, 132, 212, 112, 44, ]), - Bytes32::new_direct([ + Bytes32([ 191, 19, 180, 171, 125, 68, 104, 43, 66, 173, 194, 168, 213, 192, 117, 82, 167, 41, 139, 133, 92, 103, 124, 85, 241, 66, 1, 154, 68, 72, 171, 80, ]), - Bytes32::new_direct([ + Bytes32([ 79, 215, 118, 157, 123, 16, 70, 30, 101, 234, 117, 41, 35, 186, 99, 5, 232, 45, 253, 142, 185, 18, 172, 187, 36, 50, 218, 252, 111, 184, 158, 254, ]), - Bytes32::new_direct([ + Bytes32([ 17, 193, 206, 44, 67, 98, 171, 63, 78, 209, 71, 20, 196, 255, 64, 114, 191, 19, 246, 131, 8, 105, 211, 169, 192, 114, 249, 240, 28, 55, 230, 143, ]), - Bytes32::new_direct([ + Bytes32([ 200, 94, 187, 80, 140, 194, 238, 35, 62, 228, 202, 122, 136, 119, 228, 133, 33, 147, 161, 218, 94, 19, 207, 129, 48, 252, 242, 19, 56, 251, 92, 76, ]), - Bytes32::new_direct([ + Bytes32([ 223, 124, 52, 170, 180, 101, 70, 1, 153, 22, 178, 138, 181, 253, 35, 113, 159, 136, 77, 23, 158, 62, 11, 48, 6, 185, 147, 81, 220, 191, 94, 3, ]), - Bytes32::new_direct([ + Bytes32([ 126, 124, 205, 157, 16, 239, 172, 241, 70, 70, 205, 98, 211, 8, 84, 204, 149, 9, 208, 56, 122, 51, 224, 231, 200, 59, 41, 215, 141, 183, 91, 223, ]), - Bytes32::new_direct([ + Bytes32([ 20, 122, 156, 134, 248, 95, 140, 199, 59, 151, 120, 164, 109, 202, 165, 126, 108, 161, 8, 253, 18, 35, 36, 83, 219, 162, 58, 83, 136, 57, 43, 35, ]), - Bytes32::new_direct([ + Bytes32([ 58, 175, 246, 31, 114, 109, 109, 219, 230, 129, 128, 99, 175, 228, 65, 148, 53, 233, 226, 171, 44, 254, 222, 211, 200, 28, 193, 130, 251, 152, 160, 210, ]), - Bytes32::new_direct([ + Bytes32([ 177, 255, 19, 82, 14, 229, 84, 206, 156, 198, 252, 176, 126, 211, 226, 255, 154, 231, 131, 158, 165, 154, 142, 166, 131, 221, 203, 30, 251, 205, 27, 217, ]), - Bytes32::new_direct([ + Bytes32([ 32, 168, 192, 93, 240, 173, 218, 42, 78, 215, 104, 243, 154, 2, 50, 159, 21, 176, 28, 59, 29, 57, 193, 122, 32, 244, 91, 148, 91, 184, 126, 31, ]), - Bytes32::new_direct([ + Bytes32([ 28, 66, 164, 117, 43, 120, 84, 240, 48, 3, 55, 95, 44, 229, 231, 29, 217, 67, 49, 130, 110, 209, 72, 71, 46, 208, 63, 81, 218, 98, 167, 207, ]), - Bytes32::new_direct([ + Bytes32([ 38, 192, 60, 175, 136, 217, 168, 69, 90, 236, 62, 137, 9, 116, 244, 151, 181, 57, 229, 198, 100, 125, 114, 46, 80, 136, 150, 94, 225, 162, 170, 91, ]), - Bytes32::new_direct([ + Bytes32([ 121, 67, 11, 63, 56, 140, 67, 231, 175, 126, 41, 37, 252, 62, 35, 215, 250, 206, 190, 3, 154, 83, 237, 174, 65, 86, 83, 251, 110, 8, 44, 216, ]), - Bytes32::new_direct([ + Bytes32([ 25, 251, 117, 251, 14, 64, 166, 211, 216, 123, 38, 1, 98, 19, 119, 194, 60, 234, 185, 148, 118, 201, 4, 233, 69, 135, 13, 191, 8, 6, 136, 240, ]), - Bytes32::new_direct([ + Bytes32([ 137, 1, 201, 130, 166, 152, 216, 48, 178, 242, 46, 3, 66, 92, 4, 81, 11, 145, 205, 82, 253, 102, 78, 6, 53, 13, 36, 171, 48, 75, 165, 153, ]), - Bytes32::new_direct([ + Bytes32([ 126, 38, 201, 183, 226, 145, 26, 196, 124, 127, 185, 12, 77, 198, 146, 16, 202, 189, 113, 44, 100, 87, 81, 53, 172, 227, 97, 191, 120, 241, 86, 110, ]), - Bytes32::new_direct([ + Bytes32([ 45, 8, 41, 170, 235, 127, 133, 14, 253, 53, 201, 220, 96, 192, 168, 234, 110, 20, 174, 226, 18, 4, 230, 182, 204, 99, 138, 27, 82, 209, 28, 68, ]), ]; const TABLE_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([ + Bytes32([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]), - Bytes32::new_direct([ + Bytes32([ 164, 47, 121, 69, 150, 44, 30, 204, 210, 181, 242, 154, 59, 111, 5, 10, 47, 121, 213, 80, 163, 196, 205, 188, 241, 64, 202, 26, 242, 47, 50, 205, ]), - Bytes32::new_direct([ + Bytes32([ 166, 9, 224, 145, 14, 138, 194, 78, 202, 114, 110, 38, 244, 33, 189, 185, 170, 85, 144, 229, 123, 63, 229, 194, 59, 130, 156, 6, 184, 154, 187, 17, ]), - Bytes32::new_direct([ + Bytes32([ 32, 51, 186, 232, 39, 244, 218, 98, 243, 254, 82, 247, 63, 120, 34, 123, 128, 240, 220, 145, 41, 114, 251, 208, 209, 244, 10, 9, 179, 5, 105, 181, ]), - Bytes32::new_direct([ + Bytes32([ 73, 148, 74, 132, 241, 45, 129, 169, 83, 223, 101, 12, 184, 60, 10, 201, 169, 197, 75, 17, 198, 168, 79, 171, 207, 195, 123, 47, 249, 30, 176, 216, ]), - Bytes32::new_direct([ + Bytes32([ 145, 224, 51, 196, 211, 137, 189, 133, 232, 210, 170, 157, 227, 160, 218, 143, 15, 82, 170, 226, 241, 83, 7, 112, 138, 227, 58, 59, 149, 168, 81, 94, ]), - Bytes32::new_direct([ + Bytes32([ 241, 90, 42, 7, 231, 63, 36, 86, 238, 131, 19, 20, 38, 118, 65, 180, 109, 121, 147, 147, 213, 142, 203, 244, 239, 75, 5, 160, 16, 85, 221, 95, ]), - Bytes32::new_direct([ + Bytes32([ 213, 113, 178, 221, 213, 107, 77, 153, 222, 48, 148, 140, 250, 1, 17, 59, 73, 19, 110, 106, 94, 195, 126, 49, 126, 109, 65, 55, 104, 111, 18, 171, ]), - Bytes32::new_direct([ + Bytes32([ 43, 198, 12, 197, 95, 201, 76, 108, 96, 235, 76, 8, 117, 99, 42, 20, 177, 45, 112, 40, 2, 180, 68, 19, 25, 11, 210, 168, 170, 178, 99, 27, ]), - Bytes32::new_direct([ + Bytes32([ 142, 205, 24, 125, 81, 234, 138, 161, 206, 121, 163, 225, 50, 9, 180, 102, 0, 25, 93, 180, 137, 164, 206, 249, 222, 20, 175, 177, 199, 14, 115, 207, ]), - Bytes32::new_direct([ + Bytes32([ 213, 41, 249, 19, 173, 165, 236, 103, 42, 146, 223, 6, 190, 229, 161, 13, 96, 163, 110, 23, 203, 238, 24, 95, 130, 203, 35, 211, 63, 234, 32, 137, ]), - Bytes32::new_direct([ + Bytes32([ 176, 82, 229, 48, 113, 46, 179, 38, 231, 83, 50, 136, 179, 190, 242, 126, 152, 210, 141, 102, 191, 21, 20, 96, 235, 245, 81, 254, 231, 117, 159, 146, ]), - Bytes32::new_direct([ + Bytes32([ 216, 15, 120, 147, 70, 215, 12, 160, 223, 73, 246, 73, 195, 189, 200, 3, 19, 131, 102, 61, 173, 79, 50, 76, 39, 150, 151, 147, 35, 251, 200, 0, ]), - Bytes32::new_direct([ + Bytes32([ 88, 215, 168, 30, 218, 72, 206, 159, 91, 121, 14, 133, 241, 220, 195, 46, 93, 244, 179, 53, 158, 75, 211, 161, 8, 120, 167, 141, 235, 16, 232, 42, ]), - Bytes32::new_direct([ + Bytes32([ 114, 99, 218, 52, 203, 162, 199, 16, 225, 154, 182, 20, 59, 121, 250, 249, 166, 35, 118, 18, 142, 57, 122, 131, 32, 219, 83, 126, 147, 91, 116, 16, ]), - Bytes32::new_direct([ + Bytes32([ 193, 157, 15, 251, 179, 155, 215, 190, 98, 93, 30, 167, 23, 175, 178, 172, 142, 143, 222, 20, 18, 157, 215, 42, 105, 107, 64, 16, 216, 143, 109, 45, ]), - Bytes32::new_direct([ + Bytes32([ 178, 2, 203, 32, 83, 90, 114, 97, 124, 210, 81, 81, 179, 213, 71, 19, 181, 173, 227, 88, 226, 83, 48, 169, 134, 163, 62, 103, 222, 82, 128, 30, ]), - Bytes32::new_direct([ + Bytes32([ 252, 17, 142, 50, 185, 19, 111, 148, 204, 30, 199, 138, 143, 207, 30, 212, 254, 7, 129, 43, 100, 167, 52, 115, 247, 143, 64, 106, 220, 5, 7, 89, ]), - Bytes32::new_direct([ + Bytes32([ 117, 136, 111, 98, 95, 97, 253, 43, 82, 22, 43, 187, 65, 154, 132, 105, 55, 194, 240, 148, 170, 199, 185, 91, 157, 138, 43, 117, 218, 176, 110, 101, ]), - Bytes32::new_direct([ + Bytes32([ 228, 56, 186, 202, 73, 47, 253, 151, 48, 173, 2, 101, 153, 197, 108, 145, 227, 170, 247, 86, 80, 70, 30, 93, 232, 148, 63, 211, 197, 135, 23, 97, ]), - Bytes32::new_direct([ + Bytes32([ 162, 35, 93, 45, 208, 241, 87, 57, 138, 79, 231, 83, 75, 81, 102, 91, 115, 58, 1, 205, 193, 197, 62, 210, 144, 88, 59, 52, 149, 234, 121, 224, ]), - Bytes32::new_direct([ + Bytes32([ 165, 67, 16, 239, 234, 92, 207, 81, 64, 93, 227, 154, 132, 33, 54, 53, 102, 198, 90, 134, 24, 29, 190, 158, 121, 23, 127, 30, 27, 239, 140, 88, ]), - Bytes32::new_direct([ + Bytes32([ 61, 125, 183, 139, 186, 82, 193, 166, 2, 147, 231, 215, 179, 107, 163, 67, 122, 0, 90, 188, 142, 216, 72, 20, 63, 146, 85, 89, 231, 41, 153, 117, ]), - Bytes32::new_direct([ + Bytes32([ 206, 31, 38, 182, 78, 170, 183, 207, 211, 114, 212, 4, 108, 84, 62, 99, 245, 196, 10, 1, 188, 63, 240, 199, 27, 85, 68, 101, 212, 222, 85, 12, ]), - Bytes32::new_direct([ + Bytes32([ 106, 0, 225, 130, 195, 87, 113, 106, 101, 80, 56, 119, 93, 45, 74, 168, 240, 209, 155, 123, 8, 129, 73, 225, 204, 125, 42, 73, 102, 122, 228, 158, ]), - Bytes32::new_direct([ + Bytes32([ 251, 63, 88, 92, 59, 176, 71, 194, 46, 19, 18, 27, 83, 57, 197, 231, 202, 242, 155, 63, 252, 240, 205, 216, 96, 130, 161, 197, 123, 110, 175, 220, ]), - Bytes32::new_direct([ + Bytes32([ 239, 6, 249, 150, 189, 234, 197, 18, 79, 222, 80, 72, 205, 147, 251, 135, 226, 33, 46, 111, 186, 185, 4, 33, 219, 129, 30, 182, 57, 229, 34, 16, ]), - Bytes32::new_direct([ + Bytes32([ 192, 35, 149, 149, 16, 111, 3, 119, 173, 215, 223, 247, 70, 25, 31, 107, 104, 5, 249, 243, 193, 66, 99, 48, 107, 158, 25, 147, 163, 151, 96, 149, ]), - Bytes32::new_direct([ + Bytes32([ 197, 133, 241, 197, 67, 52, 255, 227, 180, 235, 137, 164, 174, 160, 183, 9, 159, 254, 210, 180, 231, 140, 176, 165, 113, 215, 182, 1, 177, 204, 219, 246, ]), - Bytes32::new_direct([ + Bytes32([ 51, 32, 109, 173, 131, 6, 99, 63, 75, 191, 207, 187, 73, 26, 5, 139, 167, 216, 123, 26, 199, 176, 84, 215, 158, 243, 105, 0, 91, 254, 59, 146, ]), - Bytes32::new_direct([ + Bytes32([ 229, 120, 15, 22, 225, 50, 131, 240, 190, 232, 83, 119, 169, 246, 172, 35, 99, 163, 58, 146, 234, 253, 252, 83, 5, 48, 54, 142, 172, 91, 145, 13, ]), - Bytes32::new_direct([ + Bytes32([ 159, 9, 100, 20, 215, 92, 217, 43, 208, 254, 65, 234, 124, 167, 250, 53, 159, 151, 124, 70, 26, 0, 113, 28, 78, 44, 238, 8, 34, 255, 19, 36, ]), - Bytes32::new_direct([ + Bytes32([ 193, 135, 44, 144, 13, 46, 76, 43, 127, 208, 79, 196, 229, 58, 125, 33, 71, 118, 215, 240, 80, 123, 44, 181, 174, 47, 102, 42, 137, 98, 190, 41, ]), - Bytes32::new_direct([ + Bytes32([ 78, 19, 3, 217, 174, 154, 142, 109, 189, 14, 241, 12, 23, 185, 224, 152, 209, 108, 223, 202, 191, 11, 190, 149, 31, 236, 104, 234, 22, 38, 196, 3, ]), - Bytes32::new_direct([ + Bytes32([ 60, 93, 237, 228, 186, 222, 179, 231, 151, 95, 147, 20, 188, 10, 191, 34, 126, 57, 253, 161, 154, 117, 182, 108, 143, 72, 48, 102, 191, 240, 81, 208, ]), - Bytes32::new_direct([ + Bytes32([ 179, 114, 163, 89, 172, 211, 154, 204, 11, 125, 140, 186, 107, 90, 17, 116, 214, 31, 165, 94, 36, 187, 184, 151, 210, 208, 76, 215, 75, 166, 107, 91, ]), - Bytes32::new_direct([ + Bytes32([ 125, 131, 52, 139, 120, 156, 163, 243, 206, 143, 204, 221, 123, 140, 1, 103, 235, 186, 64, 82, 194, 191, 205, 2, 32, 242, 38, 77, 184, 23, 236, 228, ]), - Bytes32::new_direct([ + Bytes32([ 137, 224, 90, 1, 116, 95, 215, 47, 8, 3, 227, 132, 154, 232, 216, 63, 3, 80, 52, 18, 42, 29, 85, 38, 117, 255, 9, 99, 88, 233, 129, 92, ]), - Bytes32::new_direct([ + Bytes32([ 54, 182, 145, 174, 54, 24, 168, 13, 71, 43, 178, 49, 153, 246, 94, 79, 228, 254, 134, 0, 21, 210, 176, 242, 82, 117, 76, 40, 221, 181, 30, 62, ]), - Bytes32::new_direct([ + Bytes32([ 145, 171, 156, 87, 15, 174, 31, 111, 175, 161, 31, 116, 123, 123, 37, 216, 43, 147, 197, 79, 218, 49, 236, 111, 35, 49, 44, 188, 197, 79, 136, 45, ]), - Bytes32::new_direct([ + Bytes32([ 169, 48, 186, 93, 10, 48, 80, 103, 68, 226, 103, 31, 176, 154, 146, 199, 166, 89, 48, 149, 116, 101, 157, 149, 149, 72, 123, 54, 153, 26, 210, 122, ]), - Bytes32::new_direct([ + Bytes32([ 225, 45, 163, 167, 213, 84, 40, 87, 106, 253, 206, 80, 189, 71, 153, 5, 15, 107, 151, 150, 14, 22, 143, 207, 4, 192, 63, 250, 207, 207, 179, 26, ]), - Bytes32::new_direct([ + Bytes32([ 110, 249, 172, 218, 206, 202, 107, 64, 48, 153, 226, 127, 165, 227, 50, 146, 140, 239, 220, 252, 188, 157, 77, 210, 92, 73, 38, 6, 16, 87, 244, 66, ]), - Bytes32::new_direct([ + Bytes32([ 39, 217, 230, 91, 60, 231, 96, 137, 37, 58, 93, 51, 79, 222, 132, 171, 196, 109, 155, 4, 252, 213, 17, 33, 160, 24, 250, 118, 187, 62, 107, 113, ]), - Bytes32::new_direct([ + Bytes32([ 120, 167, 145, 121, 184, 31, 185, 178, 241, 54, 20, 48, 132, 89, 132, 127, 235, 189, 197, 127, 249, 58, 255, 197, 40, 229, 130, 254, 213, 186, 114, 74, ]), - Bytes32::new_direct([ + Bytes32([ 7, 40, 187, 172, 225, 196, 3, 77, 113, 16, 118, 148, 95, 65, 42, 234, 233, 29, 120, 223, 105, 77, 250, 119, 245, 20, 21, 155, 177, 13, 56, 151, ]), - Bytes32::new_direct([ + Bytes32([ 22, 248, 25, 75, 36, 179, 251, 57, 101, 170, 213, 19, 216, 64, 164, 253, 151, 199, 88, 5, 92, 129, 138, 185, 9, 236, 231, 68, 112, 24, 218, 216, ]), - Bytes32::new_direct([ + Bytes32([ 95, 141, 49, 39, 213, 214, 130, 49, 143, 124, 178, 114, 200, 136, 160, 90, 233, 73, 233, 185, 60, 250, 174, 74, 2, 123, 2, 62, 192, 174, 115, 158, ]), - Bytes32::new_direct([ + Bytes32([ 142, 29, 212, 35, 71, 107, 91, 164, 226, 225, 180, 218, 99, 34, 200, 171, 33, 235, 113, 105, 191, 78, 105, 70, 221, 135, 167, 148, 24, 225, 6, 146, ]), - Bytes32::new_direct([ + Bytes32([ 176, 194, 115, 243, 138, 104, 3, 247, 184, 74, 81, 60, 173, 45, 29, 189, 252, 202, 206, 66, 129, 65, 150, 25, 246, 145, 133, 4, 93, 201, 201, 240, ]), - Bytes32::new_direct([ + Bytes32([ 18, 233, 186, 158, 43, 12, 206, 228, 80, 102, 187, 25, 78, 77, 180, 28, 82, 62, 168, 252, 14, 113, 126, 91, 243, 120, 213, 91, 189, 244, 247, 177, ]), - Bytes32::new_direct([ + Bytes32([ 79, 126, 97, 23, 112, 98, 93, 86, 24, 103, 82, 33, 155, 188, 202, 61, 29, 146, 132, 169, 116, 207, 216, 35, 29, 229, 213, 120, 135, 240, 129, 205, ]), - Bytes32::new_direct([ + Bytes32([ 146, 121, 255, 202, 145, 53, 46, 8, 102, 205, 56, 234, 49, 42, 85, 231, 217, 114, 235, 141, 233, 187, 29, 9, 122, 232, 61, 253, 42, 104, 4, 113, ]), - Bytes32::new_direct([ + Bytes32([ 103, 174, 255, 6, 115, 155, 156, 65, 84, 251, 208, 55, 89, 124, 171, 167, 133, 227, 22, 134, 32, 71, 243, 181, 16, 100, 81, 63, 22, 207, 58, 190, ]), - Bytes32::new_direct([ + Bytes32([ 69, 10, 247, 243, 56, 0, 64, 72, 218, 21, 211, 192, 62, 243, 66, 244, 230, 58, 107, 54, 180, 29, 216, 23, 86, 211, 173, 181, 118, 188, 238, 72, ]), - Bytes32::new_direct([ + Bytes32([ 25, 179, 4, 93, 169, 76, 76, 69, 158, 3, 24, 146, 130, 9, 225, 198, 102, 238, 29, 73, 74, 179, 159, 74, 40, 111, 181, 110, 76, 173, 251, 255, ]), - Bytes32::new_direct([ + Bytes32([ 236, 113, 37, 202, 149, 150, 90, 50, 233, 141, 125, 12, 212, 163, 137, 176, 15, 214, 194, 73, 138, 104, 4, 33, 235, 76, 185, 58, 125, 182, 56, 0, ]), - Bytes32::new_direct([ + Bytes32([ 238, 54, 183, 94, 50, 33, 98, 31, 133, 181, 230, 98, 43, 154, 95, 111, 250, 71, 15, 197, 156, 60, 8, 90, 208, 50, 62, 127, 30, 18, 181, 176, ]), - Bytes32::new_direct([ + Bytes32([ 246, 143, 72, 228, 143, 15, 15, 131, 178, 105, 113, 46, 85, 36, 165, 116, 63, 131, 61, 228, 98, 144, 232, 209, 228, 110, 168, 171, 252, 47, 79, 165, ]), - Bytes32::new_direct([ + Bytes32([ 146, 70, 74, 79, 139, 107, 73, 28, 231, 88, 235, 214, 163, 185, 87, 195, 147, 186, 153, 222, 191, 214, 30, 231, 173, 166, 151, 169, 244, 15, 15, 227, ]), - Bytes32::new_direct([ + Bytes32([ 137, 182, 175, 97, 212, 23, 62, 70, 50, 150, 67, 153, 253, 52, 179, 105, 147, 177, 217, 170, 125, 251, 1, 96, 4, 127, 196, 37, 254, 7, 217, 100, ]), - Bytes32::new_direct([ + Bytes32([ 32, 253, 229, 209, 120, 43, 120, 189, 245, 227, 178, 79, 134, 175, 240, 107, 25, 124, 5, 67, 120, 213, 187, 200, 159, 9, 26, 119, 13, 1, 8, 120, ]), - Bytes32::new_direct([ + Bytes32([ 115, 241, 26, 44, 83, 229, 130, 21, 249, 87, 72, 212, 75, 220, 95, 22, 151, 77, 182, 8, 196, 207, 95, 18, 9, 92, 89, 206, 114, 80, 36, 159, ]), - Bytes32::new_direct([ + Bytes32([ 174, 151, 88, 171, 52, 40, 161, 16, 106, 45, 44, 9, 142, 95, 5, 205, 82, 24, 172, 103, 152, 202, 187, 34, 217, 173, 236, 129, 32, 203, 205, 38, ]), ]; const TABLE_ELEMENT_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([ + Bytes32([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]), - Bytes32::new_direct([ + Bytes32([ 145, 218, 63, 74, 131, 182, 204, 163, 74, 206, 234, 50, 47, 3, 51, 74, 121, 225, 146, 237, 5, 128, 20, 230, 243, 89, 33, 248, 136, 154, 189, 5, ]), - Bytes32::new_direct([ + Bytes32([ 36, 240, 95, 13, 214, 136, 92, 102, 96, 137, 39, 96, 108, 223, 147, 130, 220, 61, 147, 226, 52, 133, 67, 223, 211, 164, 6, 53, 45, 117, 120, 241, ]), - Bytes32::new_direct([ + Bytes32([ 9, 2, 218, 34, 228, 8, 178, 127, 160, 30, 104, 198, 49, 37, 71, 115, 14, 35, 20, 15, 253, 160, 147, 143, 24, 186, 12, 90, 41, 169, 30, 8, ]), - Bytes32::new_direct([ + Bytes32([ 137, 242, 105, 78, 161, 99, 76, 224, 226, 100, 216, 235, 156, 132, 214, 154, 107, 120, 197, 113, 45, 221, 170, 119, 92, 228, 76, 139, 170, 159, 111, 58, ]), - Bytes32::new_direct([ + Bytes32([ 231, 165, 221, 185, 139, 22, 70, 40, 67, 162, 123, 94, 161, 156, 57, 53, 102, 217, 128, 227, 18, 132, 17, 170, 90, 31, 214, 181, 249, 220, 70, 37, ]), - Bytes32::new_direct([ + Bytes32([ 171, 253, 174, 187, 9, 186, 87, 37, 22, 83, 13, 88, 75, 11, 177, 226, 237, 136, 132, 137, 101, 109, 135, 192, 224, 80, 87, 105, 95, 81, 255, 21, ]), - Bytes32::new_direct([ + Bytes32([ 179, 50, 36, 230, 159, 162, 184, 132, 140, 121, 133, 155, 189, 44, 132, 93, 80, 79, 32, 244, 131, 57, 79, 222, 104, 63, 224, 182, 91, 162, 73, 122, ]), - Bytes32::new_direct([ + Bytes32([ 17, 55, 206, 87, 127, 185, 135, 231, 41, 56, 166, 104, 229, 102, 222, 181, 236, 233, 230, 39, 43, 163, 16, 1, 225, 86, 211, 51, 145, 7, 169, 84, ]), - Bytes32::new_direct([ + Bytes32([ 201, 174, 3, 154, 104, 190, 240, 99, 123, 201, 7, 118, 196, 85, 28, 247, 35, 232, 39, 25, 151, 52, 167, 136, 179, 13, 213, 60, 138, 158, 39, 131, ]), - Bytes32::new_direct([ + Bytes32([ 35, 33, 109, 155, 171, 252, 195, 80, 10, 115, 40, 199, 250, 1, 241, 82, 146, 225, 118, 237, 11, 125, 198, 97, 57, 21, 171, 237, 94, 60, 49, 32, ]), - Bytes32::new_direct([ + Bytes32([ 126, 95, 42, 157, 183, 168, 137, 120, 114, 64, 148, 170, 32, 156, 137, 96, 194, 91, 119, 11, 20, 3, 30, 62, 118, 12, 31, 48, 245, 144, 252, 29, ]), - Bytes32::new_direct([ + Bytes32([ 48, 135, 201, 114, 103, 35, 8, 96, 5, 101, 125, 26, 87, 0, 98, 122, 239, 140, 230, 10, 102, 112, 155, 87, 249, 181, 152, 235, 28, 79, 176, 56, ]), - Bytes32::new_direct([ + Bytes32([ 76, 70, 222, 210, 242, 159, 52, 123, 112, 106, 253, 140, 55, 160, 189, 255, 220, 64, 8, 168, 39, 196, 160, 8, 105, 154, 91, 184, 62, 63, 227, 156, ]), - Bytes32::new_direct([ + Bytes32([ 138, 201, 8, 240, 218, 190, 210, 227, 236, 168, 45, 161, 209, 115, 126, 165, 235, 162, 6, 117, 76, 239, 3, 225, 163, 251, 111, 233, 233, 228, 14, 92, ]), - Bytes32::new_direct([ + Bytes32([ 190, 166, 27, 117, 242, 0, 25, 148, 230, 125, 237, 22, 153, 158, 151, 56, 121, 194, 221, 198, 184, 147, 249, 149, 27, 29, 166, 243, 254, 181, 209, 102, ]), - Bytes32::new_direct([ + Bytes32([ 235, 63, 149, 47, 164, 152, 80, 11, 178, 203, 99, 178, 176, 226, 164, 151, 39, 65, 83, 200, 102, 90, 12, 102, 178, 15, 232, 16, 222, 141, 78, 3, ]), - Bytes32::new_direct([ + Bytes32([ 37, 179, 99, 114, 214, 120, 87, 53, 198, 229, 207, 47, 16, 112, 208, 33, 216, 152, 209, 228, 196, 14, 237, 250, 212, 90, 176, 185, 21, 248, 92, 109, ]), - Bytes32::new_direct([ + Bytes32([ 237, 200, 122, 93, 145, 116, 138, 59, 86, 220, 58, 171, 160, 31, 142, 193, 231, 131, 106, 164, 166, 44, 120, 170, 62, 81, 73, 85, 0, 52, 219, 220, ]), - Bytes32::new_direct([ + Bytes32([ 244, 173, 85, 141, 81, 198, 214, 0, 54, 21, 20, 169, 177, 235, 104, 206, 43, 218, 96, 68, 73, 37, 252, 77, 253, 18, 30, 97, 223, 122, 1, 12, ]), - Bytes32::new_direct([ + Bytes32([ 104, 169, 247, 140, 131, 245, 193, 3, 36, 119, 249, 119, 108, 102, 115, 250, 173, 225, 33, 156, 116, 87, 180, 27, 84, 215, 126, 15, 187, 189, 32, 139, ]), - Bytes32::new_direct([ + Bytes32([ 47, 156, 244, 88, 145, 227, 224, 87, 233, 138, 138, 9, 169, 96, 29, 204, 100, 170, 23, 105, 63, 4, 119, 90, 167, 161, 72, 109, 82, 254, 123, 48, ]), - Bytes32::new_direct([ + Bytes32([ 196, 68, 107, 111, 141, 253, 138, 140, 162, 104, 247, 104, 87, 144, 123, 240, 105, 251, 246, 210, 172, 172, 241, 162, 155, 90, 83, 175, 131, 251, 107, 215, ]), - Bytes32::new_direct([ + Bytes32([ 28, 100, 243, 226, 32, 234, 211, 106, 197, 179, 14, 192, 70, 11, 203, 125, 151, 53, 20, 77, 175, 99, 154, 100, 159, 249, 54, 39, 73, 168, 162, 66, ]), - Bytes32::new_direct([ + Bytes32([ 83, 176, 7, 180, 201, 178, 172, 98, 47, 34, 80, 6, 62, 10, 4, 112, 43, 93, 10, 227, 74, 91, 11, 217, 83, 230, 104, 0, 167, 2, 114, 89, ]), - Bytes32::new_direct([ + Bytes32([ 185, 162, 212, 82, 149, 182, 104, 215, 62, 244, 114, 124, 181, 74, 226, 119, 4, 42, 181, 238, 25, 212, 215, 219, 174, 231, 32, 170, 9, 234, 12, 212, ]), - Bytes32::new_direct([ + Bytes32([ 173, 38, 241, 20, 137, 119, 33, 252, 174, 245, 252, 234, 165, 181, 128, 225, 14, 147, 182, 97, 145, 19, 40, 193, 90, 238, 140, 87, 0, 222, 70, 254, ]), - Bytes32::new_direct([ + Bytes32([ 51, 218, 162, 213, 211, 23, 9, 158, 185, 156, 39, 145, 5, 146, 70, 144, 172, 10, 26, 212, 253, 37, 24, 32, 21, 65, 179, 140, 64, 237, 96, 157, ]), - Bytes32::new_direct([ + Bytes32([ 221, 87, 57, 81, 246, 126, 53, 163, 190, 220, 109, 205, 114, 234, 85, 151, 75, 245, 254, 16, 140, 131, 239, 120, 9, 209, 54, 61, 177, 6, 188, 252, ]), - Bytes32::new_direct([ + Bytes32([ 54, 161, 25, 198, 75, 151, 214, 76, 83, 74, 117, 229, 155, 237, 88, 95, 143, 119, 56, 12, 201, 164, 235, 20, 117, 49, 177, 88, 14, 248, 95, 198, ]), - Bytes32::new_direct([ + Bytes32([ 60, 16, 183, 115, 241, 45, 253, 24, 105, 43, 79, 72, 212, 238, 24, 156, 132, 93, 78, 246, 1, 228, 222, 200, 254, 130, 170, 46, 91, 254, 205, 143, ]), - Bytes32::new_direct([ + Bytes32([ 184, 30, 34, 235, 214, 40, 120, 64, 182, 15, 162, 189, 164, 202, 89, 146, 202, 177, 16, 105, 172, 158, 1, 95, 101, 146, 253, 115, 226, 233, 38, 171, ]), - Bytes32::new_direct([ + Bytes32([ 70, 152, 3, 73, 249, 222, 93, 214, 74, 179, 140, 47, 34, 42, 149, 214, 152, 75, 34, 145, 68, 226, 151, 101, 121, 54, 252, 240, 206, 140, 81, 165, ]), - Bytes32::new_direct([ + Bytes32([ 9, 88, 51, 124, 67, 108, 84, 244, 61, 241, 110, 246, 184, 105, 6, 116, 242, 58, 15, 144, 43, 76, 176, 107, 0, 138, 155, 235, 210, 138, 226, 215, ]), - Bytes32::new_direct([ + Bytes32([ 98, 170, 168, 147, 158, 223, 186, 7, 58, 130, 89, 200, 153, 24, 158, 251, 69, 100, 7, 57, 96, 115, 136, 170, 57, 145, 143, 240, 102, 6, 248, 111, ]), - Bytes32::new_direct([ + Bytes32([ 76, 75, 216, 216, 194, 146, 2, 59, 247, 64, 98, 160, 62, 105, 193, 186, 161, 191, 64, 154, 254, 196, 55, 214, 201, 103, 223, 131, 181, 192, 152, 176, ]), - Bytes32::new_direct([ + Bytes32([ 188, 141, 114, 199, 33, 45, 183, 18, 123, 231, 92, 215, 51, 191, 11, 199, 253, 46, 28, 10, 156, 23, 92, 255, 219, 236, 176, 247, 52, 105, 210, 223, ]), - Bytes32::new_direct([ + Bytes32([ 200, 67, 112, 29, 180, 70, 50, 18, 220, 122, 39, 122, 83, 186, 81, 77, 241, 44, 190, 3, 162, 217, 76, 61, 230, 237, 157, 230, 205, 172, 186, 247, ]), - Bytes32::new_direct([ + Bytes32([ 131, 131, 129, 83, 251, 217, 83, 88, 93, 39, 66, 174, 51, 19, 190, 91, 16, 187, 95, 63, 35, 178, 94, 237, 194, 42, 231, 227, 138, 202, 216, 93, ]), - Bytes32::new_direct([ + Bytes32([ 18, 177, 28, 41, 199, 59, 160, 244, 26, 162, 73, 48, 16, 74, 190, 195, 249, 216, 64, 229, 145, 65, 18, 131, 75, 57, 71, 74, 127, 239, 112, 13, ]), - Bytes32::new_direct([ + Bytes32([ 41, 120, 53, 253, 151, 12, 143, 213, 212, 31, 245, 61, 168, 113, 30, 38, 112, 126, 156, 133, 241, 102, 110, 237, 4, 138, 50, 160, 79, 235, 52, 35, ]), - Bytes32::new_direct([ + Bytes32([ 38, 74, 146, 27, 110, 86, 122, 250, 58, 243, 64, 185, 207, 174, 28, 124, 35, 183, 53, 88, 34, 234, 89, 58, 98, 223, 69, 13, 48, 15, 239, 230, ]), - Bytes32::new_direct([ + Bytes32([ 221, 132, 1, 28, 157, 232, 235, 132, 32, 58, 26, 36, 60, 217, 197, 165, 141, 19, 64, 120, 197, 139, 190, 86, 153, 152, 235, 11, 99, 129, 222, 91, ]), - Bytes32::new_direct([ + Bytes32([ 237, 76, 61, 239, 169, 108, 131, 62, 163, 67, 158, 210, 14, 45, 91, 105, 36, 182, 206, 182, 71, 11, 159, 169, 159, 248, 247, 176, 6, 176, 237, 123, ]), - Bytes32::new_direct([ + Bytes32([ 232, 190, 198, 78, 12, 148, 86, 176, 221, 115, 1, 22, 122, 163, 223, 234, 74, 129, 125, 53, 211, 137, 115, 18, 241, 170, 69, 42, 34, 74, 180, 172, ]), - Bytes32::new_direct([ + Bytes32([ 215, 199, 144, 158, 222, 153, 123, 125, 150, 97, 127, 151, 96, 43, 69, 155, 150, 119, 75, 82, 218, 48, 101, 70, 121, 18, 42, 146, 215, 183, 100, 158, ]), - Bytes32::new_direct([ + Bytes32([ 121, 182, 45, 62, 255, 78, 32, 48, 107, 186, 208, 155, 158, 80, 231, 241, 90, 227, 219, 113, 52, 20, 66, 45, 124, 67, 209, 61, 167, 74, 60, 34, ]), - Bytes32::new_direct([ + Bytes32([ 34, 136, 15, 103, 128, 220, 202, 103, 150, 123, 249, 145, 218, 227, 17, 64, 142, 129, 4, 42, 93, 7, 6, 147, 111, 117, 25, 185, 88, 104, 85, 115, ]), - Bytes32::new_direct([ + Bytes32([ 144, 191, 235, 38, 205, 102, 127, 160, 139, 105, 75, 63, 86, 192, 194, 49, 240, 35, 65, 154, 4, 113, 51, 87, 40, 70, 32, 58, 243, 16, 136, 67, ]), - Bytes32::new_direct([ + Bytes32([ 217, 150, 254, 250, 111, 69, 45, 227, 111, 59, 199, 149, 59, 216, 17, 117, 8, 226, 85, 250, 183, 187, 21, 129, 208, 0, 63, 158, 232, 106, 131, 16, ]), - Bytes32::new_direct([ + Bytes32([ 148, 212, 84, 16, 204, 49, 69, 96, 137, 125, 102, 221, 111, 8, 41, 51, 221, 241, 87, 231, 88, 215, 211, 24, 254, 131, 111, 56, 160, 143, 230, 109, ]), - Bytes32::new_direct([ + Bytes32([ 144, 48, 37, 157, 153, 7, 123, 206, 46, 224, 211, 249, 208, 217, 91, 243, 128, 62, 100, 126, 3, 253, 223, 161, 50, 108, 26, 151, 129, 242, 94, 132, ]), - Bytes32::new_direct([ + Bytes32([ 97, 167, 177, 53, 183, 154, 164, 1, 129, 184, 234, 182, 190, 197, 244, 226, 150, 217, 57, 152, 243, 206, 60, 76, 114, 194, 51, 240, 58, 93, 219, 76, ]), - Bytes32::new_direct([ + Bytes32([ 139, 70, 147, 227, 94, 147, 130, 53, 38, 112, 138, 176, 7, 148, 6, 21, 50, 199, 70, 33, 87, 180, 33, 167, 56, 89, 66, 95, 245, 247, 135, 24, ]), - Bytes32::new_direct([ + Bytes32([ 175, 169, 204, 13, 145, 18, 40, 29, 84, 88, 206, 99, 208, 137, 249, 146, 0, 237, 188, 130, 135, 223, 121, 54, 126, 251, 247, 109, 141, 217, 62, 127, ]), - Bytes32::new_direct([ + Bytes32([ 139, 188, 3, 234, 198, 124, 194, 238, 217, 237, 214, 250, 66, 220, 0, 51, 1, 203, 122, 125, 46, 213, 22, 253, 8, 218, 145, 253, 170, 156, 159, 96, ]), - Bytes32::new_direct([ + Bytes32([ 107, 130, 208, 55, 16, 249, 46, 4, 98, 236, 130, 52, 190, 126, 232, 229, 108, 126, 239, 175, 25, 229, 84, 33, 249, 66, 128, 162, 47, 221, 110, 163, ]), - Bytes32::new_direct([ + Bytes32([ 239, 176, 14, 134, 210, 125, 177, 40, 200, 42, 229, 32, 200, 58, 9, 73, 210, 161, 8, 105, 4, 70, 19, 134, 117, 132, 167, 18, 16, 108, 207, 113, ]), - Bytes32::new_direct([ + Bytes32([ 237, 116, 250, 79, 151, 228, 171, 189, 89, 213, 122, 121, 55, 25, 52, 238, 79, 19, 31, 194, 73, 158, 43, 78, 86, 194, 36, 141, 105, 10, 87, 58, ]), - Bytes32::new_direct([ + Bytes32([ 216, 125, 158, 123, 121, 158, 74, 152, 46, 18, 196, 115, 233, 149, 205, 189, 10, 232, 174, 21, 2, 52, 202, 111, 74, 160, 191, 196, 84, 93, 98, 46, ]), - Bytes32::new_direct([ + Bytes32([ 201, 148, 124, 172, 62, 154, 127, 129, 205, 197, 134, 133, 144, 78, 47, 190, 197, 190, 103, 44, 129, 57, 155, 227, 152, 212, 130, 12, 192, 223, 244, 68, ]), - Bytes32::new_direct([ + Bytes32([ 102, 147, 19, 104, 237, 188, 140, 66, 166, 77, 105, 55, 5, 165, 143, 107, 91, 247, 53, 203, 187, 163, 109, 66, 19, 164, 153, 170, 82, 251, 148, 10, ]), - Bytes32::new_direct([ + Bytes32([ 33, 89, 246, 96, 201, 15, 77, 99, 252, 111, 250, 152, 124, 80, 50, 57, 197, 124, 254, 202, 246, 131, 11, 219, 249, 102, 35, 79, 100, 173, 146, 167, ]), - Bytes32::new_direct([ + Bytes32([ 6, 27, 205, 165, 249, 112, 70, 105, 232, 156, 155, 204, 71, 5, 21, 239, 91, 69, 248, 111, 218, 154, 187, 85, 118, 72, 210, 99, 138, 40, 233, 75, ]), ]; const MODULE_HASHES: &[Bytes32; 64] = &[ - Bytes32::new_direct([ + Bytes32([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ]), - Bytes32::new_direct([ + Bytes32([ 252, 178, 61, 5, 174, 66, 106, 30, 131, 163, 114, 90, 231, 83, 228, 153, 108, 255, 60, 37, 254, 139, 153, 129, 208, 156, 109, 74, 233, 129, 174, 182, ]), - Bytes32::new_direct([ + Bytes32([ 128, 23, 154, 62, 181, 220, 154, 183, 222, 214, 79, 76, 162, 169, 179, 162, 185, 93, 179, 115, 161, 55, 19, 63, 227, 168, 140, 66, 182, 6, 60, 120, ]), - Bytes32::new_direct([ + Bytes32([ 243, 119, 126, 55, 151, 128, 119, 12, 124, 84, 146, 243, 156, 68, 82, 174, 201, 162, 29, 73, 29, 77, 103, 205, 194, 250, 45, 133, 39, 71, 224, 177, ]), - Bytes32::new_direct([ + Bytes32([ 209, 179, 222, 187, 184, 84, 131, 182, 172, 78, 20, 104, 236, 246, 114, 74, 55, 98, 29, 34, 117, 249, 89, 76, 85, 38, 248, 193, 75, 10, 243, 100, ]), - Bytes32::new_direct([ + Bytes32([ 195, 14, 58, 139, 148, 140, 218, 174, 131, 204, 69, 84, 127, 8, 142, 88, 136, 83, 253, 241, 74, 247, 143, 204, 38, 15, 138, 98, 47, 188, 255, 245, ]), - Bytes32::new_direct([ + Bytes32([ 167, 4, 177, 126, 159, 76, 19, 220, 160, 159, 81, 227, 110, 147, 179, 175, 253, 187, 46, 24, 15, 168, 153, 84, 4, 167, 247, 225, 121, 175, 134, 85, ]), - Bytes32::new_direct([ + Bytes32([ 237, 144, 152, 155, 211, 100, 202, 187, 41, 181, 45, 224, 143, 139, 18, 77, 110, 34, 212, 207, 239, 180, 73, 84, 166, 194, 22, 149, 89, 215, 86, 21, ]), - Bytes32::new_direct([ + Bytes32([ 226, 192, 91, 176, 242, 185, 212, 189, 178, 80, 238, 252, 183, 82, 220, 242, 22, 237, 84, 142, 132, 91, 95, 219, 252, 171, 51, 76, 28, 146, 86, 155, ]), - Bytes32::new_direct([ + Bytes32([ 199, 200, 237, 66, 220, 14, 221, 121, 117, 150, 118, 36, 138, 142, 50, 173, 12, 195, 131, 90, 27, 189, 247, 221, 89, 151, 41, 27, 135, 207, 137, 172, ]), - Bytes32::new_direct([ + Bytes32([ 160, 60, 124, 200, 56, 240, 67, 161, 121, 95, 247, 51, 153, 249, 125, 88, 231, 2, 85, 167, 251, 187, 21, 103, 49, 132, 213, 52, 219, 30, 146, 59, ]), - Bytes32::new_direct([ + Bytes32([ 123, 52, 142, 254, 117, 160, 215, 99, 155, 130, 134, 183, 76, 99, 166, 246, 49, 51, 142, 67, 116, 234, 69, 199, 201, 19, 70, 3, 208, 247, 40, 82, ]), - Bytes32::new_direct([ + Bytes32([ 165, 32, 183, 79, 246, 224, 220, 103, 11, 160, 233, 66, 129, 238, 194, 73, 17, 37, 128, 185, 175, 88, 144, 228, 231, 185, 22, 17, 149, 174, 72, 1, ]), - Bytes32::new_direct([ + Bytes32([ 12, 24, 45, 128, 57, 246, 187, 176, 154, 247, 169, 18, 116, 176, 70, 246, 203, 141, 211, 104, 5, 147, 78, 214, 161, 71, 33, 97, 7, 21, 158, 61, ]), - Bytes32::new_direct([ + Bytes32([ 215, 18, 110, 29, 36, 34, 133, 219, 15, 204, 206, 158, 186, 213, 181, 41, 184, 160, 71, 165, 163, 121, 88, 106, 228, 58, 34, 105, 112, 168, 84, 123, ]), - Bytes32::new_direct([ + Bytes32([ 6, 169, 156, 220, 55, 53, 26, 229, 104, 60, 113, 111, 153, 18, 251, 234, 179, 159, 56, 14, 112, 7, 144, 199, 45, 180, 116, 239, 21, 207, 173, 205, ]), - Bytes32::new_direct([ + Bytes32([ 24, 172, 76, 192, 21, 91, 250, 75, 196, 119, 231, 221, 13, 239, 113, 39, 62, 40, 165, 26, 245, 16, 61, 106, 39, 28, 78, 212, 249, 230, 84, 108, ]), - Bytes32::new_direct([ + Bytes32([ 248, 34, 1, 62, 213, 235, 20, 21, 220, 78, 178, 126, 184, 102, 242, 50, 49, 174, 163, 122, 166, 96, 40, 110, 78, 199, 89, 158, 155, 251, 233, 49, ]), - Bytes32::new_direct([ + Bytes32([ 103, 54, 133, 19, 189, 117, 46, 209, 17, 2, 64, 251, 77, 195, 197, 91, 38, 48, 214, 36, 96, 255, 133, 87, 244, 101, 166, 218, 167, 129, 225, 167, ]), - Bytes32::new_direct([ + Bytes32([ 196, 159, 226, 85, 100, 246, 179, 251, 133, 33, 114, 51, 104, 245, 81, 54, 137, 126, 245, 76, 112, 146, 139, 185, 190, 19, 106, 132, 48, 203, 34, 237, ]), - Bytes32::new_direct([ + Bytes32([ 41, 190, 7, 23, 227, 80, 13, 134, 244, 18, 215, 148, 1, 72, 1, 22, 91, 165, 182, 69, 160, 179, 241, 106, 254, 116, 245, 131, 136, 35, 190, 226, ]), - Bytes32::new_direct([ + Bytes32([ 205, 132, 211, 121, 67, 210, 191, 102, 218, 92, 56, 204, 68, 160, 188, 100, 229, 80, 77, 27, 26, 86, 248, 86, 216, 39, 242, 211, 183, 139, 219, 83, ]), - Bytes32::new_direct([ + Bytes32([ 13, 215, 68, 100, 180, 74, 23, 58, 157, 140, 76, 31, 114, 254, 85, 78, 234, 40, 251, 199, 35, 204, 111, 243, 163, 64, 221, 21, 96, 55, 127, 118, ]), - Bytes32::new_direct([ + Bytes32([ 225, 14, 246, 105, 64, 96, 225, 200, 186, 66, 40, 253, 131, 80, 102, 178, 83, 22, 150, 32, 15, 139, 76, 172, 144, 3, 30, 43, 217, 213, 89, 43, ]), - Bytes32::new_direct([ + Bytes32([ 200, 83, 93, 27, 98, 246, 87, 100, 53, 166, 89, 138, 157, 88, 148, 245, 61, 115, 246, 20, 142, 156, 54, 237, 179, 64, 148, 218, 67, 5, 142, 248, ]), - Bytes32::new_direct([ + Bytes32([ 159, 25, 150, 25, 114, 252, 162, 57, 21, 125, 147, 111, 220, 117, 17, 107, 40, 21, 157, 183, 6, 63, 226, 37, 64, 179, 133, 58, 107, 245, 78, 14, ]), - Bytes32::new_direct([ + Bytes32([ 58, 243, 16, 193, 174, 42, 255, 46, 40, 128, 26, 167, 173, 164, 71, 226, 155, 205, 26, 127, 154, 24, 74, 244, 106, 251, 25, 221, 197, 176, 194, 17, ]), - Bytes32::new_direct([ + Bytes32([ 51, 47, 251, 206, 27, 9, 142, 27, 253, 132, 189, 62, 109, 150, 246, 2, 137, 90, 157, 185, 59, 96, 0, 154, 29, 17, 231, 3, 84, 95, 49, 51, ]), - Bytes32::new_direct([ + Bytes32([ 250, 158, 158, 248, 206, 150, 95, 254, 53, 140, 80, 102, 67, 26, 76, 127, 236, 86, 182, 120, 72, 239, 190, 118, 60, 77, 28, 82, 152, 234, 73, 201, ]), - Bytes32::new_direct([ + Bytes32([ 255, 137, 155, 144, 74, 231, 231, 43, 187, 202, 137, 66, 205, 37, 40, 225, 0, 33, 87, 137, 113, 163, 58, 64, 147, 74, 123, 128, 19, 156, 46, 83, ]), - Bytes32::new_direct([ + Bytes32([ 207, 61, 79, 4, 202, 96, 238, 144, 154, 230, 145, 65, 230, 130, 246, 10, 140, 71, 66, 246, 53, 230, 148, 1, 248, 103, 145, 149, 157, 38, 169, 8, ]), - Bytes32::new_direct([ + Bytes32([ 33, 168, 110, 82, 84, 151, 70, 98, 115, 2, 221, 116, 210, 10, 247, 189, 203, 245, 186, 86, 121, 142, 218, 95, 68, 241, 21, 219, 131, 241, 185, 203, ]), - Bytes32::new_direct([ + Bytes32([ 125, 247, 7, 149, 181, 71, 68, 141, 123, 207, 144, 83, 170, 27, 244, 37, 210, 148, 0, 140, 144, 159, 237, 216, 227, 247, 85, 229, 80, 174, 40, 48, ]), - Bytes32::new_direct([ + Bytes32([ 0, 205, 68, 89, 77, 97, 204, 140, 113, 244, 168, 76, 49, 137, 236, 21, 132, 99, 10, 206, 195, 206, 208, 120, 227, 77, 21, 223, 145, 227, 48, 139, ]), - Bytes32::new_direct([ + Bytes32([ 10, 153, 106, 155, 149, 65, 211, 247, 246, 5, 129, 126, 74, 14, 113, 168, 152, 154, 205, 139, 49, 2, 182, 65, 163, 15, 62, 126, 62, 16, 26, 36, ]), - Bytes32::new_direct([ + Bytes32([ 24, 251, 204, 187, 179, 146, 114, 66, 110, 182, 131, 248, 36, 170, 169, 128, 22, 221, 134, 193, 121, 189, 128, 94, 83, 255, 226, 37, 133, 83, 220, 181, ]), - Bytes32::new_direct([ + Bytes32([ 25, 52, 245, 155, 53, 39, 73, 130, 12, 73, 106, 255, 44, 204, 208, 41, 32, 126, 159, 98, 197, 67, 58, 90, 6, 146, 25, 166, 195, 194, 215, 70, ]), - Bytes32::new_direct([ + Bytes32([ 194, 167, 206, 222, 96, 6, 86, 241, 95, 105, 225, 147, 99, 93, 201, 220, 166, 145, 4, 25, 168, 188, 21, 168, 80, 163, 132, 216, 239, 19, 115, 36, ]), - Bytes32::new_direct([ + Bytes32([ 243, 16, 4, 9, 140, 42, 62, 105, 97, 7, 4, 234, 200, 227, 42, 10, 51, 167, 38, 148, 69, 154, 143, 179, 94, 177, 248, 28, 33, 61, 166, 187, ]), - Bytes32::new_direct([ + Bytes32([ 156, 201, 97, 197, 223, 83, 229, 186, 187, 33, 49, 210, 181, 222, 180, 234, 150, 33, 99, 168, 157, 26, 241, 1, 213, 220, 165, 8, 31, 76, 134, 243, ]), - Bytes32::new_direct([ + Bytes32([ 34, 218, 29, 74, 212, 218, 95, 6, 53, 10, 63, 174, 119, 90, 90, 35, 92, 124, 169, 222, 75, 61, 199, 118, 132, 40, 193, 9, 250, 80, 12, 197, ]), - Bytes32::new_direct([ + Bytes32([ 102, 137, 75, 155, 181, 222, 86, 192, 140, 167, 3, 178, 212, 165, 49, 163, 86, 8, 76, 240, 32, 202, 34, 159, 217, 173, 101, 125, 237, 34, 48, 179, ]), - Bytes32::new_direct([ + Bytes32([ 136, 53, 156, 19, 107, 234, 210, 218, 180, 236, 9, 7, 80, 63, 146, 57, 77, 106, 135, 64, 23, 184, 9, 139, 61, 237, 225, 157, 183, 182, 137, 31, ]), - Bytes32::new_direct([ + Bytes32([ 237, 226, 115, 218, 228, 122, 45, 46, 67, 21, 130, 204, 80, 2, 28, 47, 148, 191, 28, 33, 177, 47, 207, 14, 33, 117, 28, 46, 88, 254, 97, 227, ]), - Bytes32::new_direct([ + Bytes32([ 38, 87, 252, 28, 105, 20, 117, 29, 234, 237, 60, 91, 48, 101, 219, 219, 24, 52, 169, 243, 71, 214, 117, 41, 207, 17, 148, 77, 218, 44, 122, 167, ]), - Bytes32::new_direct([ + Bytes32([ 235, 31, 185, 222, 3, 22, 222, 174, 126, 128, 55, 67, 201, 229, 55, 28, 241, 144, 184, 85, 141, 153, 183, 211, 66, 80, 152, 248, 214, 130, 64, 205, ]), - Bytes32::new_direct([ + Bytes32([ 52, 169, 226, 179, 195, 44, 245, 101, 35, 92, 145, 174, 152, 212, 192, 148, 241, 72, 248, 61, 239, 124, 98, 213, 181, 75, 84, 121, 57, 90, 172, 164, ]), - Bytes32::new_direct([ + Bytes32([ 27, 19, 12, 74, 128, 193, 65, 63, 15, 6, 174, 167, 79, 56, 88, 13, 117, 6, 189, 14, 11, 13, 133, 136, 141, 64, 74, 17, 159, 192, 251, 242, ]), - Bytes32::new_direct([ + Bytes32([ 101, 69, 132, 221, 127, 162, 162, 92, 248, 131, 39, 52, 169, 170, 231, 137, 123, 106, 161, 16, 202, 242, 216, 245, 211, 170, 74, 128, 108, 243, 166, 38, ]), - Bytes32::new_direct([ + Bytes32([ 157, 82, 193, 234, 117, 199, 118, 245, 63, 31, 186, 32, 135, 233, 29, 213, 217, 119, 208, 64, 149, 116, 117, 129, 211, 225, 207, 22, 225, 99, 194, 222, ]), - Bytes32::new_direct([ + Bytes32([ 112, 194, 64, 229, 154, 223, 109, 8, 191, 120, 32, 176, 154, 7, 174, 103, 2, 156, 230, 164, 245, 252, 0, 116, 213, 40, 20, 239, 135, 62, 198, 42, ]), - Bytes32::new_direct([ + Bytes32([ 32, 91, 5, 170, 221, 134, 167, 144, 16, 130, 237, 114, 71, 184, 131, 223, 92, 149, 161, 68, 196, 56, 73, 148, 203, 187, 174, 178, 178, 53, 156, 177, ]), - Bytes32::new_direct([ + Bytes32([ 234, 97, 64, 211, 81, 59, 14, 249, 38, 8, 247, 37, 243, 37, 88, 234, 19, 54, 146, 63, 88, 79, 127, 190, 144, 51, 240, 19, 15, 143, 18, 9, ]), - Bytes32::new_direct([ + Bytes32([ 247, 102, 43, 28, 24, 201, 189, 198, 66, 58, 210, 51, 174, 234, 52, 239, 37, 83, 212, 184, 127, 170, 168, 127, 47, 11, 248, 213, 84, 3, 201, 181, ]), - Bytes32::new_direct([ + Bytes32([ 126, 18, 116, 33, 129, 25, 247, 2, 162, 202, 103, 201, 237, 67, 28, 80, 46, 182, 163, 239, 90, 204, 47, 196, 137, 79, 19, 165, 209, 84, 140, 132, ]), - Bytes32::new_direct([ + Bytes32([ 189, 160, 148, 101, 82, 248, 215, 206, 90, 91, 205, 148, 37, 38, 172, 82, 223, 228, 66, 173, 220, 246, 194, 73, 231, 17, 220, 47, 222, 175, 7, 24, ]), - Bytes32::new_direct([ + Bytes32([ 237, 149, 54, 210, 99, 72, 182, 55, 69, 140, 161, 215, 104, 90, 104, 26, 216, 241, 232, 210, 37, 77, 56, 216, 6, 160, 199, 247, 164, 227, 142, 255, ]), - Bytes32::new_direct([ + Bytes32([ 11, 57, 131, 77, 203, 89, 156, 126, 200, 215, 103, 209, 70, 235, 78, 247, 0, 126, 209, 248, 220, 135, 158, 244, 141, 74, 6, 158, 19, 37, 42, 39, ]), - Bytes32::new_direct([ + Bytes32([ 107, 131, 231, 102, 64, 182, 78, 253, 77, 143, 94, 34, 199, 93, 44, 131, 169, 211, 71, 223, 53, 230, 59, 107, 146, 22, 188, 207, 210, 220, 168, 129, ]), - Bytes32::new_direct([ + Bytes32([ 78, 71, 246, 216, 154, 188, 152, 6, 234, 254, 21, 1, 128, 148, 56, 91, 250, 95, 76, 103, 15, 250, 137, 186, 114, 254, 122, 69, 208, 242, 69, 111, ]), - Bytes32::new_direct([ + Bytes32([ 82, 241, 242, 155, 248, 109, 84, 118, 225, 255, 122, 40, 3, 87, 20, 223, 212, 205, 141, 178, 32, 229, 234, 146, 101, 73, 79, 55, 28, 82, 81, 178, ]), - Bytes32::new_direct([ + Bytes32([ 35, 169, 243, 198, 215, 220, 113, 91, 6, 79, 48, 201, 97, 143, 212, 34, 247, 46, 38, 93, 166, 213, 158, 218, 61, 86, 240, 149, 224, 174, 225, 73, ]), - Bytes32::new_direct([ + Bytes32([ 25, 108, 21, 212, 193, 192, 96, 39, 57, 72, 193, 99, 239, 0, 231, 83, 183, 195, 105, 33, 220, 187, 18, 148, 43, 30, 42, 127, 192, 240, 13, 224, ]), - Bytes32::new_direct([ + Bytes32([ 119, 117, 186, 31, 43, 128, 143, 25, 182, 135, 156, 58, 152, 81, 70, 116, 171, 137, 125, 157, 152, 163, 34, 65, 240, 178, 12, 24, 168, 111, 39, 35, ]), ]; -pub const EMPTY_HASH: &Bytes32 = &Bytes32::new_direct([0; 32]); +pub const EMPTY_HASH: &Bytes32 = &Bytes32([0; 32]); pub const ZERO_HASHES: &[&[Bytes32; 64]; 7] = &[ VALUE_HASHES, From d967a828dbc9aa92c5b5c2accbc2fd61853894ff Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 09:53:04 +0200 Subject: [PATCH 115/268] Also remove new_direct from the zero-hash generation tests --- arbitrator/prover/src/memory.rs | 2 +- arbitrator/prover/src/merkle.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 47249560cd..793c50035a 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -384,7 +384,7 @@ mod test { pub fn empty_leaf_hash() { let leaf = [0u8; 32]; let hash = super::hash_leaf(leaf); - print!("Bytes32::new_direct(["); + print!("Bytes32(["); for i in 0..32 { print!("{}", hash[i]); if i < 31 { diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 3e50dbd1a9..1f5d611a0a 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -532,7 +532,7 @@ fn emit_memory_zerohashes() { ]) .clone(); for _ in 0..64 { - print!("Bytes32::new_direct(["); + print!("Bytes32(["); for i in 0..32 { print!("{}", empty_node[i]); if i < 31 { From dc2ed78bc8a2ab5fa2619669c7c6a5666661f547 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 10:44:23 +0200 Subject: [PATCH 116/268] Remove the PartialEq implementation It isn't needed by any of the code that interacts with Memory objects. --- arbitrator/prover/src/memory.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 793c50035a..0d935b824a 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -100,16 +100,6 @@ fn div_round_up(num: usize, denom: usize) -> usize { res } -impl PartialEq for Memory { - fn eq(&self, other: &Memory) -> bool { - self.buffer == other.buffer - && self.merkle == other.merkle - && self.max_size == other.max_size - && self.dirty_indices.lock().unwrap().deref() - == other.dirty_indices.lock().unwrap().deref() - } -} - impl Clone for Memory { fn clone(&self) -> Self { Memory { From 3cd78571d793c5733c52d301ac2f618cee8c3a99 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 10:47:42 +0200 Subject: [PATCH 117/268] Switch to the parking_lot crate's Mutex Primarily because it has a nicer API which avoids having to call unwrap() so much. --- arbitrator/prover/src/memory.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 0d935b824a..5140dffc63 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -8,9 +8,10 @@ use crate::{ use arbutil::Bytes32; use digest::Digest; use eyre::{bail, ErrReport, Result}; +use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use std::{borrow::Cow, collections::HashSet, convert::TryFrom, ops::Deref, sync::Mutex}; +use std::{borrow::Cow, collections::HashSet, convert::TryFrom, ops::Deref}; #[cfg(feature = "counters")] use std::sync::atomic::{AtomicUsize, Ordering}; @@ -106,7 +107,7 @@ impl Clone for Memory { buffer: self.buffer.clone(), merkle: self.merkle.clone(), max_size: self.max_size, - dirty_indices: Mutex::new(self.dirty_indices.lock().unwrap().clone()), + dirty_indices: Mutex::new(self.dirty_indices.lock().clone()), } } } @@ -134,7 +135,7 @@ impl Memory { pub fn merkelize(&self) -> Cow<'_, Merkle> { if let Some(m) = &self.merkle { - let mut dirt = self.dirty_indices.lock().unwrap(); + let mut dirt = self.dirty_indices.lock(); for idx in dirt.iter() { let leaf_idx = idx / Self::LEAF_SIZE; m.set(leaf_idx, hash_leaf(self.get_leaf_data(leaf_idx))); @@ -165,7 +166,7 @@ impl Memory { panic!("Couldn't resize merkle tree from {} to {}", size, leaves) }); } - self.dirty_indices.lock().unwrap().clear(); + self.dirty_indices.lock().clear(); Cow::Owned(m) } @@ -274,8 +275,8 @@ impl Memory { let end_idx = end_idx as usize; let buf = value.to_le_bytes(); self.buffer[idx..end_idx].copy_from_slice(&buf[..bytes.into()]); - self.dirty_indices.lock().unwrap().insert(idx); - self.dirty_indices.lock().unwrap().insert(end_idx - 1); + self.dirty_indices.lock().insert(idx); + self.dirty_indices.lock().insert(end_idx - 1); true } @@ -294,7 +295,7 @@ impl Memory { let idx = idx as usize; let end_idx = end_idx as usize; self.buffer[idx..end_idx].copy_from_slice(value); - self.dirty_indices.lock().unwrap().insert(idx); + self.dirty_indices.lock().insert(idx); true } From 9676230920eb38a042dc39062aa28f1a7123062e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 10:48:45 +0200 Subject: [PATCH 118/268] Remove the unused ops:Dref --- arbitrator/prover/src/memory.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 5140dffc63..8c619b47d8 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -11,7 +11,7 @@ use eyre::{bail, ErrReport, Result}; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use sha3::Keccak256; -use std::{borrow::Cow, collections::HashSet, convert::TryFrom, ops::Deref}; +use std::{borrow::Cow, collections::HashSet, convert::TryFrom}; #[cfg(feature = "counters")] use std::sync::atomic::{AtomicUsize, Ordering}; From bd93ab7b3618c5b125dd8178c287bdf1ef051536 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 11:09:02 +0200 Subject: [PATCH 119/268] Switch the dirty_indices to dirty_leaves This provides a 32x reduction in the size of the dirty tracking. It makes sense because if any index in the memory which contributes to a leaf changes, then they hash for that leaf has to be recalculated. So, we don't need to track the dirty indices in memory, but the dirty leaves in the corresponding merkle tree. This commit also removes a useless take() call, and documents some invariantes when storing to memory. --- arbitrator/prover/src/memory.rs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 8c619b47d8..390d39db57 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -72,7 +72,7 @@ pub struct Memory { pub merkle: Option, pub max_size: u64, #[serde(skip)] - dirty_indices: Mutex>, + dirty_leaves: Mutex>, } fn hash_leaf(bytes: [u8; Memory::LEAF_SIZE]) -> Bytes32 { @@ -107,7 +107,7 @@ impl Clone for Memory { buffer: self.buffer.clone(), merkle: self.merkle.clone(), max_size: self.max_size, - dirty_indices: Mutex::new(self.dirty_indices.lock().clone()), + dirty_leaves: Mutex::new(self.dirty_leaves.lock().clone()), } } } @@ -125,7 +125,7 @@ impl Memory { buffer: vec![0u8; size], merkle: None, max_size, - dirty_indices: Mutex::new(HashSet::new()), + dirty_leaves: Mutex::new(HashSet::new()), } } @@ -135,12 +135,10 @@ impl Memory { pub fn merkelize(&self) -> Cow<'_, Merkle> { if let Some(m) = &self.merkle { - let mut dirt = self.dirty_indices.lock(); - for idx in dirt.iter() { - let leaf_idx = idx / Self::LEAF_SIZE; + let mut dirt = self.dirty_leaves.lock(); + for leaf_idx in dirt.drain() { m.set(leaf_idx, hash_leaf(self.get_leaf_data(leaf_idx))); } - dirt.clear(); return Cow::Borrowed(m); } // Round the size up to 8 byte long leaves, then round up to the next power of two number of leaves @@ -166,7 +164,7 @@ impl Memory { panic!("Couldn't resize merkle tree from {} to {}", size, leaves) }); } - self.dirty_indices.lock().clear(); + self.dirty_leaves.lock().clear(); Cow::Owned(m) } @@ -264,7 +262,11 @@ impl Memory { } #[must_use] + // Stores a value in memory, returns false if the value would overflow the buffer. + // + // bytes is the number of bytes to store. It must be <= 8. pub fn store_value(&mut self, idx: u64, value: u64, bytes: u8) -> bool { + assert!(bytes <= 8); let Some(end_idx) = idx.checked_add(bytes.into()) else { return false; }; @@ -275,14 +277,19 @@ impl Memory { let end_idx = end_idx as usize; let buf = value.to_le_bytes(); self.buffer[idx..end_idx].copy_from_slice(&buf[..bytes.into()]); - self.dirty_indices.lock().insert(idx); - self.dirty_indices.lock().insert(end_idx - 1); + let mut dirty_leaves = self.dirty_leaves.lock(); + dirty_leaves.insert(idx / Self::LEAF_SIZE); + dirty_leaves.insert((end_idx - 1) / Self::LEAF_SIZE); true } #[must_use] + // Stores a slice in memory, returns false if the value would overflow the buffer. + // + // The length of value <= 32. pub fn store_slice_aligned(&mut self, idx: u64, value: &[u8]) -> bool { + assert!(value.len() <= Self::LEAF_SIZE); if idx % Self::LEAF_SIZE as u64 != 0 { return false; } @@ -295,7 +302,7 @@ impl Memory { let idx = idx as usize; let end_idx = end_idx as usize; self.buffer[idx..end_idx].copy_from_slice(value); - self.dirty_indices.lock().insert(idx); + self.dirty_leaves.lock().insert(idx / Self::LEAF_SIZE); true } @@ -338,7 +345,7 @@ impl Memory { pub fn resize(&mut self, new_size: usize) { self.buffer.resize(new_size, 0); - if let Some(merkle) = self.merkle.take() { + if let Some(merkle) = &mut self.merkle { merkle .resize(new_size / Self::LEAF_SIZE) .unwrap_or_else(|_| { @@ -348,7 +355,6 @@ impl Memory { new_size ) }); - self.merkle = Some(merkle); } } } From c58378a341ee1eca9273046174d742b6180e32a1 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 12:17:05 +0200 Subject: [PATCH 120/268] Add a test to confirm that all the zero hashes are what we expect. --- arbitrator/prover/src/memory.rs | 15 +++- arbitrator/prover/src/merkle.rs | 130 +++++++++++++++++++------------- 2 files changed, 91 insertions(+), 54 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 390d39db57..4aceee2c30 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -359,11 +359,23 @@ impl Memory { } } +pub mod testing { + use arbutil::Bytes32; + + pub fn empty_leaf_hash() -> Bytes32 { + let leaf = [0u8; 32]; + return super::hash_leaf(leaf); + } +} + #[cfg(test)] mod test { + use core::hash; + use arbutil::Bytes32; use crate::memory::round_up_to_power_of_two; + use crate::memory::testing; use super::Memory; @@ -379,8 +391,7 @@ mod test { #[test] pub fn empty_leaf_hash() { - let leaf = [0u8; 32]; - let hash = super::hash_leaf(leaf); + let hash = testing::empty_leaf_hash(); print!("Bytes32(["); for i in 0..32 { print!("{}", hash[i]); diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 1f5d611a0a..b2d9a15b62 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -39,7 +39,7 @@ use rayon::prelude::*; mod zerohashes; -use zerohashes::ZERO_HASHES; +use self::zerohashes::ZERO_HASHES; use self::zerohashes::EMPTY_HASH; @@ -514,62 +514,88 @@ fn resize_works() { assert_eq!(merkle.root(), expected); } -#[test] -fn correct_capacity() { - let merkle = Merkle::new(MerkleType::Value, vec![Bytes32::from([1; 32])]); - assert_eq!(merkle.capacity(), 1); - let merkle = Merkle::new_advanced(MerkleType::Memory, vec![Bytes32::from([1; 32])], 11); - assert_eq!(merkle.capacity(), 1024); -} +#[cfg(test)] +mod test { + use super::*; + use crate::memory; + use arbutil::Bytes32; + use enum_iterator::all; + + #[test] + fn correct_capacity() { + let merkle = Merkle::new(MerkleType::Value, vec![Bytes32::from([1; 32])]); + assert_eq!(merkle.capacity(), 1); + let merkle = Merkle::new_advanced(MerkleType::Memory, vec![Bytes32::from([1; 32])], 11); + assert_eq!(merkle.capacity(), 1024); + } -#[test] -#[ignore = "This is just used for generating the zero hashes for the memory merkle trees."] -fn emit_memory_zerohashes() { - // The following code was generated from the empty_leaf_hash() test in the memory package. - let mut empty_node = Bytes32([ - 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, 186, - 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, - ]) - .clone(); - for _ in 0..64 { - print!("Bytes32(["); - for i in 0..32 { - print!("{}", empty_node[i]); - if i < 31 { - print!(", "); + #[test] + #[ignore = "This is just used for generating the zero hashes for the memory merkle trees."] + fn emit_memory_zerohashes() { + // The following code was generated from the empty_leaf_hash() test in the memory package. + let mut empty_node = Bytes32([ + 57, 29, 211, 154, 252, 227, 18, 99, 65, 126, 203, 166, 252, 232, 32, 3, 98, 194, 254, + 186, 118, 14, 139, 192, 101, 156, 55, 194, 101, 11, 11, 168, + ]) + .clone(); + for _ in 0..64 { + print!("Bytes32(["); + for i in 0..32 { + print!("{}", empty_node[i]); + if i < 31 { + print!(", "); + } } + println!("]),"); + empty_node = hash_node(MerkleType::Memory, empty_node, empty_node); } - println!("]),"); - empty_node = hash_node(MerkleType::Memory, empty_node, empty_node); } -} -#[test] -fn clone_is_separate() { - let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); - let m2 = merkle.clone(); - m2.resize(4).expect("resize failed"); - m2.set(3, Bytes32::from([2; 32])); - assert_ne!(merkle, m2); -} + #[test] + fn clone_is_separate() { + let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); + let m2 = merkle.clone(); + m2.resize(4).expect("resize failed"); + m2.set(3, Bytes32::from([2; 32])); + assert_ne!(merkle, m2); + } -#[test] -fn serialization_roundtrip() { - let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); - merkle.resize(4).expect("resize failed"); - merkle.set(3, Bytes32::from([2; 32])); - let serialized = bincode::serialize(&merkle).unwrap(); - let deserialized: Merkle = bincode::deserialize(&serialized).unwrap(); - assert_eq!(merkle, deserialized); -} + #[test] + fn serialization_roundtrip() { + let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 4); + merkle.resize(4).expect("resize failed"); + merkle.set(3, Bytes32::from([2; 32])); + let serialized = bincode::serialize(&merkle).unwrap(); + let deserialized: Merkle = bincode::deserialize(&serialized).unwrap(); + assert_eq!(merkle, deserialized); + } -#[test] -#[should_panic(expected = "index out of bounds")] -fn set_with_bad_index_panics() { - let merkle = Merkle::new( - MerkleType::Value, - vec![Bytes32::default(), Bytes32::default()], - ); - assert_eq!(merkle.capacity(), 2); - merkle.set(2, Bytes32::default()); + #[test] + #[should_panic(expected = "index out of bounds")] + fn set_with_bad_index_panics() { + let merkle = Merkle::new( + MerkleType::Value, + vec![Bytes32::default(), Bytes32::default()], + ); + assert_eq!(merkle.capacity(), 2); + merkle.set(2, Bytes32::default()); + } + + #[test] + fn test_zero_hashes() { + for ty in all::() { + if ty == MerkleType::Empty { + continue; + } + let mut empty_hash = Bytes32::from([0; 32]); + if ty == MerkleType::Memory { + empty_hash = memory::testing::empty_leaf_hash(); + } + for layer in 0..64 { + // empty_hash_at is just a lookup, but empty_hash is calculated iteratively. + assert_eq!(empty_hash_at(ty, layer), &empty_hash); + empty_hash = hash_node(ty, &empty_hash, &empty_hash); + } + } + } } From afaef9708283ac20960215aaea30ca256c16b3d9 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 12:17:58 +0200 Subject: [PATCH 121/268] Remove accidental import --- arbitrator/prover/src/memory.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 4aceee2c30..dd4198f7b8 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -370,8 +370,6 @@ pub mod testing { #[cfg(test)] mod test { - use core::hash; - use arbutil::Bytes32; use crate::memory::round_up_to_power_of_two; From cc2a84dc4cdaa1dca4b810cf4de04485d70dd506 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 12:23:37 +0200 Subject: [PATCH 122/268] Organize imports better --- arbitrator/prover/src/merkle.rs | 38 +++++++++++---------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index b2d9a15b62..8db5084994 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -2,33 +2,14 @@ // For license information, see https://github.com/nitro/blob/master/LICENSE use arbutil::Bytes32; +use core::panic; use digest::Digest; - use enum_iterator::Sequence; - -use parking_lot::Mutex; - -#[cfg(feature = "counters")] -use enum_iterator::all; use itertools::Itertools; - -use std::cmp::max; - -#[cfg(feature = "counters")] -use std::sync::atomic::AtomicUsize; - -#[cfg(feature = "counters")] -use std::sync::atomic::Ordering; - -#[cfg(feature = "counters")] -use lazy_static::lazy_static; - -#[cfg(feature = "counters")] -use std::collections::HashMap; - -use core::panic; +use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use sha3::Keccak256; +use std::cmp::max; use std::{ collections::HashSet, convert::{TryFrom, TryInto}, @@ -38,10 +19,15 @@ use std::{ use rayon::prelude::*; mod zerohashes; - -use self::zerohashes::ZERO_HASHES; - -use self::zerohashes::EMPTY_HASH; +use self::zerohashes::{EMPTY_HASH, ZERO_HASHES}; +#[cfg(feature = "counters")] +use { + enum_iterator::all, + itertools::Itertools, + lazy_static::lazy_static, + std::collections::HashMap, + std::sync::atomic::{AtomicUsize, Ordering}, +}; #[cfg(feature = "counters")] macro_rules! init_counters { From 420f11615a9638f762fb027e5cae7f1d149b3e9e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 12:45:31 +0200 Subject: [PATCH 123/268] Fix up the counters feature There were a few bugs, and the code was sort of disorganized. --- arbitrator/prover/src/merkle.rs | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 8db5084994..d79a1e8324 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -23,36 +23,27 @@ use self::zerohashes::{EMPTY_HASH, ZERO_HASHES}; #[cfg(feature = "counters")] use { enum_iterator::all, - itertools::Itertools, lazy_static::lazy_static, std::collections::HashMap, std::sync::atomic::{AtomicUsize, Ordering}, }; #[cfg(feature = "counters")] -macro_rules! init_counters { - ($name:ident) => { - lazy_static! { - static ref $name: HashMap<&'static MerkleType, AtomicUsize> = { - let mut map = HashMap::new(); - $(map.insert(&MerkleType::$variant, AtomicUsize::new(0));)* - map - }; - } - }; +fn create_counters_hashmap() -> HashMap { + let mut map = HashMap::new(); + for ty in all::() { + map.insert(ty, AtomicUsize::new(0)); + } + map } #[cfg(feature = "counters")] -init_counters!(NEW_COUNTERS); - -#[cfg(feature = "counters")] -init_counters!(ROOT_COUNTERS); - -#[cfg(feature = "counters")] -init_counters!(SET_COUNTERS); - -#[cfg(feature = "counters")] -init_counters!(RESIZE_COUNTERS); +lazy_static! { + static ref NEW_COUNTERS: HashMap = create_counters_hashmap(); + static ref ROOT_COUNTERS: HashMap = create_counters_hashmap(); + static ref SET_COUNTERS: HashMap = create_counters_hashmap(); + static ref RESIZE_COUNTERS: HashMap = create_counters_hashmap(); +} #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Sequence)] pub enum MerkleType { From a7665f3989b1234d1dc48df1e95ec5a3137962a4 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 12:47:44 +0200 Subject: [PATCH 124/268] Use a &[Bytes32] instead of a Vec --- arbitrator/prover/src/merkle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index d79a1e8324..1bdb6df6db 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -160,7 +160,7 @@ const fn empty_hash_at(ty: MerkleType, layer_i: usize) -> &'static Bytes32 { #[inline] #[cfg(feature = "rayon")] -fn new_layer(ty: MerkleType, layer: &Vec, empty_hash: &'static Bytes32) -> Vec { +fn new_layer(ty: MerkleType, layer: &[Bytes32], empty_hash: &'static Bytes32) -> Vec { let mut new_layer: Vec = Vec::with_capacity(layer.len() >> 1); let chunks = layer.par_chunks(2); chunks From bb0b24b3abc40ffd44faadd4b054b7064dc31268 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 13:10:49 +0200 Subject: [PATCH 125/268] Change how depth is calculated This way uses integer math and is slightly more efficient. --- arbitrator/prover/src/merkle.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 1bdb6df6db..4e0ec8b0af 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -202,8 +202,11 @@ impl Merkle { if hashes.is_empty() && min_depth == 0 { return Merkle::default(); } - let mut depth = (hashes.len() as f64).log2().ceil() as usize; - depth = depth.max(min_depth); + let depth = if hashes.len() > 1 { + min_depth.max(((hashes.len() - 1).ilog2() + 1).try_into().unwrap()) + } else { + min_depth + }; let mut layers: Vec> = Vec::with_capacity(depth); layers.push(hashes); let mut dirty_indices: Vec> = Vec::with_capacity(depth); @@ -500,8 +503,15 @@ mod test { #[test] fn correct_capacity() { + let merkle: Merkle = Merkle::new(MerkleType::Value, vec![]); + assert_eq!(merkle.capacity(), 0); let merkle = Merkle::new(MerkleType::Value, vec![Bytes32::from([1; 32])]); assert_eq!(merkle.capacity(), 1); + let merkle = Merkle::new( + MerkleType::Value, + vec![Bytes32::from([1; 32]), Bytes32::from([2; 32])], + ); + assert_eq!(merkle.capacity(), 2); let merkle = Merkle::new_advanced(MerkleType::Memory, vec![Bytes32::from([1; 32])], 11); assert_eq!(merkle.capacity(), 1024); } From c35200763475e97e9efd5dcb0c38e21225c64f2e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 13:53:44 +0200 Subject: [PATCH 126/268] Assert that resizing from 5 to 6 doesn't change the root hash Because the merkle tree still has a capacity of 8, and we haven't changed the value of any of the leaves, the root hash should still be the same. --- arbitrator/prover/src/merkle.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 4e0ec8b0af..8d1f8596f6 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -461,6 +461,8 @@ fn resize_works() { Err(e) => panic!("{}", e), }; assert_eq!(new_size, 6); + assert_eq!(merkle.root(), expected); + merkle.set(5, Bytes32::from([6; 32])); expected = hash_node( MerkleType::Value, From 899f8c33b05e9f170029429be51a294b2cd2b5bc Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 13:56:26 +0200 Subject: [PATCH 127/268] Remove a doulbe-lock on a Mutex --- arbitrator/prover/src/merkle.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 8d1f8596f6..d5f31c6ed2 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -304,8 +304,11 @@ impl Merkle { #[must_use] pub fn prove(&self, idx: usize) -> Option> { - if self.layers.lock().data.is_empty() || idx >= self.layers.lock().data[0].len() { - return None; + { + let layers = self.layers.lock(); + if layers.data.is_empty() || idx >= layers.data[0].len() { + return None; + } } Some(self.prove_any(idx)) } From 04b42bdc87a6da7ad780ad8999c7d86f05f44e2b Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 13:58:40 +0200 Subject: [PATCH 128/268] Use a more efficient calculation of capacity. --- arbitrator/prover/src/merkle.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index d5f31c6ed2..10505b30aa 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -288,8 +288,7 @@ impl Merkle { if layers.data.is_empty() { return 0; } - let base: usize = 2; - base.pow((layers.data.len() - 1).try_into().unwrap()) + 1 << (layers.data.len() - 1) } // Returns the number of leaves in the tree. From 56f248ba51a11f31c9e6f6aa118d19ac4023b8b2 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 14:02:17 +0200 Subject: [PATCH 129/268] Add an assertion on index being equal to length This should always be the case because the dirt is cleaned up in order. But, this asserttion can catch it if we get it wrong. --- arbitrator/prover/src/merkle.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 10505b30aa..13ed1a6936 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -258,6 +258,7 @@ impl Merkle { layers.data[layer_i][*idx] = new_hash; } else { // Push the new parent hash onto the end of the layer. + assert_eq!(*idx, layers.data[layer_i].len()); layers.data[layer_i].push(new_hash); } // Mark the node's parent as dirty unless it's the root. From 981158be5718de97a2092663086a2078f3b16bdb Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 14:13:37 +0200 Subject: [PATCH 130/268] Explain why comparing root hashes is the right implementation of equals --- arbitrator/prover/src/merkle.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 13ed1a6936..33e6c01e13 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -390,6 +390,19 @@ impl Merkle { } impl PartialEq for Merkle { + // There are only three members of a Merkle, the type, the layers, and the min_depth. + // + // It should be obvious that only if the type and layers are equal, will the root hash + // be equal. So, it is sufficient to compare the root hash when checking equality. + // + // However, it is possible that the min_depth may differ between two merkle trees which + // have the same type and layers. The root hash will still be equal unless the min_depth + // is larger than the depth required to hold the data in the layers. + // + // For example, a Merkle tree with 5 leaves requires 3 layeers to hold the data. If the + // min_depth is 1 on one tree and 2 on another, the root has would still be equal + // because the same nodes are hashed together. However, the min_dpeth was 4, then, + // there would be 4 layers in that tree, and the root hash would be different. fn eq(&self, other: &Self) -> bool { self.root() == other.root() } From 195a009e52c9a529335edc4c907d9b0b86c3aada Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 16:24:50 +0200 Subject: [PATCH 131/268] Switch to layers.len() - 1 during constuction Keeping track of the layers_i wasn't really making the code easier to read. --- arbitrator/prover/src/merkle.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 33e6c01e13..7eb9dfe645 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -210,15 +210,13 @@ impl Merkle { let mut layers: Vec> = Vec::with_capacity(depth); layers.push(hashes); let mut dirty_indices: Vec> = Vec::with_capacity(depth); - let mut layer_i = 0usize; while layers.last().unwrap().len() > 1 || layers.len() < min_depth { let layer = layers.last().unwrap(); - let empty_hash = empty_hash_at(ty, layer_i); + let empty_hash = empty_hash_at(ty, layers.len() - 1); let new_layer = new_layer(ty, layer, empty_hash); dirty_indices.push(HashSet::with_capacity(new_layer.len())); layers.push(new_layer); - layer_i += 1; } let layers = Mutex::new(Layers { data: layers, From 8cc3728be0d198a49b6dd839d1c9d590bceaf667 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Thu, 18 Jul 2024 16:52:44 +0200 Subject: [PATCH 132/268] Add keysetHash to "Couldn't get keyset" log msg --- arbstate/daprovider/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbstate/daprovider/util.go b/arbstate/daprovider/util.go index 8f880b9228..48cec884a3 100644 --- a/arbstate/daprovider/util.go +++ b/arbstate/daprovider/util.go @@ -188,7 +188,7 @@ func RecoverPayloadFromDasBatch( keysetPreimage, err := keysetFetcher.GetKeysetByHash(ctx, cert.KeysetHash) if err != nil { - log.Error("Couldn't get keyset", "err", err) + log.Error("Couldn't get keyset", "err", err, "keysetHash", common.Bytes2Hex(cert.KeysetHash[:])) return nil, err } if preimageRecorder != nil { From 0a890a92cc8922a4484c4253a76381d68708aeb7 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 17:08:40 +0200 Subject: [PATCH 133/268] Only track the dirt for the leaves' parents on the heap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the code a little cleaner, and it performs the same or slightly better. Before: ``` Running benchmark with always merkleize feature on avg hash time 226.487µs, avg step time 226ns, step size 1, num_iters 200, total time 45.356958ms avg hash time 285.669µs, avg step time 3.454µs, step size 1024, num_iters 200, total time 57.836958ms avg hash time 673.086µs, avg step time 141.763µs, step size 32768, num_iters 200, total time 162.983ms avg hash time 800.159µs, avg step time 3.333175ms, step size 1048576, num_iters 200, total time 826.676667ms avg hash time 2.394079ms, avg step time 54.744735ms, step size 16777216, num_iters 134, total time 7.711356917s avg hash time 6.981576ms, avg step time 221.284475ms, step size 67108864, num_iters 33, total time 7.754069s avg hash time 23.845249ms, avg step time 826.907254ms, step size 268435456, num_iters 8, total time 7.632934667s ``` After: ``` Running benchmark with always merkleize feature on avg hash time 223.077µs, avg step time 196ns, step size 1, num_iters 200, total time 44.670042ms avg hash time 283.239µs, avg step time 4.477µs, step size 1024, num_iters 200, total time 57.556875ms avg hash time 631.034µs, avg step time 139.475µs, step size 32768, num_iters 200, total time 154.115083ms avg hash time 813.914µs, avg step time 3.357342ms, step size 1048576, num_iters 200, total time 834.265ms avg hash time 2.39359ms, avg step time 55.253016ms, step size 16777216, num_iters 134, total time 7.779911875s avg hash time 6.768607ms, avg step time 222.297451ms, step size 67108864, num_iters 33, total time 7.781483917s avg hash time 25.057057ms, avg step time 840.610754ms, step size 268435456, num_iters 8, total time 7.765957833s ``` --- arbitrator/prover/src/merkle.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 7eb9dfe645..36ccadd0be 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -111,7 +111,7 @@ impl MerkleType { #[derive(Debug, Clone, Default, Serialize, Deserialize)] struct Layers { data: Vec>, - dirt: Vec>, + dirty_leaf_parents: HashSet, } /// A Merkle tree with a fixed number of layers @@ -208,19 +208,18 @@ impl Merkle { min_depth }; let mut layers: Vec> = Vec::with_capacity(depth); + let dirty_leaf_parents = HashSet::with_capacity(hashes.len() / 2); layers.push(hashes); - let mut dirty_indices: Vec> = Vec::with_capacity(depth); while layers.last().unwrap().len() > 1 || layers.len() < min_depth { let layer = layers.last().unwrap(); let empty_hash = empty_hash_at(ty, layers.len() - 1); let new_layer = new_layer(ty, layer, empty_hash); - dirty_indices.push(HashSet::with_capacity(new_layer.len())); layers.push(new_layer); } let layers = Mutex::new(Layers { data: layers, - dirt: dirty_indices, + dirty_leaf_parents, }); Merkle { ty, @@ -231,14 +230,14 @@ impl Merkle { fn rehash(&self, layers: &mut Layers) { // If nothing is dirty, then there's no need to rehash. - if layers.dirt.is_empty() || layers.dirt[0].is_empty() { + if layers.dirty_leaf_parents.is_empty() { return; } + // Consume the leaf parents dirty indices. + let mut dirt = std::mem::take(&mut layers.dirty_leaf_parents); // Process dirty indices starting from layer 1 (layer 0 is the leaves). for layer_i in 1..layers.data.len() { - let dirty_i = layer_i - 1; - // Consume this layer's dirty indices. - let dirt = std::mem::take(&mut layers.dirt[dirty_i]); + let mut new_dirt = HashSet::with_capacity(dirt.len() / 2); // It is important to process the dirty indices in order because // when the leaves grown since the last rehash, the new parent is // simply pused to the end of the layer's data. @@ -261,9 +260,10 @@ impl Merkle { } // Mark the node's parent as dirty unless it's the root. if layer_i < layers.data.len() - 1 { - layers.dirt[dirty_i + 1].insert(idx >> 1); + new_dirt.insert(idx >> 1); } } + dirt = new_dirt; } } @@ -359,7 +359,7 @@ impl Merkle { return; } layers.data[0][idx] = hash; - layers.dirt[0].insert(idx >> 1); + layers.dirty_leaf_parents.insert(idx >> 1); } /// Resizes the number of leaves the tree can hold. @@ -381,7 +381,7 @@ impl Merkle { } let start = layers.data[0].len(); for i in start..new_len { - layers.dirt[0].insert(i); + layers.dirty_leaf_parents.insert(i); } Ok(layers.data[0].len()) } From 613e9dd8aec1702bd14d51ad31af8e4f1d3ddd7f Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 22:42:42 +0200 Subject: [PATCH 134/268] Use bitvec instead of HashMap for dirty indices This commit also caught an error in the logic of the resize() impleentation, and fixes it. --- arbitrator/Cargo.lock | 2 + arbitrator/prover/Cargo.toml | 1 + arbitrator/prover/src/merkle.rs | 191 +++++++++++++++++--------------- 3 files changed, 102 insertions(+), 92 deletions(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 5175b6b609..01774c0c4d 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -247,6 +247,7 @@ checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", "radium", + "serde", "tap", "wyz", ] @@ -1721,6 +1722,7 @@ version = "0.1.0" dependencies = [ "arbutil", "bincode", + "bitvec", "brotli", "c-kzg", "criterion", diff --git a/arbitrator/prover/Cargo.toml b/arbitrator/prover/Cargo.toml index a55c86695e..5475647765 100644 --- a/arbitrator/prover/Cargo.toml +++ b/arbitrator/prover/Cargo.toml @@ -8,6 +8,7 @@ publish = false bincode = "1.3.3" derivative = "2.2.0" digest = "0.9.0" +bitvec = { version = "1", features = ["serde"] } eyre = "0.6.5" fnv = "1.0.7" hex = "0.4.3" diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 36ccadd0be..232ac78d87 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -2,18 +2,15 @@ // For license information, see https://github.com/nitro/blob/master/LICENSE use arbutil::Bytes32; +use bitvec::prelude::*; use core::panic; use digest::Digest; use enum_iterator::Sequence; -use itertools::Itertools; use parking_lot::Mutex; use serde::{Deserialize, Serialize}; use sha3::Keccak256; use std::cmp::max; -use std::{ - collections::HashSet, - convert::{TryFrom, TryInto}, -}; +use std::convert::{TryFrom, TryInto}; #[cfg(feature = "rayon")] use rayon::prelude::*; @@ -111,7 +108,7 @@ impl MerkleType { #[derive(Debug, Clone, Default, Serialize, Deserialize)] struct Layers { data: Vec>, - dirty_leaf_parents: HashSet, + dirty_leaf_parents: BitVec, } /// A Merkle tree with a fixed number of layers @@ -208,7 +205,7 @@ impl Merkle { min_depth }; let mut layers: Vec> = Vec::with_capacity(depth); - let dirty_leaf_parents = HashSet::with_capacity(hashes.len() / 2); + let dirty_leaf_parents = bitvec![0; hashes.len() + 1 >> 1]; layers.push(hashes); while layers.last().unwrap().len() > 1 || layers.len() < min_depth { let layer = layers.last().unwrap(); @@ -233,15 +230,18 @@ impl Merkle { if layers.dirty_leaf_parents.is_empty() { return; } - // Consume the leaf parents dirty indices. - let mut dirt = std::mem::take(&mut layers.dirty_leaf_parents); + // Replace the dirty leaf parents with clean ones. + let mut dirt = std::mem::replace( + &mut layers.dirty_leaf_parents, + bitvec![0; (layers.data[0].len() + 1) >> 1], + ); // Process dirty indices starting from layer 1 (layer 0 is the leaves). for layer_i in 1..layers.data.len() { - let mut new_dirt = HashSet::with_capacity(dirt.len() / 2); + let mut new_dirt = bitvec![0; dirt.len() + 1 >> 1]; // It is important to process the dirty indices in order because // when the leaves grown since the last rehash, the new parent is // simply pused to the end of the layer's data. - for idx in dirt.iter().sorted() { + for idx in dirt.iter_ones() { let left_child_idx = idx << 1; let right_child_idx = left_child_idx + 1; // The left child is guaranteed to exist, but the right one @@ -251,16 +251,16 @@ impl Merkle { .get(right_child_idx) .unwrap_or(empty_hash_at(self.ty, layer_i - 1)); let new_hash = hash_node(self.ty, left, right); - if *idx < layers.data[layer_i].len() { - layers.data[layer_i][*idx] = new_hash; + if idx < layers.data[layer_i].len() { + layers.data[layer_i][idx] = new_hash; } else { // Push the new parent hash onto the end of the layer. - assert_eq!(*idx, layers.data[layer_i].len()); + assert_eq!(idx, layers.data[layer_i].len()); layers.data[layer_i].push(new_hash); } // Mark the node's parent as dirty unless it's the root. if layer_i < layers.data.len() - 1 { - new_dirt.insert(idx >> 1); + new_dirt.set(idx >> 1, true); } } dirt = new_dirt; @@ -359,7 +359,7 @@ impl Merkle { return; } layers.data[0][idx] = hash; - layers.dirty_leaf_parents.insert(idx >> 1); + layers.dirty_leaf_parents.set(idx >> 1, true); } /// Resizes the number of leaves the tree can hold. @@ -374,14 +374,20 @@ impl Merkle { ); } let mut layers = self.layers.lock(); + let start = layers.data[0].len(); let mut layer_size = new_len; for (layer_i, layer) in layers.data.iter_mut().enumerate() { layer.resize(layer_size, *empty_hash_at(self.ty, layer_i)); layer_size = max(layer_size >> 1, 1); } - let start = layers.data[0].len(); for i in start..new_len { - layers.dirty_leaf_parents.insert(i); + let parent_i = i >> 1; + assert!(parent_i <= layers.dirty_leaf_parents.len()); + if parent_i == layers.dirty_leaf_parents.len() { + layers.dirty_leaf_parents.push(true); + } else if parent_i < layers.dirty_leaf_parents.len() { + layers.dirty_leaf_parents.set(parent_i, true); + } } Ok(layers.data[0].len()) } @@ -428,94 +434,95 @@ pub mod mutex_sedre { } } -#[test] -fn resize_works() { - let hashes = vec![ - Bytes32::from([1; 32]), - Bytes32::from([2; 32]), - Bytes32::from([3; 32]), - Bytes32::from([4; 32]), - Bytes32::from([5; 32]), - ]; - let mut expected = hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - Bytes32::from([1; 32]), - Bytes32::from([2; 32]), - ), - hash_node( - MerkleType::Value, - Bytes32::from([3; 32]), - Bytes32::from([4; 32]), - ), - ), - hash_node( - MerkleType::Value, - hash_node( - MerkleType::Value, - Bytes32::from([5; 32]), - Bytes32::from([0; 32]), - ), - hash_node( - MerkleType::Value, - Bytes32::from([0; 32]), - Bytes32::from([0; 32]), - ), - ), - ); - let merkle = Merkle::new(MerkleType::Value, hashes.clone()); - assert_eq!(merkle.capacity(), 8); - assert_eq!(merkle.root(), expected); - - let new_size = match merkle.resize(6) { - Ok(size) => size, - Err(e) => panic!("{}", e), - }; - assert_eq!(new_size, 6); - assert_eq!(merkle.root(), expected); - - merkle.set(5, Bytes32::from([6; 32])); - expected = hash_node( - MerkleType::Value, - hash_node( +#[cfg(test)] +mod test { + use super::*; + use crate::memory; + use arbutil::Bytes32; + use core::panic; + use enum_iterator::all; + + #[test] + fn resize_works() { + let hashes = vec![ + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + Bytes32::from([5; 32]), + ]; + let mut expected = hash_node( MerkleType::Value, hash_node( MerkleType::Value, - Bytes32::from([1; 32]), - Bytes32::from([2; 32]), + hash_node( + MerkleType::Value, + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + ), ), hash_node( MerkleType::Value, - Bytes32::from([3; 32]), - Bytes32::from([4; 32]), + hash_node( + MerkleType::Value, + Bytes32::from([5; 32]), + Bytes32::from([0; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([0; 32]), + Bytes32::from([0; 32]), + ), ), - ), - hash_node( + ); + let merkle = Merkle::new(MerkleType::Value, hashes.clone()); + assert_eq!(merkle.capacity(), 8); + assert_eq!(merkle.root(), expected); + + let new_size = match merkle.resize(6) { + Ok(size) => size, + Err(e) => panic!("{}", e), + }; + assert_eq!(new_size, 6); + assert_eq!(merkle.root(), expected); + + merkle.set(5, Bytes32::from([6; 32])); + expected = hash_node( MerkleType::Value, hash_node( MerkleType::Value, - Bytes32::from([5; 32]), - Bytes32::from([6; 32]), + hash_node( + MerkleType::Value, + Bytes32::from([1; 32]), + Bytes32::from([2; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([3; 32]), + Bytes32::from([4; 32]), + ), ), hash_node( MerkleType::Value, - Bytes32::from([0; 32]), - Bytes32::from([0; 32]), + hash_node( + MerkleType::Value, + Bytes32::from([5; 32]), + Bytes32::from([6; 32]), + ), + hash_node( + MerkleType::Value, + Bytes32::from([0; 32]), + Bytes32::from([0; 32]), + ), ), - ), - ); - assert_eq!(merkle.root(), expected); -} - -#[cfg(test)] -mod test { - use super::*; - use crate::memory; - use arbutil::Bytes32; - use enum_iterator::all; + ); + assert_eq!(merkle.root(), expected); + } #[test] fn correct_capacity() { From 4ddf81f5420860ad21bbad77840ac6a3daf100fe Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 18 Jul 2024 22:46:58 +0200 Subject: [PATCH 135/268] Remove obsolete code comment --- arbitrator/prover/src/merkle.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 232ac78d87..a3b063786f 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -238,9 +238,6 @@ impl Merkle { // Process dirty indices starting from layer 1 (layer 0 is the leaves). for layer_i in 1..layers.data.len() { let mut new_dirt = bitvec![0; dirt.len() + 1 >> 1]; - // It is important to process the dirty indices in order because - // when the leaves grown since the last rehash, the new parent is - // simply pused to the end of the layer's data. for idx in dirt.iter_ones() { let left_child_idx = idx << 1; let right_child_idx = left_child_idx + 1; From 52df895e99c0988a6cadb879ddd271bcb8bb93f7 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Thu, 18 Jul 2024 17:50:14 -0600 Subject: [PATCH 136/268] validation spawner only recieves one validation binary --- staker/block_validator.go | 12 +++---- staker/challenge_manager.go | 2 +- staker/stateless_block_validator.go | 32 ++++++++++++++----- system_tests/validation_mock_test.go | 4 +++ validator/client/redis/producer.go | 8 +++++ validator/client/validation_client.go | 25 +++++++++++++-- validator/interface.go | 1 + validator/server_api/json.go | 38 ++++++++++------------- validator/server_arb/validator_spawner.go | 11 +++++-- validator/server_jit/jit_machine.go | 8 +++-- validator/server_jit/spawner.go | 4 +++ validator/validation_entry.go | 4 +-- validator/valnode/validation_api.go | 4 +++ 13 files changed, 107 insertions(+), 46 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index bfb7c24ac6..04851b700f 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -468,7 +468,7 @@ func (v *BlockValidator) sendRecord(s *validationStatus) error { //nolint:gosec func (v *BlockValidator) writeToFile(validationEntry *validationEntry, moduleRoot common.Hash) error { - input, err := validationEntry.ToInput() + input, err := validationEntry.ToInput("wavm") if err != nil { return err } @@ -807,11 +807,6 @@ validationsLoop: return nil, nil } if currentStatus == Prepared { - input, err := validationStatus.Entry.ToInput() - if err != nil && ctx.Err() == nil { - v.possiblyFatal(fmt.Errorf("%w: error preparing validation", err)) - continue - } replaced := validationStatus.replaceStatus(Prepared, SendingValidation) if !replaced { v.possiblyFatal(errors.New("failed to set SendingValidation status")) @@ -819,6 +814,11 @@ validationsLoop: validatorPendingValidationsGauge.Inc(1) var runs []validator.ValidationRun for _, moduleRoot := range wasmRoots { + input, err := validationStatus.Entry.ToInput(v.chosenValidator[moduleRoot].StylusArch()) + if err != nil && ctx.Err() == nil { + v.possiblyFatal(fmt.Errorf("%w: error preparing validation", err)) + continue + } run := v.chosenValidator[moduleRoot].Launch(input, moduleRoot) log.Trace("advanceValidations: launched", "pos", validationStatus.Entry.Pos, "moduleRoot", moduleRoot) runs = append(runs, run) diff --git a/staker/challenge_manager.go b/staker/challenge_manager.go index 22897e3c1d..f50b85064c 100644 --- a/staker/challenge_manager.go +++ b/staker/challenge_manager.go @@ -467,7 +467,7 @@ func (m *ChallengeManager) createExecutionBackend(ctx context.Context, step uint if err != nil { return fmt.Errorf("error creating validation entry for challenge %v msg %v for execution challenge: %w", m.challengeIndex, initialCount, err) } - input, err := entry.ToInput() + input, err := entry.ToInput("wavm") if err != nil { return fmt.Errorf("error getting validation entry input of challenge %v msg %v: %w", m.challengeIndex, initialCount, err) } diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index ec235c4bf5..7daa1ab872 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "net/url" + "runtime" "testing" "github.com/offchainlabs/nitro/arbstate/daprovider" @@ -134,21 +135,32 @@ type validationEntry struct { DelayedMsg []byte } -func (e *validationEntry) ToInput() (*validator.ValidationInput, error) { +func (e *validationEntry) ToInput(stylusArch string) (*validator.ValidationInput, error) { if e.Stage != Ready { return nil, errors.New("cannot create input from non-ready entry") } - return &validator.ValidationInput{ + res := validator.ValidationInput{ Id: uint64(e.Pos), HasDelayedMsg: e.HasDelayedMsg, DelayedMsgNr: e.DelayedMsgNr, Preimages: e.Preimages, - UserWasms: e.UserWasms, + StylusArch: stylusArch, + UserWasms: make(map[common.Hash][]byte, len(e.UserWasms)), BatchInfo: e.BatchInfo, DelayedMsg: e.DelayedMsg, StartState: e.Start, DebugChain: e.ChainConfig.DebugMode(), - }, nil + } + for hash, info := range e.UserWasms { + if stylusArch == "wavm" { + res.UserWasms[hash] = info.Module + } else if stylusArch == runtime.GOARCH { + res.UserWasms[hash] = info.Asm + } else { + return nil, fmt.Errorf("stylusArch not supported by block validator: %v", stylusArch) + } + } + return &res, nil } func newValidationEntry( @@ -373,14 +385,14 @@ func (v *StatelessBlockValidator) ValidateResult( if err != nil { return false, nil, err } - input, err := entry.ToInput() - if err != nil { - return false, nil, err - } var run validator.ValidationRun if !useExec { if v.redisValidator != nil { if validator.SpawnerSupportsModule(v.redisValidator, moduleRoot) { + input, err := entry.ToInput(v.redisValidator.StylusArch()) + if err != nil { + return false, nil, err + } run = v.redisValidator.Launch(input, moduleRoot) } } @@ -388,6 +400,10 @@ func (v *StatelessBlockValidator) ValidateResult( if run == nil { for _, spawner := range v.execSpawners { if validator.SpawnerSupportsModule(spawner, moduleRoot) { + input, err := entry.ToInput(spawner.StylusArch()) + if err != nil { + return false, nil, err + } run = spawner.Launch(input, moduleRoot) break } diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index 1330f24882..a1d9f314cc 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -60,6 +60,10 @@ func (s *mockSpawner) WasmModuleRoots() ([]common.Hash, error) { return mockWasmModuleRoots, nil } +func (s *mockSpawner) StylusArch() string { + return "mock" +} + func (s *mockSpawner) Launch(entry *validator.ValidationInput, moduleRoot common.Hash) validator.ValidationRun { run := &mockValRun{ Promise: containers.NewPromise[validator.GoGlobalState](nil), diff --git a/validator/client/redis/producer.go b/validator/client/redis/producer.go index 0adedc6784..4a81ae1fdf 100644 --- a/validator/client/redis/producer.go +++ b/validator/client/redis/producer.go @@ -23,6 +23,7 @@ type ValidationClientConfig struct { StreamPrefix string `koanf:"stream-prefix"` Room int32 `koanf:"room"` RedisURL string `koanf:"redis-url"` + StylusArch string `koanf:"stylus-arch"` ProducerConfig pubsub.ProducerConfig `koanf:"producer-config"` CreateStreams bool `koanf:"create-streams"` } @@ -35,6 +36,7 @@ var DefaultValidationClientConfig = ValidationClientConfig{ Name: "redis validation client", Room: 2, RedisURL: "", + StylusArch: "wavm", ProducerConfig: pubsub.DefaultProducerConfig, CreateStreams: true, } @@ -44,6 +46,7 @@ var TestValidationClientConfig = ValidationClientConfig{ Room: 2, RedisURL: "", StreamPrefix: "test-", + StylusArch: "wavm", ProducerConfig: pubsub.TestProducerConfig, CreateStreams: false, } @@ -53,6 +56,7 @@ func ValidationClientConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Int32(prefix+".room", DefaultValidationClientConfig.Room, "validation client room") f.String(prefix+".redis-url", DefaultValidationClientConfig.RedisURL, "redis url") f.String(prefix+".stream-prefix", DefaultValidationClientConfig.StreamPrefix, "prefix for stream name") + f.String(prefix+".stylus-arch", DefaultValidationClientConfig.StylusArch, "arch for stylus workers") pubsub.ProducerAddConfigAddOptions(prefix+".producer-config", f) f.Bool(prefix+".create-streams", DefaultValidationClientConfig.CreateStreams, "create redis streams if it does not exist") } @@ -148,6 +152,10 @@ func (c *ValidationClient) Name() string { return c.config.Name } +func (c *ValidationClient) StylusArch() string { + return c.config.StylusArch +} + func (c *ValidationClient) Room() int { return int(c.room.Load()) } diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index 79ecc6bdf4..610f3eb01f 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -8,6 +8,7 @@ import ( "encoding/base64" "errors" "fmt" + "runtime" "sync/atomic" "time" @@ -29,13 +30,16 @@ type ValidationClient struct { stopwaiter.StopWaiter client *rpcclient.RpcClient name string + stylusArch string room atomic.Int32 wasmModuleRoots []common.Hash } func NewValidationClient(config rpcclient.ClientConfigFetcher, stack *node.Node) *ValidationClient { return &ValidationClient{ - client: rpcclient.NewRpcClient(config, stack), + client: rpcclient.NewRpcClient(config, stack), + name: "not started", + stylusArch: "not started", } } @@ -64,15 +68,22 @@ func (c *ValidationClient) Start(ctx_in context.Context) error { if len(name) == 0 { return errors.New("couldn't read name from server") } + var stylusArch string + if err := c.client.CallContext(ctx, &stylusArch, server_api.Namespace+"_stylusArch"); err != nil { + return err + } + if stylusArch != "wavm" && stylusArch != runtime.GOARCH && stylusArch != "mock" { + return fmt.Errorf("unsupported stylus architecture: %v", stylusArch) + } var moduleRoots []common.Hash - if err := c.client.CallContext(c.GetContext(), &moduleRoots, server_api.Namespace+"_wasmModuleRoots"); err != nil { + if err := c.client.CallContext(ctx, &moduleRoots, server_api.Namespace+"_wasmModuleRoots"); err != nil { return err } if len(moduleRoots) == 0 { return fmt.Errorf("server reported no wasmModuleRoots") } var room int - if err := c.client.CallContext(c.GetContext(), &room, server_api.Namespace+"_room"); err != nil { + if err := c.client.CallContext(ctx, &room, server_api.Namespace+"_room"); err != nil { return err } if room < 2 { @@ -84,6 +95,7 @@ func (c *ValidationClient) Start(ctx_in context.Context) error { c.room.Store(int32(room)) c.wasmModuleRoots = moduleRoots c.name = name + c.stylusArch = stylusArch return nil } @@ -94,6 +106,13 @@ func (c *ValidationClient) WasmModuleRoots() ([]common.Hash, error) { return nil, errors.New("not started") } +func (c *ValidationClient) StylusArch() string { + if c.Started() { + return c.stylusArch + } + return "not started" +} + func (c *ValidationClient) Stop() { c.StopWaiter.StopOnly() if c.client != nil { diff --git a/validator/interface.go b/validator/interface.go index 91668a3771..d59e94c4a0 100644 --- a/validator/interface.go +++ b/validator/interface.go @@ -13,6 +13,7 @@ type ValidationSpawner interface { Start(context.Context) error Stop() Name() string + StylusArch() string Room() int } diff --git a/validator/server_api/json.go b/validator/server_api/json.go index dd646e1aa1..5de6999ef1 100644 --- a/validator/server_api/json.go +++ b/validator/server_api/json.go @@ -10,7 +10,7 @@ import ( "os" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/state" + "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/jsonapi" @@ -62,7 +62,8 @@ type InputJSON struct { BatchInfo []BatchInfoJson DelayedMsgB64 string StartState validator.GoGlobalState - UserWasms map[common.Hash]UserWasmJson + StylusArch string + UserWasms map[common.Hash]string DebugChain bool } @@ -77,11 +78,6 @@ func (i *InputJSON) WriteToFile() error { return nil } -type UserWasmJson struct { - Module string - Asm string -} - type BatchInfoJson struct { Number uint64 DataB64 string @@ -99,19 +95,20 @@ func ValidationInputToJson(entry *validator.ValidationInput) *InputJSON { DelayedMsgB64: base64.StdEncoding.EncodeToString(entry.DelayedMsg), StartState: entry.StartState, PreimagesB64: jsonPreimagesMap, - UserWasms: make(map[common.Hash]UserWasmJson), + UserWasms: make(map[common.Hash]string), + StylusArch: entry.StylusArch, DebugChain: entry.DebugChain, } for _, binfo := range entry.BatchInfo { encData := base64.StdEncoding.EncodeToString(binfo.Data) res.BatchInfo = append(res.BatchInfo, BatchInfoJson{Number: binfo.Number, DataB64: encData}) } - for moduleHash, info := range entry.UserWasms { - encWasm := UserWasmJson{ - Asm: base64.StdEncoding.EncodeToString(info.Asm), - Module: base64.StdEncoding.EncodeToString(info.Module), + for moduleHash, data := range entry.UserWasms { + compressed, err := arbcompress.CompressWell(data) + if err != nil { + entry.StylusArch = "compressError:" + err.Error() } - res.UserWasms[moduleHash] = encWasm + res.UserWasms[moduleHash] = base64.StdEncoding.EncodeToString(compressed) } return res } @@ -127,7 +124,8 @@ func ValidationInputFromJson(entry *InputJSON) (*validator.ValidationInput, erro DelayedMsgNr: entry.DelayedMsgNr, StartState: entry.StartState, Preimages: preimages, - UserWasms: make(state.UserWasms), + StylusArch: entry.StylusArch, + UserWasms: make(map[common.Hash][]byte), DebugChain: entry.DebugChain, } delayed, err := base64.StdEncoding.DecodeString(entry.DelayedMsgB64) @@ -146,20 +144,16 @@ func ValidationInputFromJson(entry *InputJSON) (*validator.ValidationInput, erro } valInput.BatchInfo = append(valInput.BatchInfo, decInfo) } - for moduleHash, info := range entry.UserWasms { - asm, err := base64.StdEncoding.DecodeString(info.Asm) + for moduleHash, encoded := range entry.UserWasms { + decoded, err := base64.StdEncoding.DecodeString(encoded) if err != nil { return nil, err } - module, err := base64.StdEncoding.DecodeString(info.Module) + uncompressed, err := arbcompress.Decompress(decoded, 30000000) if err != nil { return nil, err } - decInfo := state.ActivatedWasm{ - Asm: asm, - Module: module, - } - valInput.UserWasms[moduleHash] = decInfo + valInput.UserWasms[moduleHash] = uncompressed } return valInput, nil } diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 7b9293f7bd..73549af3ec 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -88,6 +88,10 @@ func (s *ArbitratorSpawner) WasmModuleRoots() ([]common.Hash, error) { return s.locator.ModuleRoots(), nil } +func (s *ArbitratorSpawner) StylusArch() string { + return "wavm" +} + func (s *ArbitratorSpawner) Name() string { return "arbitrator" } @@ -118,8 +122,11 @@ func (v *ArbitratorSpawner) loadEntryToMachine(ctx context.Context, entry *valid return fmt.Errorf("error while trying to add sequencer msg for proving: %w", err) } } - for moduleHash, info := range entry.UserWasms { - err = mach.AddUserWasm(moduleHash, info.Module) + if entry.StylusArch != "wavm" { + return fmt.Errorf("bad stylus arch loaded to machine. Expected wavm. Got: %s", entry.StylusArch) + } + for moduleHash, module := range entry.UserWasms { + err = mach.AddUserWasm(moduleHash, module) if err != nil { log.Error( "error adding user wasm for proving", diff --git a/validator/server_jit/jit_machine.go b/validator/server_jit/jit_machine.go index 1a3ccfa340..3a27c64e21 100644 --- a/validator/server_jit/jit_machine.go +++ b/validator/server_jit/jit_machine.go @@ -12,6 +12,7 @@ import ( "net" "os" "os/exec" + "runtime" "time" "github.com/ethereum/go-ethereum/common" @@ -212,15 +213,18 @@ func (machine *JitMachine) prove( } // send user wasms + if entry.StylusArch != runtime.GOARCH { + return state, fmt.Errorf("bad stylus arch for validation input. got: %v, expected: %v", entry.StylusArch, runtime.GOARCH) + } userWasms := entry.UserWasms if err := writeUint32(uint32(len(userWasms))); err != nil { return state, err } - for moduleHash, info := range userWasms { + for moduleHash, program := range userWasms { if err := writeExact(moduleHash[:]); err != nil { return state, err } - if err := writeBytes(info.Asm); err != nil { + if err := writeBytes(program); err != nil { return state, err } } diff --git a/validator/server_jit/spawner.go b/validator/server_jit/spawner.go index eda74b2911..dd9f3bbfc1 100644 --- a/validator/server_jit/spawner.go +++ b/validator/server_jit/spawner.go @@ -71,6 +71,10 @@ func (v *JitSpawner) WasmModuleRoots() ([]common.Hash, error) { return v.locator.ModuleRoots(), nil } +func (v *JitSpawner) StylusArch() string { + return runtime.GOARCH +} + func (v *JitSpawner) execute( ctx context.Context, entry *validator.ValidationInput, moduleRoot common.Hash, ) (validator.GoGlobalState, error) { diff --git a/validator/validation_entry.go b/validator/validation_entry.go index 446f84ca62..3c0f28eb37 100644 --- a/validator/validation_entry.go +++ b/validator/validation_entry.go @@ -2,7 +2,6 @@ package validator import ( "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/state" "github.com/offchainlabs/nitro/arbutil" ) @@ -17,7 +16,8 @@ type ValidationInput struct { HasDelayedMsg bool DelayedMsgNr uint64 Preimages map[arbutil.PreimageType]map[common.Hash][]byte - UserWasms state.UserWasms + StylusArch string + UserWasms map[common.Hash][]byte BatchInfo []BatchInfo DelayedMsg []byte StartState GoGlobalState diff --git a/validator/valnode/validation_api.go b/validator/valnode/validation_api.go index 3299366821..b8787f4f02 100644 --- a/validator/valnode/validation_api.go +++ b/validator/valnode/validation_api.go @@ -44,6 +44,10 @@ func (a *ValidationServerAPI) WasmModuleRoots() ([]common.Hash, error) { return a.spawner.WasmModuleRoots() } +func (a *ValidationServerAPI) StylusArch() (string, error) { + return a.spawner.StylusArch(), nil +} + func NewValidationServerAPI(spawner validator.ValidationSpawner) *ValidationServerAPI { return &ValidationServerAPI{spawner} } From 95981b60e6d76c9f4b810bf8be3e753a6097a3c8 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 19 Jul 2024 15:18:22 +0530 Subject: [PATCH 137/268] Changes based on PR comments --- staker/fast_confirm.go | 249 +++++++++++++++ staker/staker.go | 231 +------------- system_tests/common_test.go | 24 +- system_tests/fast_confirm_test.go | 511 ++++++++++++++++++++++++++++++ system_tests/staker_test.go | 479 ---------------------------- 5 files changed, 780 insertions(+), 714 deletions(-) create mode 100644 staker/fast_confirm.go create mode 100644 system_tests/fast_confirm_test.go diff --git a/staker/fast_confirm.go b/staker/fast_confirm.go new file mode 100644 index 0000000000..72945043f0 --- /dev/null +++ b/staker/fast_confirm.go @@ -0,0 +1,249 @@ +package staker + +import ( + "context" + "errors" + "fmt" + "math/big" + "sort" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" + + "github.com/offchainlabs/nitro/solgen/go/contractsgen" + "github.com/offchainlabs/nitro/solgen/go/rollupgen" + "github.com/offchainlabs/nitro/staker/txbuilder" + "github.com/offchainlabs/nitro/util/headerreader" +) + +type FastConfirmSafe struct { + rollupAddress common.Address + safe *contractsgen.Safe + owners []common.Address + threshold uint64 + fastConfirmNextNodeMethod abi.Method + builder *txbuilder.Builder + wallet ValidatorWalletInterface + gasRefunder common.Address + l1Reader *headerreader.HeaderReader + fastConfirmApprover common.Address +} + +func NewFastConfirmSafe( + callOpts bind.CallOpts, + rollupAddress common.Address, + fastConfirmSafeAddress common.Address, + builder *txbuilder.Builder, + wallet ValidatorWalletInterface, + gasRefunder common.Address, + l1Reader *headerreader.HeaderReader, + fastConfirmApprover common.Address, +) (*FastConfirmSafe, error) { + fastConfirmSafe := &FastConfirmSafe{ + builder: builder, + rollupAddress: rollupAddress, + wallet: wallet, + gasRefunder: gasRefunder, + l1Reader: l1Reader, + fastConfirmApprover: fastConfirmApprover, + } + safe, err := contractsgen.NewSafe(fastConfirmSafeAddress, builder) + if err != nil { + return nil, err + } + fastConfirmSafe.safe = safe + owners, err := safe.GetOwners(&callOpts) + if err != nil { + return nil, err + } + + // This is needed because safe contract needs owners to be sorted. + sort.Slice(owners, func(i, j int) bool { + return owners[i].Cmp(owners[j]) < 0 + }) + fastConfirmSafe.owners = owners + threshold, err := safe.GetThreshold(&callOpts) + if err != nil { + return nil, err + } + fastConfirmSafe.threshold = threshold.Uint64() + rollupUserLogicAbi, err := rollupgen.RollupUserLogicMetaData.GetAbi() + if err != nil { + return nil, err + } + fastConfirmNextNodeMethod, ok := rollupUserLogicAbi.Methods["fastConfirmNextNode"] + if !ok { + return nil, errors.New("RollupUserLogic ABI missing fastConfirmNextNode method") + } + fastConfirmSafe.fastConfirmNextNodeMethod = fastConfirmNextNodeMethod + return fastConfirmSafe, nil +} + +func (s *Staker) tryFastConfirmationNodeNumber(ctx context.Context, number uint64) error { + if !s.config.EnableFastConfirmation { + return nil + } + nodeInfo, err := s.rollup.LookupNode(ctx, number) + if err != nil { + return err + } + return s.tryFastConfirmation(ctx, nodeInfo.AfterState().GlobalState.BlockHash, nodeInfo.AfterState().GlobalState.SendRoot) +} + +func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { + if !s.config.EnableFastConfirmation { + return nil + } + if s.fastConfirmSafe != nil { + return s.fastConfirmSafe.tryFastConfirmation(ctx, blockHash, sendRoot) + } + auth, err := s.builder.Auth(ctx) + if err != nil { + return err + } + _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot) + return err +} + +func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { + fastConfirmCallData, err := f.createFastConfirmCalldata(blockHash, sendRoot) + if err != nil { + return err + } + callOpts := &bind.CallOpts{Context: ctx} + // Current nonce of the safe. + nonce, err := f.safe.Nonce(callOpts) + if err != nil { + return err + } + // Hash of the safe transaction. + safeTxHash, err := f.safe.GetTransactionHash( + callOpts, + f.rollupAddress, + big.NewInt(0), + fastConfirmCallData, + 0, + big.NewInt(0), + big.NewInt(0), + big.NewInt(0), + common.Address{}, + common.Address{}, + nonce, + ) + if err != nil { + return err + } + if !f.wallet.CanBatchTxs() { + err = f.flushTransactions(ctx) + if err != nil { + return err + } + } + auth, err := f.builder.Auth(ctx) + if err != nil { + return err + } + _, err = f.safe.ApproveHash(auth, safeTxHash) + if err != nil { + return err + } + if !f.wallet.CanBatchTxs() { + err = f.flushTransactions(ctx) + if err != nil { + return err + } + } + return f.checkApprovedHashAndExecTransaction(ctx, fastConfirmCallData, safeTxHash) +} + +func (f *FastConfirmSafe) flushTransactions(ctx context.Context) error { + arbTx, err := f.wallet.ExecuteTransactions(ctx, f.builder, f.gasRefunder) + if err != nil { + return err + } + if arbTx != nil { + _, err = f.l1Reader.WaitForTxApproval(ctx, arbTx) + if err == nil { + log.Info("successfully executed staker transaction", "hash", arbTx.Hash()) + } else { + return fmt.Errorf("error waiting for tx receipt: %w", err) + } + } + f.builder.ClearTransactions() + return nil +} + +func (f *FastConfirmSafe) createFastConfirmCalldata( + blockHash common.Hash, sendRoot common.Hash, +) ([]byte, error) { + calldata, err := f.fastConfirmNextNodeMethod.Inputs.Pack( + blockHash, + sendRoot, + ) + if err != nil { + return nil, err + } + fullCalldata := append([]byte{}, f.fastConfirmNextNodeMethod.ID...) + fullCalldata = append(fullCalldata, calldata...) + return fullCalldata, nil +} + +func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Context, fastConfirmCallData []byte, safeTxHash [32]byte) error { + var signatures []byte + approvedHashCount := uint64(0) + for _, owner := range f.owners { + var approved *big.Int + // No need check if fastConfirmApprover has approved the hash, + // since checkApprovedHashAndExecTransaction is called only after fastConfirmApprover has approved the hash. + if f.fastConfirmApprover == owner { + approved = common.Big1 + } else { + var err error + approved, err = f.safe.ApprovedHashes(&bind.CallOpts{Context: ctx}, owner, safeTxHash) + if err != nil { + return err + } + } + + // If the owner has approved the hash, we add the signature to the transaction. + // We add the signature in the format r, s, v. + // We set v to 1, as it is the only possible value for a approved hash. + // We set r to the owner's address. + // We set s to the empty hash. + // Refer to the Safe contract for more information. + if approved.Cmp(common.Big1) == 0 { + approvedHashCount++ + v := uint8(1) + r := common.BytesToHash(owner.Bytes()) + s := common.Hash{} + signatures = append(signatures, r.Bytes()...) + signatures = append(signatures, s.Bytes()...) + signatures = append(signatures, v) + } + } + if approvedHashCount >= f.threshold { + auth, err := f.builder.Auth(ctx) + if err != nil { + return err + } + _, err = f.safe.ExecTransaction( + auth, + f.rollupAddress, + big.NewInt(0), + fastConfirmCallData, + 0, + big.NewInt(0), + big.NewInt(0), + big.NewInt(0), + common.Address{}, + common.Address{}, + signatures, + ) + if err != nil { + return err + } + } + return nil +} diff --git a/staker/staker.go b/staker/staker.go index c2add6a390..5917559079 100644 --- a/staker/staker.go +++ b/staker/staker.go @@ -9,11 +9,9 @@ import ( "fmt" "math/big" "runtime/debug" - "sort" "strings" "time" - "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -25,8 +23,6 @@ import ( "github.com/offchainlabs/nitro/arbnode/dataposter" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/cmd/genericconf" - "github.com/offchainlabs/nitro/solgen/go/contractsgen" - "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/staker/txbuilder" "github.com/offchainlabs/nitro/util" "github.com/offchainlabs/nitro/util/arbmath" @@ -96,6 +92,7 @@ type L1ValidatorConfig struct { ParentChainWallet genericconf.WalletConfig `koanf:"parent-chain-wallet"` EnableFastConfirmation bool `koanf:"enable-fast-confirmation"` FastConfirmSafeAddress string `koanf:"fast-confirm-safe-address"` + FastConfirmApprover string `koanf:"fast-confirm-approver"` LogQueryBatchSize uint64 `koanf:"log-query-batch-size" reload:"hot"` strategy StakerStrategy @@ -165,6 +162,7 @@ var DefaultL1ValidatorConfig = L1ValidatorConfig{ ParentChainWallet: DefaultValidatorL1WalletConfig, EnableFastConfirmation: false, FastConfirmSafeAddress: "", + FastConfirmApprover: "", LogQueryBatchSize: 0, } @@ -188,6 +186,7 @@ var TestL1ValidatorConfig = L1ValidatorConfig{ ParentChainWallet: DefaultValidatorL1WalletConfig, EnableFastConfirmation: false, FastConfirmSafeAddress: "", + FastConfirmApprover: "", LogQueryBatchSize: 0, } @@ -220,6 +219,7 @@ func L1ValidatorConfigAddOptions(prefix string, f *flag.FlagSet) { genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultL1ValidatorConfig.ParentChainWallet.Pathname) f.Bool(prefix+".enable-fast-confirmation", DefaultL1ValidatorConfig.EnableFastConfirmation, "enable fast confirmation") f.String(prefix+".fast-confirm-safe-address", DefaultL1ValidatorConfig.FastConfirmSafeAddress, "safe address for fast confirmation") + f.String(prefix+".fast-confirm-approver", DefaultL1ValidatorConfig.FastConfirmApprover, "approver address for fast confirmation") } type DangerousConfig struct { @@ -269,19 +269,6 @@ type Staker struct { fastConfirmSafe *FastConfirmSafe } -type FastConfirmSafe struct { - rollupAddress common.Address - safe *contractsgen.Safe - owners []common.Address - approvedHashesOwners map[common.Hash]map[common.Address]bool - threshold uint64 - fastConfirmNextNodeMethod abi.Method - builder *txbuilder.Builder - wallet ValidatorWalletInterface - gasRefunder common.Address - l1Reader *headerreader.HeaderReader -} - type ValidatorWalletInterface interface { Initialize(context.Context) error // Address must be able to be called concurrently with other functions @@ -339,6 +326,7 @@ func NewStaker( val.wallet, config.gasRefunder, l1Reader, + common.HexToAddress(config.FastConfirmApprover), ) if err != nil { return nil, err @@ -360,55 +348,6 @@ func NewStaker( }, nil } -func NewFastConfirmSafe( - callOpts bind.CallOpts, - rollupAddress common.Address, - fastConfirmSafeAddress common.Address, - builder *txbuilder.Builder, - wallet ValidatorWalletInterface, - gasRefunder common.Address, - l1Reader *headerreader.HeaderReader, -) (*FastConfirmSafe, error) { - fastConfirmSafe := &FastConfirmSafe{ - builder: builder, - rollupAddress: rollupAddress, - wallet: wallet, - gasRefunder: gasRefunder, - l1Reader: l1Reader, - } - safe, err := contractsgen.NewSafe(fastConfirmSafeAddress, builder) - if err != nil { - return nil, err - } - fastConfirmSafe.safe = safe - owners, err := safe.GetOwners(&callOpts) - if err != nil { - return nil, err - } - - // This is needed because safe contract needs owners to be sorted. - sort.Slice(owners, func(i, j int) bool { - return owners[i].Cmp(owners[j]) < 0 - }) - fastConfirmSafe.owners = owners - threshold, err := safe.GetThreshold(&callOpts) - if err != nil { - return nil, err - } - fastConfirmSafe.threshold = threshold.Uint64() - fastConfirmSafe.approvedHashesOwners = make(map[common.Hash]map[common.Address]bool) - rollupUserLogicAbi, err := rollupgen.RollupUserLogicMetaData.GetAbi() - if err != nil { - return nil, err - } - fastConfirmNextNodeMethod, ok := rollupUserLogicAbi.Methods["fastConfirmNextNode"] - if !ok { - return nil, errors.New("RollupUserLogic ABI missing fastConfirmNextNode method") - } - fastConfirmSafe.fastConfirmNextNodeMethod = fastConfirmNextNodeMethod - return fastConfirmSafe, nil -} - func (s *Staker) Initialize(ctx context.Context) error { err := s.L1Validator.Initialize(ctx) if err != nil { @@ -1036,166 +975,6 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv } } -func (s *Staker) tryFastConfirmationNodeNumber(ctx context.Context, number uint64) error { - if !s.config.EnableFastConfirmation { - return nil - } - nodeInfo, err := s.rollup.LookupNode(ctx, number) - if err != nil { - return err - } - return s.tryFastConfirmation(ctx, nodeInfo.AfterState().GlobalState.BlockHash, nodeInfo.AfterState().GlobalState.SendRoot) -} - -func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { - if !s.config.EnableFastConfirmation { - return nil - } - if s.fastConfirmSafe != nil { - return s.fastConfirmSafe.tryFastConfirmation(ctx, blockHash, sendRoot) - } - auth, err := s.builder.Auth(ctx) - if err != nil { - return err - } - _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot) - return err -} - -func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { - fastConfirmCallData, err := f.createFastConfirmCalldata(blockHash, sendRoot) - if err != nil { - return err - } - callOpts := &bind.CallOpts{Context: ctx} - // Current nonce of the safe. - nonce, err := f.safe.Nonce(callOpts) - if err != nil { - return err - } - // Hash of the safe transaction. - safeTxHash, err := f.safe.GetTransactionHash( - callOpts, - f.rollupAddress, - big.NewInt(0), - fastConfirmCallData, - 0, - big.NewInt(0), - big.NewInt(0), - big.NewInt(0), - common.Address{}, - common.Address{}, - nonce, - ) - if err != nil { - return err - } - arbTx, err := f.wallet.ExecuteTransactions(ctx, f.builder, f.gasRefunder) - if err != nil { - return err - } - if arbTx != nil { - _, err = f.l1Reader.WaitForTxApproval(ctx, arbTx) - if err == nil { - log.Info("successfully executed staker transaction", "hash", arbTx.Hash()) - } else { - return fmt.Errorf("error waiting for tx receipt: %w", err) - } - } - f.builder.ClearTransactions() - auth, err := f.builder.Auth(ctx) - if err != nil { - return err - } - _, err = f.safe.ApproveHash(auth, safeTxHash) - if err != nil { - return err - } - arbTx, err = f.wallet.ExecuteTransactions(ctx, f.builder, f.gasRefunder) - if err != nil { - return err - } - if arbTx != nil { - _, err = f.l1Reader.WaitForTxApproval(ctx, arbTx) - if err == nil { - log.Info("successfully executed staker transaction", "hash", arbTx.Hash()) - } else { - return fmt.Errorf("error waiting for tx receipt: %w", err) - } - } - f.builder.ClearTransactions() - if _, ok := f.approvedHashesOwners[safeTxHash]; !ok { - f.approvedHashesOwners[safeTxHash] = make(map[common.Address]bool) - } - return f.checkApprovedHashAndExecTransaction(ctx, fastConfirmCallData, safeTxHash) -} - -func (f *FastConfirmSafe) createFastConfirmCalldata( - blockHash common.Hash, sendRoot common.Hash, -) ([]byte, error) { - calldata, err := f.fastConfirmNextNodeMethod.Inputs.Pack( - blockHash, - sendRoot, - ) - if err != nil { - return nil, err - } - fullCalldata := append([]byte{}, f.fastConfirmNextNodeMethod.ID...) - fullCalldata = append(fullCalldata, calldata...) - return fullCalldata, nil -} - -func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Context, fastConfirmCallData []byte, safeTxHash [32]byte) error { - var signatures []byte - for _, owner := range f.owners { - if _, ok := f.approvedHashesOwners[safeTxHash][owner]; !ok { - iter, err := f.safe.FilterApproveHash(&bind.FilterOpts{Context: ctx}, [][32]byte{safeTxHash}, []common.Address{owner}) - if err != nil { - return err - } - for iter.Next() { - f.approvedHashesOwners[iter.Event.ApprovedHash][iter.Event.Owner] = true - } - } - // If the owner has approved the hash, we add the signature to the transaction. - // We add the signature in the format r, s, v. - // We set v to 1, as it is the only possible value for a approved hash. - // We set r to the owner's address. - // We set s to the empty hash. - // Refer to the Safe contract for more information. - if _, ok := f.approvedHashesOwners[safeTxHash][owner]; ok { - v := uint8(1) - r := common.BytesToHash(owner.Bytes()) - s := common.Hash{} - signatures = append(signatures, r.Bytes()...) - signatures = append(signatures, s.Bytes()...) - signatures = append(signatures, v) - } - } - if uint64(len(f.approvedHashesOwners[safeTxHash])) >= f.threshold { - auth, err := f.builder.Auth(ctx) - if err != nil { - return err - } - _, err = f.safe.ExecTransaction( - auth, - f.rollupAddress, - big.NewInt(0), - fastConfirmCallData, - 0, - big.NewInt(0), - big.NewInt(0), - big.NewInt(0), - common.Address{}, - common.Address{}, - signatures, - ) - if err != nil { - return err - } - } - return nil -} func (s *Staker) createConflict(ctx context.Context, info *StakerInfo) error { if info.CurrentChallenge != nil { return nil diff --git a/system_tests/common_test.go b/system_tests/common_test.go index b0748f8639..ff184340ab 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -164,12 +164,13 @@ type NodeBuilder struct { L2Info info // L1, L2 Node parameters - dataDir string - isSequencer bool - takeOwnership bool - withL1 bool - addresses *chaininfo.RollupAddresses - initMessage *arbostypes.ParsedInitMessage + dataDir string + isSequencer bool + takeOwnership bool + withL1 bool + addresses *chaininfo.RollupAddresses + initMessage *arbostypes.ParsedInitMessage + withProdConfirmPeriodBlocks bool // Created nodes L1 *TestClient @@ -209,6 +210,11 @@ func (b *NodeBuilder) WithArbOSVersion(arbosVersion uint64) *NodeBuilder { return b } +func (b *NodeBuilder) WithProdConfirmPeriodBlocks() *NodeBuilder { + b.withProdConfirmPeriodBlocks = true + return b +} + func (b *NodeBuilder) WithWasmRootDir(wasmRootDir string) *NodeBuilder { b.valnodeConfig.Wasm.RootPath = wasmRootDir return b @@ -253,7 +259,7 @@ func (b *NodeBuilder) BuildL1(t *testing.T) { b.L1Info, b.L1.Client, b.L1.L1Backend, b.L1.Stack = createTestL1BlockChain(t, b.L1Info) locator, err := server_common.NewMachineLocator(b.valnodeConfig.Wasm.RootPath) Require(t, err) - b.addresses, b.initMessage = DeployOnTestL1(t, b.ctx, b.L1Info, b.L1.Client, b.chainConfig, locator.LatestWasmModuleRoot()) + b.addresses, b.initMessage = DeployOnTestL1(t, b.ctx, b.L1Info, b.L1.Client, b.chainConfig, locator.LatestWasmModuleRoot(), b.withProdConfirmPeriodBlocks) b.L1.cleanup = func() { requireClose(t, b.L1.Stack) } } @@ -883,7 +889,7 @@ func getInitMessage(ctx context.Context, t *testing.T, l1client client, addresse } func DeployOnTestL1( - t *testing.T, ctx context.Context, l1info info, l1client client, chainConfig *params.ChainConfig, wasmModuleRoot common.Hash, + t *testing.T, ctx context.Context, l1info info, l1client client, chainConfig *params.ChainConfig, wasmModuleRoot common.Hash, prodConfirmPeriodBlocks bool, ) (*chaininfo.RollupAddresses, *arbostypes.ParsedInitMessage) { l1info.GenerateAccount("RollupOwner") l1info.GenerateAccount("Sequencer") @@ -915,7 +921,7 @@ func DeployOnTestL1( []common.Address{l1info.GetAddress("Sequencer")}, l1info.GetAddress("RollupOwner"), 0, - arbnode.GenerateRollupConfig(false, wasmModuleRoot, l1info.GetAddress("RollupOwner"), chainConfig, serializedChainConfig, common.Address{}), + arbnode.GenerateRollupConfig(prodConfirmPeriodBlocks, wasmModuleRoot, l1info.GetAddress("RollupOwner"), chainConfig, serializedChainConfig, common.Address{}), nativeToken, maxDataSize, false, diff --git a/system_tests/fast_confirm_test.go b/system_tests/fast_confirm_test.go new file mode 100644 index 0000000000..750175ba1b --- /dev/null +++ b/system_tests/fast_confirm_test.go @@ -0,0 +1,511 @@ +package arbtest + +import ( + "context" + "errors" + "math/big" + "strings" + "testing" + "time" + + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/params" + + "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/arbnode/dataposter/externalsignertest" + "github.com/offchainlabs/nitro/arbnode/dataposter/storage" + "github.com/offchainlabs/nitro/arbos/l2pricing" + "github.com/offchainlabs/nitro/solgen/go/contractsgen" + "github.com/offchainlabs/nitro/solgen/go/proxiesgen" + "github.com/offchainlabs/nitro/solgen/go/rollupgen" + "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" + "github.com/offchainlabs/nitro/staker" + "github.com/offchainlabs/nitro/staker/validatorwallet" + "github.com/offchainlabs/nitro/util" + "github.com/offchainlabs/nitro/validator/valnode" +) + +func TestFastConfirmation(t *testing.T) { + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + srv := externalsignertest.NewServer(t) + go func() { + if err := srv.Start(); err != nil { + log.Error("Failed to start external signer server:", err) + return + } + }() + var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs + + builder := NewNodeBuilder(ctx).DefaultConfig(t, true).WithProdConfirmPeriodBlocks() + builder.L2Info = NewBlockChainTestInfo( + t, + types.NewArbitrumSigner(types.NewLondonSigner(builder.chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), + transferGas, + ) + + builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour + cleanup := builder.Build(t) + defer cleanup() + + addNewBatchPoster(ctx, t, builder, srv.Address) + + builder.L1.SendWaitTestTransactions(t, []*types.Transaction{ + builder.L1Info.PrepareTxTo("Faucet", &srv.Address, 30000, big.NewInt(1).Mul(big.NewInt(1e18), big.NewInt(1e18)), nil)}) + + l2node := builder.L2.ConsensusNode + execNode := builder.L2.ExecNode + + config := arbnode.ConfigDefaultL1Test() + config.Sequencer = false + config.DelayedSequencer.Enable = false + config.BatchPoster.Enable = false + builder.execConfig.Sequencer.Enable = false + + builder.BridgeBalance(t, "Faucet", big.NewInt(1).Mul(big.NewInt(params.Ether), big.NewInt(10000))) + + deployAuth := builder.L1Info.GetDefaultTransactOpts("RollupOwner", ctx) + + balance := big.NewInt(params.Ether) + balance.Mul(balance, big.NewInt(100)) + builder.L1.TransferBalance(t, "Faucet", "Validator", balance, builder.L1Info) + l1auth := builder.L1Info.GetDefaultTransactOpts("Validator", ctx) + + valWalletAddrPtr, err := validatorwallet.GetValidatorWalletContract(ctx, l2node.DeployInfo.ValidatorWalletCreator, 0, &l1auth, l2node.L1Reader, true) + Require(t, err) + valWalletAddr := *valWalletAddrPtr + valWalletAddrCheck, err := validatorwallet.GetValidatorWalletContract(ctx, l2node.DeployInfo.ValidatorWalletCreator, 0, &l1auth, l2node.L1Reader, true) + Require(t, err) + if valWalletAddr == *valWalletAddrCheck { + Require(t, err, "didn't cache validator wallet address", valWalletAddr.String(), "vs", valWalletAddrCheck.String()) + } + + rollup, err := rollupgen.NewRollupAdminLogic(l2node.DeployInfo.Rollup, builder.L1.Client) + Require(t, err) + + upgradeExecutor, err := upgrade_executorgen.NewUpgradeExecutor(l2node.DeployInfo.UpgradeExecutor, builder.L1.Client) + Require(t, err, "unable to bind upgrade executor") + rollupABI, err := abi.JSON(strings.NewReader(rollupgen.RollupAdminLogicABI)) + Require(t, err, "unable to parse rollup ABI") + + setValidatorCalldata, err := rollupABI.Pack("setValidator", []common.Address{valWalletAddr, srv.Address}, []bool{true, true}) + Require(t, err, "unable to generate setValidator calldata") + tx, err := upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setValidatorCalldata) + Require(t, err, "unable to set validators") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + setMinAssertPeriodCalldata, err := rollupABI.Pack("setMinimumAssertionPeriod", big.NewInt(1)) + Require(t, err, "unable to generate setMinimumAssertionPeriod calldata") + tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setMinAssertPeriodCalldata) + Require(t, err, "unable to set minimum assertion period") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + setAnyTrustFastConfirmerCalldata, err := rollupABI.Pack("setAnyTrustFastConfirmer", valWalletAddr) + Require(t, err, "unable to generate setAnyTrustFastConfirmer calldata") + tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setAnyTrustFastConfirmerCalldata) + Require(t, err, "unable to set anytrust fast confirmer") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + valConfig := staker.TestL1ValidatorConfig + valConfig.EnableFastConfirmation = true + parentChainID, err := builder.L1.Client.ChainID(ctx) + if err != nil { + t.Fatalf("Failed to get parent chain id: %v", err) + } + dp, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2node.ArbDB, storage.StakerPrefix), + l2node.L1Reader, + &l1auth, NewFetcherFromConfig(arbnode.ConfigDefaultL1NonSequencerTest()), + nil, + parentChainID, + ) + if err != nil { + t.Fatalf("Error creating validator dataposter: %v", err) + } + valWallet, err := validatorwallet.NewContract(dp, nil, l2node.DeployInfo.ValidatorWalletCreator, l2node.DeployInfo.Rollup, l2node.L1Reader, &l1auth, 0, func(common.Address) {}, func() uint64 { return valConfig.ExtraGas }) + Require(t, err) + valConfig.Strategy = "MakeNodes" + + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + blockValidatorConfig := staker.TestBlockValidatorConfig + + stateless, err := staker.NewStatelessBlockValidator( + l2node.InboxReader, + l2node.InboxTracker, + l2node.TxStreamer, + execNode, + l2node.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStack, + ) + Require(t, err) + err = stateless.Start(ctx) + Require(t, err) + stakerA, err := staker.NewStaker( + l2node.L1Reader, + valWallet, + bind.CallOpts{}, + valConfig, + nil, + stateless, + nil, + nil, + l2node.DeployInfo.ValidatorUtils, + nil, + ) + Require(t, err) + err = stakerA.Initialize(ctx) + if stakerA.Strategy() != staker.WatchtowerStrategy { + err = valWallet.Initialize(ctx) + Require(t, err) + } + Require(t, err) + cfg := arbnode.ConfigDefaultL1NonSequencerTest() + signerCfg, err := externalSignerTestCfg(srv.Address, srv.URL()) + if err != nil { + t.Fatalf("Error getting external signer config: %v", err) + } + cfg.Staker.DataPoster.ExternalSigner = *signerCfg + + builder.L2Info.GenerateAccount("BackgroundUser") + tx = builder.L2Info.PrepareTx("Faucet", "BackgroundUser", builder.L2Info.TransferGas, balance, nil) + err = builder.L2.Client.SendTransaction(ctx, tx) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + // Continually make L2 transactions in a background thread + backgroundTxsCtx, cancelBackgroundTxs := context.WithCancel(ctx) + backgroundTxsShutdownChan := make(chan struct{}) + defer (func() { + cancelBackgroundTxs() + <-backgroundTxsShutdownChan + })() + go (func() { + defer close(backgroundTxsShutdownChan) + err := makeBackgroundTxs(backgroundTxsCtx, builder) + if !errors.Is(err, context.Canceled) { + log.Warn("error making background txs", "err", err) + } + })() + + latestConfirmBeforeAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + tx, err = stakerA.Act(ctx) + Require(t, err) + if tx != nil { + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + } + latestConfirmAfterAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + if latestConfirmAfterAct <= latestConfirmBeforeAct { + Fatal(t, "staker A didn't advance the latest confirmed node") + } +} + +func TestFastConfirmationWithSafe(t *testing.T) { + ctx, cancelCtx := context.WithCancel(context.Background()) + defer cancelCtx() + srv := externalsignertest.NewServer(t) + go func() { + if err := srv.Start(); err != nil { + log.Error("Failed to start external signer server:", err) + return + } + }() + var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs + + // Create a node with a large confirm period to ensure that the staker can't confirm without the fast confirmer. + builder := NewNodeBuilder(ctx).DefaultConfig(t, true).WithProdConfirmPeriodBlocks() + builder.L2Info = NewBlockChainTestInfo( + t, + types.NewArbitrumSigner(types.NewLondonSigner(builder.chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), + transferGas, + ) + + builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour + cleanupA := builder.Build(t) + defer cleanupA() + + addNewBatchPoster(ctx, t, builder, srv.Address) + + builder.L1.SendWaitTestTransactions(t, []*types.Transaction{ + builder.L1Info.PrepareTxTo("Faucet", &srv.Address, 30000, big.NewInt(1).Mul(big.NewInt(1e18), big.NewInt(1e18)), nil)}) + + l2nodeA := builder.L2.ConsensusNode + execNodeA := builder.L2.ExecNode + + config := arbnode.ConfigDefaultL1Test() + config.Sequencer = false + config.DelayedSequencer.Enable = false + config.BatchPoster.Enable = false + builder.execConfig.Sequencer.Enable = false + testClientB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: config}) + defer cleanupB() + + l2nodeB := testClientB.ConsensusNode + execNodeB := testClientB.ExecNode + + nodeAGenesis := execNodeA.Backend.APIBackend().CurrentHeader().Hash() + nodeBGenesis := execNodeB.Backend.APIBackend().CurrentHeader().Hash() + if nodeAGenesis != nodeBGenesis { + Fatal(t, "node A L2 genesis hash", nodeAGenesis, "!= node B L2 genesis hash", nodeBGenesis) + } + + builder.BridgeBalance(t, "Faucet", big.NewInt(1).Mul(big.NewInt(params.Ether), big.NewInt(10000))) + + deployAuth := builder.L1Info.GetDefaultTransactOpts("RollupOwner", ctx) + + balance := big.NewInt(params.Ether) + balance.Mul(balance, big.NewInt(100)) + builder.L1Info.GenerateAccount("ValidatorA") + builder.L1.TransferBalance(t, "Faucet", "ValidatorA", balance, builder.L1Info) + l1authA := builder.L1Info.GetDefaultTransactOpts("ValidatorA", ctx) + + builder.L1Info.GenerateAccount("ValidatorB") + builder.L1.TransferBalance(t, "Faucet", "ValidatorB", balance, builder.L1Info) + l1authB := builder.L1Info.GetDefaultTransactOpts("ValidatorB", ctx) + + valWalletAddrAPtr, err := validatorwallet.GetValidatorWalletContract(ctx, l2nodeA.DeployInfo.ValidatorWalletCreator, 0, &l1authA, l2nodeA.L1Reader, true) + Require(t, err) + valWalletAddrA := *valWalletAddrAPtr + valWalletAddrCheck, err := validatorwallet.GetValidatorWalletContract(ctx, l2nodeA.DeployInfo.ValidatorWalletCreator, 0, &l1authA, l2nodeA.L1Reader, true) + Require(t, err) + if valWalletAddrA == *valWalletAddrCheck { + Require(t, err, "didn't cache validator wallet address", valWalletAddrA.String(), "vs", valWalletAddrCheck.String()) + } + + rollup, err := rollupgen.NewRollupAdminLogic(l2nodeA.DeployInfo.Rollup, builder.L1.Client) + Require(t, err) + + upgradeExecutor, err := upgrade_executorgen.NewUpgradeExecutor(l2nodeA.DeployInfo.UpgradeExecutor, builder.L1.Client) + Require(t, err, "unable to bind upgrade executor") + rollupABI, err := abi.JSON(strings.NewReader(rollupgen.RollupAdminLogicABI)) + Require(t, err, "unable to parse rollup ABI") + + safeAddress := deploySafe(t, builder.L1, builder.L1.Client, deployAuth, []common.Address{valWalletAddrA, srv.Address}) + setValidatorCalldata, err := rollupABI.Pack("setValidator", []common.Address{valWalletAddrA, l1authB.From, srv.Address, safeAddress}, []bool{true, true, true, true}) + Require(t, err, "unable to generate setValidator calldata") + tx, err := upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setValidatorCalldata) + Require(t, err, "unable to set validators") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + setMinAssertPeriodCalldata, err := rollupABI.Pack("setMinimumAssertionPeriod", big.NewInt(1)) + Require(t, err, "unable to generate setMinimumAssertionPeriod calldata") + tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setMinAssertPeriodCalldata) + Require(t, err, "unable to set minimum assertion period") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + setAnyTrustFastConfirmerCalldata, err := rollupABI.Pack("setAnyTrustFastConfirmer", safeAddress) + Require(t, err, "unable to generate setAnyTrustFastConfirmer calldata") + tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setAnyTrustFastConfirmerCalldata) + Require(t, err, "unable to set anytrust fast confirmer") + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + + valConfig := staker.TestL1ValidatorConfig + valConfig.EnableFastConfirmation = true + valConfig.FastConfirmSafeAddress = safeAddress.String() + valConfig.FastConfirmApprover = valWalletAddrA.String() + parentChainID, err := builder.L1.Client.ChainID(ctx) + if err != nil { + t.Fatalf("Failed to get parent chain id: %v", err) + } + dpA, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2nodeB.ArbDB, storage.StakerPrefix), + l2nodeA.L1Reader, + &l1authA, NewFetcherFromConfig(arbnode.ConfigDefaultL1NonSequencerTest()), + nil, + parentChainID, + ) + if err != nil { + t.Fatalf("Error creating validator dataposter: %v", err) + } + valWalletA, err := validatorwallet.NewContract(dpA, nil, l2nodeA.DeployInfo.ValidatorWalletCreator, l2nodeA.DeployInfo.Rollup, l2nodeA.L1Reader, &l1authA, 0, func(common.Address) {}, func() uint64 { return valConfig.ExtraGas }) + Require(t, err) + valConfig.Strategy = "MakeNodes" + + _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) + blockValidatorConfig := staker.TestBlockValidatorConfig + + statelessA, err := staker.NewStatelessBlockValidator( + l2nodeA.InboxReader, + l2nodeA.InboxTracker, + l2nodeA.TxStreamer, + execNodeA, + l2nodeA.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStack, + ) + Require(t, err) + err = statelessA.Start(ctx) + Require(t, err) + stakerA, err := staker.NewStaker( + l2nodeA.L1Reader, + valWalletA, + bind.CallOpts{}, + valConfig, + nil, + statelessA, + nil, + nil, + l2nodeA.DeployInfo.ValidatorUtils, + nil, + ) + Require(t, err) + err = stakerA.Initialize(ctx) + if stakerA.Strategy() != staker.WatchtowerStrategy { + err = valWalletA.Initialize(ctx) + Require(t, err) + } + Require(t, err) + cfg := arbnode.ConfigDefaultL1NonSequencerTest() + signerCfg, err := externalSignerTestCfg(srv.Address, srv.URL()) + if err != nil { + t.Fatalf("Error getting external signer config: %v", err) + } + cfg.Staker.DataPoster.ExternalSigner = *signerCfg + dpB, err := arbnode.StakerDataposter( + ctx, + rawdb.NewTable(l2nodeB.ArbDB, storage.StakerPrefix), + l2nodeB.L1Reader, + &l1authB, NewFetcherFromConfig(cfg), + nil, + parentChainID, + ) + if err != nil { + t.Fatalf("Error creating validator dataposter: %v", err) + } + valWalletB, err := validatorwallet.NewEOA(dpB, l2nodeB.DeployInfo.Rollup, l2nodeB.L1Reader.Client(), func() uint64 { return 0 }) + Require(t, err) + valConfig.Strategy = "watchtower" + valConfig.FastConfirmApprover = srv.Address.String() + statelessB, err := staker.NewStatelessBlockValidator( + l2nodeB.InboxReader, + l2nodeB.InboxTracker, + l2nodeB.TxStreamer, + execNodeB, + l2nodeB.ArbDB, + nil, + StaticFetcherFrom(t, &blockValidatorConfig), + valStack, + ) + Require(t, err) + err = statelessB.Start(ctx) + Require(t, err) + stakerB, err := staker.NewStaker( + l2nodeB.L1Reader, + valWalletB, + bind.CallOpts{}, + valConfig, + nil, + statelessB, + nil, + nil, + l2nodeB.DeployInfo.ValidatorUtils, + nil, + ) + Require(t, err) + err = stakerB.Initialize(ctx) + Require(t, err) + if stakerB.Strategy() != staker.WatchtowerStrategy { + err = valWalletB.Initialize(ctx) + Require(t, err) + } + + builder.L2Info.GenerateAccount("BackgroundUser") + tx = builder.L2Info.PrepareTx("Faucet", "BackgroundUser", builder.L2Info.TransferGas, balance, nil) + err = builder.L2.Client.SendTransaction(ctx, tx) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + // Continually make L2 transactions in a background thread + backgroundTxsCtx, cancelBackgroundTxs := context.WithCancel(ctx) + backgroundTxsShutdownChan := make(chan struct{}) + defer (func() { + cancelBackgroundTxs() + <-backgroundTxsShutdownChan + })() + go (func() { + defer close(backgroundTxsShutdownChan) + err := makeBackgroundTxs(backgroundTxsCtx, builder) + if !errors.Is(err, context.Canceled) { + log.Warn("error making background txs", "err", err) + } + })() + + latestConfirmBeforeAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + tx, err = stakerA.Act(ctx) + Require(t, err) + if tx != nil { + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + } + latestConfirmAfterStakerAAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + if latestConfirmAfterStakerAAct != latestConfirmBeforeAct { + Fatal(t, "staker A alone advanced the latest confirmed node", latestConfirmAfterStakerAAct, "when it shouldn't have") + } + for j := 0; j < 5; j++ { + builder.L1.TransferBalance(t, "Faucet", "Faucet", common.Big0, builder.L1Info) + } + tx, err = stakerB.Act(ctx) + Require(t, err) + if tx != nil { + _, err = builder.L1.EnsureTxSucceeded(tx) + Require(t, err) + } + latestConfirmAfterStakerBAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) + Require(t, err) + if latestConfirmAfterStakerBAct <= latestConfirmBeforeAct { + Fatal(t, "staker A and B together didn't advance the latest confirmed node") + } +} + +func deploySafe(t *testing.T, l1 *TestClient, backend bind.ContractBackend, deployAuth bind.TransactOpts, owners []common.Address) common.Address { + safeAddress, tx, _, err := contractsgen.DeploySafeL2(&deployAuth, backend) + Require(t, err) + _, err = l1.EnsureTxSucceeded(tx) + Require(t, err) + safeProxyAddress, tx, _, err := proxiesgen.DeploySafeProxy(&deployAuth, backend, safeAddress) + Require(t, err) + _, err = l1.EnsureTxSucceeded(tx) + Require(t, err) + var safe *contractsgen.Safe + safe, err = contractsgen.NewSafe(safeProxyAddress, backend) + Require(t, err) + _, err = l1.EnsureTxSucceeded(tx) + Require(t, err) + tx, err = safe.Setup( + &deployAuth, + owners, + big.NewInt(2), + common.Address{}, + nil, + common.Address{}, + common.Address{}, + big.NewInt(0), + common.Address{}, + ) + Require(t, err) + _, err = l1.EnsureTxSucceeded(tx) + Require(t, err) + return safeProxyAddress +} diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 75e902933b..52f16614f7 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -29,9 +29,7 @@ import ( "github.com/offchainlabs/nitro/arbnode/dataposter/externalsignertest" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/arbos/l2pricing" - "github.com/offchainlabs/nitro/solgen/go/contractsgen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" - "github.com/offchainlabs/nitro/solgen/go/proxiesgen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" "github.com/offchainlabs/nitro/staker" @@ -466,480 +464,3 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) func TestStakersCooperative(t *testing.T) { stakerTestImpl(t, false, false) } - -func TestFastConfirmation(t *testing.T) { - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() - srv := externalsignertest.NewServer(t) - go func() { - if err := srv.Start(); err != nil { - log.Error("Failed to start external signer server:", err) - return - } - }() - var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs - - builder := NewNodeBuilder(ctx).DefaultConfig(t, true) - builder.L2Info = NewBlockChainTestInfo( - t, - types.NewArbitrumSigner(types.NewLondonSigner(builder.chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), - transferGas, - ) - - builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour - cleanup := builder.Build(t) - defer cleanup() - - addNewBatchPoster(ctx, t, builder, srv.Address) - - builder.L1.SendWaitTestTransactions(t, []*types.Transaction{ - builder.L1Info.PrepareTxTo("Faucet", &srv.Address, 30000, big.NewInt(1).Mul(big.NewInt(1e18), big.NewInt(1e18)), nil)}) - - l2node := builder.L2.ConsensusNode - execNode := builder.L2.ExecNode - - config := arbnode.ConfigDefaultL1Test() - config.Sequencer = false - config.DelayedSequencer.Enable = false - config.BatchPoster.Enable = false - builder.execConfig.Sequencer.Enable = false - - builder.BridgeBalance(t, "Faucet", big.NewInt(1).Mul(big.NewInt(params.Ether), big.NewInt(10000))) - - deployAuth := builder.L1Info.GetDefaultTransactOpts("RollupOwner", ctx) - - balance := big.NewInt(params.Ether) - balance.Mul(balance, big.NewInt(100)) - builder.L1.TransferBalance(t, "Faucet", "Validator", balance, builder.L1Info) - l1auth := builder.L1Info.GetDefaultTransactOpts("Validator", ctx) - - valWalletAddrPtr, err := validatorwallet.GetValidatorWalletContract(ctx, l2node.DeployInfo.ValidatorWalletCreator, 0, &l1auth, l2node.L1Reader, true) - Require(t, err) - valWalletAddr := *valWalletAddrPtr - valWalletAddrCheck, err := validatorwallet.GetValidatorWalletContract(ctx, l2node.DeployInfo.ValidatorWalletCreator, 0, &l1auth, l2node.L1Reader, true) - Require(t, err) - if valWalletAddr == *valWalletAddrCheck { - Require(t, err, "didn't cache validator wallet address", valWalletAddr.String(), "vs", valWalletAddrCheck.String()) - } - - rollup, err := rollupgen.NewRollupAdminLogic(l2node.DeployInfo.Rollup, builder.L1.Client) - Require(t, err) - - upgradeExecutor, err := upgrade_executorgen.NewUpgradeExecutor(l2node.DeployInfo.UpgradeExecutor, builder.L1.Client) - Require(t, err, "unable to bind upgrade executor") - rollupABI, err := abi.JSON(strings.NewReader(rollupgen.RollupAdminLogicABI)) - Require(t, err, "unable to parse rollup ABI") - - setValidatorCalldata, err := rollupABI.Pack("setValidator", []common.Address{valWalletAddr, srv.Address}, []bool{true, true}) - Require(t, err, "unable to generate setValidator calldata") - tx, err := upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setValidatorCalldata) - Require(t, err, "unable to set validators") - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - - setMinAssertPeriodCalldata, err := rollupABI.Pack("setMinimumAssertionPeriod", big.NewInt(1)) - Require(t, err, "unable to generate setMinimumAssertionPeriod calldata") - tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setMinAssertPeriodCalldata) - Require(t, err, "unable to set minimum assertion period") - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - - setAnyTrustFastConfirmerCalldata, err := rollupABI.Pack("setAnyTrustFastConfirmer", valWalletAddr) - Require(t, err, "unable to generate setAnyTrustFastConfirmer calldata") - tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2node.DeployInfo.Rollup, setAnyTrustFastConfirmerCalldata) - Require(t, err, "unable to set anytrust fast confirmer") - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - - valConfig := staker.TestL1ValidatorConfig - valConfig.EnableFastConfirmation = true - parentChainID, err := builder.L1.Client.ChainID(ctx) - if err != nil { - t.Fatalf("Failed to get parent chain id: %v", err) - } - dp, err := arbnode.StakerDataposter( - ctx, - rawdb.NewTable(l2node.ArbDB, storage.StakerPrefix), - l2node.L1Reader, - &l1auth, NewFetcherFromConfig(arbnode.ConfigDefaultL1NonSequencerTest()), - nil, - parentChainID, - ) - if err != nil { - t.Fatalf("Error creating validator dataposter: %v", err) - } - valWallet, err := validatorwallet.NewContract(dp, nil, l2node.DeployInfo.ValidatorWalletCreator, l2node.DeployInfo.Rollup, l2node.L1Reader, &l1auth, 0, func(common.Address) {}, func() uint64 { return valConfig.ExtraGas }) - Require(t, err) - valConfig.Strategy = "MakeNodes" - - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) - blockValidatorConfig := staker.TestBlockValidatorConfig - - stateless, err := staker.NewStatelessBlockValidator( - l2node.InboxReader, - l2node.InboxTracker, - l2node.TxStreamer, - execNode, - l2node.ArbDB, - nil, - StaticFetcherFrom(t, &blockValidatorConfig), - valStack, - ) - Require(t, err) - err = stateless.Start(ctx) - Require(t, err) - stakerA, err := staker.NewStaker( - l2node.L1Reader, - valWallet, - bind.CallOpts{}, - valConfig, - nil, - stateless, - nil, - nil, - l2node.DeployInfo.ValidatorUtils, - nil, - ) - Require(t, err) - err = stakerA.Initialize(ctx) - if stakerA.Strategy() != staker.WatchtowerStrategy { - err = valWallet.Initialize(ctx) - Require(t, err) - } - Require(t, err) - cfg := arbnode.ConfigDefaultL1NonSequencerTest() - signerCfg, err := externalSignerTestCfg(srv.Address, srv.URL()) - if err != nil { - t.Fatalf("Error getting external signer config: %v", err) - } - cfg.Staker.DataPoster.ExternalSigner = *signerCfg - - builder.L2Info.GenerateAccount("BackgroundUser") - tx = builder.L2Info.PrepareTx("Faucet", "BackgroundUser", builder.L2Info.TransferGas, balance, nil) - err = builder.L2.Client.SendTransaction(ctx, tx) - Require(t, err) - _, err = builder.L2.EnsureTxSucceeded(tx) - Require(t, err) - - // Continually make L2 transactions in a background thread - backgroundTxsCtx, cancelBackgroundTxs := context.WithCancel(ctx) - backgroundTxsShutdownChan := make(chan struct{}) - defer (func() { - cancelBackgroundTxs() - <-backgroundTxsShutdownChan - })() - go (func() { - defer close(backgroundTxsShutdownChan) - err := makeBackgroundTxs(backgroundTxsCtx, builder) - if !errors.Is(err, context.Canceled) { - log.Warn("error making background txs", "err", err) - } - })() - - latestConfirmBeforeAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) - Require(t, err) - tx, err = stakerA.Act(ctx) - Require(t, err) - if tx != nil { - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - } - latestConfirmAfterAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) - Require(t, err) - if latestConfirmAfterAct <= latestConfirmBeforeAct { - Fatal(t, "staker A didn't advance the latest confirmed node") - } -} - -func TestFastConfirmationWithSafe(t *testing.T) { - ctx, cancelCtx := context.WithCancel(context.Background()) - defer cancelCtx() - srv := externalsignertest.NewServer(t) - go func() { - if err := srv.Start(); err != nil { - log.Error("Failed to start external signer server:", err) - return - } - }() - var transferGas = util.NormalizeL2GasForL1GasInitial(800_000, params.GWei) // include room for aggregator L1 costs - - builder := NewNodeBuilder(ctx).DefaultConfig(t, true) - builder.L2Info = NewBlockChainTestInfo( - t, - types.NewArbitrumSigner(types.NewLondonSigner(builder.chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), - transferGas, - ) - - builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour - cleanupA := builder.Build(t) - defer cleanupA() - - addNewBatchPoster(ctx, t, builder, srv.Address) - - builder.L1.SendWaitTestTransactions(t, []*types.Transaction{ - builder.L1Info.PrepareTxTo("Faucet", &srv.Address, 30000, big.NewInt(1).Mul(big.NewInt(1e18), big.NewInt(1e18)), nil)}) - - l2nodeA := builder.L2.ConsensusNode - execNodeA := builder.L2.ExecNode - - config := arbnode.ConfigDefaultL1Test() - config.Sequencer = false - config.DelayedSequencer.Enable = false - config.BatchPoster.Enable = false - builder.execConfig.Sequencer.Enable = false - testClientB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: config}) - defer cleanupB() - - l2nodeB := testClientB.ConsensusNode - execNodeB := testClientB.ExecNode - - nodeAGenesis := execNodeA.Backend.APIBackend().CurrentHeader().Hash() - nodeBGenesis := execNodeB.Backend.APIBackend().CurrentHeader().Hash() - if nodeAGenesis != nodeBGenesis { - Fatal(t, "node A L2 genesis hash", nodeAGenesis, "!= node B L2 genesis hash", nodeBGenesis) - } - - builder.BridgeBalance(t, "Faucet", big.NewInt(1).Mul(big.NewInt(params.Ether), big.NewInt(10000))) - - deployAuth := builder.L1Info.GetDefaultTransactOpts("RollupOwner", ctx) - - balance := big.NewInt(params.Ether) - balance.Mul(balance, big.NewInt(100)) - builder.L1Info.GenerateAccount("ValidatorA") - builder.L1.TransferBalance(t, "Faucet", "ValidatorA", balance, builder.L1Info) - l1authA := builder.L1Info.GetDefaultTransactOpts("ValidatorA", ctx) - - builder.L1Info.GenerateAccount("ValidatorB") - builder.L1.TransferBalance(t, "Faucet", "ValidatorB", balance, builder.L1Info) - l1authB := builder.L1Info.GetDefaultTransactOpts("ValidatorB", ctx) - - valWalletAddrAPtr, err := validatorwallet.GetValidatorWalletContract(ctx, l2nodeA.DeployInfo.ValidatorWalletCreator, 0, &l1authA, l2nodeA.L1Reader, true) - Require(t, err) - valWalletAddrA := *valWalletAddrAPtr - valWalletAddrCheck, err := validatorwallet.GetValidatorWalletContract(ctx, l2nodeA.DeployInfo.ValidatorWalletCreator, 0, &l1authA, l2nodeA.L1Reader, true) - Require(t, err) - if valWalletAddrA == *valWalletAddrCheck { - Require(t, err, "didn't cache validator wallet address", valWalletAddrA.String(), "vs", valWalletAddrCheck.String()) - } - - rollup, err := rollupgen.NewRollupAdminLogic(l2nodeA.DeployInfo.Rollup, builder.L1.Client) - Require(t, err) - - upgradeExecutor, err := upgrade_executorgen.NewUpgradeExecutor(l2nodeA.DeployInfo.UpgradeExecutor, builder.L1.Client) - Require(t, err, "unable to bind upgrade executor") - rollupABI, err := abi.JSON(strings.NewReader(rollupgen.RollupAdminLogicABI)) - Require(t, err, "unable to parse rollup ABI") - - safeAddress := deploySafe(t, builder.L1, builder.L1.Client, deployAuth, []common.Address{valWalletAddrA, srv.Address}) - setValidatorCalldata, err := rollupABI.Pack("setValidator", []common.Address{valWalletAddrA, l1authB.From, srv.Address, safeAddress}, []bool{true, true, true, true}) - Require(t, err, "unable to generate setValidator calldata") - tx, err := upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setValidatorCalldata) - Require(t, err, "unable to set validators") - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - - setMinAssertPeriodCalldata, err := rollupABI.Pack("setMinimumAssertionPeriod", big.NewInt(1)) - Require(t, err, "unable to generate setMinimumAssertionPeriod calldata") - tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setMinAssertPeriodCalldata) - Require(t, err, "unable to set minimum assertion period") - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - - setAnyTrustFastConfirmerCalldata, err := rollupABI.Pack("setAnyTrustFastConfirmer", safeAddress) - Require(t, err, "unable to generate setAnyTrustFastConfirmer calldata") - tx, err = upgradeExecutor.ExecuteCall(&deployAuth, l2nodeA.DeployInfo.Rollup, setAnyTrustFastConfirmerCalldata) - Require(t, err, "unable to set anytrust fast confirmer") - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - - valConfig := staker.TestL1ValidatorConfig - valConfig.EnableFastConfirmation = true - valConfig.FastConfirmSafeAddress = safeAddress.String() - parentChainID, err := builder.L1.Client.ChainID(ctx) - if err != nil { - t.Fatalf("Failed to get parent chain id: %v", err) - } - dpA, err := arbnode.StakerDataposter( - ctx, - rawdb.NewTable(l2nodeB.ArbDB, storage.StakerPrefix), - l2nodeA.L1Reader, - &l1authA, NewFetcherFromConfig(arbnode.ConfigDefaultL1NonSequencerTest()), - nil, - parentChainID, - ) - if err != nil { - t.Fatalf("Error creating validator dataposter: %v", err) - } - valWalletA, err := validatorwallet.NewContract(dpA, nil, l2nodeA.DeployInfo.ValidatorWalletCreator, l2nodeA.DeployInfo.Rollup, l2nodeA.L1Reader, &l1authA, 0, func(common.Address) {}, func() uint64 { return valConfig.ExtraGas }) - Require(t, err) - valConfig.Strategy = "MakeNodes" - - _, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig) - blockValidatorConfig := staker.TestBlockValidatorConfig - - statelessA, err := staker.NewStatelessBlockValidator( - l2nodeA.InboxReader, - l2nodeA.InboxTracker, - l2nodeA.TxStreamer, - execNodeA, - l2nodeA.ArbDB, - nil, - StaticFetcherFrom(t, &blockValidatorConfig), - valStack, - ) - Require(t, err) - err = statelessA.Start(ctx) - Require(t, err) - stakerA, err := staker.NewStaker( - l2nodeA.L1Reader, - valWalletA, - bind.CallOpts{}, - valConfig, - nil, - statelessA, - nil, - nil, - l2nodeA.DeployInfo.ValidatorUtils, - nil, - ) - Require(t, err) - err = stakerA.Initialize(ctx) - if stakerA.Strategy() != staker.WatchtowerStrategy { - err = valWalletA.Initialize(ctx) - Require(t, err) - } - Require(t, err) - cfg := arbnode.ConfigDefaultL1NonSequencerTest() - signerCfg, err := externalSignerTestCfg(srv.Address, srv.URL()) - if err != nil { - t.Fatalf("Error getting external signer config: %v", err) - } - cfg.Staker.DataPoster.ExternalSigner = *signerCfg - dpB, err := arbnode.StakerDataposter( - ctx, - rawdb.NewTable(l2nodeB.ArbDB, storage.StakerPrefix), - l2nodeB.L1Reader, - &l1authB, NewFetcherFromConfig(cfg), - nil, - parentChainID, - ) - if err != nil { - t.Fatalf("Error creating validator dataposter: %v", err) - } - valWalletB, err := validatorwallet.NewEOA(dpB, l2nodeB.DeployInfo.Rollup, l2nodeB.L1Reader.Client(), func() uint64 { return 0 }) - Require(t, err) - valConfig.Strategy = "watchtower" - statelessB, err := staker.NewStatelessBlockValidator( - l2nodeB.InboxReader, - l2nodeB.InboxTracker, - l2nodeB.TxStreamer, - execNodeB, - l2nodeB.ArbDB, - nil, - StaticFetcherFrom(t, &blockValidatorConfig), - valStack, - ) - Require(t, err) - err = statelessB.Start(ctx) - Require(t, err) - stakerB, err := staker.NewStaker( - l2nodeB.L1Reader, - valWalletB, - bind.CallOpts{}, - valConfig, - nil, - statelessB, - nil, - nil, - l2nodeB.DeployInfo.ValidatorUtils, - nil, - ) - Require(t, err) - err = stakerB.Initialize(ctx) - Require(t, err) - if stakerB.Strategy() != staker.WatchtowerStrategy { - err = valWalletB.Initialize(ctx) - Require(t, err) - } - - builder.L2Info.GenerateAccount("BackgroundUser") - tx = builder.L2Info.PrepareTx("Faucet", "BackgroundUser", builder.L2Info.TransferGas, balance, nil) - err = builder.L2.Client.SendTransaction(ctx, tx) - Require(t, err) - _, err = builder.L2.EnsureTxSucceeded(tx) - Require(t, err) - - // Continually make L2 transactions in a background thread - backgroundTxsCtx, cancelBackgroundTxs := context.WithCancel(ctx) - backgroundTxsShutdownChan := make(chan struct{}) - defer (func() { - cancelBackgroundTxs() - <-backgroundTxsShutdownChan - })() - go (func() { - defer close(backgroundTxsShutdownChan) - err := makeBackgroundTxs(backgroundTxsCtx, builder) - if !errors.Is(err, context.Canceled) { - log.Warn("error making background txs", "err", err) - } - })() - - latestConfirmBeforeAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) - Require(t, err) - tx, err = stakerA.Act(ctx) - Require(t, err) - if tx != nil { - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - } - latestConfirmAfterStakerAAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) - Require(t, err) - if latestConfirmAfterStakerAAct != latestConfirmBeforeAct { - Fatal(t, "staker A alone advanced the latest confirmed node", latestConfirmAfterStakerAAct, "when it shouldn't have") - } - for j := 0; j < 5; j++ { - builder.L1.TransferBalance(t, "Faucet", "Faucet", common.Big0, builder.L1Info) - } - tx, err = stakerB.Act(ctx) - Require(t, err) - if tx != nil { - _, err = builder.L1.EnsureTxSucceeded(tx) - Require(t, err) - } - latestConfirmAfterStakerBAct, err := rollup.LatestConfirmed(&bind.CallOpts{}) - Require(t, err) - if latestConfirmAfterStakerBAct <= latestConfirmBeforeAct { - Fatal(t, "staker A and B together didn't advance the latest confirmed node") - } -} - -func deploySafe(t *testing.T, l1 *TestClient, backend bind.ContractBackend, deployAuth bind.TransactOpts, owners []common.Address) common.Address { - safeAddress, tx, _, err := contractsgen.DeploySafeL2(&deployAuth, backend) - Require(t, err) - _, err = l1.EnsureTxSucceeded(tx) - Require(t, err) - safeProxyAddress, tx, _, err := proxiesgen.DeploySafeProxy(&deployAuth, backend, safeAddress) - Require(t, err) - _, err = l1.EnsureTxSucceeded(tx) - Require(t, err) - var safe *contractsgen.Safe - safe, err = contractsgen.NewSafe(safeProxyAddress, backend) - Require(t, err) - _, err = l1.EnsureTxSucceeded(tx) - Require(t, err) - tx, err = safe.Setup( - &deployAuth, - owners, - big.NewInt(2), - common.Address{}, - nil, - common.Address{}, - common.Address{}, - big.NewInt(0), - common.Address{}, - ) - Require(t, err) - _, err = l1.EnsureTxSucceeded(tx) - Require(t, err) - return safeProxyAddress -} From 234278daa045f1153ab292ed6952806bdf5237b5 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Fri, 19 Jul 2024 14:13:52 +0200 Subject: [PATCH 138/268] Configurable timeout for HeaderReader polling Previously if the backend stopped responding the client.HeaderByNumber call inside the timed main loop would never return, meaning that if the HeaderReader was only operating in polling mode, calls to LastHeader would always return the last successfully fetched header until OldHeaderTimeout, and if that was set to a high duration then it would effectively always return the last successfully fetched header and never an error. This would lead to the chain appear to be stuck and not advancing to clients of HeaderReader.LastHeader. This change adds a configurable timeout on this call, defaulting to 5s. Other places in HeaderReader that use LastHeader use the passed-in context which the client can control, so no extra timeout was added for these. --- util/headerreader/header_reader.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/util/headerreader/header_reader.go b/util/headerreader/header_reader.go index 06dfcfbfa8..074d24338e 100644 --- a/util/headerreader/header_reader.go +++ b/util/headerreader/header_reader.go @@ -63,6 +63,7 @@ type Config struct { Enable bool `koanf:"enable"` PollOnly bool `koanf:"poll-only" reload:"hot"` PollInterval time.Duration `koanf:"poll-interval" reload:"hot"` + PollTimeout time.Duration `koanf:"poll-timeout" reload:"hot"` SubscribeErrInterval time.Duration `koanf:"subscribe-err-interval" reload:"hot"` TxTimeout time.Duration `koanf:"tx-timeout" reload:"hot"` OldHeaderTimeout time.Duration `koanf:"old-header-timeout" reload:"hot"` @@ -80,6 +81,7 @@ var DefaultConfig = Config{ Enable: true, PollOnly: false, PollInterval: 15 * time.Second, + PollTimeout: 5 * time.Second, SubscribeErrInterval: 5 * time.Minute, TxTimeout: 5 * time.Minute, OldHeaderTimeout: 5 * time.Minute, @@ -94,6 +96,7 @@ func AddOptions(prefix string, f *flag.FlagSet) { f.Bool(prefix+".poll-only", DefaultConfig.PollOnly, "do not attempt to subscribe to header events") f.Bool(prefix+".use-finality-data", DefaultConfig.UseFinalityData, "use l1 data about finalized/safe blocks") f.Duration(prefix+".poll-interval", DefaultConfig.PollInterval, "interval when polling endpoint") + f.Duration(prefix+".poll-timeout", DefaultConfig.PollTimeout, "timeout when polling endpoint") f.Duration(prefix+".subscribe-err-interval", DefaultConfig.SubscribeErrInterval, "interval for subscribe error") f.Duration(prefix+".tx-timeout", DefaultConfig.TxTimeout, "timeout when waiting for a transaction") f.Duration(prefix+".old-header-timeout", DefaultConfig.OldHeaderTimeout, "warns if the latest l1 block is at least this old") @@ -108,6 +111,7 @@ var TestConfig = Config{ Enable: true, PollOnly: false, PollInterval: time.Millisecond * 10, + PollTimeout: time.Second * 5, TxTimeout: time.Second * 5, OldHeaderTimeout: 5 * time.Minute, UseFinalityData: false, @@ -287,7 +291,9 @@ func (s *HeaderReader) broadcastLoop(ctx context.Context) { s.possiblyBroadcast(h) timer.Stop() case <-timer.C: - h, err := s.client.HeaderByNumber(ctx, nil) + timedCtx, cancelFunc := context.WithTimeout(ctx, s.config().PollTimeout) + h, err := s.client.HeaderByNumber(timedCtx, nil) + cancelFunc() if err != nil { s.setError(fmt.Errorf("failed reading HeaderByNumber: %w", err)) if !errors.Is(err, context.Canceled) { From 678fd4462edfc64670e12009fb46472c29600d7d Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 19 Jul 2024 08:55:01 -0600 Subject: [PATCH 139/268] Use default rpcclient config when unmarshalling JSON --- util/rpcclient/rpcclient.go | 7 +++++++ util/rpcclient/rpcclient_test.go | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/util/rpcclient/rpcclient.go b/util/rpcclient/rpcclient.go index e171e6e99b..be5825a28d 100644 --- a/util/rpcclient/rpcclient.go +++ b/util/rpcclient/rpcclient.go @@ -44,6 +44,13 @@ func (c *ClientConfig) Validate() error { return err } +func (c *ClientConfig) UnmarshalJSON(data []byte) error { + // Use DefaultClientConfig for default values when unmarshalling JSON + *c = DefaultClientConfig + type clientConfigWithoutCustomUnmarshal ClientConfig + return json.Unmarshal(data, (*clientConfigWithoutCustomUnmarshal)(c)) +} + type ClientConfigFetcher func() *ClientConfig var TestClientConfig = ClientConfig{ diff --git a/util/rpcclient/rpcclient_test.go b/util/rpcclient/rpcclient_test.go index ae7e4fc226..1a7da54774 100644 --- a/util/rpcclient/rpcclient_test.go +++ b/util/rpcclient/rpcclient_test.go @@ -2,13 +2,17 @@ package rpcclient import ( "context" + "encoding/json" "errors" + "regexp" "sync/atomic" "testing" "time" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -204,6 +208,21 @@ func TestIsAlreadyKnownError(t *testing.T) { } } +func TestUnmarshalClientConfig(t *testing.T) { + exampleJson := `[{"jwtsecret":"/tmp/nitro-val.jwt","url":"http://127.0.0.10:52000"}, {"jwtsecret":"/tmp/nitro-val.jwt","url":"http://127.0.0.10:52001"}]` + var clientConfigs []ClientConfig + Require(t, json.Unmarshal([]byte(exampleJson), &clientConfigs)) + expectedClientConfigs := []ClientConfig{DefaultClientConfig, DefaultClientConfig} + expectedClientConfigs[0].JWTSecret = "/tmp/nitro-val.jwt" + expectedClientConfigs[0].URL = "http://127.0.0.10:52000" + expectedClientConfigs[1].JWTSecret = "/tmp/nitro-val.jwt" + expectedClientConfigs[1].URL = "http://127.0.0.10:52001" + // Ensure the configs are equivalent to the expected configs, ignoring the retryErrors regexp as cmp can't compare it + if diff := cmp.Diff(expectedClientConfigs, clientConfigs, cmpopts.IgnoreTypes(®exp.Regexp{})); diff != "" { + t.Errorf("unmarshalling example JSON unexpected diff:\n%s", diff) + } +} + func Require(t *testing.T, err error, printables ...interface{}) { t.Helper() testhelpers.RequireImpl(t, err, printables...) From c00b5176c3369cb0a18d1ee706b5cb1cb5421579 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 19 Jul 2024 09:23:56 -0600 Subject: [PATCH 140/268] allow multiple stylusArchs per validation spawner --- staker/block_validator.go | 4 +- staker/challenge_manager.go | 2 +- staker/stateless_block_validator.go | 26 +++++++------ system_tests/validation_mock_test.go | 4 +- validator/client/redis/producer.go | 12 +++--- validator/client/validation_client.go | 29 +++++++++------ validator/interface.go | 2 +- validator/server_api/json.go | 45 +++++++++++++---------- validator/server_arb/validator_spawner.go | 14 ++++--- validator/server_jit/jit_machine.go | 14 +++++-- validator/server_jit/spawner.go | 4 +- validator/validation_entry.go | 3 +- validator/valnode/validation_api.go | 4 +- 13 files changed, 93 insertions(+), 70 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index 04851b700f..8063f74d58 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -468,7 +468,7 @@ func (v *BlockValidator) sendRecord(s *validationStatus) error { //nolint:gosec func (v *BlockValidator) writeToFile(validationEntry *validationEntry, moduleRoot common.Hash) error { - input, err := validationEntry.ToInput("wavm") + input, err := validationEntry.ToInput([]string{"wavm"}) if err != nil { return err } @@ -814,7 +814,7 @@ validationsLoop: validatorPendingValidationsGauge.Inc(1) var runs []validator.ValidationRun for _, moduleRoot := range wasmRoots { - input, err := validationStatus.Entry.ToInput(v.chosenValidator[moduleRoot].StylusArch()) + input, err := validationStatus.Entry.ToInput(v.chosenValidator[moduleRoot].StylusArchs()) if err != nil && ctx.Err() == nil { v.possiblyFatal(fmt.Errorf("%w: error preparing validation", err)) continue diff --git a/staker/challenge_manager.go b/staker/challenge_manager.go index f50b85064c..80cafccced 100644 --- a/staker/challenge_manager.go +++ b/staker/challenge_manager.go @@ -467,7 +467,7 @@ func (m *ChallengeManager) createExecutionBackend(ctx context.Context, step uint if err != nil { return fmt.Errorf("error creating validation entry for challenge %v msg %v for execution challenge: %w", m.challengeIndex, initialCount, err) } - input, err := entry.ToInput("wavm") + input, err := entry.ToInput([]string{"wavm"}) if err != nil { return fmt.Errorf("error getting validation entry input of challenge %v msg %v: %w", m.challengeIndex, initialCount, err) } diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index 7daa1ab872..65f5787e03 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -135,7 +135,7 @@ type validationEntry struct { DelayedMsg []byte } -func (e *validationEntry) ToInput(stylusArch string) (*validator.ValidationInput, error) { +func (e *validationEntry) ToInput(stylusArchs []string) (*validator.ValidationInput, error) { if e.Stage != Ready { return nil, errors.New("cannot create input from non-ready entry") } @@ -144,20 +144,24 @@ func (e *validationEntry) ToInput(stylusArch string) (*validator.ValidationInput HasDelayedMsg: e.HasDelayedMsg, DelayedMsgNr: e.DelayedMsgNr, Preimages: e.Preimages, - StylusArch: stylusArch, - UserWasms: make(map[common.Hash][]byte, len(e.UserWasms)), + UserWasms: make(map[string]map[common.Hash][]byte, len(e.UserWasms)), BatchInfo: e.BatchInfo, DelayedMsg: e.DelayedMsg, StartState: e.Start, DebugChain: e.ChainConfig.DebugMode(), } + for _, stylusArch := range stylusArchs { + res.UserWasms[stylusArch] = make(map[common.Hash][]byte) + } for hash, info := range e.UserWasms { - if stylusArch == "wavm" { - res.UserWasms[hash] = info.Module - } else if stylusArch == runtime.GOARCH { - res.UserWasms[hash] = info.Asm - } else { - return nil, fmt.Errorf("stylusArch not supported by block validator: %v", stylusArch) + for _, stylusArch := range stylusArchs { + if stylusArch == "wavm" { + res.UserWasms[stylusArch][hash] = info.Module + } else if stylusArch == runtime.GOARCH { + res.UserWasms[stylusArch][hash] = info.Asm + } else { + return nil, fmt.Errorf("stylusArch not supported by block validator: %v", stylusArch) + } } } return &res, nil @@ -389,7 +393,7 @@ func (v *StatelessBlockValidator) ValidateResult( if !useExec { if v.redisValidator != nil { if validator.SpawnerSupportsModule(v.redisValidator, moduleRoot) { - input, err := entry.ToInput(v.redisValidator.StylusArch()) + input, err := entry.ToInput(v.redisValidator.StylusArchs()) if err != nil { return false, nil, err } @@ -400,7 +404,7 @@ func (v *StatelessBlockValidator) ValidateResult( if run == nil { for _, spawner := range v.execSpawners { if validator.SpawnerSupportsModule(spawner, moduleRoot) { - input, err := entry.ToInput(spawner.StylusArch()) + input, err := entry.ToInput(spawner.StylusArchs()) if err != nil { return false, nil, err } diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index a1d9f314cc..2c6321d009 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -60,8 +60,8 @@ func (s *mockSpawner) WasmModuleRoots() ([]common.Hash, error) { return mockWasmModuleRoots, nil } -func (s *mockSpawner) StylusArch() string { - return "mock" +func (s *mockSpawner) StylusArchs() []string { + return []string{"mock"} } func (s *mockSpawner) Launch(entry *validator.ValidationInput, moduleRoot common.Hash) validator.ValidationRun { diff --git a/validator/client/redis/producer.go b/validator/client/redis/producer.go index 4a81ae1fdf..b3ad0f8839 100644 --- a/validator/client/redis/producer.go +++ b/validator/client/redis/producer.go @@ -23,7 +23,7 @@ type ValidationClientConfig struct { StreamPrefix string `koanf:"stream-prefix"` Room int32 `koanf:"room"` RedisURL string `koanf:"redis-url"` - StylusArch string `koanf:"stylus-arch"` + StylusArchs []string `koanf:"stylus-archs"` ProducerConfig pubsub.ProducerConfig `koanf:"producer-config"` CreateStreams bool `koanf:"create-streams"` } @@ -36,7 +36,7 @@ var DefaultValidationClientConfig = ValidationClientConfig{ Name: "redis validation client", Room: 2, RedisURL: "", - StylusArch: "wavm", + StylusArchs: []string{"wavm"}, ProducerConfig: pubsub.DefaultProducerConfig, CreateStreams: true, } @@ -46,7 +46,7 @@ var TestValidationClientConfig = ValidationClientConfig{ Room: 2, RedisURL: "", StreamPrefix: "test-", - StylusArch: "wavm", + StylusArchs: []string{"wavm"}, ProducerConfig: pubsub.TestProducerConfig, CreateStreams: false, } @@ -56,7 +56,7 @@ func ValidationClientConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Int32(prefix+".room", DefaultValidationClientConfig.Room, "validation client room") f.String(prefix+".redis-url", DefaultValidationClientConfig.RedisURL, "redis url") f.String(prefix+".stream-prefix", DefaultValidationClientConfig.StreamPrefix, "prefix for stream name") - f.String(prefix+".stylus-arch", DefaultValidationClientConfig.StylusArch, "arch for stylus workers") + f.StringSlice(prefix+".stylus-archs", DefaultValidationClientConfig.StylusArchs, "archs required for stylus workers") pubsub.ProducerAddConfigAddOptions(prefix+".producer-config", f) f.Bool(prefix+".create-streams", DefaultValidationClientConfig.CreateStreams, "create redis streams if it does not exist") } @@ -152,8 +152,8 @@ func (c *ValidationClient) Name() string { return c.config.Name } -func (c *ValidationClient) StylusArch() string { - return c.config.StylusArch +func (c *ValidationClient) StylusArchs() []string { + return c.config.StylusArchs } func (c *ValidationClient) Room() int { diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index 610f3eb01f..43231b913e 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -30,16 +30,16 @@ type ValidationClient struct { stopwaiter.StopWaiter client *rpcclient.RpcClient name string - stylusArch string + stylusArchs []string room atomic.Int32 wasmModuleRoots []common.Hash } func NewValidationClient(config rpcclient.ClientConfigFetcher, stack *node.Node) *ValidationClient { return &ValidationClient{ - client: rpcclient.NewRpcClient(config, stack), - name: "not started", - stylusArch: "not started", + client: rpcclient.NewRpcClient(config, stack), + name: "not started", + stylusArchs: []string{"not started"}, } } @@ -68,12 +68,17 @@ func (c *ValidationClient) Start(ctx_in context.Context) error { if len(name) == 0 { return errors.New("couldn't read name from server") } - var stylusArch string - if err := c.client.CallContext(ctx, &stylusArch, server_api.Namespace+"_stylusArch"); err != nil { + var stylusArchs []string + if err := c.client.CallContext(ctx, &stylusArchs, server_api.Namespace+"_stylusArchs"); err != nil { return err } - if stylusArch != "wavm" && stylusArch != runtime.GOARCH && stylusArch != "mock" { - return fmt.Errorf("unsupported stylus architecture: %v", stylusArch) + if len(stylusArchs) == 0 { + return fmt.Errorf("could not read stylus archs from validation server") + } + for _, stylusArch := range stylusArchs { + if stylusArch != "wavm" && stylusArch != runtime.GOARCH && stylusArch != "mock" { + return fmt.Errorf("unsupported stylus architecture: %v", stylusArch) + } } var moduleRoots []common.Hash if err := c.client.CallContext(ctx, &moduleRoots, server_api.Namespace+"_wasmModuleRoots"); err != nil { @@ -95,7 +100,7 @@ func (c *ValidationClient) Start(ctx_in context.Context) error { c.room.Store(int32(room)) c.wasmModuleRoots = moduleRoots c.name = name - c.stylusArch = stylusArch + c.stylusArchs = stylusArchs return nil } @@ -106,11 +111,11 @@ func (c *ValidationClient) WasmModuleRoots() ([]common.Hash, error) { return nil, errors.New("not started") } -func (c *ValidationClient) StylusArch() string { +func (c *ValidationClient) StylusArchs() []string { if c.Started() { - return c.stylusArch + return c.stylusArchs } - return "not started" + return []string{"not started"} } func (c *ValidationClient) Stop() { diff --git a/validator/interface.go b/validator/interface.go index d59e94c4a0..80aa2c1fcc 100644 --- a/validator/interface.go +++ b/validator/interface.go @@ -13,7 +13,7 @@ type ValidationSpawner interface { Start(context.Context) error Stop() Name() string - StylusArch() string + StylusArchs() []string Room() int } diff --git a/validator/server_api/json.go b/validator/server_api/json.go index 5de6999ef1..942013d280 100644 --- a/validator/server_api/json.go +++ b/validator/server_api/json.go @@ -62,8 +62,7 @@ type InputJSON struct { BatchInfo []BatchInfoJson DelayedMsgB64 string StartState validator.GoGlobalState - StylusArch string - UserWasms map[common.Hash]string + UserWasms map[string]map[common.Hash]string DebugChain bool } @@ -95,20 +94,23 @@ func ValidationInputToJson(entry *validator.ValidationInput) *InputJSON { DelayedMsgB64: base64.StdEncoding.EncodeToString(entry.DelayedMsg), StartState: entry.StartState, PreimagesB64: jsonPreimagesMap, - UserWasms: make(map[common.Hash]string), - StylusArch: entry.StylusArch, + UserWasms: make(map[string]map[common.Hash]string), DebugChain: entry.DebugChain, } for _, binfo := range entry.BatchInfo { encData := base64.StdEncoding.EncodeToString(binfo.Data) res.BatchInfo = append(res.BatchInfo, BatchInfoJson{Number: binfo.Number, DataB64: encData}) } - for moduleHash, data := range entry.UserWasms { - compressed, err := arbcompress.CompressWell(data) - if err != nil { - entry.StylusArch = "compressError:" + err.Error() + for arch, wasms := range entry.UserWasms { + archWasms := make(map[common.Hash]string) + for moduleHash, data := range wasms { + compressed, err := arbcompress.CompressWell(data) + if err != nil { + continue + } + archWasms[moduleHash] = base64.StdEncoding.EncodeToString(compressed) } - res.UserWasms[moduleHash] = base64.StdEncoding.EncodeToString(compressed) + res.UserWasms[arch] = archWasms } return res } @@ -124,8 +126,7 @@ func ValidationInputFromJson(entry *InputJSON) (*validator.ValidationInput, erro DelayedMsgNr: entry.DelayedMsgNr, StartState: entry.StartState, Preimages: preimages, - StylusArch: entry.StylusArch, - UserWasms: make(map[common.Hash][]byte), + UserWasms: make(map[string]map[common.Hash][]byte), DebugChain: entry.DebugChain, } delayed, err := base64.StdEncoding.DecodeString(entry.DelayedMsgB64) @@ -144,16 +145,20 @@ func ValidationInputFromJson(entry *InputJSON) (*validator.ValidationInput, erro } valInput.BatchInfo = append(valInput.BatchInfo, decInfo) } - for moduleHash, encoded := range entry.UserWasms { - decoded, err := base64.StdEncoding.DecodeString(encoded) - if err != nil { - return nil, err - } - uncompressed, err := arbcompress.Decompress(decoded, 30000000) - if err != nil { - return nil, err + for arch, wasms := range entry.UserWasms { + archWasms := make(map[common.Hash][]byte) + for moduleHash, encoded := range wasms { + decoded, err := base64.StdEncoding.DecodeString(encoded) + if err != nil { + return nil, err + } + uncompressed, err := arbcompress.Decompress(decoded, 30000000) + if err != nil { + return nil, err + } + archWasms[moduleHash] = uncompressed } - valInput.UserWasms[moduleHash] = uncompressed + valInput.UserWasms[arch] = archWasms } return valInput, nil } diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 73549af3ec..1d4126dc7c 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -88,8 +88,8 @@ func (s *ArbitratorSpawner) WasmModuleRoots() ([]common.Hash, error) { return s.locator.ModuleRoots(), nil } -func (s *ArbitratorSpawner) StylusArch() string { - return "wavm" +func (s *ArbitratorSpawner) StylusArchs() []string { + return []string{"wavm"} } func (s *ArbitratorSpawner) Name() string { @@ -122,10 +122,14 @@ func (v *ArbitratorSpawner) loadEntryToMachine(ctx context.Context, entry *valid return fmt.Errorf("error while trying to add sequencer msg for proving: %w", err) } } - if entry.StylusArch != "wavm" { - return fmt.Errorf("bad stylus arch loaded to machine. Expected wavm. Got: %s", entry.StylusArch) + if len(entry.UserWasms["wavm"]) == 0 { + for stylusArch, wasms := range entry.UserWasms { + if len(wasms) > 0 { + return fmt.Errorf("bad stylus arch loaded to machine. Expected wavm. Got: %s", stylusArch) + } + } } - for moduleHash, module := range entry.UserWasms { + for moduleHash, module := range entry.UserWasms["wavm"] { err = mach.AddUserWasm(moduleHash, module) if err != nil { log.Error( diff --git a/validator/server_jit/jit_machine.go b/validator/server_jit/jit_machine.go index 3a27c64e21..e4fb840cbb 100644 --- a/validator/server_jit/jit_machine.go +++ b/validator/server_jit/jit_machine.go @@ -212,11 +212,17 @@ func (machine *JitMachine) prove( } } - // send user wasms - if entry.StylusArch != runtime.GOARCH { - return state, fmt.Errorf("bad stylus arch for validation input. got: %v, expected: %v", entry.StylusArch, runtime.GOARCH) + userWasms := entry.UserWasms[runtime.GOARCH] + + // if there are user wasms, but only for wrong architecture - error + if len(userWasms) == 0 { + for arch, userWasms := range entry.UserWasms { + if len(userWasms) != 0 { + return state, fmt.Errorf("bad stylus arch for validation input. got: %v, expected: %v", arch, runtime.GOARCH) + } + } } - userWasms := entry.UserWasms + if err := writeUint32(uint32(len(userWasms))); err != nil { return state, err } diff --git a/validator/server_jit/spawner.go b/validator/server_jit/spawner.go index dd9f3bbfc1..5ba3664109 100644 --- a/validator/server_jit/spawner.go +++ b/validator/server_jit/spawner.go @@ -71,8 +71,8 @@ func (v *JitSpawner) WasmModuleRoots() ([]common.Hash, error) { return v.locator.ModuleRoots(), nil } -func (v *JitSpawner) StylusArch() string { - return runtime.GOARCH +func (v *JitSpawner) StylusArchs() []string { + return []string{runtime.GOARCH} } func (v *JitSpawner) execute( diff --git a/validator/validation_entry.go b/validator/validation_entry.go index 3c0f28eb37..133a67a8a8 100644 --- a/validator/validation_entry.go +++ b/validator/validation_entry.go @@ -16,8 +16,7 @@ type ValidationInput struct { HasDelayedMsg bool DelayedMsgNr uint64 Preimages map[arbutil.PreimageType]map[common.Hash][]byte - StylusArch string - UserWasms map[common.Hash][]byte + UserWasms map[string]map[common.Hash][]byte BatchInfo []BatchInfo DelayedMsg []byte StartState GoGlobalState diff --git a/validator/valnode/validation_api.go b/validator/valnode/validation_api.go index b8787f4f02..6245ffc5e3 100644 --- a/validator/valnode/validation_api.go +++ b/validator/valnode/validation_api.go @@ -44,8 +44,8 @@ func (a *ValidationServerAPI) WasmModuleRoots() ([]common.Hash, error) { return a.spawner.WasmModuleRoots() } -func (a *ValidationServerAPI) StylusArch() (string, error) { - return a.spawner.StylusArch(), nil +func (a *ValidationServerAPI) StylusArchs() ([]string, error) { + return a.spawner.StylusArchs(), nil } func NewValidationServerAPI(spawner validator.ValidationSpawner) *ValidationServerAPI { From ca4b1d58f1876416e748cf967314a1b7b2056172 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 19 Jul 2024 21:11:34 +0530 Subject: [PATCH 141/268] Changes based on PR comments --- staker/fast_confirm.go | 46 +++++-------------------------- staker/staker.go | 34 ++++++++++++++++++----- system_tests/fast_confirm_test.go | 15 ++++------ 3 files changed, 39 insertions(+), 56 deletions(-) diff --git a/staker/fast_confirm.go b/staker/fast_confirm.go index 72945043f0..ef0a6fddb7 100644 --- a/staker/fast_confirm.go +++ b/staker/fast_confirm.go @@ -19,7 +19,6 @@ import ( ) type FastConfirmSafe struct { - rollupAddress common.Address safe *contractsgen.Safe owners []common.Address threshold uint64 @@ -28,26 +27,21 @@ type FastConfirmSafe struct { wallet ValidatorWalletInterface gasRefunder common.Address l1Reader *headerreader.HeaderReader - fastConfirmApprover common.Address } func NewFastConfirmSafe( callOpts bind.CallOpts, - rollupAddress common.Address, fastConfirmSafeAddress common.Address, builder *txbuilder.Builder, wallet ValidatorWalletInterface, gasRefunder common.Address, l1Reader *headerreader.HeaderReader, - fastConfirmApprover common.Address, ) (*FastConfirmSafe, error) { fastConfirmSafe := &FastConfirmSafe{ - builder: builder, - rollupAddress: rollupAddress, - wallet: wallet, - gasRefunder: gasRefunder, - l1Reader: l1Reader, - fastConfirmApprover: fastConfirmApprover, + builder: builder, + wallet: wallet, + gasRefunder: gasRefunder, + l1Reader: l1Reader, } safe, err := contractsgen.NewSafe(fastConfirmSafeAddress, builder) if err != nil { @@ -81,32 +75,6 @@ func NewFastConfirmSafe( return fastConfirmSafe, nil } -func (s *Staker) tryFastConfirmationNodeNumber(ctx context.Context, number uint64) error { - if !s.config.EnableFastConfirmation { - return nil - } - nodeInfo, err := s.rollup.LookupNode(ctx, number) - if err != nil { - return err - } - return s.tryFastConfirmation(ctx, nodeInfo.AfterState().GlobalState.BlockHash, nodeInfo.AfterState().GlobalState.SendRoot) -} - -func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { - if !s.config.EnableFastConfirmation { - return nil - } - if s.fastConfirmSafe != nil { - return s.fastConfirmSafe.tryFastConfirmation(ctx, blockHash, sendRoot) - } - auth, err := s.builder.Auth(ctx) - if err != nil { - return err - } - _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot) - return err -} - func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { fastConfirmCallData, err := f.createFastConfirmCalldata(blockHash, sendRoot) if err != nil { @@ -121,7 +89,7 @@ func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash com // Hash of the safe transaction. safeTxHash, err := f.safe.GetTransactionHash( callOpts, - f.rollupAddress, + f.wallet.RollupAddress(), big.NewInt(0), fastConfirmCallData, 0, @@ -197,7 +165,7 @@ func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Contex var approved *big.Int // No need check if fastConfirmApprover has approved the hash, // since checkApprovedHashAndExecTransaction is called only after fastConfirmApprover has approved the hash. - if f.fastConfirmApprover == owner { + if *f.wallet.Address() == owner { approved = common.Big1 } else { var err error @@ -230,7 +198,7 @@ func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Contex } _, err = f.safe.ExecTransaction( auth, - f.rollupAddress, + f.wallet.RollupAddress(), big.NewInt(0), fastConfirmCallData, 0, diff --git a/staker/staker.go b/staker/staker.go index 5917559079..e3dd11dc07 100644 --- a/staker/staker.go +++ b/staker/staker.go @@ -92,7 +92,6 @@ type L1ValidatorConfig struct { ParentChainWallet genericconf.WalletConfig `koanf:"parent-chain-wallet"` EnableFastConfirmation bool `koanf:"enable-fast-confirmation"` FastConfirmSafeAddress string `koanf:"fast-confirm-safe-address"` - FastConfirmApprover string `koanf:"fast-confirm-approver"` LogQueryBatchSize uint64 `koanf:"log-query-batch-size" reload:"hot"` strategy StakerStrategy @@ -162,7 +161,6 @@ var DefaultL1ValidatorConfig = L1ValidatorConfig{ ParentChainWallet: DefaultValidatorL1WalletConfig, EnableFastConfirmation: false, FastConfirmSafeAddress: "", - FastConfirmApprover: "", LogQueryBatchSize: 0, } @@ -186,7 +184,6 @@ var TestL1ValidatorConfig = L1ValidatorConfig{ ParentChainWallet: DefaultValidatorL1WalletConfig, EnableFastConfirmation: false, FastConfirmSafeAddress: "", - FastConfirmApprover: "", LogQueryBatchSize: 0, } @@ -219,7 +216,6 @@ func L1ValidatorConfigAddOptions(prefix string, f *flag.FlagSet) { genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultL1ValidatorConfig.ParentChainWallet.Pathname) f.Bool(prefix+".enable-fast-confirmation", DefaultL1ValidatorConfig.EnableFastConfirmation, "enable fast confirmation") f.String(prefix+".fast-confirm-safe-address", DefaultL1ValidatorConfig.FastConfirmSafeAddress, "safe address for fast confirmation") - f.String(prefix+".fast-confirm-approver", DefaultL1ValidatorConfig.FastConfirmApprover, "approver address for fast confirmation") } type DangerousConfig struct { @@ -320,13 +316,11 @@ func NewStaker( if config.EnableFastConfirmation && config.FastConfirmSafeAddress != "" { fastConfirmSafe, err = NewFastConfirmSafe( callOpts, - wallet.RollupAddress(), common.HexToAddress(config.FastConfirmSafeAddress), val.builder, - val.wallet, + wallet, config.gasRefunder, l1Reader, - common.HexToAddress(config.FastConfirmApprover), ) if err != nil { return nil, err @@ -377,6 +371,32 @@ func (s *Staker) Initialize(ctx context.Context) error { return nil } +func (s *Staker) tryFastConfirmationNodeNumber(ctx context.Context, number uint64) error { + if !s.config.EnableFastConfirmation { + return nil + } + nodeInfo, err := s.rollup.LookupNode(ctx, number) + if err != nil { + return err + } + return s.tryFastConfirmation(ctx, nodeInfo.AfterState().GlobalState.BlockHash, nodeInfo.AfterState().GlobalState.SendRoot) +} + +func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { + if !s.config.EnableFastConfirmation { + return nil + } + if s.fastConfirmSafe != nil { + return s.fastConfirmSafe.tryFastConfirmation(ctx, blockHash, sendRoot) + } + auth, err := s.builder.Auth(ctx) + if err != nil { + return err + } + _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot) + return err +} + func (s *Staker) getLatestStakedState(ctx context.Context, staker common.Address) (uint64, arbutil.MessageIndex, *validator.GoGlobalState, error) { callOpts := s.getCallOpts(ctx) if s.l1Reader.UseFinalityData() { diff --git a/system_tests/fast_confirm_test.go b/system_tests/fast_confirm_test.go index 750175ba1b..c552aa51e0 100644 --- a/system_tests/fast_confirm_test.go +++ b/system_tests/fast_confirm_test.go @@ -319,7 +319,7 @@ func TestFastConfirmationWithSafe(t *testing.T) { valConfig := staker.TestL1ValidatorConfig valConfig.EnableFastConfirmation = true valConfig.FastConfirmSafeAddress = safeAddress.String() - valConfig.FastConfirmApprover = valWalletAddrA.String() + parentChainID, err := builder.L1.Client.ChainID(ctx) if err != nil { t.Fatalf("Failed to get parent chain id: %v", err) @@ -369,10 +369,8 @@ func TestFastConfirmationWithSafe(t *testing.T) { ) Require(t, err) err = stakerA.Initialize(ctx) - if stakerA.Strategy() != staker.WatchtowerStrategy { - err = valWalletA.Initialize(ctx) - Require(t, err) - } + Require(t, err) + err = valWalletA.Initialize(ctx) Require(t, err) cfg := arbnode.ConfigDefaultL1NonSequencerTest() signerCfg, err := externalSignerTestCfg(srv.Address, srv.URL()) @@ -394,7 +392,6 @@ func TestFastConfirmationWithSafe(t *testing.T) { valWalletB, err := validatorwallet.NewEOA(dpB, l2nodeB.DeployInfo.Rollup, l2nodeB.L1Reader.Client(), func() uint64 { return 0 }) Require(t, err) valConfig.Strategy = "watchtower" - valConfig.FastConfirmApprover = srv.Address.String() statelessB, err := staker.NewStatelessBlockValidator( l2nodeB.InboxReader, l2nodeB.InboxTracker, @@ -423,10 +420,8 @@ func TestFastConfirmationWithSafe(t *testing.T) { Require(t, err) err = stakerB.Initialize(ctx) Require(t, err) - if stakerB.Strategy() != staker.WatchtowerStrategy { - err = valWalletB.Initialize(ctx) - Require(t, err) - } + err = valWalletB.Initialize(ctx) + Require(t, err) builder.L2Info.GenerateAccount("BackgroundUser") tx = builder.L2Info.PrepareTx("Faucet", "BackgroundUser", builder.L2Info.TransferGas, balance, nil) From 2ccca3b4c7d2adda4ac5b40f115a110838cdeae6 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 19 Jul 2024 21:14:10 +0530 Subject: [PATCH 142/268] Changes based on PR comments --- staker/fast_confirm.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/staker/fast_confirm.go b/staker/fast_confirm.go index ef0a6fddb7..1f0e775d94 100644 --- a/staker/fast_confirm.go +++ b/staker/fast_confirm.go @@ -162,9 +162,12 @@ func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Contex var signatures []byte approvedHashCount := uint64(0) for _, owner := range f.owners { + if f.wallet.Address() == nil { + return errors.New("wallet address is nil") + } var approved *big.Int - // No need check if fastConfirmApprover has approved the hash, - // since checkApprovedHashAndExecTransaction is called only after fastConfirmApprover has approved the hash. + // No need check if wallet has approved the hash, + // since checkApprovedHashAndExecTransaction is called only after wallet has approved the hash. if *f.wallet.Address() == owner { approved = common.Big1 } else { From 478a2194ca040917af21018a0abdb3458667665f Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 19 Jul 2024 21:39:42 +0530 Subject: [PATCH 143/268] fix test --- system_tests/fast_confirm_test.go | 16 ++++++++++++++++ system_tests/staker_test.go | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/system_tests/fast_confirm_test.go b/system_tests/fast_confirm_test.go index c552aa51e0..e1ba80fbe0 100644 --- a/system_tests/fast_confirm_test.go +++ b/system_tests/fast_confirm_test.go @@ -504,3 +504,19 @@ func deploySafe(t *testing.T, l1 *TestClient, backend bind.ContractBackend, depl Require(t, err) return safeProxyAddress } + +func makeBackgroundTxs(ctx context.Context, builder *NodeBuilder) error { + for i := uint64(0); ctx.Err() == nil; i++ { + builder.L2Info.Accounts["BackgroundUser"].Nonce.Store(i) + tx := builder.L2Info.PrepareTx("BackgroundUser", "BackgroundUser", builder.L2Info.TransferGas, common.Big0, nil) + err := builder.L2.Client.SendTransaction(ctx, tx) + if err != nil { + return err + } + _, err = builder.L2.EnsureTxSucceeded(tx) + if err != nil { + return err + } + } + return nil +} diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 52f16614f7..3eb5c2891c 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -40,22 +40,6 @@ import ( "github.com/offchainlabs/nitro/validator/valnode" ) -func makeBackgroundTxs(ctx context.Context, builder *NodeBuilder) error { - for i := uint64(0); ctx.Err() == nil; i++ { - builder.L2Info.Accounts["BackgroundUser"].Nonce.Store(i) - tx := builder.L2Info.PrepareTx("BackgroundUser", "BackgroundUser", builder.L2Info.TransferGas, common.Big0, nil) - err := builder.L2.Client.SendTransaction(ctx, tx) - if err != nil { - return err - } - _, err = builder.L2.EnsureTxSucceeded(tx) - if err != nil { - return err - } - } - return nil -} - func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) { t.Parallel() ctx, cancelCtx := context.WithCancel(context.Background()) From a13ddb6b48963fb76d9d1cf9d6e173d090955305 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 19 Jul 2024 22:04:52 +0530 Subject: [PATCH 144/268] skip race --- system_tests/fast_confirm_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/system_tests/fast_confirm_test.go b/system_tests/fast_confirm_test.go index e1ba80fbe0..3719d5422c 100644 --- a/system_tests/fast_confirm_test.go +++ b/system_tests/fast_confirm_test.go @@ -1,3 +1,10 @@ +// Copyright 2023-2024, Offchain Labs, Inc. +// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE + +// race detection makes things slow and miss timeouts +//go:build !race +// +build !race + package arbtest import ( From 84c2fec9a6e08c7a7427b28cdab93298174a68cd Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 19 Jul 2024 22:07:17 +0530 Subject: [PATCH 145/268] fix --- staker/fast_confirm.go | 3 +++ system_tests/fast_confirm_test.go | 16 ---------------- system_tests/staker_test.go | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/staker/fast_confirm.go b/staker/fast_confirm.go index 1f0e775d94..22e4c84350 100644 --- a/staker/fast_confirm.go +++ b/staker/fast_confirm.go @@ -1,3 +1,6 @@ +// Copyright 2023-2024, Offchain Labs, Inc. +// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE + package staker import ( diff --git a/system_tests/fast_confirm_test.go b/system_tests/fast_confirm_test.go index 3719d5422c..d780f80414 100644 --- a/system_tests/fast_confirm_test.go +++ b/system_tests/fast_confirm_test.go @@ -511,19 +511,3 @@ func deploySafe(t *testing.T, l1 *TestClient, backend bind.ContractBackend, depl Require(t, err) return safeProxyAddress } - -func makeBackgroundTxs(ctx context.Context, builder *NodeBuilder) error { - for i := uint64(0); ctx.Err() == nil; i++ { - builder.L2Info.Accounts["BackgroundUser"].Nonce.Store(i) - tx := builder.L2Info.PrepareTx("BackgroundUser", "BackgroundUser", builder.L2Info.TransferGas, common.Big0, nil) - err := builder.L2.Client.SendTransaction(ctx, tx) - if err != nil { - return err - } - _, err = builder.L2.EnsureTxSucceeded(tx) - if err != nil { - return err - } - } - return nil -} diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 3eb5c2891c..52f16614f7 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -40,6 +40,22 @@ import ( "github.com/offchainlabs/nitro/validator/valnode" ) +func makeBackgroundTxs(ctx context.Context, builder *NodeBuilder) error { + for i := uint64(0); ctx.Err() == nil; i++ { + builder.L2Info.Accounts["BackgroundUser"].Nonce.Store(i) + tx := builder.L2Info.PrepareTx("BackgroundUser", "BackgroundUser", builder.L2Info.TransferGas, common.Big0, nil) + err := builder.L2.Client.SendTransaction(ctx, tx) + if err != nil { + return err + } + _, err = builder.L2.EnsureTxSucceeded(tx) + if err != nil { + return err + } + } + return nil +} + func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) { t.Parallel() ctx, cancelCtx := context.WithCancel(context.Background()) From dda572ef06ec49abcc3bf51a7f04981002d72cdb Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 19 Jul 2024 17:12:25 -0600 Subject: [PATCH 146/268] ci: test one package at a time --- .github/workflows/ci.yml | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fea04de4b..fe26b1044b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,13 +145,23 @@ jobs: if: matrix.test-mode == 'defaults' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 -tags=cionly > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + for package in $packages; do + echo running tests for $package + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -tags=cionly > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + exit 1 + fi + done - name: run tests with race detection if: matrix.test-mode == 'race' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -race -timeout 30m -parallel=8 > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + for package in $packages; do + echo running tests for $package + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -race -timeout 30m > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + exit 1 + fi + done - name: run redis tests if: matrix.test-mode == 'defaults' @@ -161,19 +171,34 @@ jobs: if: matrix.test-mode == 'challenge' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -parallel=8 -tags=challengetest -run=TestChallenge > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + for package in $packages; do + echo running tests for $package + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=challengetest -run=TestChallenge > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + exit 1 + fi + done - name: run stylus tests if: matrix.test-mode == 'stylus' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -parallel=8 -tags=stylustest -run="TestProgramArbitrator" > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + for package in $packages; do + echo running tests for $package + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=stylustest -run="TestProgramArbitrator" > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + exit 1 + fi + done - name: run long stylus tests if: matrix.test-mode == 'long' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -parallel=8 -tags=stylustest -run="TestProgramLong" > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + for package in $packages; do + echo running tests for $package + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=stylustest -run="TestProgramLong" > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + exit 1 + fi + done - name: Archive detailed run log uses: actions/upload-artifact@v3 From 4ac4001c0c99ea8d6dcfd42b74c541f1c02fe7c6 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 19 Jul 2024 18:37:40 -0600 Subject: [PATCH 147/268] validation input: use compression level 1 --- validator/server_api/json.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/server_api/json.go b/validator/server_api/json.go index 942013d280..173429d9b1 100644 --- a/validator/server_api/json.go +++ b/validator/server_api/json.go @@ -104,7 +104,7 @@ func ValidationInputToJson(entry *validator.ValidationInput) *InputJSON { for arch, wasms := range entry.UserWasms { archWasms := make(map[common.Hash]string) for moduleHash, data := range wasms { - compressed, err := arbcompress.CompressWell(data) + compressed, err := arbcompress.CompressLevel(data, 1) if err != nil { continue } From 9985c67d7637f8cdbd4830b70f5d9f9ff29254d0 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Sat, 20 Jul 2024 07:51:27 +0530 Subject: [PATCH 148/268] Changes based on PR comments --- staker/fast_confirm.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/staker/fast_confirm.go b/staker/fast_confirm.go index 22e4c84350..59a7443826 100644 --- a/staker/fast_confirm.go +++ b/staker/fast_confirm.go @@ -126,7 +126,22 @@ func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash com return err } } - return f.checkApprovedHashAndExecTransaction(ctx, fastConfirmCallData, safeTxHash) + executedTx, err := f.checkApprovedHashAndExecTransaction(ctx, fastConfirmCallData, safeTxHash) + if err != nil { + return err + } + if executedTx { + return nil + } + // If the transaction was not executed, we need to flush the transactions (for approve hash) and try again. + // This is because the hash might have been approved by another wallet in the same block, + // which might have led to a race condition. + err = f.flushTransactions(ctx) + if err != nil { + return err + } + _, err = f.checkApprovedHashAndExecTransaction(ctx, fastConfirmCallData, safeTxHash) + return err } func (f *FastConfirmSafe) flushTransactions(ctx context.Context) error { @@ -161,12 +176,12 @@ func (f *FastConfirmSafe) createFastConfirmCalldata( return fullCalldata, nil } -func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Context, fastConfirmCallData []byte, safeTxHash [32]byte) error { +func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Context, fastConfirmCallData []byte, safeTxHash [32]byte) (bool, error) { var signatures []byte approvedHashCount := uint64(0) for _, owner := range f.owners { if f.wallet.Address() == nil { - return errors.New("wallet address is nil") + return false, errors.New("wallet address is nil") } var approved *big.Int // No need check if wallet has approved the hash, @@ -177,7 +192,7 @@ func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Contex var err error approved, err = f.safe.ApprovedHashes(&bind.CallOpts{Context: ctx}, owner, safeTxHash) if err != nil { - return err + return false, err } } @@ -200,7 +215,7 @@ func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Contex if approvedHashCount >= f.threshold { auth, err := f.builder.Auth(ctx) if err != nil { - return err + return false, err } _, err = f.safe.ExecTransaction( auth, @@ -216,8 +231,9 @@ func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Contex signatures, ) if err != nil { - return err + return false, err } + return true, nil } - return nil + return false, nil } From 4fdae71a9d139a55d84e902958235272f777dab9 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 22 Jul 2024 13:41:58 +0200 Subject: [PATCH 149/268] Fallback to trying old layout --- das/local_file_storage_service.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index 621cf3efdb..cad323b165 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -110,17 +110,21 @@ func (s *LocalFileStorageService) Close(ctx context.Context) error { func (s *LocalFileStorageService) GetByHash(ctx context.Context, key common.Hash) ([]byte, error) { log.Trace("das.LocalFileStorageService.GetByHash", "key", pretty.PrettyHash(key), "this", s) - var batchPath string - if s.enableLegacyLayout { - batchPath = s.legacyLayout.batchPath(key) - } else { - batchPath = s.layout.batchPath(key) - } + + legacyBatchPath := s.legacyLayout.batchPath(key) + batchPath := s.layout.batchPath(key) data, err := os.ReadFile(batchPath) if err != nil { if errors.Is(err, os.ErrNotExist) { - return nil, ErrNotFound + data, err = os.ReadFile(legacyBatchPath) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return nil, ErrNotFound + } + return nil, err + } + return data, nil } return nil, err } From ffe3a59c1e9c2d969c45dcea69cd0acc33a487d2 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Wed, 8 May 2024 22:06:12 +0200 Subject: [PATCH 150/268] add pathdb related notes --- arbos/arbosState/arbosstate.go | 1 + arbos/arbosState/initialize.go | 4 +++- arbos/storage/storage.go | 1 + cmd/pruning/pruning.go | 1 + cmd/staterecovery/staterecovery.go | 1 + execution/gethexec/blockchain.go | 3 +++ 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index 9ff3dd3aa5..7cce64a426 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -115,6 +115,7 @@ func OpenSystemArbosStateOrPanic(stateDB vm.StateDB, tracingInfo *util.TracingIn // NewArbosMemoryBackedArbOSState creates and initializes a memory-backed ArbOS state (for testing only) func NewArbosMemoryBackedArbOSState() (*ArbosState, *state.StateDB) { raw := rawdb.NewMemoryDatabase() + // TODO pathdb db := state.NewDatabase(raw) statedb, err := state.New(common.Hash{}, db, nil) if err != nil { diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 486c6ae33a..7c4bff3188 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/trie/triedb/pathdb" "github.com/holiman/uint256" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" @@ -52,7 +53,8 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint } func InitializeArbosInDatabase(db ethdb.Database, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (common.Hash, error) { - stateDatabase := state.NewDatabase(db) + // TODO pathdb + stateDatabase := state.NewDatabaseWithConfig(db, &trie.Config{Preimages: false, PathDB: pathdb.Defaults}) statedb, err := state.New(common.Hash{}, stateDatabase, nil) if err != nil { log.Crit("failed to init empty statedb", "error", err) diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index 158b8896c1..8b8877caf1 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -81,6 +81,7 @@ func NewMemoryBacked(burner burn.Burner) *Storage { // NewMemoryBackedStateDB uses Geth's memory-backed database to create a statedb func NewMemoryBackedStateDB() vm.StateDB { raw := rawdb.NewMemoryDatabase() + // TODO pathdb db := state.NewDatabase(raw) statedb, err := state.New(common.Hash{}, db, nil) if err != nil { diff --git a/cmd/pruning/pruning.go b/cmd/pruning/pruning.go index ab6ec80942..2eeff3c88d 100644 --- a/cmd/pruning/pruning.go +++ b/cmd/pruning/pruning.go @@ -233,6 +233,7 @@ func findImportantRoots(ctx context.Context, chainDb ethdb.Database, stack *node } func PruneChainDb(ctx context.Context, chainDb ethdb.Database, stack *node.Node, initConfig *conf.InitConfig, cacheConfig *core.CacheConfig, persistentConfig *conf.PersistentConfig, l1Client arbutil.L1Interface, rollupAddrs chaininfo.RollupAddresses, validatorRequired bool) error { + // TODO pathdb doesn't need and doesn't support prunning if initConfig.Prune == "" { return pruner.RecoverPruning(stack.InstanceDir(), chainDb, initConfig.PruneThreads) } diff --git a/cmd/staterecovery/staterecovery.go b/cmd/staterecovery/staterecovery.go index 19ed51ef2d..19c8bdef57 100644 --- a/cmd/staterecovery/staterecovery.go +++ b/cmd/staterecovery/staterecovery.go @@ -30,6 +30,7 @@ func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheCon if previousBlock == nil { return fmt.Errorf("start block parent is missing, parent block number: %d", current-1) } + // TODO pathdb hashConfig := *hashdb.Defaults hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024 trieConfig := &triedb.Config{ diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index 1d5060ca8a..aba07d6bc9 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -105,6 +105,9 @@ func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core SnapshotRestoreMaxGas: cachingConfig.SnapshotRestoreGasLimit, MaxNumberOfBlocksToSkipStateSaving: cachingConfig.MaxNumberOfBlocksToSkipStateSaving, MaxAmountOfGasToSkipStateSaving: cachingConfig.MaxAmountOfGasToSkipStateSaving, + + // TODO pathdb + StateScheme: rawdb.PathScheme, } } From 3249cbb4300c11177cdc8fd05681f600073f861f Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 16 May 2024 16:43:21 -0300 Subject: [PATCH 151/268] adds --execution.caching.state-scheme command line flag --- cmd/nitro/config_test.go | 18 ++++++++++++++++++ cmd/nitro/nitro.go | 8 ++++++++ execution/gethexec/blockchain.go | 27 +++++++++++++++++++++++++-- execution/gethexec/node.go | 3 +++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/cmd/nitro/config_test.go b/cmd/nitro/config_test.go index f94f941e0b..3861aa497e 100644 --- a/cmd/nitro/config_test.go +++ b/cmd/nitro/config_test.go @@ -17,8 +17,10 @@ import ( "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util/confighelpers" "github.com/offchainlabs/nitro/das" + "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/testhelpers" + "github.com/pkg/errors" "github.com/r3labs/diff/v3" flag "github.com/spf13/pflag" @@ -59,6 +61,22 @@ func TestValidatorConfig(t *testing.T) { Require(t, err) } +func TestInvalidCachingStateSchemeForValidator(t *testing.T) { + args := strings.Split("--execution.caching.state-scheme path --persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --parent-chain.wallet.pathname /l1keystore --parent-chain.wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.staker.enable --node.staker.strategy MakeNodes --node.staker.staker-interval 10s --execution.forwarding-target null", " ") + _, _, _, err := ParseNode(context.Background(), args) + if !errors.Is(err, invalidCachingStateSchemeForValidator) { + Fail(t, "failed to detect invalid state scheme for validator") + } +} + +func TestInvalidArchiveConfig(t *testing.T) { + args := strings.Split("--execution.caching.archive --execution.caching.state-scheme path --persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --parent-chain.wallet.pathname /l1keystore --parent-chain.wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.staker.enable --node.staker.strategy MakeNodes --node.staker.staker-interval 10s --execution.forwarding-target null", " ") + _, _, _, err := ParseNode(context.Background(), args) + if !errors.Is(err, gethexec.InvalidStateSchemeForArchive) { + Fail(t, "failed to detect invalid state scheme for archive") + } +} + func TestAggregatorConfig(t *testing.T) { args := strings.Split("--persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --node.batch-poster.parent-chain-wallet.pathname /l1keystore --node.batch-poster.parent-chain-wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.sequencer --execution.sequencer.enable --node.feed.output.enable --node.feed.output.port 9642 --node.data-availability.enable --node.data-availability.rpc-aggregator.backends [{\"url\":\"http://localhost:8547\",\"pubkey\":\"abc==\"}]", " ") _, _, err := ParseNode(context.Background(), args) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 3a34229768..fd06e509dc 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" _ "github.com/ethereum/go-ethereum/eth/tracers/js" @@ -817,6 +818,10 @@ func (c *NodeConfig) CanReload(new *NodeConfig) error { return err } +var ( + invalidCachingStateSchemeForValidator = errors.New("PathScheme cannot be used as Caching.StateScheme when validator is required") +) + func (c *NodeConfig) Validate() error { if c.Init.RecreateMissingStateFrom > 0 && !c.Execution.Caching.Archive { return errors.New("recreate-missing-state-from enabled for a non-archive node") @@ -836,6 +841,9 @@ func (c *NodeConfig) Validate() error { if err := c.BlocksReExecutor.Validate(); err != nil { return err } + if c.Node.ValidatorRequired() && (c.Execution.Caching.StateScheme == rawdb.PathScheme) { + return invalidCachingStateSchemeForValidator + } return c.Persistent.Validate() } diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index aba07d6bc9..a25c636a40 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -38,6 +38,7 @@ type CachingConfig struct { MaxNumberOfBlocksToSkipStateSaving uint32 `koanf:"max-number-of-blocks-to-skip-state-saving"` MaxAmountOfGasToSkipStateSaving uint64 `koanf:"max-amount-of-gas-to-skip-state-saving"` StylusLRUCache uint32 `koanf:"stylus-lru-cache"` + StateScheme string `koanf:"state-scheme"` } func CachingConfigAddOptions(prefix string, f *flag.FlagSet) { @@ -53,6 +54,7 @@ func CachingConfigAddOptions(prefix string, f *flag.FlagSet) { f.Uint32(prefix+".max-number-of-blocks-to-skip-state-saving", DefaultCachingConfig.MaxNumberOfBlocksToSkipStateSaving, "maximum number of blocks to skip state saving to persistent storage (archive node only) -- warning: this option seems to cause issues") f.Uint64(prefix+".max-amount-of-gas-to-skip-state-saving", DefaultCachingConfig.MaxAmountOfGasToSkipStateSaving, "maximum amount of gas in blocks to skip saving state to Persistent storage (archive node only) -- warning: this option seems to cause issues") f.Uint32(prefix+".stylus-lru-cache", DefaultCachingConfig.StylusLRUCache, "initialized stylus programs to keep in LRU cache") + f.String(prefix+".state-scheme", DefaultCachingConfig.StateScheme, "scheme to use for state trie storage (hashdb, pathdb)") } var DefaultCachingConfig = CachingConfig{ @@ -68,6 +70,7 @@ var DefaultCachingConfig = CachingConfig{ MaxNumberOfBlocksToSkipStateSaving: 0, MaxAmountOfGasToSkipStateSaving: 0, StylusLRUCache: 256, + StateScheme: rawdb.HashScheme, } var TestCachingConfig = CachingConfig{ @@ -83,8 +86,13 @@ var TestCachingConfig = CachingConfig{ MaxNumberOfBlocksToSkipStateSaving: 0, MaxAmountOfGasToSkipStateSaving: 0, StylusLRUCache: 0, + StateScheme: rawdb.PathScheme, } +var ( + InvalidStateSchemeForArchive = errors.New("Archive cannot be set when using PathScheme as the StateScheme") +) + // TODO remove stack from parameters as it is no longer needed here func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core.CacheConfig { baseConf := ethconfig.Defaults @@ -105,10 +113,25 @@ func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core SnapshotRestoreMaxGas: cachingConfig.SnapshotRestoreGasLimit, MaxNumberOfBlocksToSkipStateSaving: cachingConfig.MaxNumberOfBlocksToSkipStateSaving, MaxAmountOfGasToSkipStateSaving: cachingConfig.MaxAmountOfGasToSkipStateSaving, + StateScheme: cachingConfig.StateScheme, + } +} - // TODO pathdb - StateScheme: rawdb.PathScheme, +func (c *CachingConfig) validateStateScheme() error { + switch c.StateScheme { + case rawdb.HashScheme: + case rawdb.PathScheme: + if c.Archive { + return InvalidStateSchemeForArchive + } + default: + return errors.New("Invalid StateScheme") } + return nil +} + +func (c *CachingConfig) Validate() error { + return c.validateStateScheme() } func WriteOrTestGenblock(chainDb ethdb.Database, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, accountsPerSync uint) error { diff --git a/execution/gethexec/node.go b/execution/gethexec/node.go index 8ee16095d9..2fb0684124 100644 --- a/execution/gethexec/node.go +++ b/execution/gethexec/node.go @@ -57,6 +57,9 @@ type Config struct { } func (c *Config) Validate() error { + if err := c.Caching.Validate(); err != nil { + return err + } if err := c.Sequencer.Validate(); err != nil { return err } From 16ef2838b0ad88571bbd200143a808bcc741a131 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 17 May 2024 09:31:31 -0300 Subject: [PATCH 152/268] use pathdb or hashdb according with command line flag --- cmd/pruning/pruning.go | 5 ++++- cmd/staterecovery/staterecovery.go | 15 +++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/pruning/pruning.go b/cmd/pruning/pruning.go index 2eeff3c88d..096bb4b1ae 100644 --- a/cmd/pruning/pruning.go +++ b/cmd/pruning/pruning.go @@ -233,7 +233,10 @@ func findImportantRoots(ctx context.Context, chainDb ethdb.Database, stack *node } func PruneChainDb(ctx context.Context, chainDb ethdb.Database, stack *node.Node, initConfig *conf.InitConfig, cacheConfig *core.CacheConfig, persistentConfig *conf.PersistentConfig, l1Client arbutil.L1Interface, rollupAddrs chaininfo.RollupAddresses, validatorRequired bool) error { - // TODO pathdb doesn't need and doesn't support prunning + if cacheConfig.StateScheme == rawdb.PathScheme { + return nil + } + if initConfig.Prune == "" { return pruner.RecoverPruning(stack.InstanceDir(), chainDb, initConfig.PruneThreads) } diff --git a/cmd/staterecovery/staterecovery.go b/cmd/staterecovery/staterecovery.go index 19c8bdef57..716989aa41 100644 --- a/cmd/staterecovery/staterecovery.go +++ b/cmd/staterecovery/staterecovery.go @@ -5,12 +5,14 @@ import ( "time" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/hashdb" + "github.com/ethereum/go-ethereum/triedb/pathdb" ) func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheConfig *core.CacheConfig, startBlock uint64) error { @@ -30,13 +32,18 @@ func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheCon if previousBlock == nil { return fmt.Errorf("start block parent is missing, parent block number: %d", current-1) } - // TODO pathdb - hashConfig := *hashdb.Defaults - hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024 + trieConfig := &triedb.Config{ Preimages: false, - HashDB: &hashConfig, } + if cacheConfig.StateScheme == rawdb.PathScheme { + trieConfig.PathDB = pathdb.Defaults + } else { + hashConfig := *hashdb.Defaults + hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024 + trieConfig.HashDB = &hashConfig + } + database := state.NewDatabaseWithConfig(chainDb, trieConfig) defer database.TrieDB().Close() previousState, err := state.New(previousBlock.Root(), database, nil) From 07eb9833205e7e9a672aac987f0bc9b0fd383a7f Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 17 May 2024 09:32:30 -0300 Subject: [PATCH 153/268] use pathdb on memory backed state db --- arbos/arbosState/arbosstate.go | 5 +++-- arbos/storage/storage.go | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index 7cce64a426..aa775b6d07 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -15,6 +15,8 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/trie/triedb/pathdb" "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbos/addressSet" @@ -115,8 +117,7 @@ func OpenSystemArbosStateOrPanic(stateDB vm.StateDB, tracingInfo *util.TracingIn // NewArbosMemoryBackedArbOSState creates and initializes a memory-backed ArbOS state (for testing only) func NewArbosMemoryBackedArbOSState() (*ArbosState, *state.StateDB) { raw := rawdb.NewMemoryDatabase() - // TODO pathdb - db := state.NewDatabase(raw) + db := state.NewDatabaseWithConfig(raw, &trie.Config{Preimages: false, PathDB: pathdb.Defaults}) statedb, err := state.New(common.Hash{}, db, nil) if err != nil { log.Crit("failed to init empty statedb", "error", err) diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index 8b8877caf1..be4cd435be 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -18,6 +18,8 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/trie/triedb/pathdb" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" @@ -73,16 +75,17 @@ func NewGeth(statedb vm.StateDB, burner burn.Burner) *Storage { } } -// NewMemoryBacked uses Geth's memory-backed database to create an evm key-value store +// NewMemoryBacked uses Geth's memory-backed database to create an evm key-value store. +// Only used for testing. func NewMemoryBacked(burner burn.Burner) *Storage { return NewGeth(NewMemoryBackedStateDB(), burner) } // NewMemoryBackedStateDB uses Geth's memory-backed database to create a statedb +// Only used for testing. func NewMemoryBackedStateDB() vm.StateDB { raw := rawdb.NewMemoryDatabase() - // TODO pathdb - db := state.NewDatabase(raw) + db := state.NewDatabaseWithConfig(raw, &trie.Config{Preimages: false, PathDB: pathdb.Defaults}) statedb, err := state.New(common.Hash{}, db, nil) if err != nil { panic("failed to init empty statedb") From 2d0e08c9c2bac0b9b32e5dc901119cf6b6c2a7d8 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 17 May 2024 11:21:32 -0300 Subject: [PATCH 154/268] StateHistory caching option --- cmd/staterecovery/staterecovery.go | 8 +++++++- execution/gethexec/blockchain.go | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/staterecovery/staterecovery.go b/cmd/staterecovery/staterecovery.go index 716989aa41..f7dc87971d 100644 --- a/cmd/staterecovery/staterecovery.go +++ b/cmd/staterecovery/staterecovery.go @@ -37,7 +37,13 @@ func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheCon Preimages: false, } if cacheConfig.StateScheme == rawdb.PathScheme { - trieConfig.PathDB = pathdb.Defaults + // TODO: RecreateMissingStates should only be used for archive nodes, + // check if it is worth keeping this option here + trieConfig.PathDB = &pathdb.Config{ + StateHistory: cacheConfig.StateHistory, + CleanCacheSize: cacheConfig.TrieCleanLimit * 1024 * 1024, + DirtyCacheSize: cacheConfig.TrieDirtyLimit * 1024 * 1024, + } } else { hashConfig := *hashdb.Defaults hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024 diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index a25c636a40..7b550e9601 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -39,6 +39,7 @@ type CachingConfig struct { MaxAmountOfGasToSkipStateSaving uint64 `koanf:"max-amount-of-gas-to-skip-state-saving"` StylusLRUCache uint32 `koanf:"stylus-lru-cache"` StateScheme string `koanf:"state-scheme"` + StateHistory uint64 `koanf:"state-history"` } func CachingConfigAddOptions(prefix string, f *flag.FlagSet) { @@ -55,6 +56,7 @@ func CachingConfigAddOptions(prefix string, f *flag.FlagSet) { f.Uint64(prefix+".max-amount-of-gas-to-skip-state-saving", DefaultCachingConfig.MaxAmountOfGasToSkipStateSaving, "maximum amount of gas in blocks to skip saving state to Persistent storage (archive node only) -- warning: this option seems to cause issues") f.Uint32(prefix+".stylus-lru-cache", DefaultCachingConfig.StylusLRUCache, "initialized stylus programs to keep in LRU cache") f.String(prefix+".state-scheme", DefaultCachingConfig.StateScheme, "scheme to use for state trie storage (hashdb, pathdb)") + f.Uint64(prefix+".state-history", DefaultCachingConfig.StateHistory, "number of recent blocks to retain state history for (pathdb state-scheme only)") } var DefaultCachingConfig = CachingConfig{ @@ -71,6 +73,7 @@ var DefaultCachingConfig = CachingConfig{ MaxAmountOfGasToSkipStateSaving: 0, StylusLRUCache: 256, StateScheme: rawdb.HashScheme, + StateHistory: 90000, } var TestCachingConfig = CachingConfig{ @@ -114,6 +117,7 @@ func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core MaxNumberOfBlocksToSkipStateSaving: cachingConfig.MaxNumberOfBlocksToSkipStateSaving, MaxAmountOfGasToSkipStateSaving: cachingConfig.MaxAmountOfGasToSkipStateSaving, StateScheme: cachingConfig.StateScheme, + StateHistory: cachingConfig.StateHistory, } } From ab10d4cb9d30992fbf9f6c8bb41f191ffaef9616 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 17 May 2024 16:36:55 -0300 Subject: [PATCH 155/268] define pathdb as the default state scheme to be used in tests --- arbnode/inbox_test.go | 3 ++- arbos/arbosState/initialization_test.go | 4 +++- execution/gethexec/blockchain.go | 6 ++++++ execution/gethexec/node.go | 2 ++ system_tests/block_validator_test.go | 3 +++ system_tests/debug_trace_test.go | 2 ++ system_tests/program_test.go | 2 ++ system_tests/pruning_test.go | 2 ++ system_tests/recreatestate_rpc_test.go | 9 +++++++++ system_tests/staterecovery_test.go | 2 ++ system_tests/triedb_race_test.go | 2 ++ 11 files changed, 35 insertions(+), 2 deletions(-) diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index ef4acd038c..64879b7eb4 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -59,7 +59,8 @@ func NewTransactionStreamerForTest(t *testing.T, ownerAddress common.Address) (* arbDb := rawdb.NewMemoryDatabase() initReader := statetransfer.NewMemoryInitDataReader(&initData) - bc, err := gethexec.WriteOrTestBlockChain(chainDb, nil, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefaultTest().TxLookupLimit, 0) + cacheConfig := core.DefaultCacheConfigWithScheme(rawdb.PathScheme) + bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefaultTest().TxLookupLimit, 0) if err != nil { Fail(t, err) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 0ef9cea4c5..c400d9e7a0 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -13,6 +13,8 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/trie/triedb/pathdb" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/statetransfer" @@ -63,7 +65,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin stateroot, err := InitializeArbosInDatabase(raw, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) - stateDb, err := state.New(stateroot, state.NewDatabase(raw), nil) + stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, &trie.Config{Preimages: false, PathDB: pathdb.Defaults}), nil) Require(t, err) arbState, err := OpenArbosState(stateDb, &burn.SystemBurner{}) diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index 7b550e9601..fca86157b7 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -96,6 +96,12 @@ var ( InvalidStateSchemeForArchive = errors.New("Archive cannot be set when using PathScheme as the StateScheme") ) +func DefaultTestCachingConfig() CachingConfig { + c := DefaultCachingConfig + c.StateScheme = rawdb.PathScheme + return c +} + // TODO remove stack from parameters as it is no longer needed here func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core.CacheConfig { baseConf := ethconfig.Defaults diff --git a/execution/gethexec/node.go b/execution/gethexec/node.go index 2fb0684124..d52021745a 100644 --- a/execution/gethexec/node.go +++ b/execution/gethexec/node.go @@ -115,6 +115,7 @@ func ConfigDefaultNonSequencerTest() *Config { config.Sequencer.Enable = false config.Forwarder = DefaultTestForwarderConfig config.ForwardingTarget = "null" + config.Caching = DefaultTestCachingConfig() _ = config.Validate() @@ -127,6 +128,7 @@ func ConfigDefaultTest() *Config { config.Sequencer = TestSequencerConfig config.ParentChainReader = headerreader.TestConfig config.ForwardingTarget = "null" + config.Caching = DefaultTestCachingConfig() _ = config.Validate() diff --git a/system_tests/block_validator_test.go b/system_tests/block_validator_test.go index b4dafbff15..2915288f9e 100644 --- a/system_tests/block_validator_test.go +++ b/system_tests/block_validator_test.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -68,6 +69,8 @@ func testBlockValidatorSimple(t *testing.T, opts Options) { builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder = builder.WithWasmRootDir(opts.wasmRootDir) + // By now PathDB is not supported when using block validation + builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.nodeConfig = l1NodeConfigA builder.chainConfig = chainConfig builder.L2Info = nil diff --git a/system_tests/debug_trace_test.go b/system_tests/debug_trace_test.go index 1a83e5ad2f..0c080df686 100644 --- a/system_tests/debug_trace_test.go +++ b/system_tests/debug_trace_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" ) @@ -22,6 +23,7 @@ func TestDebugTraceCallForRecentBlock(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true + builder.execConfig.Caching.StateScheme = rawdb.HashScheme cleanup := builder.Build(t) defer cleanup() builder.L2Info.GenerateAccount("User2") diff --git a/system_tests/program_test.go b/system_tests/program_test.go index b748739cdc..5515888574 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -20,6 +20,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -1474,6 +1475,7 @@ func setupProgramTest(t *testing.T, jit bool, builderOpts ...func(*NodeBuilder)) opt(builder) } + builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.nodeConfig.BlockValidator.Enable = false builder.nodeConfig.Staker.Enable = true builder.nodeConfig.BatchPoster.Enable = true diff --git a/system_tests/pruning_test.go b/system_tests/pruning_test.go index 041781ac48..90ac3c6909 100644 --- a/system_tests/pruning_test.go +++ b/system_tests/pruning_test.go @@ -35,6 +35,8 @@ func TestPruning(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) + // PathScheme prunes the state trie by itself, so only HashScheme should be tested + builder.execConfig.Caching.StateScheme = rawdb.HashScheme _ = builder.Build(t) l2cleanupDone := false defer func() { diff --git a/system_tests/recreatestate_rpc_test.go b/system_tests/recreatestate_rpc_test.go index de123aee78..e23cb5c392 100644 --- a/system_tests/recreatestate_rpc_test.go +++ b/system_tests/recreatestate_rpc_test.go @@ -100,6 +100,7 @@ func TestRecreateStateForRPCNoDepthLimit(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + execConfig.Caching.StateScheme = rawdb.HashScheme execConfig.Caching.SnapshotCache = 0 // disable snapshots // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -136,6 +137,7 @@ func TestRecreateStateForRPCBigEnoughDepthLimit(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 0 @@ -171,6 +173,7 @@ func TestRecreateStateForRPCDepthLimitExceeded(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 0 @@ -206,6 +209,7 @@ func TestRecreateStateForRPCMissingBlockParent(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 0 @@ -252,6 +256,7 @@ func TestRecreateStateForRPCBeyondGenesis(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 0 @@ -288,6 +293,7 @@ func TestRecreateStateForRPCBlockNotFoundWhileRecreating(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -429,6 +435,7 @@ func testSkippingSavingStateAndRecreatingAfterRestart(t *testing.T, cacheConfig func TestSkippingSavingStateAndRecreatingAfterRestart(t *testing.T) { cacheConfig := gethexec.TestCachingConfig cacheConfig.Archive = true + cacheConfig.StateScheme = rawdb.HashScheme cacheConfig.SnapshotCache = 0 // disable snapshots cacheConfig.BlockAge = 0 // use only Caching.BlockCount to keep only last N blocks in dirties cache, no matter how new they are @@ -512,6 +519,7 @@ func TestGettingStateForRPCHybridArchiveNode(t *testing.T) { defer cancel() execConfig := gethexec.ConfigDefaultTest() execConfig.Caching.Archive = true + execConfig.Caching.StateScheme = rawdb.HashScheme execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 128 execConfig.Caching.BlockCount = 128 execConfig.Caching.SnapshotCache = 0 // disable snapshots @@ -558,6 +566,7 @@ func TestStateAndHeaderForRecentBlock(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true + builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.RPC.MaxRecreateStateDepth = 0 cleanup := builder.Build(t) defer cleanup() diff --git a/system_tests/staterecovery_test.go b/system_tests/staterecovery_test.go index 1dd4be2444..0e3e391b40 100644 --- a/system_tests/staterecovery_test.go +++ b/system_tests/staterecovery_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/trie" @@ -19,6 +20,7 @@ func TestRectreateMissingStates(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true + builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 16 builder.execConfig.Caching.SnapshotCache = 0 // disable snapshots _ = builder.Build(t) diff --git a/system_tests/triedb_race_test.go b/system_tests/triedb_race_test.go index 9f14f08898..d2ae9dd56b 100644 --- a/system_tests/triedb_race_test.go +++ b/system_tests/triedb_race_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/util/testhelpers" @@ -23,6 +24,7 @@ func TestTrieDBCommitRace(t *testing.T) { builder.execConfig.Sequencer.MaxBlockSpeed = 0 builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 builder.execConfig.Caching.Archive = true + builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.Caching.BlockCount = 127 builder.execConfig.Caching.BlockAge = 0 builder.execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 127 From e8956ed62f6cd6357713f44083a41b0dd6898f3e Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 20 May 2024 12:18:40 -0300 Subject: [PATCH 156/268] pathdb support in InitializeArbosInDatabase --- arbos/arbosState/initialization_test.go | 10 +++++---- arbos/arbosState/initialize.go | 27 ++++++++++++++++++++++--- execution/gethexec/blockchain.go | 6 +++--- system_tests/state_fuzz_test.go | 5 ++++- 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index c400d9e7a0..ae9c826544 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -10,11 +10,10 @@ import ( "testing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/trie" - "github.com/ethereum/go-ethereum/trie/triedb/pathdb" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/statetransfer" @@ -62,10 +61,13 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin initReader := statetransfer.NewMemoryInitDataReader(&initData) chainConfig := params.ArbitrumDevTestChainConfig() - stateroot, err := InitializeArbosInDatabase(raw, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) + + cacheConfig := core.DefaultCacheConfigWithScheme(rawdb.PathScheme) + stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) - stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, &trie.Config{Preimages: false, PathDB: pathdb.Defaults}), nil) + triedbConfig := TriedbConfig(cacheConfig) + stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, triedbConfig), nil) Require(t, err) arbState, err := OpenArbosState(stateDb, &burn.SystemBurner{}) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 7c4bff3188..b8cdc69446 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -9,12 +9,15 @@ import ( "sort" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/trie/triedb/hashdb" "github.com/ethereum/go-ethereum/trie/triedb/pathdb" "github.com/holiman/uint256" "github.com/offchainlabs/nitro/arbos/arbostypes" @@ -52,9 +55,27 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)) } -func InitializeArbosInDatabase(db ethdb.Database, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (common.Hash, error) { - // TODO pathdb - stateDatabase := state.NewDatabaseWithConfig(db, &trie.Config{Preimages: false, PathDB: pathdb.Defaults}) +func TriedbConfig(c *core.CacheConfig) *trie.Config { + config := &trie.Config{Preimages: c.Preimages} + if c.StateScheme == rawdb.HashScheme { + config.HashDB = &hashdb.Config{ + CleanCacheSize: c.TrieCleanLimit * 1024 * 1024, + } + } + if c.StateScheme == rawdb.PathScheme { + config.PathDB = &pathdb.Config{ + StateHistory: c.StateHistory, + CleanCacheSize: c.TrieCleanLimit * 1024 * 1024, + DirtyCacheSize: c.TrieDirtyLimit * 1024 * 1024, + } + } + return config +} + +func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (common.Hash, error) { + triedbConfig := TriedbConfig(cacheConfig) + triedbConfig.Preimages = false + stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig) statedb, err := state.New(common.Hash{}, stateDatabase, nil) if err != nil { log.Crit("failed to init empty statedb", "error", err) diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index fca86157b7..29bc77e17c 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -144,7 +144,7 @@ func (c *CachingConfig) Validate() error { return c.validateStateScheme() } -func WriteOrTestGenblock(chainDb ethdb.Database, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, accountsPerSync uint) error { +func WriteOrTestGenblock(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, accountsPerSync uint) error { EmptyHash := common.Hash{} prevHash := EmptyHash prevDifficulty := big.NewInt(0) @@ -165,7 +165,7 @@ func WriteOrTestGenblock(chainDb ethdb.Database, initData statetransfer.InitData } timestamp = prevHeader.Time } - stateRoot, err := arbosState.InitializeArbosInDatabase(chainDb, initData, chainConfig, initMessage, timestamp, accountsPerSync) + stateRoot, err := arbosState.InitializeArbosInDatabase(chainDb, cacheConfig, initData, chainConfig, initMessage, timestamp, accountsPerSync) if err != nil { return err } @@ -233,7 +233,7 @@ func GetBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, chainC } func WriteOrTestBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, txLookupLimit uint64, accountsPerSync uint) (*core.BlockChain, error) { - err := WriteOrTestGenblock(chainDb, initData, chainConfig, initMessage, accountsPerSync) + err := WriteOrTestGenblock(chainDb, cacheConfig, initData, chainConfig, initMessage, accountsPerSync) if err != nil { return nil, err } diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index bb78bda480..09ca6d265c 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -137,8 +137,10 @@ func FuzzStateTransition(f *testing.F) { ChainConfig: chainConfig, SerializedChainConfig: serializedChainConfig, } + cacheConfig := core.DefaultCacheConfigWithScheme(rawdb.PathScheme) stateRoot, err := arbosState.InitializeArbosInDatabase( chainDb, + cacheConfig, statetransfer.NewMemoryInitDataReader(&statetransfer.ArbosInitializationInfo{}), chainConfig, initMessage, @@ -148,7 +150,8 @@ func FuzzStateTransition(f *testing.F) { if err != nil { panic(err) } - statedb, err := state.New(stateRoot, state.NewDatabase(chainDb), nil) + trieDBConfig := arbosState.TriedbConfig(cacheConfig) + statedb, err := state.New(stateRoot, state.NewDatabaseWithConfig(chainDb, trieDBConfig), nil) if err != nil { panic(err) } From e8c1b302a2bc2ff79eeca982bf1ebed6c47948b2 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 20 May 2024 14:38:45 -0300 Subject: [PATCH 157/268] general improvements when testing state-scheme args --- cmd/nitro/config_test.go | 11 +++++++---- cmd/nitro/nitro.go | 2 +- execution/gethexec/blockchain.go | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/nitro/config_test.go b/cmd/nitro/config_test.go index 3861aa497e..af902fab0f 100644 --- a/cmd/nitro/config_test.go +++ b/cmd/nitro/config_test.go @@ -55,6 +55,8 @@ func TestUnsafeStakerConfig(t *testing.T) { Require(t, err) } +const validatorArgs = "--persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --node.staker.parent-chain-wallet.pathname /l1keystore --node.staker.parent-chain-wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.staker.enable --node.staker.strategy MakeNodes --node.staker.staker-interval 10s --execution.forwarding-target null" + func TestValidatorConfig(t *testing.T) { args := strings.Split("--persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --node.staker.parent-chain-wallet.pathname /l1keystore --node.staker.parent-chain-wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.staker.enable --node.staker.strategy MakeNodes --node.staker.staker-interval 10s --execution.forwarding-target null", " ") _, _, err := ParseNode(context.Background(), args) @@ -62,16 +64,17 @@ func TestValidatorConfig(t *testing.T) { } func TestInvalidCachingStateSchemeForValidator(t *testing.T) { - args := strings.Split("--execution.caching.state-scheme path --persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --parent-chain.wallet.pathname /l1keystore --parent-chain.wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.staker.enable --node.staker.strategy MakeNodes --node.staker.staker-interval 10s --execution.forwarding-target null", " ") - _, _, _, err := ParseNode(context.Background(), args) + validatorArgsWithPathScheme := fmt.Sprintf("%s --execution.caching.state-scheme path", validatorArgs) + args := strings.Split(validatorArgsWithPathScheme, " ") + _, _, err := ParseNode(context.Background(), args) if !errors.Is(err, invalidCachingStateSchemeForValidator) { Fail(t, "failed to detect invalid state scheme for validator") } } func TestInvalidArchiveConfig(t *testing.T) { - args := strings.Split("--execution.caching.archive --execution.caching.state-scheme path --persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --parent-chain.wallet.pathname /l1keystore --parent-chain.wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.staker.enable --node.staker.strategy MakeNodes --node.staker.staker-interval 10s --execution.forwarding-target null", " ") - _, _, _, err := ParseNode(context.Background(), args) + args := strings.Split("--execution.caching.archive --execution.caching.state-scheme path --persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --node.staker.parent-chain-wallet.pathname /l1keystore --node.staker.parent-chain-wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.staker.enable --node.staker.strategy MakeNodes --node.staker.staker-interval 10s --execution.forwarding-target null", " ") + _, _, err := ParseNode(context.Background(), args) if !errors.Is(err, gethexec.InvalidStateSchemeForArchive) { Fail(t, "failed to detect invalid state scheme for archive") } diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index fd06e509dc..0b979d5624 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -819,7 +819,7 @@ func (c *NodeConfig) CanReload(new *NodeConfig) error { } var ( - invalidCachingStateSchemeForValidator = errors.New("PathScheme cannot be used as Caching.StateScheme when validator is required") + invalidCachingStateSchemeForValidator = errors.New("path cannot be used as execution.caching.state-scheme when validator is required") ) func (c *NodeConfig) Validate() error { diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index 29bc77e17c..47436ab173 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -93,7 +93,7 @@ var TestCachingConfig = CachingConfig{ } var ( - InvalidStateSchemeForArchive = errors.New("Archive cannot be set when using PathScheme as the StateScheme") + InvalidStateSchemeForArchive = errors.New("archive cannot be set when using path as the state-scheme") ) func DefaultTestCachingConfig() CachingConfig { From 5364d3945db320227278d12662f7f809f25c7cd3 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 20 May 2024 14:59:14 -0300 Subject: [PATCH 158/268] recreate missing states fails if is executed with path scheme recreate missing states should be run in archive mode, and by now path scheme doesn't support archive mode --- cmd/staterecovery/staterecovery.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/cmd/staterecovery/staterecovery.go b/cmd/staterecovery/staterecovery.go index f7dc87971d..bb01477414 100644 --- a/cmd/staterecovery/staterecovery.go +++ b/cmd/staterecovery/staterecovery.go @@ -12,7 +12,6 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/hashdb" - "github.com/ethereum/go-ethereum/triedb/pathdb" ) func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheConfig *core.CacheConfig, startBlock uint64) error { @@ -33,21 +32,15 @@ func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheCon return fmt.Errorf("start block parent is missing, parent block number: %d", current-1) } + if cacheConfig.StateScheme == rawdb.PathScheme { + return fmt.Errorf("recreating missing states, which is supposed to only run in archive mode, is not supported with path scheme") + } + + hashConfig := *hashdb.Defaults + hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024 trieConfig := &triedb.Config{ Preimages: false, - } - if cacheConfig.StateScheme == rawdb.PathScheme { - // TODO: RecreateMissingStates should only be used for archive nodes, - // check if it is worth keeping this option here - trieConfig.PathDB = &pathdb.Config{ - StateHistory: cacheConfig.StateHistory, - CleanCacheSize: cacheConfig.TrieCleanLimit * 1024 * 1024, - DirtyCacheSize: cacheConfig.TrieDirtyLimit * 1024 * 1024, - } - } else { - hashConfig := *hashdb.Defaults - hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024 - trieConfig.HashDB = &hashConfig + HashDB: &hashConfig, } database := state.NewDatabaseWithConfig(chainDb, trieConfig) From 1a15b72e0b5365a93a8ddad6f3dcb92c89b7d484 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 20 May 2024 15:14:32 -0300 Subject: [PATCH 159/268] add comment on why HashScheme is being used in setupProgramTest --- system_tests/program_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 5515888574..4b13b5fa15 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1475,6 +1475,8 @@ func setupProgramTest(t *testing.T, jit bool, builderOpts ...func(*NodeBuilder)) opt(builder) } + // setupProgramTest is being called from tests that validate blocks. + // By now validation only works with HashScheme set. builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.nodeConfig.BlockValidator.Enable = false builder.nodeConfig.Staker.Enable = true From a2bf33157c872fd17cb61a2bf36558e86d13e2d3 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 20 May 2024 19:54:55 -0300 Subject: [PATCH 160/268] gracefully fails if provided state scheme is incompatible with stored trie --- cmd/nitro/init.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index ea48ec8784..c8b4011c54 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -423,6 +423,10 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo return nil, nil, err } chainDb := rawdb.WrapDatabaseWithWasm(chainData, wasmDb, 1) + _, err = rawdb.ParseStateScheme(cacheConfig.StateScheme, chainDb) + if err != nil { + return nil, nil, err + } err = pruning.PruneChainDb(ctx, chainDb, stack, &config.Init, cacheConfig, persistentConfig, l1Client, rollupAddrs, config.Node.ValidatorRequired()) if err != nil { return chainDb, nil, fmt.Errorf("error pruning: %w", err) @@ -533,6 +537,10 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo return nil, nil, err } chainDb := rawdb.WrapDatabaseWithWasm(chainData, wasmDb, 1) + _, err = rawdb.ParseStateScheme(cacheConfig.StateScheme, chainDb) + if err != nil { + return nil, nil, err + } // Rebuilding wasm store is not required when just starting out err = gethexec.WriteToKeyValueStore(wasmDb, gethexec.RebuildingPositionKey, gethexec.RebuildingDone) From 7c508685f704bab76c34e8293530b172e0908959 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Tue, 21 May 2024 15:11:20 -0300 Subject: [PATCH 161/268] fix challenger tests, some of them require hashdb by now --- system_tests/full_challenge_impl_test.go | 3 +++ system_tests/program_test.go | 2 +- system_tests/staker_test.go | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/system_tests/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index bf95c390ba..520886af2a 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" @@ -262,6 +263,8 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall if useStubs { mockSpawn, valStack = createMockValidationNode(t, ctx, &builder.valnodeConfig.Arbitrator) } else { + // By now validation only works with HashScheme set + builder.execConfig.Caching.StateScheme = rawdb.HashScheme _, valStack = createTestValidationNode(t, ctx, builder.valnodeConfig) } configByValidationNode(conf, valStack) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 4b13b5fa15..53b771361c 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1475,7 +1475,7 @@ func setupProgramTest(t *testing.T, jit bool, builderOpts ...func(*NodeBuilder)) opt(builder) } - // setupProgramTest is being called from tests that validate blocks. + // setupProgramTest is being called by tests that validate blocks. // By now validation only works with HashScheme set. builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.nodeConfig.BlockValidator.Enable = false diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 52f16614f7..993f2d0612 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -76,6 +76,9 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) transferGas, ) + // By now validation only works with HashScheme set + builder.execConfig.Caching.StateScheme = rawdb.HashScheme + builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour cleanupA := builder.Build(t) defer cleanupA() From d30e66ca5f98db1bd563dc036416773feab30d9a Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 23 May 2024 17:40:38 -0300 Subject: [PATCH 162/268] Closes stateDatabase.TrieDB() after finishing using it --- arbos/arbosState/initialize.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index b8cdc69446..d8b2af9d7d 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -72,10 +72,13 @@ func TriedbConfig(c *core.CacheConfig) *trie.Config { return config } -func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (common.Hash, error) { +func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) { triedbConfig := TriedbConfig(cacheConfig) triedbConfig.Preimages = false stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig) + defer func() { + err = stateDatabase.TrieDB().Close() + }() statedb, err := state.New(common.Hash{}, stateDatabase, nil) if err != nil { log.Crit("failed to init empty statedb", "error", err) From 3426e473ceff4a8144ba4772ef1751d94ca70551 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 24 May 2024 09:42:57 -0300 Subject: [PATCH 163/268] Removes DefaultTestCachingConfig --- execution/gethexec/blockchain.go | 6 ------ execution/gethexec/node.go | 2 -- system_tests/staterecovery_test.go | 4 +++- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index 47436ab173..60740af039 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -96,12 +96,6 @@ var ( InvalidStateSchemeForArchive = errors.New("archive cannot be set when using path as the state-scheme") ) -func DefaultTestCachingConfig() CachingConfig { - c := DefaultCachingConfig - c.StateScheme = rawdb.PathScheme - return c -} - // TODO remove stack from parameters as it is no longer needed here func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core.CacheConfig { baseConf := ethconfig.Defaults diff --git a/execution/gethexec/node.go b/execution/gethexec/node.go index d52021745a..2fb0684124 100644 --- a/execution/gethexec/node.go +++ b/execution/gethexec/node.go @@ -115,7 +115,6 @@ func ConfigDefaultNonSequencerTest() *Config { config.Sequencer.Enable = false config.Forwarder = DefaultTestForwarderConfig config.ForwardingTarget = "null" - config.Caching = DefaultTestCachingConfig() _ = config.Validate() @@ -128,7 +127,6 @@ func ConfigDefaultTest() *Config { config.Sequencer = TestSequencerConfig config.ParentChainReader = headerreader.TestConfig config.ForwardingTarget = "null" - config.Caching = DefaultTestCachingConfig() _ = config.Validate() diff --git a/system_tests/staterecovery_test.go b/system_tests/staterecovery_test.go index 0e3e391b40..60445c2f29 100644 --- a/system_tests/staterecovery_test.go +++ b/system_tests/staterecovery_test.go @@ -55,7 +55,9 @@ func TestRectreateMissingStates(t *testing.T) { chainDb, err := stack.OpenDatabaseWithExtraOptions("l2chaindata", 0, 0, "l2chaindata/", false, conf.PersistentConfigDefault.Pebble.ExtraOptions("l2chaindata")) Require(t, err) defer chainDb.Close() - cacheConfig := gethexec.DefaultCacheConfigFor(stack, &gethexec.TestCachingConfig) + cachingConfig := gethexec.TestCachingConfig + cachingConfig.StateScheme = rawdb.HashScheme + cacheConfig := gethexec.DefaultCacheConfigFor(stack, &cachingConfig) bc, err := gethexec.GetBlockChain(chainDb, cacheConfig, builder.chainConfig, builder.execConfig.TxLookupLimit) Require(t, err) err = staterecovery.RecreateMissingStates(chainDb, bc, cacheConfig, 1) From 74775729566fd9b77d0cf4e5e166c6c37c54c2c1 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 24 May 2024 14:54:59 -0300 Subject: [PATCH 164/268] Only calls TrieDB.Commit once for PathScheme in InitializeArbosInDatabase --- arbos/arbosState/initialize.go | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index d8b2af9d7d..8b46c19fde 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -84,14 +84,21 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, log.Crit("failed to init empty statedb", "error", err) } + // commit avoids keeping the entire state in memory while importing the state. + // At some time it was also used to avoid reprocessing the whole import in case of a crash. commit := func() (common.Hash, error) { root, err := statedb.Commit(chainConfig.ArbitrumChainParams.GenesisBlockNum, true) if err != nil { return common.Hash{}, err } - err = stateDatabase.TrieDB().Commit(root, true) - if err != nil { - return common.Hash{}, err + // When using PathScheme TrieDB.Commit should only be called once. + // When using HashScheme it is called multiple times to avoid keeping + // the entire trie in memory. + if cacheConfig.StateScheme == rawdb.HashScheme { + err = stateDatabase.TrieDB().Commit(root, true) + if err != nil { + return common.Hash{}, err + } } statedb, err = state.New(root, stateDatabase, nil) if err != nil { @@ -189,7 +196,18 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, if err := accountDataReader.Close(); err != nil { return common.Hash{}, err } - return commit() + + root, err = commit() + if err != nil { + return common.Hash{}, err + } + if cacheConfig.StateScheme == rawdb.PathScheme { + err = stateDatabase.TrieDB().Commit(root, true) + if err != nil { + return common.Hash{}, err + } + } + return root, nil } func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState, initData statetransfer.RetryableDataReader, currentTimestamp uint64) error { From 924fbefe47a93ee1e1975133d83b4da68514a7d8 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 24 May 2024 20:40:12 -0300 Subject: [PATCH 165/268] Test for openInitializeChainDb --- cmd/nitro/init_test.go | 78 +++++++++++++++++++++++++++++++-- system_tests/common_test.go | 29 +++--------- system_tests/das_test.go | 3 +- system_tests/program_test.go | 2 +- util/testhelpers/stackconfig.go | 23 ++++++++++ 5 files changed, 107 insertions(+), 28 deletions(-) create mode 100644 util/testhelpers/stackconfig.go diff --git a/cmd/nitro/init_test.go b/cmd/nitro/init_test.go index 6c363972e9..add13feee1 100644 --- a/cmd/nitro/init_test.go +++ b/cmd/nitro/init_test.go @@ -1,6 +1,3 @@ -// Copyright 2021-2022, Offchain Labs, Inc. -// For license information, see https://github.com/nitro/blob/master/LICENSE - package main import ( @@ -10,6 +7,7 @@ import ( "encoding/hex" "errors" "fmt" + "math/big" "net" "net/http" "os" @@ -19,8 +17,13 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/node" + "github.com/offchainlabs/nitro/arbnode" + "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/cmd/conf" + "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -361,3 +364,72 @@ func TestEmptyDatabaseDir(t *testing.T) { }) } } + +func TestOpenInitializeChainDbIncompatibleStateScheme(t *testing.T) { + t.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + stackConfig := testhelpers.CreateStackConfigForTest(t.TempDir()) + stack, err := node.New(stackConfig) + defer stack.Close() + Require(t, err) + + nodeConfig := NodeConfigDefault + nodeConfig.Execution.Caching.StateScheme = rawdb.PathScheme + nodeConfig.Chain.ID = 42161 + nodeConfig.Node = *arbnode.ConfigDefaultL2Test() + nodeConfig.Init.DevInit = true + nodeConfig.Init.DevInitAddress = "0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E" + + l1Client := ethclient.NewClient(stack.Attach()) + + // opening for the first time doesn't error + chainDb, blockchain, err := openInitializeChainDb( + ctx, + stack, + &nodeConfig, + new(big.Int).SetUint64(nodeConfig.Chain.ID), + gethexec.DefaultCacheConfigFor(stack, &nodeConfig.Execution.Caching), + &nodeConfig.Persistent, + l1Client, + chaininfo.RollupAddresses{}, + ) + Require(t, err) + blockchain.Stop() + err = chainDb.Close() + Require(t, err) + + // opening for the second time doesn't error + chainDb, blockchain, err = openInitializeChainDb( + ctx, + stack, + &nodeConfig, + new(big.Int).SetUint64(nodeConfig.Chain.ID), + gethexec.DefaultCacheConfigFor(stack, &nodeConfig.Execution.Caching), + &nodeConfig.Persistent, + l1Client, + chaininfo.RollupAddresses{}, + ) + Require(t, err) + blockchain.Stop() + err = chainDb.Close() + Require(t, err) + + // opening with a different state scheme errors + nodeConfig.Execution.Caching.StateScheme = rawdb.HashScheme + _, _, err = openInitializeChainDb( + ctx, + stack, + &nodeConfig, + new(big.Int).SetUint64(nodeConfig.Chain.ID), + gethexec.DefaultCacheConfigFor(stack, &nodeConfig.Execution.Caching), + &nodeConfig.Persistent, + l1Client, + chaininfo.RollupAddresses{}, + ) + if !strings.Contains(err.Error(), "incompatible state scheme, stored: path, provided: hash") { + t.Fatalf("Failed to detect incompatible state scheme") + } +} diff --git a/system_tests/common_test.go b/system_tests/common_test.go index b0748f8639..191a33cb22 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -19,6 +19,7 @@ import ( "time" "github.com/go-redis/redis/v8" + "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/arbstate/daprovider" @@ -66,7 +67,6 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/arbnode" - "github.com/offchainlabs/nitro/arbos" "github.com/offchainlabs/nitro/arbutil" _ "github.com/offchainlabs/nitro/execution/nodeInterface" "github.com/offchainlabs/nitro/solgen/go/bridgegen" @@ -194,8 +194,8 @@ func (b *NodeBuilder) DefaultConfig(t *testing.T, withL1 bool) *NodeBuilder { b.L1Info = NewL1TestInfo(t) b.L2Info = NewArbTestInfo(t, b.chainConfig.ChainID) b.dataDir = t.TempDir() - b.l1StackConfig = createStackConfigForTest(b.dataDir) - b.l2StackConfig = createStackConfigForTest(b.dataDir) + b.l1StackConfig = testhelpers.CreateStackConfigForTest(b.dataDir) + b.l2StackConfig = testhelpers.CreateStackConfigForTest(b.dataDir) cp := valnode.TestValidationConfig b.valnodeConfig = &cp b.execConfig = gethexec.ConfigDefaultTest() @@ -681,23 +681,6 @@ func (c *staticNodeConfigFetcher) Started() bool { return true } -func createStackConfigForTest(dataDir string) *node.Config { - stackConf := node.DefaultConfig - stackConf.DataDir = dataDir - stackConf.UseLightweightKDF = true - stackConf.WSPort = 0 - stackConf.WSModules = append(stackConf.WSModules, "eth", "debug") - stackConf.HTTPPort = 0 - stackConf.HTTPHost = "" - stackConf.HTTPModules = append(stackConf.HTTPModules, "eth", "debug") - stackConf.P2P.NoDiscovery = true - stackConf.P2P.NoDial = true - stackConf.P2P.ListenAddr = "" - stackConf.P2P.NAT = nil - stackConf.DBEngine = "leveldb" // TODO Try pebble again in future once iterator race condition issues are fixed - return &stackConf -} - func createRedisGroup(ctx context.Context, t *testing.T, streamName string, client redis.UniversalClient) { t.Helper() // Stream name and group name are the same. @@ -809,7 +792,7 @@ func createTestL1BlockChain(t *testing.T, l1info info) (info, *ethclient.Client, if l1info == nil { l1info = NewL1TestInfo(t) } - stackConfig := createStackConfigForTest(t.TempDir()) + stackConfig := testhelpers.CreateStackConfigForTest(t.TempDir()) l1info.GenerateAccount("Faucet") chainConfig := params.ArbitrumDevTestChainConfig() @@ -944,7 +927,7 @@ func createL2BlockChainWithStackConfig( var stack *node.Node var err error if stackConfig == nil { - stackConfig = createStackConfigForTest(dataDir) + stackConfig = testhelpers.CreateStackConfigForTest(dataDir) } stack, err = node.New(stackConfig) Require(t, err) @@ -1032,7 +1015,7 @@ func Create2ndNodeWithConfig( l1client := ethclient.NewClient(l1rpcClient) if stackConfig == nil { - stackConfig = createStackConfigForTest(t.TempDir()) + stackConfig = testhelpers.CreateStackConfigForTest(t.TempDir()) } l2stack, err := node.New(stackConfig) Require(t, err) diff --git a/system_tests/das_test.go b/system_tests/das_test.go index 76ec2d7493..3dfe38b7af 100644 --- a/system_tests/das_test.go +++ b/system_tests/das_test.go @@ -29,6 +29,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/headerreader" + "github.com/offchainlabs/nitro/util/testhelpers" "golang.org/x/exp/slog" ) @@ -153,7 +154,7 @@ func TestDASRekey(t *testing.T) { // Restart the node on the new keyset against the new DAS server running on the same disk as the first with new keys builder.nodeConfig.DataAvailability.RPCAggregator = aggConfigForBackend(t, backendConfigB) - builder.l2StackConfig = createStackConfigForTest(builder.dataDir) + builder.l2StackConfig = testhelpers.CreateStackConfigForTest(builder.dataDir) cleanup := builder.BuildL2OnL1(t) defer cleanup() diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 53b771361c..389426d2e1 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1683,7 +1683,7 @@ func testWasmRecreate(t *testing.T, builder *NodeBuilder, storeTx *types.Transac Require(t, err) testDir := t.TempDir() - nodeBStack := createStackConfigForTest(testDir) + nodeBStack := testhelpers.CreateStackConfigForTest(testDir) nodeB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{stackConfig: nodeBStack}) _, err = EnsureTxSucceeded(ctx, nodeB.Client, storeTx) diff --git a/util/testhelpers/stackconfig.go b/util/testhelpers/stackconfig.go new file mode 100644 index 0000000000..a15e6f94a9 --- /dev/null +++ b/util/testhelpers/stackconfig.go @@ -0,0 +1,23 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package testhelpers + +import "github.com/ethereum/go-ethereum/node" + +func CreateStackConfigForTest(dataDir string) *node.Config { + stackConf := node.DefaultConfig + stackConf.DataDir = dataDir + stackConf.UseLightweightKDF = true + stackConf.WSPort = 0 + stackConf.WSModules = append(stackConf.WSModules, "eth", "debug") + stackConf.HTTPPort = 0 + stackConf.HTTPHost = "" + stackConf.HTTPModules = append(stackConf.HTTPModules, "eth", "debug") + stackConf.P2P.NoDiscovery = true + stackConf.P2P.NoDial = true + stackConf.P2P.ListenAddr = "" + stackConf.P2P.NAT = nil + stackConf.DBEngine = "leveldb" // TODO Try pebble again in future once iterator race condition issues are fixed + return &stackConf +} From b1a695255dbb1ede65f12f8eda69c703245402dd Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 27 May 2024 15:54:07 -0300 Subject: [PATCH 166/268] fix state-scheme flag usage --- execution/gethexec/blockchain.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index 60740af039..0053d7f4eb 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -55,8 +55,8 @@ func CachingConfigAddOptions(prefix string, f *flag.FlagSet) { f.Uint32(prefix+".max-number-of-blocks-to-skip-state-saving", DefaultCachingConfig.MaxNumberOfBlocksToSkipStateSaving, "maximum number of blocks to skip state saving to persistent storage (archive node only) -- warning: this option seems to cause issues") f.Uint64(prefix+".max-amount-of-gas-to-skip-state-saving", DefaultCachingConfig.MaxAmountOfGasToSkipStateSaving, "maximum amount of gas in blocks to skip saving state to Persistent storage (archive node only) -- warning: this option seems to cause issues") f.Uint32(prefix+".stylus-lru-cache", DefaultCachingConfig.StylusLRUCache, "initialized stylus programs to keep in LRU cache") - f.String(prefix+".state-scheme", DefaultCachingConfig.StateScheme, "scheme to use for state trie storage (hashdb, pathdb)") - f.Uint64(prefix+".state-history", DefaultCachingConfig.StateHistory, "number of recent blocks to retain state history for (pathdb state-scheme only)") + f.String(prefix+".state-scheme", DefaultCachingConfig.StateScheme, "scheme to use for state trie storage (hash, path)") + f.Uint64(prefix+".state-history", DefaultCachingConfig.StateHistory, "number of recent blocks to retain state history for (path state-scheme only)") } var DefaultCachingConfig = CachingConfig{ From 588d99373137b140bd7965c31cf9b418eae2b39c Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 17 Jun 2024 09:48:13 -0300 Subject: [PATCH 167/268] Fix tests. --- system_tests/program_test.go | 2 +- system_tests/snap_sync_test.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 389426d2e1..f5aa83b814 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1820,7 +1820,7 @@ func TestWasmStoreRebuilding(t *testing.T) { Require(t, err) testDir := t.TempDir() - nodeBStack := createStackConfigForTest(testDir) + nodeBStack := testhelpers.CreateStackConfigForTest(testDir) nodeB, cleanupB := builder.Build2ndNode(t, &SecondNodeParams{stackConfig: nodeBStack}) _, err = EnsureTxSucceeded(ctx, nodeB.Client, storeTx) diff --git a/system_tests/snap_sync_test.go b/system_tests/snap_sync_test.go index 31d5ea8492..e0bba4b37c 100644 --- a/system_tests/snap_sync_test.go +++ b/system_tests/snap_sync_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/params" @@ -17,6 +18,7 @@ import ( "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/util" + "github.com/offchainlabs/nitro/util/testhelpers" ) func TestSnapSync(t *testing.T) { @@ -27,6 +29,9 @@ func TestSnapSync(t *testing.T) { // 1st node with sequencer, stays up all the time. builder := NewNodeBuilder(ctx).DefaultConfig(t, true) + // TODO: check why snap sync is not working with path scheme. + // At least nodeB and nodeC should be able to use path scheme. + builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.L2Info = NewBlockChainTestInfo( t, types.NewArbitrumSigner(types.NewLondonSigner(builder.chainConfig.ChainID)), big.NewInt(l2pricing.InitialBaseFeeWei*2), @@ -38,7 +43,7 @@ func TestSnapSync(t *testing.T) { // 2nd node without sequencer, syncs up to the first node. // This node will be stopped in middle and arbitrumdata will be deleted. testDir := t.TempDir() - nodeBStack := createStackConfigForTest(testDir) + nodeBStack := testhelpers.CreateStackConfigForTest(testDir) nodeBConfig := builder.nodeConfig nodeBConfig.BatchPoster.Enable = false nodeBParams := &SecondNodeParams{ From cbf365626fbb71ef286cf94f9727fd6b4eec5dbc Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 13 Jun 2024 11:30:18 -0300 Subject: [PATCH 168/268] use pebble instead of leveldb in CreateStackConfigForTest --- util/testhelpers/stackconfig.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/testhelpers/stackconfig.go b/util/testhelpers/stackconfig.go index a15e6f94a9..a3c794ff28 100644 --- a/util/testhelpers/stackconfig.go +++ b/util/testhelpers/stackconfig.go @@ -18,6 +18,6 @@ func CreateStackConfigForTest(dataDir string) *node.Config { stackConf.P2P.NoDial = true stackConf.P2P.ListenAddr = "" stackConf.P2P.NAT = nil - stackConf.DBEngine = "leveldb" // TODO Try pebble again in future once iterator race condition issues are fixed + stackConf.DBEngine = "pebble" return &stackConf } From 54fc0561cc3a365f5e72be64400fd0bac234a3ad Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 14 Jun 2024 12:30:40 -0300 Subject: [PATCH 169/268] Gets state scheme to use in tests through an env var --- arbnode/inbox_test.go | 2 +- arbos/arbosState/initialization_test.go | 2 +- execution/gethexec/blockchain.go | 3 ++- system_tests/state_fuzz_test.go | 3 ++- util/testhelpers/statescheme.go | 23 +++++++++++++++++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 util/testhelpers/statescheme.go diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index 64879b7eb4..63f960e37a 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -59,7 +59,7 @@ func NewTransactionStreamerForTest(t *testing.T, ownerAddress common.Address) (* arbDb := rawdb.NewMemoryDatabase() initReader := statetransfer.NewMemoryInitDataReader(&initData) - cacheConfig := core.DefaultCacheConfigWithScheme(rawdb.PathScheme) + cacheConfig := core.DefaultCacheConfigWithScheme(testhelpers.GetTestStateScheme()) bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefaultTest().TxLookupLimit, 0) if err != nil { diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index ae9c826544..3d12a2c2c3 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -62,7 +62,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin initReader := statetransfer.NewMemoryInitDataReader(&initData) chainConfig := params.ArbitrumDevTestChainConfig() - cacheConfig := core.DefaultCacheConfigWithScheme(rawdb.PathScheme) + cacheConfig := core.DefaultCacheConfigWithScheme(testhelpers.GetTestStateScheme()) stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index 0053d7f4eb..d599b12743 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -23,6 +23,7 @@ import ( "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/gethhook" "github.com/offchainlabs/nitro/statetransfer" + "github.com/offchainlabs/nitro/util/testhelpers" ) type CachingConfig struct { @@ -89,7 +90,7 @@ var TestCachingConfig = CachingConfig{ MaxNumberOfBlocksToSkipStateSaving: 0, MaxAmountOfGasToSkipStateSaving: 0, StylusLRUCache: 0, - StateScheme: rawdb.PathScheme, + StateScheme: testhelpers.GetTestStateScheme(), } var ( diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 09ca6d265c..39c3f01b9f 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -28,6 +28,7 @@ import ( "github.com/offchainlabs/nitro/arbstate" "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/statetransfer" + "github.com/offchainlabs/nitro/util/testhelpers" ) func BuildBlock( @@ -137,7 +138,7 @@ func FuzzStateTransition(f *testing.F) { ChainConfig: chainConfig, SerializedChainConfig: serializedChainConfig, } - cacheConfig := core.DefaultCacheConfigWithScheme(rawdb.PathScheme) + cacheConfig := core.DefaultCacheConfigWithScheme(testhelpers.GetTestStateScheme()) stateRoot, err := arbosState.InitializeArbosInDatabase( chainDb, cacheConfig, diff --git a/util/testhelpers/statescheme.go b/util/testhelpers/statescheme.go new file mode 100644 index 0000000000..96394b1db2 --- /dev/null +++ b/util/testhelpers/statescheme.go @@ -0,0 +1,23 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package testhelpers + +import ( + "os" + + "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/log" +) + +// There are two CI steps, one to run tests using the path state scheme, and one to run tests using the hash state scheme. +// An environment controls that behavior. +func GetTestStateScheme() string { + envTestStateScheme := os.Getenv("TEST_STATE_SCHEME") + stateScheme := rawdb.PathScheme + if envTestStateScheme == rawdb.PathScheme || envTestStateScheme == rawdb.HashScheme { + stateScheme = envTestStateScheme + } + log.Debug("test state scheme", "testStateScheme", stateScheme) + return stateScheme +} From 6832aca93c212adc49df63c84427b41f970c1f75 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 14 Jun 2024 14:52:42 -0300 Subject: [PATCH 170/268] Runs tests with hash and path states scheme in github ci --- .github/workflows/ci.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe26b1044b..450d9ab313 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -141,8 +141,10 @@ jobs: echo "GOMEMLIMIT=6GiB" >> "$GITHUB_ENV" echo "GOGC=80" >> "$GITHUB_ENV" - - name: run tests without race detection + - name: run tests without race detection and path state scheme if: matrix.test-mode == 'defaults' + env: + TEST_STATE_SCHEME: path run: | packages=`go list ./...` for package in $packages; do @@ -152,6 +154,14 @@ jobs: fi done + - name: run tests without race detection and hash state scheme + if: matrix.test-mode == 'defaults' + env: + TEST_STATE_SCHEME: hash + run: | + packages=`go list ./...` + stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -timeout 20m -parallel=8 + - name: run tests with race detection if: matrix.test-mode == 'race' run: | @@ -214,4 +224,3 @@ jobs: files: ./coverage.txt,./coverage-redis.txt verbose: false token: ${{ secrets.CODECOV_TOKEN }} - From cfb5947e107cb2e77fd0883079aeada503da1762 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 14 Jun 2024 18:45:47 -0300 Subject: [PATCH 171/268] Default Caching.StateHistory based on DefaultSequencerConfig.MaxBlockSpeed --- execution/gethexec/blockchain.go | 6 +++++- execution/gethexec/blockchain_test.go | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 execution/gethexec/blockchain_test.go diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index d599b12743..f4479dd131 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -60,6 +60,10 @@ func CachingConfigAddOptions(prefix string, f *flag.FlagSet) { f.Uint64(prefix+".state-history", DefaultCachingConfig.StateHistory, "number of recent blocks to retain state history for (path state-scheme only)") } +func getStateHistory(maxBlockSpeed time.Duration) uint64 { + return uint64(24 * time.Hour / maxBlockSpeed) +} + var DefaultCachingConfig = CachingConfig{ Archive: false, BlockCount: 128, @@ -74,7 +78,7 @@ var DefaultCachingConfig = CachingConfig{ MaxAmountOfGasToSkipStateSaving: 0, StylusLRUCache: 256, StateScheme: rawdb.HashScheme, - StateHistory: 90000, + StateHistory: getStateHistory(DefaultSequencerConfig.MaxBlockSpeed), } var TestCachingConfig = CachingConfig{ diff --git a/execution/gethexec/blockchain_test.go b/execution/gethexec/blockchain_test.go new file mode 100644 index 0000000000..375488cedc --- /dev/null +++ b/execution/gethexec/blockchain_test.go @@ -0,0 +1,18 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package gethexec + +import ( + "testing" + "time" +) + +func TestGetStateHistory(t *testing.T) { + maxBlockSpeed := time.Millisecond * 250 + expectedStateHistory := uint64(345600) + actualStateHistory := getStateHistory(maxBlockSpeed) + if actualStateHistory != expectedStateHistory { + t.Errorf("Expected state history to be %d, but got %d", expectedStateHistory, actualStateHistory) + } +} From f6c9ca59611bf2a607282fb3cd52c18a0775df8c Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 14 Jun 2024 18:55:30 -0300 Subject: [PATCH 172/268] Adds copyright to init_test.go --- cmd/nitro/init_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/nitro/init_test.go b/cmd/nitro/init_test.go index add13feee1..0797ac9b46 100644 --- a/cmd/nitro/init_test.go +++ b/cmd/nitro/init_test.go @@ -1,3 +1,6 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + package main import ( From 3b1cd936b9cb43e523d606c82a989dd2d8d2a847 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 14 Jun 2024 19:17:03 -0300 Subject: [PATCH 173/268] Adds comments regarding why using HashScheme for Archive tests --- system_tests/debug_trace_test.go | 1 + system_tests/recreatestate_rpc_test.go | 9 +++++++++ system_tests/staterecovery_test.go | 2 ++ system_tests/triedb_race_test.go | 1 + 4 files changed, 13 insertions(+) diff --git a/system_tests/debug_trace_test.go b/system_tests/debug_trace_test.go index 0c080df686..fffef1522b 100644 --- a/system_tests/debug_trace_test.go +++ b/system_tests/debug_trace_test.go @@ -23,6 +23,7 @@ func TestDebugTraceCallForRecentBlock(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true + // By now Archive node should use HashScheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme cleanup := builder.Build(t) defer cleanup() diff --git a/system_tests/recreatestate_rpc_test.go b/system_tests/recreatestate_rpc_test.go index e23cb5c392..0bcfd4c21e 100644 --- a/system_tests/recreatestate_rpc_test.go +++ b/system_tests/recreatestate_rpc_test.go @@ -100,6 +100,7 @@ func TestRecreateStateForRPCNoDepthLimit(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + // By now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme execConfig.Caching.SnapshotCache = 0 // disable snapshots // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there @@ -137,6 +138,7 @@ func TestRecreateStateForRPCBigEnoughDepthLimit(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + // By now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -173,6 +175,7 @@ func TestRecreateStateForRPCDepthLimitExceeded(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + // By now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -209,6 +212,7 @@ func TestRecreateStateForRPCMissingBlockParent(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + // By now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -256,6 +260,7 @@ func TestRecreateStateForRPCBeyondGenesis(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + // By now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -293,6 +298,7 @@ func TestRecreateStateForRPCBlockNotFoundWhileRecreating(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true + // By now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -435,6 +441,7 @@ func testSkippingSavingStateAndRecreatingAfterRestart(t *testing.T, cacheConfig func TestSkippingSavingStateAndRecreatingAfterRestart(t *testing.T) { cacheConfig := gethexec.TestCachingConfig cacheConfig.Archive = true + // By now Archive node should use HashScheme cacheConfig.StateScheme = rawdb.HashScheme cacheConfig.SnapshotCache = 0 // disable snapshots cacheConfig.BlockAge = 0 // use only Caching.BlockCount to keep only last N blocks in dirties cache, no matter how new they are @@ -519,6 +526,7 @@ func TestGettingStateForRPCHybridArchiveNode(t *testing.T) { defer cancel() execConfig := gethexec.ConfigDefaultTest() execConfig.Caching.Archive = true + // By now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 128 execConfig.Caching.BlockCount = 128 @@ -566,6 +574,7 @@ func TestStateAndHeaderForRecentBlock(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true + // By now Archive node should use HashScheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.RPC.MaxRecreateStateDepth = 0 cleanup := builder.Build(t) diff --git a/system_tests/staterecovery_test.go b/system_tests/staterecovery_test.go index 60445c2f29..0b3efe6f73 100644 --- a/system_tests/staterecovery_test.go +++ b/system_tests/staterecovery_test.go @@ -20,6 +20,7 @@ func TestRectreateMissingStates(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true + // By now Archive node should use HashScheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 16 builder.execConfig.Caching.SnapshotCache = 0 // disable snapshots @@ -56,6 +57,7 @@ func TestRectreateMissingStates(t *testing.T) { Require(t, err) defer chainDb.Close() cachingConfig := gethexec.TestCachingConfig + // By now Archive node should use HashScheme cachingConfig.StateScheme = rawdb.HashScheme cacheConfig := gethexec.DefaultCacheConfigFor(stack, &cachingConfig) bc, err := gethexec.GetBlockChain(chainDb, cacheConfig, builder.chainConfig, builder.execConfig.TxLookupLimit) diff --git a/system_tests/triedb_race_test.go b/system_tests/triedb_race_test.go index d2ae9dd56b..606dfc901d 100644 --- a/system_tests/triedb_race_test.go +++ b/system_tests/triedb_race_test.go @@ -24,6 +24,7 @@ func TestTrieDBCommitRace(t *testing.T) { builder.execConfig.Sequencer.MaxBlockSpeed = 0 builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 builder.execConfig.Caching.Archive = true + // By now Archive node should use HashScheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.Caching.BlockCount = 127 builder.execConfig.Caching.BlockAge = 0 From d9d3ffcab47a85d6a5a407e13c581872c1ddf8d8 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 14 Jun 2024 19:22:58 -0300 Subject: [PATCH 174/268] Adds missing word in comment --- util/testhelpers/statescheme.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/testhelpers/statescheme.go b/util/testhelpers/statescheme.go index 96394b1db2..31e1c1070d 100644 --- a/util/testhelpers/statescheme.go +++ b/util/testhelpers/statescheme.go @@ -11,7 +11,7 @@ import ( ) // There are two CI steps, one to run tests using the path state scheme, and one to run tests using the hash state scheme. -// An environment controls that behavior. +// An environment variable controls that behavior. func GetTestStateScheme() string { envTestStateScheme := os.Getenv("TEST_STATE_SCHEME") stateScheme := rawdb.PathScheme From 39e313dc5badbbb0e11f2e9b61992b6a6bfdb0c4 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 17 Jun 2024 11:13:24 -0300 Subject: [PATCH 175/268] Uses env var to define trie in NewMemoryBackedStateDB and NewArbosMemoryBackedArbOSState --- arbnode/inbox_test.go | 3 ++- arbos/arbosState/arbosstate.go | 8 +++++++- arbos/arbosState/initialization_test.go | 3 ++- arbos/storage/storage.go | 8 +++++++- execution/gethexec/blockchain.go | 4 ++-- system_tests/state_fuzz_test.go | 4 ++-- util/{testhelpers/statescheme.go => env/env.go} | 2 +- 7 files changed, 23 insertions(+), 9 deletions(-) rename util/{testhelpers/statescheme.go => env/env.go} (97%) diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index 63f960e37a..88120a9b37 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -18,6 +18,7 @@ import ( "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/env" "github.com/offchainlabs/nitro/util/testhelpers" "github.com/ethereum/go-ethereum/common" @@ -59,7 +60,7 @@ func NewTransactionStreamerForTest(t *testing.T, ownerAddress common.Address) (* arbDb := rawdb.NewMemoryDatabase() initReader := statetransfer.NewMemoryInitDataReader(&initData) - cacheConfig := core.DefaultCacheConfigWithScheme(testhelpers.GetTestStateScheme()) + cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefaultTest().TxLookupLimit, 0) if err != nil { diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index aa775b6d07..e1b21871e5 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/trie/triedb/hashdb" "github.com/ethereum/go-ethereum/trie/triedb/pathdb" "github.com/offchainlabs/nitro/arbcompress" @@ -31,6 +32,7 @@ import ( "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" + "github.com/offchainlabs/nitro/util/env" ) // ArbosState contains ArbOS-related state. It is backed by ArbOS's storage in the persistent stateDB. @@ -117,7 +119,11 @@ func OpenSystemArbosStateOrPanic(stateDB vm.StateDB, tracingInfo *util.TracingIn // NewArbosMemoryBackedArbOSState creates and initializes a memory-backed ArbOS state (for testing only) func NewArbosMemoryBackedArbOSState() (*ArbosState, *state.StateDB) { raw := rawdb.NewMemoryDatabase() - db := state.NewDatabaseWithConfig(raw, &trie.Config{Preimages: false, PathDB: pathdb.Defaults}) + trieConfig := &trie.Config{Preimages: false, PathDB: pathdb.Defaults} + if env.GetTestStateScheme() == rawdb.HashScheme { + trieConfig = &trie.Config{Preimages: false, HashDB: hashdb.Defaults} + } + db := state.NewDatabaseWithConfig(raw, trieConfig) statedb, err := state.New(common.Hash{}, db, nil) if err != nil { log.Crit("failed to init empty statedb", "error", err) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index 3d12a2c2c3..aed84799aa 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -17,6 +17,7 @@ import ( "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/statetransfer" + "github.com/offchainlabs/nitro/util/env" "github.com/offchainlabs/nitro/util/testhelpers" ) @@ -62,7 +63,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin initReader := statetransfer.NewMemoryInitDataReader(&initData) chainConfig := params.ArbitrumDevTestChainConfig() - cacheConfig := core.DefaultCacheConfigWithScheme(testhelpers.GetTestStateScheme()) + cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index be4cd435be..3ee4149914 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -19,10 +19,12 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/trie/triedb/hashdb" "github.com/ethereum/go-ethereum/trie/triedb/pathdb" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/env" ) // Storage allows ArbOS to store data persistently in the Ethereum-compatible stateDB. This is represented in @@ -85,7 +87,11 @@ func NewMemoryBacked(burner burn.Burner) *Storage { // Only used for testing. func NewMemoryBackedStateDB() vm.StateDB { raw := rawdb.NewMemoryDatabase() - db := state.NewDatabaseWithConfig(raw, &trie.Config{Preimages: false, PathDB: pathdb.Defaults}) + trieConfig := &trie.Config{Preimages: false, PathDB: pathdb.Defaults} + if env.GetTestStateScheme() == rawdb.HashScheme { + trieConfig = &trie.Config{Preimages: false, HashDB: hashdb.Defaults} + } + db := state.NewDatabaseWithConfig(raw, trieConfig) statedb, err := state.New(common.Hash{}, db, nil) if err != nil { panic("failed to init empty statedb") diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index f4479dd131..e43d8bf477 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -23,7 +23,7 @@ import ( "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/gethhook" "github.com/offchainlabs/nitro/statetransfer" - "github.com/offchainlabs/nitro/util/testhelpers" + "github.com/offchainlabs/nitro/util/env" ) type CachingConfig struct { @@ -94,7 +94,7 @@ var TestCachingConfig = CachingConfig{ MaxNumberOfBlocksToSkipStateSaving: 0, MaxAmountOfGasToSkipStateSaving: 0, StylusLRUCache: 0, - StateScheme: testhelpers.GetTestStateScheme(), + StateScheme: env.GetTestStateScheme(), } var ( diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 39c3f01b9f..5c63eb858a 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -28,7 +28,7 @@ import ( "github.com/offchainlabs/nitro/arbstate" "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/statetransfer" - "github.com/offchainlabs/nitro/util/testhelpers" + "github.com/offchainlabs/nitro/util/env" ) func BuildBlock( @@ -138,7 +138,7 @@ func FuzzStateTransition(f *testing.F) { ChainConfig: chainConfig, SerializedChainConfig: serializedChainConfig, } - cacheConfig := core.DefaultCacheConfigWithScheme(testhelpers.GetTestStateScheme()) + cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) stateRoot, err := arbosState.InitializeArbosInDatabase( chainDb, cacheConfig, diff --git a/util/testhelpers/statescheme.go b/util/env/env.go similarity index 97% rename from util/testhelpers/statescheme.go rename to util/env/env.go index 31e1c1070d..d20b1770c8 100644 --- a/util/testhelpers/statescheme.go +++ b/util/env/env.go @@ -1,7 +1,7 @@ // Copyright 2021-2024, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package testhelpers +package env import ( "os" From 6cfde26ed2bd6b6d0ca57bf821655bf0452c2ef6 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 8 Jul 2024 12:36:02 -0300 Subject: [PATCH 176/268] Do not create new error variables --- cmd/nitro/config_test.go | 6 ++---- cmd/nitro/nitro.go | 6 +----- execution/gethexec/blockchain.go | 6 +----- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/cmd/nitro/config_test.go b/cmd/nitro/config_test.go index af902fab0f..33feac887b 100644 --- a/cmd/nitro/config_test.go +++ b/cmd/nitro/config_test.go @@ -17,10 +17,8 @@ import ( "github.com/offchainlabs/nitro/cmd/genericconf" "github.com/offchainlabs/nitro/cmd/util/confighelpers" "github.com/offchainlabs/nitro/das" - "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/testhelpers" - "github.com/pkg/errors" "github.com/r3labs/diff/v3" flag "github.com/spf13/pflag" @@ -67,7 +65,7 @@ func TestInvalidCachingStateSchemeForValidator(t *testing.T) { validatorArgsWithPathScheme := fmt.Sprintf("%s --execution.caching.state-scheme path", validatorArgs) args := strings.Split(validatorArgsWithPathScheme, " ") _, _, err := ParseNode(context.Background(), args) - if !errors.Is(err, invalidCachingStateSchemeForValidator) { + if !strings.Contains(err.Error(), "path cannot be used as execution.caching.state-scheme when validator is required") { Fail(t, "failed to detect invalid state scheme for validator") } } @@ -75,7 +73,7 @@ func TestInvalidCachingStateSchemeForValidator(t *testing.T) { func TestInvalidArchiveConfig(t *testing.T) { args := strings.Split("--execution.caching.archive --execution.caching.state-scheme path --persistent.chain /tmp/data --init.dev-init --node.parent-chain-reader.enable=false --parent-chain.id 5 --chain.id 421613 --node.staker.parent-chain-wallet.pathname /l1keystore --node.staker.parent-chain-wallet.password passphrase --http.addr 0.0.0.0 --ws.addr 0.0.0.0 --node.staker.enable --node.staker.strategy MakeNodes --node.staker.staker-interval 10s --execution.forwarding-target null", " ") _, _, err := ParseNode(context.Background(), args) - if !errors.Is(err, gethexec.InvalidStateSchemeForArchive) { + if !strings.Contains(err.Error(), "archive cannot be set when using path as the state-scheme") { Fail(t, "failed to detect invalid state scheme for archive") } } diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 0b979d5624..9861bb673e 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -818,10 +818,6 @@ func (c *NodeConfig) CanReload(new *NodeConfig) error { return err } -var ( - invalidCachingStateSchemeForValidator = errors.New("path cannot be used as execution.caching.state-scheme when validator is required") -) - func (c *NodeConfig) Validate() error { if c.Init.RecreateMissingStateFrom > 0 && !c.Execution.Caching.Archive { return errors.New("recreate-missing-state-from enabled for a non-archive node") @@ -842,7 +838,7 @@ func (c *NodeConfig) Validate() error { return err } if c.Node.ValidatorRequired() && (c.Execution.Caching.StateScheme == rawdb.PathScheme) { - return invalidCachingStateSchemeForValidator + return errors.New("path cannot be used as execution.caching.state-scheme when validator is required") } return c.Persistent.Validate() } diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index e43d8bf477..1b2cbdc332 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -97,10 +97,6 @@ var TestCachingConfig = CachingConfig{ StateScheme: env.GetTestStateScheme(), } -var ( - InvalidStateSchemeForArchive = errors.New("archive cannot be set when using path as the state-scheme") -) - // TODO remove stack from parameters as it is no longer needed here func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core.CacheConfig { baseConf := ethconfig.Defaults @@ -131,7 +127,7 @@ func (c *CachingConfig) validateStateScheme() error { case rawdb.HashScheme: case rawdb.PathScheme: if c.Archive { - return InvalidStateSchemeForArchive + return errors.New("archive cannot be set when using path as the state-scheme") } default: return errors.New("Invalid StateScheme") From ffda7a715d5c624dd658d5cb250fb416651fec0c Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 8 Jul 2024 12:38:39 -0300 Subject: [PATCH 177/268] Runs race tests with hash and path schemes --- .github/workflows/ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 450d9ab313..9b60fcc206 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,8 +162,10 @@ jobs: packages=`go list ./...` stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -timeout 20m -parallel=8 - - name: run tests with race detection + - name: run tests with race detection and path state scheme if: matrix.test-mode == 'race' + env: + TEST_STATE_SCHEME: path run: | packages=`go list ./...` for package in $packages; do @@ -173,6 +175,14 @@ jobs: fi done + - name: run tests with race detection and hash state scheme + if: matrix.test-mode == 'race' + env: + TEST_STATE_SCHEME: hash + run: | + packages=`go list ./...` + stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -race -timeout 30m -parallel=8 + - name: run redis tests if: matrix.test-mode == 'defaults' run: TEST_REDIS=redis://localhost:6379/0 gotestsum --format short-verbose -- -p 1 -run TestRedis ./arbnode/... ./system_tests/... -coverprofile=coverage-redis.txt -covermode=atomic -coverpkg=./... From 875d815d3814fe8ec3d5552cd4f974154237a8cb Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 11 Jul 2024 23:07:45 -0300 Subject: [PATCH 178/268] Removes unncessary path logic when initializing arbos in database --- arbos/arbosState/initialize.go | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 8b46c19fde..1893308055 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -91,14 +91,9 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, if err != nil { return common.Hash{}, err } - // When using PathScheme TrieDB.Commit should only be called once. - // When using HashScheme it is called multiple times to avoid keeping - // the entire trie in memory. - if cacheConfig.StateScheme == rawdb.HashScheme { - err = stateDatabase.TrieDB().Commit(root, true) - if err != nil { - return common.Hash{}, err - } + err = stateDatabase.TrieDB().Commit(root, true) + if err != nil { + return common.Hash{}, err } statedb, err = state.New(root, stateDatabase, nil) if err != nil { @@ -196,18 +191,7 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, if err := accountDataReader.Close(); err != nil { return common.Hash{}, err } - - root, err = commit() - if err != nil { - return common.Hash{}, err - } - if cacheConfig.StateScheme == rawdb.PathScheme { - err = stateDatabase.TrieDB().Commit(root, true) - if err != nil { - return common.Hash{}, err - } - } - return root, nil + return commit() } func initializeRetryables(statedb *state.StateDB, rs *retryables.RetryableState, initData statetransfer.RetryableDataReader, currentTimestamp uint64) error { From e3a0460a792a4208e1ef82f8d919b572e182b6e6 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 18 Jul 2024 16:17:40 -0300 Subject: [PATCH 179/268] By now -> For now --- system_tests/block_validator_test.go | 2 +- system_tests/debug_trace_test.go | 2 +- system_tests/full_challenge_impl_test.go | 2 +- system_tests/program_test.go | 2 +- system_tests/recreatestate_rpc_test.go | 18 +++++++++--------- system_tests/seqfeed_test.go | 2 +- system_tests/staker_test.go | 2 +- system_tests/staterecovery_test.go | 4 ++-- system_tests/triedb_race_test.go | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/system_tests/block_validator_test.go b/system_tests/block_validator_test.go index 2915288f9e..6b4e6d2088 100644 --- a/system_tests/block_validator_test.go +++ b/system_tests/block_validator_test.go @@ -69,7 +69,7 @@ func testBlockValidatorSimple(t *testing.T, opts Options) { builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder = builder.WithWasmRootDir(opts.wasmRootDir) - // By now PathDB is not supported when using block validation + // For now PathDB is not supported when using block validation builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.nodeConfig = l1NodeConfigA builder.chainConfig = chainConfig diff --git a/system_tests/debug_trace_test.go b/system_tests/debug_trace_test.go index fffef1522b..13d9ed834b 100644 --- a/system_tests/debug_trace_test.go +++ b/system_tests/debug_trace_test.go @@ -23,7 +23,7 @@ func TestDebugTraceCallForRecentBlock(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme cleanup := builder.Build(t) defer cleanup() diff --git a/system_tests/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index 520886af2a..ddc229074c 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -263,7 +263,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall if useStubs { mockSpawn, valStack = createMockValidationNode(t, ctx, &builder.valnodeConfig.Arbitrator) } else { - // By now validation only works with HashScheme set + // For now validation only works with HashScheme set builder.execConfig.Caching.StateScheme = rawdb.HashScheme _, valStack = createTestValidationNode(t, ctx, builder.valnodeConfig) } diff --git a/system_tests/program_test.go b/system_tests/program_test.go index f5aa83b814..20bc873adc 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1476,7 +1476,7 @@ func setupProgramTest(t *testing.T, jit bool, builderOpts ...func(*NodeBuilder)) } // setupProgramTest is being called by tests that validate blocks. - // By now validation only works with HashScheme set. + // For now validation only works with HashScheme set. builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.nodeConfig.BlockValidator.Enable = false builder.nodeConfig.Staker.Enable = true diff --git a/system_tests/recreatestate_rpc_test.go b/system_tests/recreatestate_rpc_test.go index 0bcfd4c21e..0debc42143 100644 --- a/system_tests/recreatestate_rpc_test.go +++ b/system_tests/recreatestate_rpc_test.go @@ -100,7 +100,7 @@ func TestRecreateStateForRPCNoDepthLimit(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme execConfig.Caching.SnapshotCache = 0 // disable snapshots // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there @@ -138,7 +138,7 @@ func TestRecreateStateForRPCBigEnoughDepthLimit(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -175,7 +175,7 @@ func TestRecreateStateForRPCDepthLimitExceeded(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -212,7 +212,7 @@ func TestRecreateStateForRPCMissingBlockParent(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -260,7 +260,7 @@ func TestRecreateStateForRPCBeyondGenesis(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -298,7 +298,7 @@ func TestRecreateStateForRPCBlockNotFoundWhileRecreating(t *testing.T) { execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme // disable trie/Database.cleans cache, so as states removed from ChainDb won't be cached there execConfig.Caching.TrieCleanCache = 0 @@ -441,7 +441,7 @@ func testSkippingSavingStateAndRecreatingAfterRestart(t *testing.T, cacheConfig func TestSkippingSavingStateAndRecreatingAfterRestart(t *testing.T) { cacheConfig := gethexec.TestCachingConfig cacheConfig.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme cacheConfig.StateScheme = rawdb.HashScheme cacheConfig.SnapshotCache = 0 // disable snapshots cacheConfig.BlockAge = 0 // use only Caching.BlockCount to keep only last N blocks in dirties cache, no matter how new they are @@ -526,7 +526,7 @@ func TestGettingStateForRPCHybridArchiveNode(t *testing.T) { defer cancel() execConfig := gethexec.ConfigDefaultTest() execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 128 execConfig.Caching.BlockCount = 128 @@ -574,7 +574,7 @@ func TestStateAndHeaderForRecentBlock(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.RPC.MaxRecreateStateDepth = 0 cleanup := builder.Build(t) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index e3a98b4961..9637c7d4fc 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -333,7 +333,7 @@ func testBlockHashComparison(t *testing.T, blockHash *common.Hash, mustMismatch } wsBroadcastServer.Broadcast(&broadcastMessage) - // By now, even though block hash mismatch, the transaction should still be processed + // For now, even though block hash mismatch, the transaction should still be processed _, err = WaitForTx(ctx, testClient.Client, tx.Hash(), time.Second*15) if err != nil { t.Fatal("error waiting for tx:", err) diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 993f2d0612..f57b68ad8a 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -76,7 +76,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) transferGas, ) - // By now validation only works with HashScheme set + // For now validation only works with HashScheme set builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.nodeConfig.BatchPoster.MaxDelay = -1000 * time.Hour diff --git a/system_tests/staterecovery_test.go b/system_tests/staterecovery_test.go index 0b3efe6f73..986c8eeda7 100644 --- a/system_tests/staterecovery_test.go +++ b/system_tests/staterecovery_test.go @@ -20,7 +20,7 @@ func TestRectreateMissingStates(t *testing.T) { defer cancel() builder := NewNodeBuilder(ctx).DefaultConfig(t, true) builder.execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.Caching.MaxNumberOfBlocksToSkipStateSaving = 16 builder.execConfig.Caching.SnapshotCache = 0 // disable snapshots @@ -57,7 +57,7 @@ func TestRectreateMissingStates(t *testing.T) { Require(t, err) defer chainDb.Close() cachingConfig := gethexec.TestCachingConfig - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme cachingConfig.StateScheme = rawdb.HashScheme cacheConfig := gethexec.DefaultCacheConfigFor(stack, &cachingConfig) bc, err := gethexec.GetBlockChain(chainDb, cacheConfig, builder.chainConfig, builder.execConfig.TxLookupLimit) diff --git a/system_tests/triedb_race_test.go b/system_tests/triedb_race_test.go index 606dfc901d..609a4c0b60 100644 --- a/system_tests/triedb_race_test.go +++ b/system_tests/triedb_race_test.go @@ -24,7 +24,7 @@ func TestTrieDBCommitRace(t *testing.T) { builder.execConfig.Sequencer.MaxBlockSpeed = 0 builder.execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 builder.execConfig.Caching.Archive = true - // By now Archive node should use HashScheme + // For now Archive node should use HashScheme builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.execConfig.Caching.BlockCount = 127 builder.execConfig.Caching.BlockAge = 0 From 82c5ec71a02d0d267a08bb9e996b88abb7e715fa Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 18 Jul 2024 18:04:15 -0300 Subject: [PATCH 180/268] Moves GetTestStateScheme to util/testhelpers/env --- arbnode/inbox_test.go | 2 +- arbos/arbosState/arbosstate.go | 2 +- arbos/arbosState/initialization_test.go | 2 +- arbos/storage/storage.go | 2 +- execution/gethexec/blockchain.go | 2 +- system_tests/state_fuzz_test.go | 2 +- util/{ => testhelpers}/env/env.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) rename util/{ => testhelpers}/env/env.go (94%) diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index 88120a9b37..54b783cf9d 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -18,8 +18,8 @@ import ( "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/env" "github.com/offchainlabs/nitro/util/testhelpers" + "github.com/offchainlabs/nitro/util/testhelpers/env" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index e1b21871e5..357fe265b5 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -32,7 +32,7 @@ import ( "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/util/env" + "github.com/offchainlabs/nitro/util/testhelpers/env" ) // ArbosState contains ArbOS-related state. It is backed by ArbOS's storage in the persistent stateDB. diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index aed84799aa..ffba4cf9b1 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -17,8 +17,8 @@ import ( "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/statetransfer" - "github.com/offchainlabs/nitro/util/env" "github.com/offchainlabs/nitro/util/testhelpers" + "github.com/offchainlabs/nitro/util/testhelpers/env" ) func TestJsonMarshalUnmarshal(t *testing.T) { diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index 3ee4149914..8d7fa09304 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -24,7 +24,7 @@ import ( "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" - "github.com/offchainlabs/nitro/util/env" + "github.com/offchainlabs/nitro/util/testhelpers/env" ) // Storage allows ArbOS to store data persistently in the Ethereum-compatible stateDB. This is represented in diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index 1b2cbdc332..adfe8ffb1c 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -23,7 +23,7 @@ import ( "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/gethhook" "github.com/offchainlabs/nitro/statetransfer" - "github.com/offchainlabs/nitro/util/env" + "github.com/offchainlabs/nitro/util/testhelpers/env" ) type CachingConfig struct { diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 5c63eb858a..5cff2108cf 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -28,7 +28,7 @@ import ( "github.com/offchainlabs/nitro/arbstate" "github.com/offchainlabs/nitro/arbstate/daprovider" "github.com/offchainlabs/nitro/statetransfer" - "github.com/offchainlabs/nitro/util/env" + "github.com/offchainlabs/nitro/util/testhelpers/env" ) func BuildBlock( diff --git a/util/env/env.go b/util/testhelpers/env/env.go similarity index 94% rename from util/env/env.go rename to util/testhelpers/env/env.go index d20b1770c8..27d74465de 100644 --- a/util/env/env.go +++ b/util/testhelpers/env/env.go @@ -1,4 +1,4 @@ -// Copyright 2021-2024, Offchain Labs, Inc. +// Copyright 2024, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE package env From 6256b5bb95324d6b85f107c4a1b6a92f5462e795 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 19 Jul 2024 16:12:48 -0300 Subject: [PATCH 181/268] Do not WriteOrTestGenBlock when blockchain is not empty and using path scheme. --- cmd/nitro/init.go | 4 ++++ execution/gethexec/blockchain.go | 8 ++++++++ system_tests/snap_sync_test.go | 2 -- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index c8b4011c54..a958572458 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -681,6 +681,10 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo log.Warn("Created fake init message as L1Reader is disabled and serialized chain config from init message is not available", "json", string(serializedChainConfig)) } + emptyBlockChain := rawdb.ReadHeadHeader(chainDb) == nil + if !emptyBlockChain && (cacheConfig.StateScheme == rawdb.PathScheme) && config.Init.Force { + return chainDb, nil, errors.New("It is not possible to force init with non-empty blockchain when using path scheme") + } l2BlockChain, err = gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initDataReader, chainConfig, parsedInitMessage, config.Execution.TxLookupLimit, config.Init.AccountsPerSync) if err != nil { return chainDb, nil, err diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index adfe8ffb1c..dfa044676b 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -228,6 +228,14 @@ func GetBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, chainC } func WriteOrTestBlockChain(chainDb ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, txLookupLimit uint64, accountsPerSync uint) (*core.BlockChain, error) { + emptyBlockChain := rawdb.ReadHeadHeader(chainDb) == nil + if !emptyBlockChain && (cacheConfig.StateScheme == rawdb.PathScheme) { + // When using path scheme, and the stored state trie is not empty, + // WriteOrTestGenBlock is not able to recover EmptyRootHash state trie node. + // In that case Nitro doesn't test genblock, but just returns the BlockChain. + return GetBlockChain(chainDb, cacheConfig, chainConfig, txLookupLimit) + } + err := WriteOrTestGenblock(chainDb, cacheConfig, initData, chainConfig, initMessage, accountsPerSync) if err != nil { return nil, err diff --git a/system_tests/snap_sync_test.go b/system_tests/snap_sync_test.go index e0bba4b37c..a04d9f5bf3 100644 --- a/system_tests/snap_sync_test.go +++ b/system_tests/snap_sync_test.go @@ -29,8 +29,6 @@ func TestSnapSync(t *testing.T) { // 1st node with sequencer, stays up all the time. builder := NewNodeBuilder(ctx).DefaultConfig(t, true) - // TODO: check why snap sync is not working with path scheme. - // At least nodeB and nodeC should be able to use path scheme. builder.execConfig.Caching.StateScheme = rawdb.HashScheme builder.L2Info = NewBlockChainTestInfo( t, From 3379ab6d0e49820435d76f1c209165f139ef2ae2 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 19 Jul 2024 19:38:34 -0300 Subject: [PATCH 182/268] Fixes TrieDB().Close() error handling in InitializeArbosInDatabase --- arbos/arbosState/initialize.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 1893308055..e2a4a3c5e0 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -77,7 +77,7 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, triedbConfig.Preimages = false stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig) defer func() { - err = stateDatabase.TrieDB().Close() + err = errors.Join(err, stateDatabase.TrieDB().Close()) }() statedb, err := state.New(common.Hash{}, stateDatabase, nil) if err != nil { From 18575a75915b27ac4bbe8119223f3cce61f99380 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 19 Jul 2024 19:48:19 -0300 Subject: [PATCH 183/268] Fixex github defaults test for hash scheme --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b60fcc206..05c3f3cbd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,7 +160,7 @@ jobs: TEST_STATE_SCHEME: hash run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -timeout 20m -parallel=8 + stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -timeout 20m -parallel=8 -tags=cionly - name: run tests with race detection and path state scheme if: matrix.test-mode == 'race' From 24252954ce2c07bf33b7f6d0a5018ca65909d710 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 18 Jul 2024 19:30:29 -0300 Subject: [PATCH 184/268] Moves test configs from gethexec to system_tests --- arbnode/inbox_test.go | 2 +- execution/gethexec/blockchain.go | 17 ------ execution/gethexec/forwarder.go | 9 --- execution/gethexec/node.go | 25 -------- execution/gethexec/sequencer.go | 18 ------ system_tests/common_test.go | 79 ++++++++++++++++++++++++-- system_tests/forwarder_test.go | 9 ++- system_tests/recreatestate_rpc_test.go | 20 +++---- system_tests/retryable_test.go | 3 +- system_tests/staterecovery_test.go | 2 +- 10 files changed, 91 insertions(+), 93 deletions(-) diff --git a/arbnode/inbox_test.go b/arbnode/inbox_test.go index 54b783cf9d..70392598d6 100644 --- a/arbnode/inbox_test.go +++ b/arbnode/inbox_test.go @@ -61,7 +61,7 @@ func NewTransactionStreamerForTest(t *testing.T, ownerAddress common.Address) (* initReader := statetransfer.NewMemoryInitDataReader(&initData) cacheConfig := core.DefaultCacheConfigWithScheme(env.GetTestStateScheme()) - bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefaultTest().TxLookupLimit, 0) + bc, err := gethexec.WriteOrTestBlockChain(chainDb, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, gethexec.ConfigDefault.TxLookupLimit, 0) if err != nil { Fail(t, err) diff --git a/execution/gethexec/blockchain.go b/execution/gethexec/blockchain.go index dfa044676b..996b87a9e6 100644 --- a/execution/gethexec/blockchain.go +++ b/execution/gethexec/blockchain.go @@ -23,7 +23,6 @@ import ( "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/gethhook" "github.com/offchainlabs/nitro/statetransfer" - "github.com/offchainlabs/nitro/util/testhelpers/env" ) type CachingConfig struct { @@ -81,22 +80,6 @@ var DefaultCachingConfig = CachingConfig{ StateHistory: getStateHistory(DefaultSequencerConfig.MaxBlockSpeed), } -var TestCachingConfig = CachingConfig{ - Archive: false, - BlockCount: 128, - BlockAge: 30 * time.Minute, - TrieTimeLimit: time.Hour, - TrieDirtyCache: 1024, - TrieCleanCache: 600, - SnapshotCache: 400, - DatabaseCache: 2048, - SnapshotRestoreGasLimit: 300_000_000_000, - MaxNumberOfBlocksToSkipStateSaving: 0, - MaxAmountOfGasToSkipStateSaving: 0, - StylusLRUCache: 0, - StateScheme: env.GetTestStateScheme(), -} - // TODO remove stack from parameters as it is no longer needed here func DefaultCacheConfigFor(stack *node.Node, cachingConfig *CachingConfig) *core.CacheConfig { baseConf := ethconfig.Defaults diff --git a/execution/gethexec/forwarder.go b/execution/gethexec/forwarder.go index 984c7224e8..cdb4f394e5 100644 --- a/execution/gethexec/forwarder.go +++ b/execution/gethexec/forwarder.go @@ -35,15 +35,6 @@ type ForwarderConfig struct { RetryInterval time.Duration `koanf:"retry-interval"` } -var DefaultTestForwarderConfig = ForwarderConfig{ - ConnectionTimeout: 2 * time.Second, - IdleConnectionTimeout: 2 * time.Second, - MaxIdleConnections: 1, - RedisUrl: "", - UpdateInterval: time.Millisecond * 10, - RetryInterval: time.Millisecond * 3, -} - var DefaultNodeForwarderConfig = ForwarderConfig{ ConnectionTimeout: 30 * time.Second, IdleConnectionTimeout: 15 * time.Second, diff --git a/execution/gethexec/node.go b/execution/gethexec/node.go index 2fb0684124..93f643b8a1 100644 --- a/execution/gethexec/node.go +++ b/execution/gethexec/node.go @@ -108,31 +108,6 @@ var ConfigDefault = Config{ EnablePrefetchBlock: true, } -func ConfigDefaultNonSequencerTest() *Config { - config := ConfigDefault - config.Caching = TestCachingConfig - config.ParentChainReader = headerreader.TestConfig - config.Sequencer.Enable = false - config.Forwarder = DefaultTestForwarderConfig - config.ForwardingTarget = "null" - - _ = config.Validate() - - return &config -} - -func ConfigDefaultTest() *Config { - config := ConfigDefault - config.Caching = TestCachingConfig - config.Sequencer = TestSequencerConfig - config.ParentChainReader = headerreader.TestConfig - config.ForwardingTarget = "null" - - _ = config.Validate() - - return &config -} - type ConfigFetcher func() *Config type ExecutionNode struct { diff --git a/execution/gethexec/sequencer.go b/execution/gethexec/sequencer.go index c5e97342d2..e620e6ccd1 100644 --- a/execution/gethexec/sequencer.go +++ b/execution/gethexec/sequencer.go @@ -132,24 +132,6 @@ var DefaultSequencerConfig = SequencerConfig{ EnableProfiling: false, } -var TestSequencerConfig = SequencerConfig{ - Enable: true, - MaxBlockSpeed: time.Millisecond * 10, - MaxRevertGasReject: params.TxGas + 10000, - MaxAcceptableTimestampDelta: time.Hour, - SenderWhitelist: "", - Forwarder: DefaultTestForwarderConfig, - QueueSize: 128, - QueueTimeout: time.Second * 5, - NonceCacheSize: 4, - MaxTxDataSize: 95000, - NonceFailureCacheSize: 1024, - NonceFailureCacheExpiry: time.Second, - ExpectedSurplusSoftThreshold: "default", - ExpectedSurplusHardThreshold: "default", - EnableProfiling: false, -} - func SequencerConfigAddOptions(prefix string, f *flag.FlagSet) { f.Bool(prefix+".enable", DefaultSequencerConfig.Enable, "act and post to l1 as sequencer") f.Duration(prefix+".max-block-speed", DefaultSequencerConfig.MaxBlockSpeed, "minimum delay between blocks (sets a maximum speed of block production)") diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 191a33cb22..1bc9043a26 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -75,6 +75,7 @@ import ( "github.com/offchainlabs/nitro/solgen/go/upgrade_executorgen" "github.com/offchainlabs/nitro/statetransfer" "github.com/offchainlabs/nitro/util/testhelpers" + "github.com/offchainlabs/nitro/util/testhelpers/env" "github.com/offchainlabs/nitro/util/testhelpers/github" "golang.org/x/exp/slog" ) @@ -151,6 +152,74 @@ func (tc *TestClient) EnsureTxSucceededWithTimeout(transaction *types.Transactio return EnsureTxSucceededWithTimeout(tc.ctx, tc.Client, transaction, timeout) } +var TestCachingConfig = gethexec.CachingConfig{ + Archive: false, + BlockCount: 128, + BlockAge: 30 * time.Minute, + TrieTimeLimit: time.Hour, + TrieDirtyCache: 1024, + TrieCleanCache: 600, + SnapshotCache: 400, + DatabaseCache: 2048, + SnapshotRestoreGasLimit: 300_000_000_000, + MaxNumberOfBlocksToSkipStateSaving: 0, + MaxAmountOfGasToSkipStateSaving: 0, + StylusLRUCache: 0, + StateScheme: env.GetTestStateScheme(), +} + +var DefaultTestForwarderConfig = gethexec.ForwarderConfig{ + ConnectionTimeout: 2 * time.Second, + IdleConnectionTimeout: 2 * time.Second, + MaxIdleConnections: 1, + RedisUrl: "", + UpdateInterval: time.Millisecond * 10, + RetryInterval: time.Millisecond * 3, +} + +var TestSequencerConfig = gethexec.SequencerConfig{ + Enable: true, + MaxBlockSpeed: time.Millisecond * 10, + MaxRevertGasReject: params.TxGas + 10000, + MaxAcceptableTimestampDelta: time.Hour, + SenderWhitelist: "", + Forwarder: DefaultTestForwarderConfig, + QueueSize: 128, + QueueTimeout: time.Second * 5, + NonceCacheSize: 4, + MaxTxDataSize: 95000, + NonceFailureCacheSize: 1024, + NonceFailureCacheExpiry: time.Second, + ExpectedSurplusSoftThreshold: "default", + ExpectedSurplusHardThreshold: "default", + EnableProfiling: false, +} + +func ExecConfigDefaultNonSequencerTest() *gethexec.Config { + config := gethexec.ConfigDefault + config.Caching = TestCachingConfig + config.ParentChainReader = headerreader.TestConfig + config.Sequencer.Enable = false + config.Forwarder = DefaultTestForwarderConfig + config.ForwardingTarget = "null" + + _ = config.Validate() + + return &config +} + +func ExecConfigDefaultTest() *gethexec.Config { + config := gethexec.ConfigDefault + config.Caching = TestCachingConfig + config.Sequencer = TestSequencerConfig + config.ParentChainReader = headerreader.TestConfig + config.ForwardingTarget = "null" + + _ = config.Validate() + + return &config +} + type NodeBuilder struct { // NodeBuilder configuration ctx context.Context @@ -198,7 +267,7 @@ func (b *NodeBuilder) DefaultConfig(t *testing.T, withL1 bool) *NodeBuilder { b.l2StackConfig = testhelpers.CreateStackConfigForTest(b.dataDir) cp := valnode.TestValidationConfig b.valnodeConfig = &cp - b.execConfig = gethexec.ConfigDefaultTest() + b.execConfig = ExecConfigDefaultTest() return b } @@ -231,7 +300,7 @@ func (b *NodeBuilder) CheckConfig(t *testing.T) { b.nodeConfig = arbnode.ConfigDefaultL1Test() } if b.execConfig == nil { - b.execConfig = gethexec.ConfigDefaultTest() + b.execConfig = ExecConfigDefaultTest() } if b.L1Info == nil { b.L1Info = NewL1TestInfo(t) @@ -955,7 +1024,7 @@ func createL2BlockChainWithStackConfig( if cacheConfig != nil { coreCacheConfig = gethexec.DefaultCacheConfigFor(stack, cacheConfig) } - blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, gethexec.ConfigDefaultTest().TxLookupLimit, 0) + blockchain, err := gethexec.WriteOrTestBlockChain(chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest().TxLookupLimit, 0) Require(t, err) return l2info, stack, chainDb, arbDb, blockchain @@ -1008,7 +1077,7 @@ func Create2ndNodeWithConfig( nodeConfig = arbnode.ConfigDefaultL1NonSequencerTest() } if execConfig == nil { - execConfig = gethexec.ConfigDefaultNonSequencerTest() + execConfig = ExecConfigDefaultNonSequencerTest() } feedErrChan := make(chan error, 10) l1rpcClient := l1stack.Attach() @@ -1038,7 +1107,7 @@ func Create2ndNodeWithConfig( chainConfig := firstExec.ArbInterface.BlockChain().Config() coreCacheConfig := gethexec.DefaultCacheConfigFor(l2stack, &execConfig.Caching) - l2blockchain, err := gethexec.WriteOrTestBlockChain(l2chainDb, coreCacheConfig, initReader, chainConfig, initMessage, gethexec.ConfigDefaultTest().TxLookupLimit, 0) + l2blockchain, err := gethexec.WriteOrTestBlockChain(l2chainDb, coreCacheConfig, initReader, chainConfig, initMessage, ExecConfigDefaultTest().TxLookupLimit, 0) Require(t, err) AddDefaultValNode(t, ctx, nodeConfig, true, "", valnodeConfig.Wasm.RootPath) diff --git a/system_tests/forwarder_test.go b/system_tests/forwarder_test.go index d29e82c12c..2919377d6f 100644 --- a/system_tests/forwarder_test.go +++ b/system_tests/forwarder_test.go @@ -17,7 +17,6 @@ import ( "github.com/alicebob/miniredis/v2" "github.com/ethereum/go-ethereum/ethclient" "github.com/offchainlabs/nitro/arbnode" - "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/util/redisutil" ) @@ -39,7 +38,7 @@ func TestStaticForwarder(t *testing.T) { clientA := builder.L2.Client nodeConfigB := arbnode.ConfigDefaultL1Test() - execConfigB := gethexec.ConfigDefaultTest() + execConfigB := ExecConfigDefaultTest() execConfigB.Sequencer.Enable = false nodeConfigB.Sequencer = false nodeConfigB.DelayedSequencer.Enable = false @@ -110,7 +109,7 @@ func createForwardingNode(t *testing.T, builder *NodeBuilder, ipcPath string, re nodeConfig.Sequencer = false nodeConfig.DelayedSequencer.Enable = false nodeConfig.BatchPoster.Enable = false - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.Sequencer.Enable = false execConfig.Forwarder.RedisUrl = redisUrl execConfig.ForwardingTarget = fallbackPath @@ -264,7 +263,7 @@ func TestRedisForwarder(t *testing.T) { tx := builder.L2Info.PrepareTx(userA, userB, builder.L2Info.TransferGas, transferAmount, nil) sendFunc := func() error { return forwardingClient.SendTransaction(ctx, tx) } - if err := tryWithTimeout(ctx, sendFunc, gethexec.DefaultTestForwarderConfig.UpdateInterval*10); err != nil { + if err := tryWithTimeout(ctx, sendFunc, DefaultTestForwarderConfig.UpdateInterval*10); err != nil { t.Fatalf("Client: %v, error sending transaction: %v", i, err) } _, err := EnsureTxSucceeded(ctx, seqClients[i], tx) @@ -309,7 +308,7 @@ func TestRedisForwarderFallbackNoRedis(t *testing.T) { builder.L2Info.GenerateAccount(user) tx := builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, transferAmount, nil) sendFunc := func() error { return forwardingClient.SendTransaction(ctx, tx) } - err := tryWithTimeout(ctx, sendFunc, gethexec.DefaultTestForwarderConfig.UpdateInterval*10) + err := tryWithTimeout(ctx, sendFunc, DefaultTestForwarderConfig.UpdateInterval*10) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) diff --git a/system_tests/recreatestate_rpc_test.go b/system_tests/recreatestate_rpc_test.go index 0debc42143..985ca09f19 100644 --- a/system_tests/recreatestate_rpc_test.go +++ b/system_tests/recreatestate_rpc_test.go @@ -95,7 +95,7 @@ func removeStatesFromDb(t *testing.T, bc *core.BlockChain, db ethdb.Database, fr func TestRecreateStateForRPCNoDepthLimit(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 @@ -133,7 +133,7 @@ func TestRecreateStateForRPCBigEnoughDepthLimit(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() depthGasLimit := int64(256 * util.NormalizeL2GasForL1GasInitial(800_000, params.GWei)) - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.RPC.MaxRecreateStateDepth = depthGasLimit execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 @@ -170,7 +170,7 @@ func TestRecreateStateForRPCBigEnoughDepthLimit(t *testing.T) { func TestRecreateStateForRPCDepthLimitExceeded(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.RPC.MaxRecreateStateDepth = int64(200) execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 @@ -207,7 +207,7 @@ func TestRecreateStateForRPCMissingBlockParent(t *testing.T) { var headerCacheLimit uint64 = 512 ctx, cancel := context.WithCancel(context.Background()) defer cancel() - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 @@ -255,7 +255,7 @@ func TestRecreateStateForRPCBeyondGenesis(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 @@ -293,7 +293,7 @@ func TestRecreateStateForRPCBlockNotFoundWhileRecreating(t *testing.T) { var blockCacheLimit uint64 = 256 ctx, cancel := context.WithCancel(context.Background()) defer cancel() - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.RPC.MaxRecreateStateDepth = arbitrum.InfiniteMaxRecreateStateDepth execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 @@ -341,7 +341,7 @@ func testSkippingSavingStateAndRecreatingAfterRestart(t *testing.T, cacheConfig ctx, cancel := context.WithCancel(context.Background()) defer cancel() - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.RPC.MaxRecreateStateDepth = maxRecreateStateDepth execConfig.Sequencer.MaxBlockSpeed = 0 execConfig.Sequencer.MaxTxDataSize = 150 // 1 test tx ~= 110 @@ -439,7 +439,7 @@ func testSkippingSavingStateAndRecreatingAfterRestart(t *testing.T, cacheConfig } func TestSkippingSavingStateAndRecreatingAfterRestart(t *testing.T) { - cacheConfig := gethexec.TestCachingConfig + cacheConfig := TestCachingConfig cacheConfig.Archive = true // For now Archive node should use HashScheme cacheConfig.StateScheme = rawdb.HashScheme @@ -482,7 +482,7 @@ func TestSkippingSavingStateAndRecreatingAfterRestart(t *testing.T) { func TestGettingStateForRPCFullNode(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.Caching.SnapshotCache = 0 // disable snapshots execConfig.Caching.BlockAge = 0 // use only Caching.BlockCount to keep only last N blocks in dirties cache, no matter how new they are execConfig.Sequencer.MaxBlockSpeed = 0 @@ -524,7 +524,7 @@ func TestGettingStateForRPCFullNode(t *testing.T) { func TestGettingStateForRPCHybridArchiveNode(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() - execConfig := gethexec.ConfigDefaultTest() + execConfig := ExecConfigDefaultTest() execConfig.Caching.Archive = true // For now Archive node should use HashScheme execConfig.Caching.StateScheme = rawdb.HashScheme diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index 268d59ac98..8f9507aea2 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -22,7 +22,6 @@ import ( "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbos/retryables" "github.com/offchainlabs/nitro/arbos/util" - "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/solgen/go/mocksgen" @@ -940,7 +939,7 @@ func elevateL2Basefee(t *testing.T, ctx context.Context, builder *NodeBuilder) { _, err = precompilesgen.NewArbosTest(common.HexToAddress("0x69"), builder.L2.Client) Require(t, err, "failed to deploy ArbosTest") - burnAmount := gethexec.ConfigDefaultTest().RPC.RPCGasCap + burnAmount := ExecConfigDefaultTest().RPC.RPCGasCap burnTarget := uint64(5 * l2pricing.InitialSpeedLimitPerSecondV6 * l2pricing.InitialBacklogTolerance) for i := uint64(0); i < (burnTarget+burnAmount)/burnAmount; i++ { burnArbGas := arbostestabi.Methods["burnArbGas"] diff --git a/system_tests/staterecovery_test.go b/system_tests/staterecovery_test.go index 986c8eeda7..42faee7e0d 100644 --- a/system_tests/staterecovery_test.go +++ b/system_tests/staterecovery_test.go @@ -56,7 +56,7 @@ func TestRectreateMissingStates(t *testing.T) { chainDb, err := stack.OpenDatabaseWithExtraOptions("l2chaindata", 0, 0, "l2chaindata/", false, conf.PersistentConfigDefault.Pebble.ExtraOptions("l2chaindata")) Require(t, err) defer chainDb.Close() - cachingConfig := gethexec.TestCachingConfig + cachingConfig := TestCachingConfig // For now Archive node should use HashScheme cachingConfig.StateScheme = rawdb.HashScheme cacheConfig := gethexec.DefaultCacheConfigFor(stack, &cachingConfig) From 5993bc8d0da7f7f066d61e8e06a2b2c9e54590cb Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 19 Jul 2024 22:04:35 -0300 Subject: [PATCH 185/268] Fixes triedb import from geth --- arbos/arbosState/arbosstate.go | 10 +++++----- arbos/arbosState/initialize.go | 9 +++++---- arbos/storage/storage.go | 10 +++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/arbos/arbosState/arbosstate.go b/arbos/arbosState/arbosstate.go index 357fe265b5..91c2207aae 100644 --- a/arbos/arbosState/arbosstate.go +++ b/arbos/arbosState/arbosstate.go @@ -15,9 +15,9 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/trie" - "github.com/ethereum/go-ethereum/trie/triedb/hashdb" - "github.com/ethereum/go-ethereum/trie/triedb/pathdb" + "github.com/ethereum/go-ethereum/triedb" + "github.com/ethereum/go-ethereum/triedb/hashdb" + "github.com/ethereum/go-ethereum/triedb/pathdb" "github.com/offchainlabs/nitro/arbcompress" "github.com/offchainlabs/nitro/arbos/addressSet" @@ -119,9 +119,9 @@ func OpenSystemArbosStateOrPanic(stateDB vm.StateDB, tracingInfo *util.TracingIn // NewArbosMemoryBackedArbOSState creates and initializes a memory-backed ArbOS state (for testing only) func NewArbosMemoryBackedArbOSState() (*ArbosState, *state.StateDB) { raw := rawdb.NewMemoryDatabase() - trieConfig := &trie.Config{Preimages: false, PathDB: pathdb.Defaults} + trieConfig := &triedb.Config{Preimages: false, PathDB: pathdb.Defaults} if env.GetTestStateScheme() == rawdb.HashScheme { - trieConfig = &trie.Config{Preimages: false, HashDB: hashdb.Defaults} + trieConfig = &triedb.Config{Preimages: false, HashDB: hashdb.Defaults} } db := state.NewDatabaseWithConfig(raw, trieConfig) statedb, err := state.New(common.Hash{}, db, nil) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index e2a4a3c5e0..d7b277970d 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -17,8 +17,9 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" - "github.com/ethereum/go-ethereum/trie/triedb/hashdb" - "github.com/ethereum/go-ethereum/trie/triedb/pathdb" + "github.com/ethereum/go-ethereum/triedb" + "github.com/ethereum/go-ethereum/triedb/hashdb" + "github.com/ethereum/go-ethereum/triedb/pathdb" "github.com/holiman/uint256" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" @@ -55,8 +56,8 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)) } -func TriedbConfig(c *core.CacheConfig) *trie.Config { - config := &trie.Config{Preimages: c.Preimages} +func TriedbConfig(c *core.CacheConfig) *triedb.Config { + config := &triedb.Config{Preimages: c.Preimages} if c.StateScheme == rawdb.HashScheme { config.HashDB = &hashdb.Config{ CleanCacheSize: c.TrieCleanLimit * 1024 * 1024, diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index 8d7fa09304..6e6c976644 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -18,9 +18,9 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/trie" - "github.com/ethereum/go-ethereum/trie/triedb/hashdb" - "github.com/ethereum/go-ethereum/trie/triedb/pathdb" + "github.com/ethereum/go-ethereum/triedb" + "github.com/ethereum/go-ethereum/triedb/hashdb" + "github.com/ethereum/go-ethereum/triedb/pathdb" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" @@ -87,9 +87,9 @@ func NewMemoryBacked(burner burn.Burner) *Storage { // Only used for testing. func NewMemoryBackedStateDB() vm.StateDB { raw := rawdb.NewMemoryDatabase() - trieConfig := &trie.Config{Preimages: false, PathDB: pathdb.Defaults} + trieConfig := &triedb.Config{Preimages: false, PathDB: pathdb.Defaults} if env.GetTestStateScheme() == rawdb.HashScheme { - trieConfig = &trie.Config{Preimages: false, HashDB: hashdb.Defaults} + trieConfig = &triedb.Config{Preimages: false, HashDB: hashdb.Defaults} } db := state.NewDatabaseWithConfig(raw, trieConfig) statedb, err := state.New(common.Hash{}, db, nil) From 903c937d9eb62c7009f74555f89c999469405285 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 22 Jul 2024 14:23:20 +0200 Subject: [PATCH 186/268] Fix health check spamming the expiry index --- das/local_file_storage_service.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index cad323b165..5623195657 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -229,7 +229,14 @@ func (s *LocalFileStorageService) String() string { func (s *LocalFileStorageService) HealthCheck(ctx context.Context) error { testData := []byte("Test-Data") - err := s.Put(ctx, testData, uint64(time.Now().Add(time.Minute).Unix())) + // Store some data with an expiry time at the start of the epoch. + // If expiry is disabled it will only create an index entry for the + // same timestamp each time the health check happens. + // If expiry is enabled, it will be cleaned up each time the pruning + // runs. There is a slight chance of a race between pruning and the + // Put and Get calls, but systems using the HealthCheck will just retry + // and succeed the next time. + err := s.Put(ctx, testData /* start of epoch */, 0) if err != nil { return err } From 5736c56857bafd6d04d09cb2381593f928b27d86 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 22 Jul 2024 09:35:08 -0300 Subject: [PATCH 187/268] Fixes ci, runs gotestsum package by package --- .github/workflows/ci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05c3f3cbd3..c5dc37148b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,7 +160,12 @@ jobs: TEST_STATE_SCHEME: hash run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -timeout 20m -parallel=8 -tags=cionly + for package in $packages; do + echo running tests for $package + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -timeout 20m -tags=cionly; then + exit 1 + fi + done - name: run tests with race detection and path state scheme if: matrix.test-mode == 'race' @@ -181,7 +186,12 @@ jobs: TEST_STATE_SCHEME: hash run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -race -timeout 30m -parallel=8 + for package in $packages; do + echo running tests for $package + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -race -timeout 30m; then + exit 1 + fi + done - name: run redis tests if: matrix.test-mode == 'defaults' From fc900cc6dbe011cddcdd770ca5cd59c810f52b15 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 22 Jul 2024 13:35:53 -0300 Subject: [PATCH 188/268] Updates go-ethereum --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 18256c2dfc..334c337af3 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 18256c2dfcce8fd567aa05e03fbc11a4c17aa550 +Subproject commit 334c337af3e58523a23170aaa8dd0139bc57671e From 6f04d12aa3c87aae00284cb2e26fa1b88733af3b Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 22 Jul 2024 13:40:34 -0300 Subject: [PATCH 189/268] Uses TriedbConfig from geth --- arbos/arbosState/initialization_test.go | 2 +- arbos/arbosState/initialize.go | 23 +---------------------- system_tests/state_fuzz_test.go | 2 +- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/arbos/arbosState/initialization_test.go b/arbos/arbosState/initialization_test.go index ffba4cf9b1..34802392fe 100644 --- a/arbos/arbosState/initialization_test.go +++ b/arbos/arbosState/initialization_test.go @@ -67,7 +67,7 @@ func tryMarshalUnmarshal(input *statetransfer.ArbosInitializationInfo, t *testin stateroot, err := InitializeArbosInDatabase(raw, cacheConfig, initReader, chainConfig, arbostypes.TestInitMessage, 0, 0) Require(t, err) - triedbConfig := TriedbConfig(cacheConfig) + triedbConfig := cacheConfig.TriedbConfig() stateDb, err := state.New(stateroot, state.NewDatabaseWithConfig(raw, triedbConfig), nil) Require(t, err) diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index d7b277970d..c44febf386 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -10,16 +10,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" - "github.com/ethereum/go-ethereum/triedb" - "github.com/ethereum/go-ethereum/triedb/hashdb" - "github.com/ethereum/go-ethereum/triedb/pathdb" "github.com/holiman/uint256" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/burn" @@ -56,25 +52,8 @@ func MakeGenesisBlock(parentHash common.Hash, blockNumber uint64, timestamp uint return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)) } -func TriedbConfig(c *core.CacheConfig) *triedb.Config { - config := &triedb.Config{Preimages: c.Preimages} - if c.StateScheme == rawdb.HashScheme { - config.HashDB = &hashdb.Config{ - CleanCacheSize: c.TrieCleanLimit * 1024 * 1024, - } - } - if c.StateScheme == rawdb.PathScheme { - config.PathDB = &pathdb.Config{ - StateHistory: c.StateHistory, - CleanCacheSize: c.TrieCleanLimit * 1024 * 1024, - DirtyCacheSize: c.TrieDirtyLimit * 1024 * 1024, - } - } - return config -} - func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, initData statetransfer.InitDataReader, chainConfig *params.ChainConfig, initMessage *arbostypes.ParsedInitMessage, timestamp uint64, accountsPerSync uint) (root common.Hash, err error) { - triedbConfig := TriedbConfig(cacheConfig) + triedbConfig := cacheConfig.TriedbConfig() triedbConfig.Preimages = false stateDatabase := state.NewDatabaseWithConfig(db, triedbConfig) defer func() { diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 5cff2108cf..713aefcfba 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -151,7 +151,7 @@ func FuzzStateTransition(f *testing.F) { if err != nil { panic(err) } - trieDBConfig := arbosState.TriedbConfig(cacheConfig) + trieDBConfig := cacheConfig.TriedbConfig() statedb, err := state.New(stateRoot, state.NewDatabaseWithConfig(chainDb, trieDBConfig), nil) if err != nil { panic(err) From 8cd0d648428243d04ce412c71bf61e29559b2d34 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 22 Jul 2024 17:33:03 -0600 Subject: [PATCH 190/268] block_validator: add histograms --- staker/block_validator.go | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index 8063f74d58..a354bafc50 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -31,13 +31,18 @@ import ( ) var ( - validatorPendingValidationsGauge = metrics.NewRegisteredGauge("arb/validator/validations/pending", nil) - validatorValidValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/valid", nil) - validatorFailedValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/failed", nil) - validatorMsgCountCurrentBatch = metrics.NewRegisteredGauge("arb/validator/msg_count_current_batch", nil) - validatorMsgCountCreatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_created", nil) - validatorMsgCountRecordSentGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_record_sent", nil) - validatorMsgCountValidatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_validated", nil) + validatorPendingValidationsGauge = metrics.NewRegisteredGauge("arb/validator/validations/pending", nil) + validatorValidValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/valid", nil) + validatorFailedValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/failed", nil) + validatorValidationWaitToRecordHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRecord", nil, metrics.NewBoundedHistogramSample()) + validatorValidationRecordingHist = metrics.NewRegisteredHistogram("arb/validator/validations/recording", nil, metrics.NewBoundedHistogramSample()) + validatorValidationWaitToLaunchHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRun", nil, metrics.NewBoundedHistogramSample()) + validatorValidationLaunchHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRun", nil, metrics.NewBoundedHistogramSample()) + validatorValidationRunningHist = metrics.NewRegisteredHistogram("arb/validator/validations/running", nil, metrics.NewBoundedHistogramSample()) + validatorMsgCountCurrentBatch = metrics.NewRegisteredGauge("arb/validator/msg_count_current_batch", nil) + validatorMsgCountCreatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_created", nil) + validatorMsgCountRecordSentGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_record_sent", nil) + validatorMsgCountValidatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_validated", nil) ) type BlockValidator struct { @@ -210,10 +215,11 @@ const ( ) type validationStatus struct { - Status atomic.Uint32 // atomic: value is one of validationStatus* - Cancel func() // non-atomic: only read/written to with reorg mutex - Entry *validationEntry // non-atomic: only read if Status >= validationStatusPrepared - Runs []validator.ValidationRun // if status >= ValidationSent + Status atomic.Uint32 // atomic: value is one of validationStatus* + Cancel func() // non-atomic: only read/written to with reorg mutex + Entry *validationEntry // non-atomic: only read if Status >= validationStatusPrepared + Runs []validator.ValidationRun // if status >= ValidationSent + tsMilli int64 } func (s *validationStatus) getStatus() valStatusField { @@ -225,6 +231,12 @@ func (s *validationStatus) replaceStatus(old, new valStatusField) bool { return s.Status.CompareAndSwap(uint32(old), uint32(new)) } +func (s *validationStatus) timeStampInterval() int64 { + start := s.tsMilli + s.tsMilli = time.Now().UnixMilli() + return s.tsMilli - start +} + func NewBlockValidator( statelessBlockValidator *StatelessBlockValidator, inbox InboxTrackerInterface, @@ -447,6 +459,8 @@ func (v *BlockValidator) sendRecord(s *validationStatus) error { if !s.replaceStatus(Created, RecordSent) { return fmt.Errorf("failed status check for send record. Status: %v", s.getStatus()) } + + validatorValidationWaitToRecordHist.Update(s.timeStampInterval()) v.LaunchThread(func(ctx context.Context) { err := v.ValidationEntryRecord(ctx, s.Entry) if ctx.Err() != nil { @@ -457,11 +471,11 @@ func (v *BlockValidator) sendRecord(s *validationStatus) error { log.Error("Error while recording", "err", err, "status", s.getStatus()) return } + validatorValidationRecordingHist.Update(s.timeStampInterval()) if !s.replaceStatus(RecordSent, Prepared) { log.Error("Fault trying to update validation with recording", "entry", s.Entry, "status", s.getStatus()) return } - nonBlockingTrigger(v.progressValidationsChan) }) return nil } @@ -585,7 +599,8 @@ func (v *BlockValidator) createNextValidationEntry(ctx context.Context) (bool, e return false, err } status := &validationStatus{ - Entry: entry, + Entry: entry, + tsMilli: time.Now().UnixMilli(), } status.Status.Store(uint32(Created)) v.validations.Store(pos, status) @@ -811,6 +826,7 @@ validationsLoop: if !replaced { v.possiblyFatal(errors.New("failed to set SendingValidation status")) } + validatorValidationWaitToLaunchHist.Update(validationStatus.timeStampInterval()) validatorPendingValidationsGauge.Inc(1) var runs []validator.ValidationRun for _, moduleRoot := range wasmRoots { @@ -823,12 +839,14 @@ validationsLoop: log.Trace("advanceValidations: launched", "pos", validationStatus.Entry.Pos, "moduleRoot", moduleRoot) runs = append(runs, run) } + validatorValidationLaunchHist.Update(validationStatus.timeStampInterval()) validationCtx, cancel := context.WithCancel(ctx) validationStatus.Runs = runs validationStatus.Cancel = cancel v.LaunchUntrackedThread(func() { defer validatorPendingValidationsGauge.Dec(1) defer cancel() + startTsMilli := validationStatus.tsMilli replaced = validationStatus.replaceStatus(SendingValidation, ValidationSent) if !replaced { v.possiblyFatal(errors.New("failed to set status to ValidationSent")) @@ -842,6 +860,7 @@ validationsLoop: return } } + validatorValidationRunningHist.Update(time.Now().UnixMilli() - startTsMilli) nonBlockingTrigger(v.progressValidationsChan) }) } From df93f6045d3c5b7a80f7de71ba503128eee9ec17 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 22 Jul 2024 18:12:22 -0600 Subject: [PATCH 191/268] update geth pin to 1.13.15 --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 18256c2dfc..48de2030c7 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 18256c2dfcce8fd567aa05e03fbc11a4c17aa550 +Subproject commit 48de2030c7a6fa8689bc0a0212ebca2a0c73e3ad From 161f447d8b7ce644bb85a935588b3e6221c9e6e3 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 23 Jul 2024 10:52:51 +0200 Subject: [PATCH 192/268] Change the test data stored by das fs healthcheck For some installations, if they had already stored 65000 expiry index entries for the hold health check data, simply setting the expiry time to the start of epoch isn't enough to fix the health check for them since it already has 65000 entries and start of epoch would be another entry, exceeding the max inode links. Simply changing the test data preimage fixes this becauese it will be stored at a different hash. --- das/local_file_storage_service.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index 5623195657..66a08d0d95 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -228,7 +228,7 @@ func (s *LocalFileStorageService) String() string { } func (s *LocalFileStorageService) HealthCheck(ctx context.Context) error { - testData := []byte("Test-Data") + testData := []byte("Test Data") // Store some data with an expiry time at the start of the epoch. // If expiry is disabled it will only create an index entry for the // same timestamp each time the health check happens. @@ -236,7 +236,7 @@ func (s *LocalFileStorageService) HealthCheck(ctx context.Context) error { // runs. There is a slight chance of a race between pruning and the // Put and Get calls, but systems using the HealthCheck will just retry // and succeed the next time. - err := s.Put(ctx, testData /* start of epoch */, 0) + err := s.Put(ctx, testData, 0 /* start of epoch */) if err != nil { return err } From 78da69cc4ab551e003c33543331801383217b10e Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 23 Jul 2024 11:10:51 +0200 Subject: [PATCH 193/268] Move validateMessageNumber method to arbdebug ns This is a debugging related call, changed namespace to make it clear. --- arbnode/node.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbnode/node.go b/arbnode/node.go index a2ccdd1834..ac18a6c7d4 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -779,7 +779,7 @@ func CreateNode( } if currentNode.StatelessBlockValidator != nil { apis = append(apis, rpc.API{ - Namespace: "arbvalidator", + Namespace: "arbdebug", Version: "1.0", Service: &BlockValidatorDebugAPI{ val: currentNode.StatelessBlockValidator, From d63fc0ef077f7c814ef07c0f16583aa519a16b7c Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Jul 2024 15:01:12 +0200 Subject: [PATCH 194/268] Make two comments proper Rust doc comments This way online documentation can be generated correctly. --- arbitrator/prover/src/memory.rs | 12 ++++++------ arbitrator/wasm-libraries/Cargo.lock | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index dd4198f7b8..139ddcf272 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -262,9 +262,9 @@ impl Memory { } #[must_use] - // Stores a value in memory, returns false if the value would overflow the buffer. - // - // bytes is the number of bytes to store. It must be <= 8. + /// Stores a value in memory, returns false if the value would overflow the buffer. + /// + /// bytes is the number of bytes to store. It must be <= 8. pub fn store_value(&mut self, idx: u64, value: u64, bytes: u8) -> bool { assert!(bytes <= 8); let Some(end_idx) = idx.checked_add(bytes.into()) else { @@ -285,9 +285,9 @@ impl Memory { } #[must_use] - // Stores a slice in memory, returns false if the value would overflow the buffer. - // - // The length of value <= 32. + /// Stores a slice in memory, returns false if the value would overflow the buffer. + /// + /// The length of value <= 32. pub fn store_slice_aligned(&mut self, idx: u64, value: &[u8]) -> bool { assert!(value.len() <= Self::LEAF_SIZE); if idx % Self::LEAF_SIZE as u64 != 0 { diff --git a/arbitrator/wasm-libraries/Cargo.lock b/arbitrator/wasm-libraries/Cargo.lock index 3817d0b40f..88525ececa 100644 --- a/arbitrator/wasm-libraries/Cargo.lock +++ b/arbitrator/wasm-libraries/Cargo.lock @@ -120,6 +120,7 @@ checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" dependencies = [ "funty", "radium", + "serde", "tap", "wyz", ] @@ -885,6 +886,7 @@ version = "0.1.0" dependencies = [ "arbutil", "bincode", + "bitvec", "brotli", "derivative", "digest 0.9.0", From f3a9b4dd8c145166a526d152fd8794c45134b99a Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Jul 2024 15:40:42 +0200 Subject: [PATCH 195/268] Simplify the resizing of the dirty_leaf_parents --- arbitrator/prover/src/merkle.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index a3b063786f..ebaefbe401 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -377,15 +377,8 @@ impl Merkle { layer.resize(layer_size, *empty_hash_at(self.ty, layer_i)); layer_size = max(layer_size >> 1, 1); } - for i in start..new_len { - let parent_i = i >> 1; - assert!(parent_i <= layers.dirty_leaf_parents.len()); - if parent_i == layers.dirty_leaf_parents.len() { - layers.dirty_leaf_parents.push(true); - } else if parent_i < layers.dirty_leaf_parents.len() { - layers.dirty_leaf_parents.set(parent_i, true); - } - } + layers.dirty_leaf_parents[(start >> 1)..].fill(true); + layers.dirty_leaf_parents.resize(new_len >> 1, true); Ok(layers.data[0].len()) } } From 62b5246ba2f2995a90f14d7016dcb7455e5ad059 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Jul 2024 16:18:48 +0200 Subject: [PATCH 196/268] Just clone the dirty_leaf_parents and fill(false) This way, it's clearer what the end-state of the `dirty_leaf_parents` is after `rehash` is called? --- arbitrator/prover/src/merkle.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index ebaefbe401..d6d666eb62 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -230,11 +230,7 @@ impl Merkle { if layers.dirty_leaf_parents.is_empty() { return; } - // Replace the dirty leaf parents with clean ones. - let mut dirt = std::mem::replace( - &mut layers.dirty_leaf_parents, - bitvec![0; (layers.data[0].len() + 1) >> 1], - ); + let mut dirt = layers.dirty_leaf_parents.clone(); // Process dirty indices starting from layer 1 (layer 0 is the leaves). for layer_i in 1..layers.data.len() { let mut new_dirt = bitvec![0; dirt.len() + 1 >> 1]; @@ -262,6 +258,7 @@ impl Merkle { } dirt = new_dirt; } + layers.dirty_leaf_parents.fill(false); } pub fn root(&self) -> Bytes32 { @@ -377,7 +374,9 @@ impl Merkle { layer.resize(layer_size, *empty_hash_at(self.ty, layer_i)); layer_size = max(layer_size >> 1, 1); } + // This will set one or no values depending on if the length was even or odd. layers.dirty_leaf_parents[(start >> 1)..].fill(true); + // This then resizes and marks the dirty leaf parents as dirty. layers.dirty_leaf_parents.resize(new_len >> 1, true); Ok(layers.data[0].len()) } @@ -398,7 +397,7 @@ impl PartialEq for Merkle { // because the same nodes are hashed together. However, the min_dpeth was 4, then, // there would be 4 layers in that tree, and the root hash would be different. fn eq(&self, other: &Self) -> bool { - self.root() == other.root() + self.root() == other.root() && self.ty == other.ty } } From 963a23bb2e901617100a0bd45c0ee0016c9f2a2e Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 23 Jul 2024 16:34:00 +0200 Subject: [PATCH 197/268] Make clippy happy. --- arbitrator/prover/src/memory.rs | 2 +- arbitrator/prover/src/merkle.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arbitrator/prover/src/memory.rs b/arbitrator/prover/src/memory.rs index 139ddcf272..5853dc87e1 100644 --- a/arbitrator/prover/src/memory.rs +++ b/arbitrator/prover/src/memory.rs @@ -364,7 +364,7 @@ pub mod testing { pub fn empty_leaf_hash() -> Bytes32 { let leaf = [0u8; 32]; - return super::hash_leaf(leaf); + super::hash_leaf(leaf) } } diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index d6d666eb62..98ba6591f0 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -205,7 +205,7 @@ impl Merkle { min_depth }; let mut layers: Vec> = Vec::with_capacity(depth); - let dirty_leaf_parents = bitvec![0; hashes.len() + 1 >> 1]; + let dirty_leaf_parents = bitvec![0; (hashes.len() + 1) >> 1]; layers.push(hashes); while layers.last().unwrap().len() > 1 || layers.len() < min_depth { let layer = layers.last().unwrap(); @@ -233,7 +233,7 @@ impl Merkle { let mut dirt = layers.dirty_leaf_parents.clone(); // Process dirty indices starting from layer 1 (layer 0 is the leaves). for layer_i in 1..layers.data.len() { - let mut new_dirt = bitvec![0; dirt.len() + 1 >> 1]; + let mut new_dirt = bitvec![0; (dirt.len() + 1) >> 1]; for idx in dirt.iter_ones() { let left_child_idx = idx << 1; let right_child_idx = left_child_idx + 1; From a517597a2e4f119efc28b08f50547135823ccf5f Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Tue, 23 Jul 2024 14:10:15 -0300 Subject: [PATCH 198/268] Increases number of CI reruns. --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5dc37148b..b9fcfba7fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -149,7 +149,7 @@ jobs: packages=`go list ./...` for package in $packages; do echo running tests for $package - if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -tags=cionly > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -tags=cionly > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then exit 1 fi done @@ -162,7 +162,7 @@ jobs: packages=`go list ./...` for package in $packages; do echo running tests for $package - if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -timeout 20m -tags=cionly; then + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -timeout 20m -tags=cionly; then exit 1 fi done @@ -175,7 +175,7 @@ jobs: packages=`go list ./...` for package in $packages; do echo running tests for $package - if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -race -timeout 30m > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -race -timeout 30m > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then exit 1 fi done @@ -188,7 +188,7 @@ jobs: packages=`go list ./...` for package in $packages; do echo running tests for $package - if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -race -timeout 30m; then + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -race -timeout 30m; then exit 1 fi done @@ -203,7 +203,7 @@ jobs: packages=`go list ./...` for package in $packages; do echo running tests for $package - if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=challengetest -run=TestChallenge > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=challengetest -run=TestChallenge > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then exit 1 fi done @@ -214,7 +214,7 @@ jobs: packages=`go list ./...` for package in $packages; do echo running tests for $package - if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=stylustest -run="TestProgramArbitrator" > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=stylustest -run="TestProgramArbitrator" > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then exit 1 fi done @@ -225,7 +225,7 @@ jobs: packages=`go list ./...` for package in $packages; do echo running tests for $package - if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=1 --no-color=false -- -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=stylustest -run="TestProgramLong" > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then + if ! stdbuf -oL gotestsum --format short-verbose --packages="$package" --rerun-fails=2 --no-color=false -- -timeout 60m -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -tags=stylustest -run="TestProgramLong" > >(stdbuf -oL tee -a full.log | grep -vE "INFO|seal"); then exit 1 fi done From 657e1cea82dcb2613c41be0d753642d91be86ffa Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 1 Jul 2024 18:12:24 -0300 Subject: [PATCH 199/268] Saves MessageResult in consensus. --- arbnode/schema.go | 1 + arbnode/transaction_streamer.go | 56 +++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/arbnode/schema.go b/arbnode/schema.go index 2854b7e785..1aaded2b95 100644 --- a/arbnode/schema.go +++ b/arbnode/schema.go @@ -6,6 +6,7 @@ package arbnode var ( messagePrefix []byte = []byte("m") // maps a message sequence number to a message blockHashInputFeedPrefix []byte = []byte("b") // maps a message sequence number to a block hash received through the input feed + messageResultPrefix []byte = []byte("r") // maps a message sequence number to a message result legacyDelayedMessagePrefix []byte = []byte("d") // maps a delayed sequence number to an accumulator and a message as serialized on L1 rlpDelayedMessagePrefix []byte = []byte("e") // maps a delayed sequence number to an accumulator and an RLP encoded message parentChainBlockNumberPrefix []byte = []byte("p") // maps a delayed sequence number to a parent chain block number diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 22ecdd553c..8de4e0f2d4 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -374,6 +374,11 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde } } + pos := uint64(count) - 1 + err = deleteStartingAt(s.db, batch, messageResultPrefix, uint64ToKey(pos)) + if err != nil { + return err + } err = deleteStartingAt(s.db, batch, blockHashInputFeedPrefix, uint64ToKey(uint64(count))) if err != nil { return err @@ -383,6 +388,14 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde return err } + for i := 0; i < len(messagesResults); i++ { + pos := count + arbutil.MessageIndex(i) - 1 + err = s.saveResult(pos, *messagesResults[i], batch) + if err != nil { + return err + } + } + return setMessageCount(batch, count) } @@ -1046,12 +1059,26 @@ func (s *TransactionStreamer) writeMessages(pos arbutil.MessageIndex, messages [ return nil } -// TODO: eventually there will be a table maintained by txStreamer itself func (s *TransactionStreamer) ResultAtCount(count arbutil.MessageIndex) (*execution.MessageResult, error) { if count == 0 { return &execution.MessageResult{}, nil } - return s.exec.ResultAtPos(count - 1) + pos := count - 1 + + key := dbKey(messageResultPrefix, uint64(pos)) + data, err := s.db.Get(key) + if err == nil { + var msgResult execution.MessageResult + err = rlp.DecodeBytes(data, &msgResult) + if err == nil { + return &msgResult, nil + } + } else if !isErrNotFound(err) { + return nil, err + } + + log.Warn("streamer: failed getting message result from db", "count", count, "err", err) + return s.exec.ResultAtPos(pos) } func (s *TransactionStreamer) checkResult(msgResult *execution.MessageResult, expectedBlockHash *common.Hash) { @@ -1068,6 +1095,19 @@ func (s *TransactionStreamer) checkResult(msgResult *execution.MessageResult, ex } } +func (s *TransactionStreamer) saveResult( + pos arbutil.MessageIndex, + msgResult execution.MessageResult, + batch ethdb.Batch, +) error { + msgResultBytes, err := rlp.EncodeToBytes(msgResult) + if err != nil { + return err + } + key := dbKey(messageResultPrefix, uint64(pos)) + return batch.Put(key, msgResultBytes) +} + // exposed for testing // return value: true if should be called again immediately func (s *TransactionStreamer) ExecuteNextMsg(ctx context.Context, exec execution.ExecutionSequencer) bool { @@ -1120,6 +1160,18 @@ func (s *TransactionStreamer) ExecuteNextMsg(ctx context.Context, exec execution s.checkResult(msgResult, msgAndBlockHash.BlockHash) + batch := s.db.NewBatch() + err = s.saveResult(pos, *msgResult, batch) + if err != nil { + log.Error("feedOneMsg failed to save result", "err", err) + return false + } + err = batch.Write() + if err != nil { + log.Error("feedOneMsg failed to save result", "err", err) + return false + } + msgWithBlockHash := arbostypes.MessageWithMetadataAndBlockHash{ MessageWithMeta: msgAndBlockHash.MessageWithMeta, BlockHash: &msgResult.BlockHash, From ecf988f6297022cdf83d47ea6a875388b1edc4ed Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 1 Jul 2024 20:02:58 -0300 Subject: [PATCH 200/268] Moves isErrNotFound to dbutil --- arbnode/dataposter/dbstorage/storage.go | 15 +++++---------- arbnode/transaction_streamer.go | 13 ++++--------- util/dbutil/dbutil.go | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 util/dbutil/dbutil.go diff --git a/arbnode/dataposter/dbstorage/storage.go b/arbnode/dataposter/dbstorage/storage.go index 2cfda5d779..4c49d695c5 100644 --- a/arbnode/dataposter/dbstorage/storage.go +++ b/arbnode/dataposter/dbstorage/storage.go @@ -11,10 +11,9 @@ import ( "fmt" "strconv" - "github.com/cockroachdb/pebble" "github.com/ethereum/go-ethereum/ethdb" - "github.com/ethereum/go-ethereum/ethdb/memorydb" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" + "github.com/offchainlabs/nitro/util/dbutil" "github.com/syndtr/goleveldb/leveldb" ) @@ -134,7 +133,7 @@ func (s *Storage) Prune(ctx context.Context, until uint64) error { func (s *Storage) valueAt(_ context.Context, key []byte) ([]byte, error) { val, err := s.db.Get(key) if err != nil { - if isErrNotFound(err) { + if dbutil.IsErrNotFound(err) { return s.encDec().Encode((*storage.QueuedTransaction)(nil)) } return nil, err @@ -168,10 +167,10 @@ func (s *Storage) Put(ctx context.Context, index uint64, prev, new *storage.Queu return fmt.Errorf("updating value at: %v: %w", key, err) } lastItemIdx, err := s.lastItemIdx(ctx) - if err != nil && !isErrNotFound(err) { + if err != nil && !dbutil.IsErrNotFound(err) { return err } - if isErrNotFound(err) { + if dbutil.IsErrNotFound(err) { lastItemIdx = []byte{} } if cnt == 0 || bytes.Compare(key, lastItemIdx) > 0 { @@ -188,7 +187,7 @@ func (s *Storage) Put(ctx context.Context, index uint64, prev, new *storage.Queu func (s *Storage) Length(context.Context) (int, error) { val, err := s.db.Get(countKey) if err != nil { - if isErrNotFound(err) { + if dbutil.IsErrNotFound(err) { return 0, nil } return 0, err @@ -199,7 +198,3 @@ func (s *Storage) Length(context.Context) (int, error) { func (s *Storage) IsPersistent() bool { return true } - -func isErrNotFound(err error) bool { - return errors.Is(err, leveldb.ErrNotFound) || errors.Is(err, pebble.ErrNotFound) || errors.Is(err, memorydb.ErrMemorydbNotFound) -} diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 8de4e0f2d4..91e7d69736 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -19,9 +19,7 @@ import ( "errors" - "github.com/cockroachdb/pebble" flag "github.com/spf13/pflag" - "github.com/syndtr/goleveldb/leveldb" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" @@ -36,6 +34,7 @@ import ( "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/staker" "github.com/offchainlabs/nitro/util/arbmath" + "github.com/offchainlabs/nitro/util/dbutil" "github.com/offchainlabs/nitro/util/sharedmetrics" "github.com/offchainlabs/nitro/util/stopwaiter" ) @@ -420,10 +419,6 @@ func dbKey(prefix []byte, pos uint64) []byte { return key } -func isErrNotFound(err error) bool { - return errors.Is(err, leveldb.ErrNotFound) || errors.Is(err, pebble.ErrNotFound) -} - // Note: if changed to acquire the mutex, some internal users may need to be updated to a non-locking version. func (s *TransactionStreamer) GetMessage(seqNum arbutil.MessageIndex) (*arbostypes.MessageWithMetadata, error) { key := dbKey(messagePrefix, uint64(seqNum)) @@ -459,7 +454,7 @@ func (s *TransactionStreamer) getMessageWithMetadataAndBlockHash(seqNum arbutil. return nil, err } blockHash = blockHashDBVal.BlockHash - } else if !isErrNotFound(err) { + } else if !dbutil.IsErrNotFound(err) { return nil, err } @@ -605,7 +600,7 @@ func (s *TransactionStreamer) AddBroadcastMessages(feedMessages []*m.BroadcastFe if broadcastStartPos > 0 { _, err := s.GetMessage(broadcastStartPos - 1) if err != nil { - if !isErrNotFound(err) { + if !dbutil.IsErrNotFound(err) { return err } // Message before current message doesn't exist in database, so don't add current messages yet @@ -1073,7 +1068,7 @@ func (s *TransactionStreamer) ResultAtCount(count arbutil.MessageIndex) (*execut if err == nil { return &msgResult, nil } - } else if !isErrNotFound(err) { + } else if !dbutil.IsErrNotFound(err) { return nil, err } diff --git a/util/dbutil/dbutil.go b/util/dbutil/dbutil.go new file mode 100644 index 0000000000..a1eb6ce208 --- /dev/null +++ b/util/dbutil/dbutil.go @@ -0,0 +1,16 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/nitro/blob/master/LICENSE + +package dbutil + +import ( + "errors" + + "github.com/cockroachdb/pebble" + "github.com/ethereum/go-ethereum/ethdb/memorydb" + "github.com/syndtr/goleveldb/leveldb" +) + +func IsErrNotFound(err error) bool { + return errors.Is(err, leveldb.ErrNotFound) || errors.Is(err, pebble.ErrNotFound) || errors.Is(err, memorydb.ErrMemorydbNotFound) +} From 8f9d6e10650199727e26723362f901a6a6e7e4df Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Tue, 2 Jul 2024 20:24:54 -0300 Subject: [PATCH 201/268] Tests comparing msg result retrieved from consensus and execution. --- arbnode/transaction_streamer.go | 17 +++++++------ system_tests/seqfeed_test.go | 45 ++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 91e7d69736..5309e0969d 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -129,7 +129,8 @@ type blockHashDBValue struct { } const ( - BlockHashMismatchLogMsg = "BlockHash from feed doesn't match locally computed hash. Check feed source." + BlockHashMismatchLogMsg = "BlockHash from feed doesn't match locally computed hash. Check feed source." + FailedToGetMsgResultFromDB = "Streamer: failed getting message result from db" ) // Encodes a uint64 as bytes in a lexically sortable manner for database iteration. @@ -388,8 +389,8 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde } for i := 0; i < len(messagesResults); i++ { - pos := count + arbutil.MessageIndex(i) - 1 - err = s.saveResult(pos, *messagesResults[i], batch) + pos := count + arbutil.MessageIndex(i) + err = s.storeResult(pos, *messagesResults[i], batch) if err != nil { return err } @@ -1072,7 +1073,7 @@ func (s *TransactionStreamer) ResultAtCount(count arbutil.MessageIndex) (*execut return nil, err } - log.Warn("streamer: failed getting message result from db", "count", count, "err", err) + log.Warn(FailedToGetMsgResultFromDB, "count", count, "err", err) return s.exec.ResultAtPos(pos) } @@ -1090,7 +1091,7 @@ func (s *TransactionStreamer) checkResult(msgResult *execution.MessageResult, ex } } -func (s *TransactionStreamer) saveResult( +func (s *TransactionStreamer) storeResult( pos arbutil.MessageIndex, msgResult execution.MessageResult, batch ethdb.Batch, @@ -1156,14 +1157,14 @@ func (s *TransactionStreamer) ExecuteNextMsg(ctx context.Context, exec execution s.checkResult(msgResult, msgAndBlockHash.BlockHash) batch := s.db.NewBatch() - err = s.saveResult(pos, *msgResult, batch) + err = s.storeResult(pos, *msgResult, batch) if err != nil { - log.Error("feedOneMsg failed to save result", "err", err) + log.Error("feedOneMsg failed to store result", "err", err) return false } err = batch.Write() if err != nil { - log.Error("feedOneMsg failed to save result", "err", err) + log.Error("feedOneMsg failed to store result", "err", err) return false } diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index 9637c7d4fc..ab006391fc 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -8,6 +8,7 @@ import ( "fmt" "math/big" "net" + "reflect" "testing" "time" @@ -17,9 +18,11 @@ import ( "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbos/l1pricing" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/broadcastclient" "github.com/offchainlabs/nitro/broadcaster/backlog" "github.com/offchainlabs/nitro/broadcaster/message" + "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/execution/gethexec" "github.com/offchainlabs/nitro/relay" "github.com/offchainlabs/nitro/util/signature" @@ -144,8 +147,36 @@ func TestRelayedSequencerFeed(t *testing.T) { } } +func comparesMsgResultFromConsensusAndExecution( + t *testing.T, + testClient *TestClient, + testScenario string, +) *execution.MessageResult { + pos := 1 + count := pos + 1 + + headMsgNum, err := testClient.ExecNode.HeadMessageNumber() + Require(t, err) + if headMsgNum != arbutil.MessageIndex(pos) { + t.Fatal("Unexpected head message number:", headMsgNum, "pos: ", pos, "testScenario:", testScenario) + } + + resultExec, err := testClient.ExecNode.ResultAtPos(arbutil.MessageIndex(pos)) + Require(t, err) + resultConsensus, err := testClient.ConsensusNode.TxStreamer.ResultAtCount(arbutil.MessageIndex(count)) + Require(t, err) + if !reflect.DeepEqual(resultExec, resultConsensus) { + t.Fatal("resultExec", resultExec, "is different than resultConsensus", resultConsensus, "testScenario:", testScenario) + } + + return resultExec +} + func testLyingSequencer(t *testing.T, dasModeStr string) { t.Parallel() + + logHandler := testhelpers.InitTestLog(t, log.LvlTrace) + ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -224,7 +255,9 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { t.Fatal("Unexpected balance:", l2balance) } - // Send the real transaction to client A + fraudResult := comparesMsgResultFromConsensusAndExecution(t, testClientB, "fraud") + + // Send the real transaction to client A, will cause a reorg on nodeB err = l2clientA.SendTransaction(ctx, realTx) if err != nil { t.Fatal("error sending real transaction:", err) @@ -255,6 +288,16 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { if l2balanceRealAcct.Cmp(big.NewInt(1e12)) != 0 { t.Fatal("Unexpected balance of real account:", l2balanceRealAcct) } + + // Consensus should update message result stored in its database after a reorg + realResult := comparesMsgResultFromConsensusAndExecution(t, testClientB, "real") + // Checks that results changed + if reflect.DeepEqual(fraudResult, realResult) { + t.Fatal("realResult and fraudResult are equal") + } + if logHandler.WasLogged(arbnode.FailedToGetMsgResultFromDB) { + t.Fatal("Consensus relied on execution database to return the results") + } } func TestLyingSequencer(t *testing.T) { From f768d72950b474508ddf82c10f0f4e1a781703f6 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Tue, 2 Jul 2024 21:37:49 -0300 Subject: [PATCH 202/268] Fixes deleting messageResultPrefix entries --- arbnode/transaction_streamer.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 5309e0969d..6069827802 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -374,8 +374,7 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde } } - pos := uint64(count) - 1 - err = deleteStartingAt(s.db, batch, messageResultPrefix, uint64ToKey(pos)) + err = deleteStartingAt(s.db, batch, messageResultPrefix, uint64ToKey(uint64(count))) if err != nil { return err } From 07725907f696f6f510ab1656e4e18764a36596d3 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 8 Jul 2024 00:01:34 -0300 Subject: [PATCH 203/268] Prunes message results --- arbnode/message_pruner.go | 11 ++++++++++- arbnode/message_pruner_test.go | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arbnode/message_pruner.go b/arbnode/message_pruner.go index 5d18341a27..e1bc72632b 100644 --- a/arbnode/message_pruner.go +++ b/arbnode/message_pruner.go @@ -30,6 +30,7 @@ type MessagePruner struct { lastPruneDone time.Time cachedPrunedMessages uint64 cachedPrunedBlockHashesInputFeed uint64 + cachedPrunedMessageResult uint64 cachedPrunedDelayedMessages uint64 } @@ -116,7 +117,15 @@ func (m *MessagePruner) prune(ctx context.Context, count arbutil.MessageIndex, g } func (m *MessagePruner) deleteOldMessagesFromDB(ctx context.Context, messageCount arbutil.MessageIndex, delayedMessageCount uint64) error { - prunedKeysRange, err := deleteFromLastPrunedUptoEndKey(ctx, m.transactionStreamer.db, blockHashInputFeedPrefix, &m.cachedPrunedBlockHashesInputFeed, uint64(messageCount)) + prunedKeysRange, err := deleteFromLastPrunedUptoEndKey(ctx, m.transactionStreamer.db, messageResultPrefix, &m.cachedPrunedMessageResult, uint64(messageCount)) + if err != nil { + return fmt.Errorf("error deleting message results: %w", err) + } + if len(prunedKeysRange) > 0 { + log.Info("Pruned message results:", "first pruned key", prunedKeysRange[0], "last pruned key", prunedKeysRange[len(prunedKeysRange)-1]) + } + + prunedKeysRange, err = deleteFromLastPrunedUptoEndKey(ctx, m.transactionStreamer.db, blockHashInputFeedPrefix, &m.cachedPrunedBlockHashesInputFeed, uint64(messageCount)) if err != nil { return fmt.Errorf("error deleting expected block hashes: %w", err) } diff --git a/arbnode/message_pruner_test.go b/arbnode/message_pruner_test.go index ed85c0ebce..e64bb4f838 100644 --- a/arbnode/message_pruner_test.go +++ b/arbnode/message_pruner_test.go @@ -23,6 +23,7 @@ func TestMessagePrunerWithPruningEligibleMessagePresent(t *testing.T) { checkDbKeys(t, messagesCount, transactionStreamerDb, messagePrefix) checkDbKeys(t, messagesCount, transactionStreamerDb, blockHashInputFeedPrefix) + checkDbKeys(t, messagesCount, transactionStreamerDb, messageResultPrefix) checkDbKeys(t, messagesCount, inboxTrackerDb, rlpDelayedMessagePrefix) } @@ -72,8 +73,8 @@ func TestMessagePrunerWithNoPruningEligibleMessagePresent(t *testing.T) { checkDbKeys(t, uint64(messagesCount), transactionStreamerDb, messagePrefix) checkDbKeys(t, uint64(messagesCount), transactionStreamerDb, blockHashInputFeedPrefix) + checkDbKeys(t, uint64(messagesCount), transactionStreamerDb, messageResultPrefix) checkDbKeys(t, messagesCount, inboxTrackerDb, rlpDelayedMessagePrefix) - } func setupDatabase(t *testing.T, messageCount, delayedMessageCount uint64) (ethdb.Database, ethdb.Database, *MessagePruner) { @@ -83,6 +84,8 @@ func setupDatabase(t *testing.T, messageCount, delayedMessageCount uint64) (ethd Require(t, err) err = transactionStreamerDb.Put(dbKey(blockHashInputFeedPrefix, i), []byte{}) Require(t, err) + err = transactionStreamerDb.Put(dbKey(messageResultPrefix, i), []byte{}) + Require(t, err) } inboxTrackerDb := rawdb.NewMemoryDatabase() From f291dede828d7745ffb2d3456b43be28a23f6258 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 22 Jul 2024 10:03:58 -0300 Subject: [PATCH 204/268] Uses Info instead of Warn in ResultAtCount --- arbnode/transaction_streamer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 6069827802..8cc84a0eb8 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -1072,7 +1072,7 @@ func (s *TransactionStreamer) ResultAtCount(count arbutil.MessageIndex) (*execut return nil, err } - log.Warn(FailedToGetMsgResultFromDB, "count", count, "err", err) + log.Info(FailedToGetMsgResultFromDB, "count", count, "err", err) return s.exec.ResultAtPos(pos) } From 3ad61f04456bd09415a3e92e92864d846392af83 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 22 Jul 2024 10:25:36 -0300 Subject: [PATCH 205/268] Tries to store message result at ResultAtCount in a best-effort manner --- arbnode/transaction_streamer.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 8cc84a0eb8..7371e28126 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -1071,9 +1071,26 @@ func (s *TransactionStreamer) ResultAtCount(count arbutil.MessageIndex) (*execut } else if !dbutil.IsErrNotFound(err) { return nil, err } - log.Info(FailedToGetMsgResultFromDB, "count", count, "err", err) - return s.exec.ResultAtPos(pos) + + msgResult, err := s.exec.ResultAtPos(pos) + if err != nil { + return nil, err + } + // Stores result in Consensus DB in a best-effort manner + batch := s.db.NewBatch() + err = s.storeResult(pos, *msgResult, batch) + if err != nil { + log.Warn("Failed to store result at ResultAtCount", "err", err) + return msgResult, nil + } + err = batch.Write() + if err != nil { + log.Warn("Failed to store result at ResultAtCount", "err", err) + return msgResult, nil + } + + return msgResult, nil } func (s *TransactionStreamer) checkResult(msgResult *execution.MessageResult, expectedBlockHash *common.Hash) { From 8ce3746246679a020b86e1861728a849d658a9ce Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Tue, 23 Jul 2024 09:52:19 -0300 Subject: [PATCH 206/268] Update FailedToGetMsgResultFromDB msg. --- arbnode/transaction_streamer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 7371e28126..116092383a 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -130,7 +130,7 @@ type blockHashDBValue struct { const ( BlockHashMismatchLogMsg = "BlockHash from feed doesn't match locally computed hash. Check feed source." - FailedToGetMsgResultFromDB = "Streamer: failed getting message result from db" + FailedToGetMsgResultFromDB = "Reading message result remotely." ) // Encodes a uint64 as bytes in a lexically sortable manner for database iteration. @@ -1071,7 +1071,7 @@ func (s *TransactionStreamer) ResultAtCount(count arbutil.MessageIndex) (*execut } else if !dbutil.IsErrNotFound(err) { return nil, err } - log.Info(FailedToGetMsgResultFromDB, "count", count, "err", err) + log.Info(FailedToGetMsgResultFromDB, "count", count) msgResult, err := s.exec.ResultAtPos(pos) if err != nil { From 9ea15b9025234b5a1c8a8dc285f94a57eb49cfc4 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Tue, 23 Jul 2024 14:44:43 -0600 Subject: [PATCH 207/268] block_validator: fix metrics --- staker/block_validator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index a354bafc50..13ece78405 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -36,8 +36,8 @@ var ( validatorFailedValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/failed", nil) validatorValidationWaitToRecordHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRecord", nil, metrics.NewBoundedHistogramSample()) validatorValidationRecordingHist = metrics.NewRegisteredHistogram("arb/validator/validations/recording", nil, metrics.NewBoundedHistogramSample()) - validatorValidationWaitToLaunchHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRun", nil, metrics.NewBoundedHistogramSample()) - validatorValidationLaunchHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRun", nil, metrics.NewBoundedHistogramSample()) + validatorValidationWaitToLaunchHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToLaunch", nil, metrics.NewBoundedHistogramSample()) + validatorValidationLaunchingHist = metrics.NewRegisteredHistogram("arb/validator/validations/launching", nil, metrics.NewBoundedHistogramSample()) validatorValidationRunningHist = metrics.NewRegisteredHistogram("arb/validator/validations/running", nil, metrics.NewBoundedHistogramSample()) validatorMsgCountCurrentBatch = metrics.NewRegisteredGauge("arb/validator/msg_count_current_batch", nil) validatorMsgCountCreatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_created", nil) @@ -839,7 +839,7 @@ validationsLoop: log.Trace("advanceValidations: launched", "pos", validationStatus.Entry.Pos, "moduleRoot", moduleRoot) runs = append(runs, run) } - validatorValidationLaunchHist.Update(validationStatus.timeStampInterval()) + validatorValidationLaunchingHist.Update(validationStatus.timeStampInterval()) validationCtx, cancel := context.WithCancel(ctx) validationStatus.Runs = runs validationStatus.Cancel = cancel From f96aafd80720e0cfbaee455244b2101e96031976 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Tue, 23 Jul 2024 19:01:35 -0600 Subject: [PATCH 208/268] json to input: retry if decompress too large --- arbcompress/native.go | 10 +++++++++- validator/server_api/json.go | 19 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arbcompress/native.go b/arbcompress/native.go index 4624d6222e..8244010979 100644 --- a/arbcompress/native.go +++ b/arbcompress/native.go @@ -12,7 +12,10 @@ package arbcompress #include "arbitrator.h" */ import "C" -import "fmt" +import ( + "errors" + "fmt" +) type u8 = C.uint8_t type u32 = C.uint32_t @@ -44,6 +47,8 @@ func Compress(input []byte, level uint32, dictionary Dictionary) ([]byte, error) return output, nil } +var ErrOutputWontFit = errors.New("output won't fit in maxsize") + func Decompress(input []byte, maxSize int) ([]byte, error) { return DecompressWithDictionary(input, maxSize, EmptyDictionary) } @@ -54,6 +59,9 @@ func DecompressWithDictionary(input []byte, maxSize int, dictionary Dictionary) inbuf := sliceToBuffer(input) status := C.brotli_decompress(inbuf, outbuf, C.Dictionary(dictionary)) + if status == C.BrotliStatus_NeedsMoreOutput { + return nil, ErrOutputWontFit + } if status != C.BrotliStatus_Success { return nil, fmt.Errorf("failed decompression: %d", status) } diff --git a/validator/server_api/json.go b/validator/server_api/json.go index 173429d9b1..d93bc2f4e7 100644 --- a/validator/server_api/json.go +++ b/validator/server_api/json.go @@ -6,6 +6,7 @@ package server_api import ( "encoding/base64" "encoding/json" + "errors" "fmt" "os" @@ -152,9 +153,21 @@ func ValidationInputFromJson(entry *InputJSON) (*validator.ValidationInput, erro if err != nil { return nil, err } - uncompressed, err := arbcompress.Decompress(decoded, 30000000) - if err != nil { - return nil, err + maxSize := 2_000_000 + var uncompressed []byte + for { + uncompressed, err = arbcompress.Decompress(decoded, maxSize) + if errors.Is(err, arbcompress.ErrOutputWontFit) { + if maxSize >= 128_000_000 { + return nil, errors.New("failed decompression: too large") + } + maxSize = maxSize * 4 + continue + } + if err != nil { + return nil, err + } + break } archWasms[moduleHash] = uncompressed } From 789b96942c9105708e49d63dc4bdbf14f555abaa Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Tue, 23 Jul 2024 21:23:04 -0600 Subject: [PATCH 209/268] validator/toInput: increase limit --- validator/server_api/json.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/server_api/json.go b/validator/server_api/json.go index d93bc2f4e7..90746e4c57 100644 --- a/validator/server_api/json.go +++ b/validator/server_api/json.go @@ -158,7 +158,7 @@ func ValidationInputFromJson(entry *InputJSON) (*validator.ValidationInput, erro for { uncompressed, err = arbcompress.Decompress(decoded, maxSize) if errors.Is(err, arbcompress.ErrOutputWontFit) { - if maxSize >= 128_000_000 { + if maxSize >= 512_000_000 { return nil, errors.New("failed decompression: too large") } maxSize = maxSize * 4 From 432b0537b5e2832a8ba13f49dc988cb7d0e616a6 Mon Sep 17 00:00:00 2001 From: chuwt Date: Wed, 24 Jul 2024 15:12:06 +0800 Subject: [PATCH 210/268] fix: stop timer --- wsbroadcastserver/clientconnection.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wsbroadcastserver/clientconnection.go b/wsbroadcastserver/clientconnection.go index 7fb88bf9eb..16a8f64daf 100644 --- a/wsbroadcastserver/clientconnection.go +++ b/wsbroadcastserver/clientconnection.go @@ -193,6 +193,7 @@ func (cc *ClientConnection) Start(parentCtx context.Context) { t := time.NewTimer(cc.delay) select { case <-ctx.Done(): + t.Stop() return case <-t.C: } @@ -222,8 +223,10 @@ func (cc *ClientConnection) Start(parentCtx context.Context) { timer := time.NewTimer(5 * time.Second) select { case <-ctx.Done(): + timer.Stop() return case <-cc.registered: + timer.Stop() log.Debug("ClientConnection registered with ClientManager", "client", cc.Name) case <-timer.C: log.Error("timed out waiting for ClientConnection to register with ClientManager", "client", cc.Name) From 2c3dca4d9248a2444a9791193aabba7c2688ce51 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 24 Jul 2024 15:51:43 +0200 Subject: [PATCH 211/268] Add test for retryable redeem block gas usage --- system_tests/common_test.go | 52 +++++++++++++++ system_tests/retryable_test.go | 115 +++++++++++++++++++++++++++++++-- 2 files changed, 161 insertions(+), 6 deletions(-) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index ff184340ab..774ef037eb 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -6,6 +6,7 @@ package arbtest import ( "bytes" "context" + "encoding/binary" "encoding/hex" "encoding/json" "io" @@ -550,6 +551,57 @@ func BridgeBalance( return tx, res } +func SendSignedTxesInBatchViaL1( + t *testing.T, + ctx context.Context, + l1info *BlockchainTestInfo, + l1client arbutil.L1Interface, + l2client arbutil.L1Interface, + delayedTxes types.Transactions, +) types.Receipts { + delayedInboxContract, err := bridgegen.NewInbox(l1info.GetAddress("Inbox"), l1client) + Require(t, err) + usertxopts := l1info.GetDefaultTransactOpts("User", ctx) + + wraped, err := l2MessageBatchDataFromTxes(delayedTxes) + Require(t, err) + l1tx, err := delayedInboxContract.SendL2Message(&usertxopts, wraped) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, l1client, l1tx) + Require(t, err) + + // sending l1 messages creates l1 blocks.. make enough to get that delayed inbox message in + for i := 0; i < 30; i++ { + SendWaitTestTransactions(t, ctx, l1client, []*types.Transaction{ + l1info.PrepareTx("Faucet", "Faucet", 30000, big.NewInt(1e12), nil), + }) + } + var receipts types.Receipts + for _, tx := range delayedTxes { + receipt, err := EnsureTxSucceeded(ctx, l2client, tx) + Require(t, err) + receipts = append(receipts, receipt) + } + return receipts +} + +func l2MessageBatchDataFromTxes(txes types.Transactions) ([]byte, error) { + var l2Message []byte + l2Message = append(l2Message, arbos.L2MessageKind_Batch) + sizeBuf := make([]byte, 8) + for _, tx := range txes { + txBytes, err := tx.MarshalBinary() + if err != nil { + return nil, err + } + binary.BigEndian.PutUint64(sizeBuf, uint64(len(txBytes)+1)) + l2Message = append(l2Message, sizeBuf...) + l2Message = append(l2Message, arbos.L2MessageKind_SignedTx) + l2Message = append(l2Message, txBytes...) + } + return l2Message, nil +} + func SendSignedTxViaL1( t *testing.T, ctx context.Context, diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index 268d59ac98..4e63888b83 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -931,11 +931,114 @@ func TestRetryableSubmissionAndRedeemFees(t *testing.T) { } } +func TestRetryableRedeemBlockGasUsage(t *testing.T) { + builder, delayedInbox, lookupL2Tx, ctx, teardown := retryableSetup(t) + defer teardown() + l2client := builder.L2.Client + l2info := builder.L2Info + l1client := builder.L1.Client + l1info := builder.L1Info + + _, err := precompilesgen.NewArbosTest(common.HexToAddress("0x69"), l2client) + Require(t, err, "failed to deploy ArbosTest") + _, err = precompilesgen.NewArbRetryableTx(common.HexToAddress("6e"), l2client) + Require(t, err) + + ownerTxOpts := l2info.GetDefaultTransactOpts("Owner", ctx) + simpleAddr, _ := deploySimple(t, ctx, ownerTxOpts, l2client) + simpleABI, err := mocksgen.SimpleMetaData.GetAbi() + Require(t, err) + + beneficiaryAddress := l2info.GetAddress("Beneficiary") + deposit := arbmath.BigMul(big.NewInt(1e12), big.NewInt(1e12)) + callValue := common.Big0 + usertxoptsL1 := l1info.GetDefaultTransactOpts("Faucet", ctx) + usertxoptsL1.Value = deposit + l1tx, err := delayedInbox.CreateRetryableTicket( + &usertxoptsL1, + simpleAddr, + callValue, + big.NewInt(1e16), + beneficiaryAddress, + beneficiaryAddress, + // send enough L2 gas for intrinsic but not compute + big.NewInt(int64(params.TxGas+params.TxDataNonZeroGasEIP2028*4)), + big.NewInt(int64(l2pricing.InitialBaseFeeWei)*2), + simpleABI.Methods["incrementRedeem"].ID, + ) + Require(t, err) + l1Receipt, err := EnsureTxSucceeded(ctx, l1client, l1tx) + Require(t, err) + if l1Receipt.Status != types.ReceiptStatusSuccessful { + Fatal(t, "l1Receipt indicated failure") + } + waitForL1DelayBlocks(t, ctx, builder) + submissionReceipt, err := EnsureTxSucceeded(ctx, l2client, lookupL2Tx(l1Receipt)) + Require(t, err) + if len(submissionReceipt.Logs) != 2 { + Fatal(t, len(submissionReceipt.Logs)) + } + ticketId := submissionReceipt.Logs[0].Topics[1] + firstRetryTxId := submissionReceipt.Logs[1].Topics[2] + // get receipt for the auto redeem, make sure it failed + autoRedeemReceipt, err := WaitForTx(ctx, l2client, firstRetryTxId, time.Second*5) + Require(t, err) + if autoRedeemReceipt.Status != types.ReceiptStatusFailed { + Fatal(t, "first retry tx shouldn't have succeeded") + } + + redeemTx := func() *types.Transaction { + arbRetryableTxAbi, err := precompilesgen.ArbRetryableTxMetaData.GetAbi() + Require(t, err) + redeem := arbRetryableTxAbi.Methods["redeem"] + input, err := redeem.Inputs.Pack(ticketId) + Require(t, err) + data := append([]byte{}, redeem.ID...) + data = append(data, input...) + to := common.HexToAddress("6e") + gas := uint64(l2pricing.InitialPerBlockGasLimitV6) + return l2info.PrepareTxTo("Faucet", &to, gas, big.NewInt(0), data) + }() + burnTx := func() *types.Transaction { + burnAmount := uint64(20 * 1e6) + arbosTestAbi, err := precompilesgen.ArbosTestMetaData.GetAbi() + Require(t, err) + burnArbGas := arbosTestAbi.Methods["burnArbGas"] + input, err := burnArbGas.Inputs.Pack(arbmath.UintToBig(burnAmount - l2info.TransferGas)) + Require(t, err) + data := append([]byte{}, burnArbGas.ID...) + data = append(data, input...) + to := common.HexToAddress("0x69") + return l2info.PrepareTxTo("Faucet", &to, burnAmount, big.NewInt(0), data) + }() + receipts := SendSignedTxesInBatchViaL1(t, ctx, l1info, l1client, l2client, types.Transactions{redeemTx, burnTx}) + redeemReceipt, burnReceipt := receipts[0], receipts[1] + if len(redeemReceipt.Logs) != 1 { + Fatal(t, "Unexpected log count:", len(redeemReceipt.Logs)) + } + retryTxId := redeemReceipt.Logs[0].Topics[2] + + // check the receipt for the retry + retryReceipt, err := WaitForTx(ctx, l2client, retryTxId, time.Second*1) + Require(t, err) + if retryReceipt.Status != types.ReceiptStatusSuccessful { + Fatal(t, "retry failed") + } + t.Log("submission - block:", submissionReceipt.BlockNumber, "txInd:", submissionReceipt.TransactionIndex) + t.Log("auto redeem - block:", autoRedeemReceipt.BlockNumber, "txInd:", autoRedeemReceipt.TransactionIndex) + t.Log("redeem - block:", redeemReceipt.BlockNumber, "txInd:", redeemReceipt.TransactionIndex) + t.Log("retry - block:", retryReceipt.BlockNumber, "txInd:", retryReceipt.TransactionIndex) + t.Log("burn - block:", burnReceipt.BlockNumber, "txInd:", burnReceipt.TransactionIndex) + if !arbmath.BigEquals(burnReceipt.BlockNumber, redeemReceipt.BlockNumber) { + Fatal(t, "Failed to fit a tx to the same block as redeem and retry") + } +} + // elevateL2Basefee by burning gas exceeding speed limit func elevateL2Basefee(t *testing.T, ctx context.Context, builder *NodeBuilder) { baseFeeBefore := builder.L2.GetBaseFee(t) colors.PrintBlue("Elevating base fee...") - arbostestabi, err := precompilesgen.ArbosTestMetaData.GetAbi() + arbosTestAbi, err := precompilesgen.ArbosTestMetaData.GetAbi() Require(t, err) _, err = precompilesgen.NewArbosTest(common.HexToAddress("0x69"), builder.L2.Client) Require(t, err, "failed to deploy ArbosTest") @@ -943,13 +1046,13 @@ func elevateL2Basefee(t *testing.T, ctx context.Context, builder *NodeBuilder) { burnAmount := gethexec.ConfigDefaultTest().RPC.RPCGasCap burnTarget := uint64(5 * l2pricing.InitialSpeedLimitPerSecondV6 * l2pricing.InitialBacklogTolerance) for i := uint64(0); i < (burnTarget+burnAmount)/burnAmount; i++ { - burnArbGas := arbostestabi.Methods["burnArbGas"] - data, err := burnArbGas.Inputs.Pack(arbmath.UintToBig(burnAmount - builder.L2Info.TransferGas)) + burnArbGas := arbosTestAbi.Methods["burnArbGas"] + input, err := burnArbGas.Inputs.Pack(arbmath.UintToBig(burnAmount - builder.L2Info.TransferGas)) Require(t, err) - input := append([]byte{}, burnArbGas.ID...) - input = append(input, data...) + data := append([]byte{}, burnArbGas.ID...) + data = append(data, input...) to := common.HexToAddress("0x69") - tx := builder.L2Info.PrepareTxTo("Faucet", &to, burnAmount, big.NewInt(0), input) + tx := builder.L2Info.PrepareTxTo("Faucet", &to, burnAmount, big.NewInt(0), data) Require(t, builder.L2.Client.SendTransaction(ctx, tx)) _, err = builder.L2.EnsureTxSucceeded(tx) Require(t, err) From 810f3c95d32e8024d424a7053dd906b0bf2b8d6d Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 24 Jul 2024 11:55:30 -0300 Subject: [PATCH 212/268] Tests if Consensus.ResultAtCount and Execution.ResultAtSync are in sync for reorg tests. --- system_tests/meaningless_reorg_test.go | 4 ++ system_tests/reorg_resequencing_test.go | 11 ++++++ system_tests/seqfeed_test.go | 51 +++++++++++++++---------- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/system_tests/meaningless_reorg_test.go b/system_tests/meaningless_reorg_test.go index 27ed8572c8..06a5d3d2b3 100644 --- a/system_tests/meaningless_reorg_test.go +++ b/system_tests/meaningless_reorg_test.go @@ -62,6 +62,8 @@ func TestMeaninglessBatchReorg(t *testing.T) { builder.L1.TransferBalance(t, "Faucet", "Faucet", common.Big1, builder.L1Info) } + compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "before reorg") + parentBlock := builder.L1.L1Backend.BlockChain().GetBlockByNumber(batchReceipt.BlockNumber.Uint64() - 1) err = builder.L1.L1Backend.BlockChain().ReorgToOldBlock(parentBlock) Require(t, err) @@ -104,4 +106,6 @@ func TestMeaninglessBatchReorg(t *testing.T) { if l2Header.Hash() != l2Receipt.BlockHash { Fatal(t, "L2 block hash changed") } + + compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after reorg") } diff --git a/system_tests/reorg_resequencing_test.go b/system_tests/reorg_resequencing_test.go index b188504acb..027416d8eb 100644 --- a/system_tests/reorg_resequencing_test.go +++ b/system_tests/reorg_resequencing_test.go @@ -7,6 +7,7 @@ import ( "context" "math/big" "testing" + "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" @@ -56,7 +57,12 @@ func TestReorgResequencing(t *testing.T) { _, err = builder.L2.ExecNode.ExecEngine.HeadMessageNumberSync(t) Require(t, err) + // Reorg of old messages is done in the background. + // As a strategy to avoid test flakiness, this sleep tries to ensure that the reorg is done before we continue. + time.Sleep(2 * time.Second) + verifyBalances("after empty reorg") + compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after empty reorg") prevMessage, err := builder.L2.ConsensusNode.TxStreamer.GetMessage(startMsgCount - 1) Require(t, err) @@ -82,7 +88,10 @@ func TestReorgResequencing(t *testing.T) { Require(t, err) accountsWithBalance = append(accountsWithBalance, "User4") + + time.Sleep(2 * time.Second) verifyBalances("after reorg with new deposit") + compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after reorg with new deposit") err = builder.L2.ConsensusNode.TxStreamer.ReorgTo(startMsgCount) Require(t, err) @@ -90,5 +99,7 @@ func TestReorgResequencing(t *testing.T) { _, err = builder.L2.ExecNode.ExecEngine.HeadMessageNumberSync(t) Require(t, err) + time.Sleep(2 * time.Second) verifyBalances("after second empty reorg") + compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after second empty reorg") } diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index ab006391fc..2981113a19 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -147,36 +147,48 @@ func TestRelayedSequencerFeed(t *testing.T) { } } -func comparesMsgResultFromConsensusAndExecution( +func compareAllMsgResultsFromConsensusAndExecution( t *testing.T, testClient *TestClient, testScenario string, ) *execution.MessageResult { - pos := 1 - count := pos + 1 - - headMsgNum, err := testClient.ExecNode.HeadMessageNumber() + execHeadMsgNum, err := testClient.ExecNode.HeadMessageNumber() + Require(t, err) + consensusMsgCount, err := testClient.ConsensusNode.TxStreamer.GetMessageCount() Require(t, err) - if headMsgNum != arbutil.MessageIndex(pos) { - t.Fatal("Unexpected head message number:", headMsgNum, "pos: ", pos, "testScenario:", testScenario) + if consensusMsgCount != execHeadMsgNum+1 { + t.Fatal( + "consensusMsgCount", consensusMsgCount, "is different than (execHeadMsgNum + 1)", execHeadMsgNum, + "testScenario:", testScenario, + ) } - resultExec, err := testClient.ExecNode.ResultAtPos(arbutil.MessageIndex(pos)) - Require(t, err) - resultConsensus, err := testClient.ConsensusNode.TxStreamer.ResultAtCount(arbutil.MessageIndex(count)) - Require(t, err) - if !reflect.DeepEqual(resultExec, resultConsensus) { - t.Fatal("resultExec", resultExec, "is different than resultConsensus", resultConsensus, "testScenario:", testScenario) + var lastResult *execution.MessageResult + for msgCount := 1; arbutil.MessageIndex(msgCount) <= consensusMsgCount; msgCount++ { + pos := msgCount - 1 + resultExec, err := testClient.ExecNode.ResultAtPos(arbutil.MessageIndex(pos)) + Require(t, err) + + resultConsensus, err := testClient.ConsensusNode.TxStreamer.ResultAtCount(arbutil.MessageIndex(msgCount)) + Require(t, err) + + if !reflect.DeepEqual(resultExec, resultConsensus) { + t.Fatal( + "resultExec", resultExec, "is different than resultConsensus", resultConsensus, + "pos:", pos, + "testScenario:", testScenario, + ) + } + + lastResult = resultExec } - return resultExec + return lastResult } func testLyingSequencer(t *testing.T, dasModeStr string) { t.Parallel() - logHandler := testhelpers.InitTestLog(t, log.LvlTrace) - ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -255,7 +267,7 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { t.Fatal("Unexpected balance:", l2balance) } - fraudResult := comparesMsgResultFromConsensusAndExecution(t, testClientB, "fraud") + fraudResult := compareAllMsgResultsFromConsensusAndExecution(t, testClientB, "fraud") // Send the real transaction to client A, will cause a reorg on nodeB err = l2clientA.SendTransaction(ctx, realTx) @@ -290,14 +302,11 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { } // Consensus should update message result stored in its database after a reorg - realResult := comparesMsgResultFromConsensusAndExecution(t, testClientB, "real") + realResult := compareAllMsgResultsFromConsensusAndExecution(t, testClientB, "real") // Checks that results changed if reflect.DeepEqual(fraudResult, realResult) { t.Fatal("realResult and fraudResult are equal") } - if logHandler.WasLogged(arbnode.FailedToGetMsgResultFromDB) { - t.Fatal("Consensus relied on execution database to return the results") - } } func TestLyingSequencer(t *testing.T) { From 85cb8718ea79e9d306a3e8e309612d870164e233 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 24 Jul 2024 12:02:00 -0300 Subject: [PATCH 213/268] Tests if Consensus.ResultAtCount is not relying on Execution.ResultAtPos --- system_tests/seqfeed_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index 2981113a19..347a167660 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -307,6 +307,23 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { if reflect.DeepEqual(fraudResult, realResult) { t.Fatal("realResult and fraudResult are equal") } + // Since NodeB is not a sequencer, it will produce blocks through Consensus. + // So it is expected that Consensus.ResultAtCount will not rely on Execution to retrieve results. + // However, since count 1 is related to genesis, and Execution is initialized through InitializeArbosInDatabase and not through Consensus, + // first call to Consensus.ResultAtCount with count equals to 1 will fall back to Execution. + // Not necessarily the first call to Consensus.ResultAtCount with count equals to 1 will happen through compareMsgResultFromConsensusAndExecution, + // so we don't test this here. + consensusMsgCount, err := testClientB.ConsensusNode.TxStreamer.GetMessageCount() + Require(t, err) + if consensusMsgCount != 2 { + t.Fatal("consensusMsgCount is different than 2") + } + logHandler := testhelpers.InitTestLog(t, log.LvlTrace) + _, err = testClientB.ConsensusNode.TxStreamer.ResultAtCount(arbutil.MessageIndex(2)) + Require(t, err) + if logHandler.WasLogged(arbnode.FailedToGetMsgResultFromDB) { + t.Fatal("Consensus relied on execution database to return the result") + } } func TestLyingSequencer(t *testing.T) { From ff5e413575f72b641ed369a4aed0f05b336ca60a Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 24 Jul 2024 12:31:37 -0300 Subject: [PATCH 214/268] Increases sleep time in reorg resequencing test --- system_tests/reorg_resequencing_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system_tests/reorg_resequencing_test.go b/system_tests/reorg_resequencing_test.go index 027416d8eb..4ad46e07ef 100644 --- a/system_tests/reorg_resequencing_test.go +++ b/system_tests/reorg_resequencing_test.go @@ -59,7 +59,7 @@ func TestReorgResequencing(t *testing.T) { // Reorg of old messages is done in the background. // As a strategy to avoid test flakiness, this sleep tries to ensure that the reorg is done before we continue. - time.Sleep(2 * time.Second) + time.Sleep(5 * time.Second) verifyBalances("after empty reorg") compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after empty reorg") @@ -89,7 +89,7 @@ func TestReorgResequencing(t *testing.T) { accountsWithBalance = append(accountsWithBalance, "User4") - time.Sleep(2 * time.Second) + time.Sleep(5 * time.Second) verifyBalances("after reorg with new deposit") compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after reorg with new deposit") @@ -99,7 +99,7 @@ func TestReorgResequencing(t *testing.T) { _, err = builder.L2.ExecNode.ExecEngine.HeadMessageNumberSync(t) Require(t, err) - time.Sleep(2 * time.Second) + time.Sleep(5 * time.Second) verifyBalances("after second empty reorg") compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after second empty reorg") } From 973f244f4d0e53beca97ecb8703b8524721da7ba Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 24 Jul 2024 13:34:56 -0300 Subject: [PATCH 215/268] Removes time.Sleep from TestReorgResequencing. Adds a comment describing why this test is flaky. --- system_tests/reorg_resequencing_test.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/system_tests/reorg_resequencing_test.go b/system_tests/reorg_resequencing_test.go index 4ad46e07ef..3c131b9a41 100644 --- a/system_tests/reorg_resequencing_test.go +++ b/system_tests/reorg_resequencing_test.go @@ -7,7 +7,6 @@ import ( "context" "math/big" "testing" - "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/params" @@ -16,6 +15,14 @@ import ( "github.com/offchainlabs/nitro/util/arbmath" ) +// This is a flaky test. +// During a reorg: +// - TransactionStreamer, holding insertionMutex lock, calls ExecutionEngine, +// which then adds old messages to a channel, so they can be resequenced asynchronously by ExecutionEngine. +// After that, and before releasing the lock, TransactionStreamer does more computations. +// - Asynchronously, ExecutionEngine reads from this channel and calls TransactionStreamer, +// which expects that insertionMutex is free in order to succeed. Which cause then this error: +// 'failed to re-sequence old user message removed by reorg err="insert lock taken"' func TestReorgResequencing(t *testing.T) { t.Parallel() ctx, cancel := context.WithCancel(context.Background()) @@ -57,10 +64,6 @@ func TestReorgResequencing(t *testing.T) { _, err = builder.L2.ExecNode.ExecEngine.HeadMessageNumberSync(t) Require(t, err) - // Reorg of old messages is done in the background. - // As a strategy to avoid test flakiness, this sleep tries to ensure that the reorg is done before we continue. - time.Sleep(5 * time.Second) - verifyBalances("after empty reorg") compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after empty reorg") @@ -89,7 +92,6 @@ func TestReorgResequencing(t *testing.T) { accountsWithBalance = append(accountsWithBalance, "User4") - time.Sleep(5 * time.Second) verifyBalances("after reorg with new deposit") compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after reorg with new deposit") @@ -99,7 +101,6 @@ func TestReorgResequencing(t *testing.T) { _, err = builder.L2.ExecNode.ExecEngine.HeadMessageNumberSync(t) Require(t, err) - time.Sleep(5 * time.Second) verifyBalances("after second empty reorg") compareAllMsgResultsFromConsensusAndExecution(t, builder.L2, "after second empty reorg") } From cac99f9c5536ccc6b7a5e49b1d490d5fb9ac79e3 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 24 Jul 2024 13:37:02 -0300 Subject: [PATCH 216/268] Improves comments on TestReorgResequencing --- system_tests/reorg_resequencing_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_tests/reorg_resequencing_test.go b/system_tests/reorg_resequencing_test.go index 3c131b9a41..81e226ea18 100644 --- a/system_tests/reorg_resequencing_test.go +++ b/system_tests/reorg_resequencing_test.go @@ -21,7 +21,7 @@ import ( // which then adds old messages to a channel, so they can be resequenced asynchronously by ExecutionEngine. // After that, and before releasing the lock, TransactionStreamer does more computations. // - Asynchronously, ExecutionEngine reads from this channel and calls TransactionStreamer, -// which expects that insertionMutex is free in order to succeed. Which cause then this error: +// which expects that insertionMutex is free in order to succeed. When that happens this error generated: // 'failed to re-sequence old user message removed by reorg err="insert lock taken"' func TestReorgResequencing(t *testing.T) { t.Parallel() From 678a37057570833f63b1f37dbd0ee80ea1bc39d6 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 24 Jul 2024 11:16:20 -0600 Subject: [PATCH 217/268] Try to fast confirm past nodes too --- contracts | 2 +- staker/fast_confirm.go | 26 +++++++++++++----- staker/staker.go | 60 ++++++++++++++++++++++++++++++++++-------- 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/contracts b/contracts index 61204dd455..6d59d872e4 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 61204dd455966cb678192427a07aa9795ff91c14 +Subproject commit 6d59d872e45eac3e43e7cb65fccc245800b8e7d5 diff --git a/staker/fast_confirm.go b/staker/fast_confirm.go index 59a7443826..7ae620838b 100644 --- a/staker/fast_confirm.go +++ b/staker/fast_confirm.go @@ -78,8 +78,11 @@ func NewFastConfirmSafe( return fastConfirmSafe, nil } -func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { - fastConfirmCallData, err := f.createFastConfirmCalldata(blockHash, sendRoot) +func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash, nodeHash common.Hash) error { + if f.wallet.Address() == nil { + return errors.New("fast confirmation requires a wallet which is not setup") + } + fastConfirmCallData, err := f.createFastConfirmCalldata(blockHash, sendRoot, nodeHash) if err != nil { return err } @@ -112,6 +115,16 @@ func (f *FastConfirmSafe) tryFastConfirmation(ctx context.Context, blockHash com return err } } + + alreadyApproved, err := f.safe.ApprovedHashes(&bind.CallOpts{Context: ctx}, *f.wallet.Address(), safeTxHash) + if err != nil { + return err + } + if alreadyApproved.Cmp(common.Big1) == 0 { + _, err = f.checkApprovedHashAndExecTransaction(ctx, fastConfirmCallData, safeTxHash) + return err + } + auth, err := f.builder.Auth(ctx) if err != nil { return err @@ -162,11 +175,12 @@ func (f *FastConfirmSafe) flushTransactions(ctx context.Context) error { } func (f *FastConfirmSafe) createFastConfirmCalldata( - blockHash common.Hash, sendRoot common.Hash, + blockHash common.Hash, sendRoot common.Hash, nodeHash common.Hash, ) ([]byte, error) { calldata, err := f.fastConfirmNextNodeMethod.Inputs.Pack( blockHash, sendRoot, + nodeHash, ) if err != nil { return nil, err @@ -177,12 +191,12 @@ func (f *FastConfirmSafe) createFastConfirmCalldata( } func (f *FastConfirmSafe) checkApprovedHashAndExecTransaction(ctx context.Context, fastConfirmCallData []byte, safeTxHash [32]byte) (bool, error) { + if f.wallet.Address() == nil { + return false, errors.New("wallet address is nil") + } var signatures []byte approvedHashCount := uint64(0) for _, owner := range f.owners { - if f.wallet.Address() == nil { - return false, errors.New("wallet address is nil") - } var approved *big.Int // No need check if wallet has approved the hash, // since checkApprovedHashAndExecTransaction is called only after wallet has approved the hash. diff --git a/staker/staker.go b/staker/staker.go index e3dd11dc07..1b1317948a 100644 --- a/staker/staker.go +++ b/staker/staker.go @@ -371,7 +371,7 @@ func (s *Staker) Initialize(ctx context.Context) error { return nil } -func (s *Staker) tryFastConfirmationNodeNumber(ctx context.Context, number uint64) error { +func (s *Staker) tryFastConfirmationNodeNumber(ctx context.Context, number uint64, hash common.Hash) error { if !s.config.EnableFastConfirmation { return nil } @@ -379,21 +379,21 @@ func (s *Staker) tryFastConfirmationNodeNumber(ctx context.Context, number uint6 if err != nil { return err } - return s.tryFastConfirmation(ctx, nodeInfo.AfterState().GlobalState.BlockHash, nodeInfo.AfterState().GlobalState.SendRoot) + return s.tryFastConfirmation(ctx, nodeInfo.AfterState().GlobalState.BlockHash, nodeInfo.AfterState().GlobalState.SendRoot, hash) } -func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash) error { +func (s *Staker) tryFastConfirmation(ctx context.Context, blockHash common.Hash, sendRoot common.Hash, nodeHash common.Hash) error { if !s.config.EnableFastConfirmation { return nil } if s.fastConfirmSafe != nil { - return s.fastConfirmSafe.tryFastConfirmation(ctx, blockHash, sendRoot) + return s.fastConfirmSafe.tryFastConfirmation(ctx, blockHash, sendRoot, nodeHash) } auth, err := s.builder.Auth(ctx) if err != nil { return err } - _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot) + _, err = s.rollup.FastConfirmNextNode(auth, blockHash, sendRoot, nodeHash) return err } @@ -683,6 +683,43 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { StakeExists: rawInfo != nil, } + if s.config.EnableFastConfirmation { + firstUnresolvedNode, err := s.rollup.FirstUnresolvedNode(callOpts) + if err != nil { + return nil, err + } + if latestStakedNodeNum >= firstUnresolvedNode { + lastHeader, err := s.l1Reader.LastHeader(ctx) + if err != nil { + return nil, err + } + // To check if a node is correct, we simply check if we're staked on it. + // Since we're staked on it or a later node, this will tell us if it's correct. + // To keep this call consistent with the GetNode call, we pin a specific parent chain block hash. + checkNodeCorrectCallOpts := s.getCallOpts(ctx) + checkNodeCorrectCallOpts.BlockHash = lastHeader.ParentHash + stakedOnNode, err := s.rollup.NodeHasStaker(checkNodeCorrectCallOpts, firstUnresolvedNode, walletAddressOrZero) + if err != nil { + return nil, err + } + if stakedOnNode { + nodeInfo, err := s.rollup.GetNode(checkNodeCorrectCallOpts, firstUnresolvedNode) + if err != nil { + return nil, err + } + err = s.tryFastConfirmationNodeNumber(ctx, firstUnresolvedNode, nodeInfo.NodeHash) + if err != nil { + return nil, err + } + if s.builder.BuildingTransactionCount() > 0 { + // Try to fast confirm previous nodes before working on new ones + log.Info("fast confirming previous node", "node", firstUnresolvedNode) + return s.wallet.ExecuteTransactions(ctx, s.builder, s.config.gasRefunder) + } + } + } + } + effectiveStrategy := s.config.strategy nodesLinear, err := s.validatorUtils.AreUnresolvedNodesLinear(callOpts, s.rollupAddress) if err != nil { @@ -900,7 +937,8 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv s.bringActiveUntilNode = info.LatestStakedNode + 1 } info.CanProgress = false - return s.tryFastConfirmation(ctx, action.assertion.AfterState.GlobalState.BlockHash, action.assertion.AfterState.GlobalState.SendRoot) + // We can't fast confirm a node that doesn't exist + return nil } // Details are already logged with more details in generateNodeAction @@ -918,7 +956,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv if err != nil { return fmt.Errorf("error staking on new node: %w", err) } - return s.tryFastConfirmation(ctx, action.assertion.AfterState.GlobalState.BlockHash, action.assertion.AfterState.GlobalState.SendRoot) + return s.tryFastConfirmation(ctx, action.assertion.AfterState.GlobalState.BlockHash, action.assertion.AfterState.GlobalState.SendRoot, action.hash) } // If we have no stake yet, we'll put one down @@ -940,7 +978,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv return fmt.Errorf("error placing new stake on new node: %w", err) } info.StakeExists = true - return s.tryFastConfirmation(ctx, action.assertion.AfterState.GlobalState.BlockHash, action.assertion.AfterState.GlobalState.SendRoot) + return s.tryFastConfirmation(ctx, action.assertion.AfterState.GlobalState.BlockHash, action.assertion.AfterState.GlobalState.SendRoot, action.hash) case existingNodeAction: info.LatestStakedNode = action.number info.LatestStakedNodeHash = action.hash @@ -955,7 +993,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv hash: action.hash, } } - return s.tryFastConfirmationNodeNumber(ctx, action.number) + return s.tryFastConfirmationNodeNumber(ctx, action.number, action.hash) } log.Info("staking on existing node", "node", action.number) // We'll return early if we already havea stake @@ -968,7 +1006,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv if err != nil { return fmt.Errorf("error staking on existing node: %w", err) } - return s.tryFastConfirmationNodeNumber(ctx, action.number) + return s.tryFastConfirmationNodeNumber(ctx, action.number, action.hash) } // If we have no stake yet, we'll put one down @@ -989,7 +1027,7 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv return fmt.Errorf("error placing new stake on existing node: %w", err) } info.StakeExists = true - return s.tryFastConfirmationNodeNumber(ctx, action.number) + return s.tryFastConfirmationNodeNumber(ctx, action.number, action.hash) default: panic("invalid action type") } From b5a0ef9f943d649530e2219c4744ca6c718cc401 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 24 Jul 2024 11:56:48 -0600 Subject: [PATCH 218/268] Update submodule pin and arbutil.L1Interface --- arbutil/wait_for_l1.go | 2 +- contracts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arbutil/wait_for_l1.go b/arbutil/wait_for_l1.go index eaa5d0790d..4b4819156d 100644 --- a/arbutil/wait_for_l1.go +++ b/arbutil/wait_for_l1.go @@ -19,12 +19,12 @@ import ( type L1Interface interface { bind.ContractBackend + bind.BlockHashContractCaller ethereum.ChainReader ethereum.ChainStateReader ethereum.TransactionReader TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error) BlockNumber(ctx context.Context) (uint64, error) - CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error) ChainID(ctx context.Context) (*big.Int, error) Client() rpc.ClientInterface diff --git a/contracts b/contracts index 6d59d872e4..f7894d3a6d 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 6d59d872e45eac3e43e7cb65fccc245800b8e7d5 +Subproject commit f7894d3a6d4035ba60f51a7f1334f0f2d4f02dce From 26102c37d8b834d4b7652909877f2d42596a6a40 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 24 Jul 2024 12:13:37 -0600 Subject: [PATCH 219/268] Fix stubL1Client --- arbnode/dataposter/dataposter_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arbnode/dataposter/dataposter_test.go b/arbnode/dataposter/dataposter_test.go index f840d8c84e..172b486df0 100644 --- a/arbnode/dataposter/dataposter_test.go +++ b/arbnode/dataposter/dataposter_test.go @@ -212,6 +212,10 @@ func (c *stubL1Client) CallContractAtHash(ctx context.Context, msg ethereum.Call return []byte{}, nil } +func (c *stubL1Client) CodeAtHash(ctx context.Context, address common.Address, blockHash common.Hash) ([]byte, error) { + return []byte{}, nil +} + func (c *stubL1Client) ChainID(ctx context.Context) (*big.Int, error) { return nil, nil } From 5e9b6ec376e8308f3c076c87cc5e341d6bfed793 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 24 Jul 2024 20:25:55 +0200 Subject: [PATCH 220/268] Fix DAS sync default retention period The default retention period used when the DAS is syncing data should be the same as the default batch poster retention period, not the default maximum allowed by the DAS, since when syncing recent data, the max time bound (ahead of current time) is added to the retention period, and if it's the same as the max time allowed, this will be in the future. --- arbnode/batch_poster.go | 4 ++-- arbstate/daprovider/util.go | 3 +++ das/syncing_fallback_storage.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arbnode/batch_poster.go b/arbnode/batch_poster.go index ccf9b4aab7..965f6c2695 100644 --- a/arbnode/batch_poster.go +++ b/arbnode/batch_poster.go @@ -238,7 +238,7 @@ var DefaultBatchPosterConfig = BatchPosterConfig{ MaxDelay: time.Hour, WaitForMaxDelay: false, CompressionLevel: brotli.BestCompression, - DASRetentionPeriod: time.Hour * 24 * 15, + DASRetentionPeriod: daprovider.DefaultDASRetentionPeriod, GasRefunderAddress: "", ExtraBatchGas: 50_000, Post4844Blobs: false, @@ -270,7 +270,7 @@ var TestBatchPosterConfig = BatchPosterConfig{ MaxDelay: 0, WaitForMaxDelay: false, CompressionLevel: 2, - DASRetentionPeriod: time.Hour * 24 * 15, + DASRetentionPeriod: daprovider.DefaultDASRetentionPeriod, GasRefunderAddress: "", ExtraBatchGas: 10_000, Post4844Blobs: true, diff --git a/arbstate/daprovider/util.go b/arbstate/daprovider/util.go index 48cec884a3..d5a369bf3c 100644 --- a/arbstate/daprovider/util.go +++ b/arbstate/daprovider/util.go @@ -11,6 +11,7 @@ import ( "errors" "fmt" "io" + "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -34,6 +35,8 @@ type DASWriter interface { fmt.Stringer } +var DefaultDASRetentionPeriod time.Duration = time.Hour * 24 * 15 + type DASKeysetFetcher interface { GetKeysetByHash(context.Context, common.Hash) ([]byte, error) } diff --git a/das/syncing_fallback_storage.go b/das/syncing_fallback_storage.go index 1cf6a832f3..ee0ddc6b5f 100644 --- a/das/syncing_fallback_storage.go +++ b/das/syncing_fallback_storage.go @@ -68,7 +68,7 @@ type SyncToStorageConfig struct { var DefaultSyncToStorageConfig = SyncToStorageConfig{ Eager: false, EagerLowerBoundBlock: 0, - RetentionPeriod: defaultStorageRetention, + RetentionPeriod: daprovider.DefaultDASRetentionPeriod, DelayOnError: time.Second, IgnoreWriteErrors: true, ParentChainBlocksPerRead: 100, From 6587944e38919f10de221cddc27da9c535302c0e Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 24 Jul 2024 18:02:49 -0300 Subject: [PATCH 221/268] Check if consensus relied on execution at ResultAtCount before comparing result retrieved through consensus with result retrieved through execution. --- system_tests/seqfeed_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index 347a167660..4a4dd3fee5 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -301,12 +301,6 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { t.Fatal("Unexpected balance of real account:", l2balanceRealAcct) } - // Consensus should update message result stored in its database after a reorg - realResult := compareAllMsgResultsFromConsensusAndExecution(t, testClientB, "real") - // Checks that results changed - if reflect.DeepEqual(fraudResult, realResult) { - t.Fatal("realResult and fraudResult are equal") - } // Since NodeB is not a sequencer, it will produce blocks through Consensus. // So it is expected that Consensus.ResultAtCount will not rely on Execution to retrieve results. // However, since count 1 is related to genesis, and Execution is initialized through InitializeArbosInDatabase and not through Consensus, @@ -324,6 +318,12 @@ func testLyingSequencer(t *testing.T, dasModeStr string) { if logHandler.WasLogged(arbnode.FailedToGetMsgResultFromDB) { t.Fatal("Consensus relied on execution database to return the result") } + // Consensus should update message result stored in its database after a reorg + realResult := compareAllMsgResultsFromConsensusAndExecution(t, testClientB, "real") + // Checks that results changed + if reflect.DeepEqual(fraudResult, realResult) { + t.Fatal("realResult and fraudResult are equal") + } } func TestLyingSequencer(t *testing.T) { From 0e972b5f2cc16295baea1451438c17eff8d47fef Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 24 Jul 2024 18:30:37 +0200 Subject: [PATCH 222/268] Add some dataposter metrics This commit adds the following metrics to the DataPoster: arb/dataposter/nonce/unconfirmed: current unconfirmed nonce arb/dataposter/nonce/finalized: nonce as of finalized block arb/dataposter/nonce/softconfirmed: soft confirmed nonce ie nonce as of latest block number - nonce-rbf-soft-confs arb/dataposter/queue/length: number of unconfirmed batches in the queue arb/dataposter/queue/weight: weight of unconfirmed batches in the queue All are udpated every 10 seconds except softconfirmed, which is updated is updated whenever there is a new batch posted or a tx is replaced. --- arbnode/dataposter/data_poster.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index 1229d9f7a6..ac76da276d 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -28,6 +28,7 @@ import ( "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -50,6 +51,14 @@ import ( redisstorage "github.com/offchainlabs/nitro/arbnode/dataposter/redis" ) +var ( + latestFinalizedNonceGauge = metrics.NewRegisteredGauge("arb/dataposter/nonce/finalized", nil) + latestSoftConfirmedNonceGauge = metrics.NewRegisteredGauge("arb/dataposter/nonce/softconfirmed", nil) + latestUnconfirmedNonceGauge = metrics.NewRegisteredGauge("arb/dataposter/nonce/unconfirmed", nil) + totalQueueLengthGauge = metrics.NewRegisteredGauge("arb/dataposter/queue/length", nil) + totalQueueWeightGauge = metrics.NewRegisteredGauge("arb/dataposter/queue/weight", nil) +) + // Dataposter implements functionality to post transactions on the chain. It // is initialized with specified sender/signer and keeps nonce of that address // as it posts transactions. @@ -383,6 +392,7 @@ func (p *DataPoster) canPostWithNonce(ctx context.Context, nextNonce uint64, thi if err != nil { return fmt.Errorf("getting nonce of a dataposter sender: %w", err) } + latestUnconfirmedNonceGauge.Update(int64(unconfirmedNonce)) if nextNonce >= cfg.MaxMempoolTransactions+unconfirmedNonce { return fmt.Errorf("%w: transaction nonce: %d, unconfirmed nonce: %d, max mempool size: %d", ErrExceedsMaxMempoolSize, nextNonce, unconfirmedNonce, cfg.MaxMempoolTransactions) } @@ -394,6 +404,7 @@ func (p *DataPoster) canPostWithNonce(ctx context.Context, nextNonce uint64, thi if err != nil { return fmt.Errorf("getting nonce of a dataposter sender: %w", err) } + latestUnconfirmedNonceGauge.Update(int64(unconfirmedNonce)) if unconfirmedNonce > nextNonce { return fmt.Errorf("latest on-chain nonce %v is greater than to next nonce %v", unconfirmedNonce, nextNonce) } @@ -547,6 +558,7 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u if err != nil { return nil, nil, nil, fmt.Errorf("failed to get latest nonce %v blocks ago (block %v): %w", config.NonceRbfSoftConfs, softConfBlock, err) } + latestSoftConfirmedNonceGauge.Update(int64(softConfNonce)) suggestedTip, err := p.client.SuggestGasTipCap(ctx) if err != nil { @@ -1073,6 +1085,7 @@ func (p *DataPoster) updateNonce(ctx context.Context) error { } return nil } + latestFinalizedNonceGauge.Update(int64(nonce)) log.Info("Data poster transactions confirmed", "previousNonce", p.nonce, "newNonce", nonce, "previousL1Block", p.lastBlock, "newL1Block", header.Number) if len(p.errorCount) > 0 { for x := p.nonce; x < nonce; x++ { @@ -1152,6 +1165,7 @@ func (p *DataPoster) Start(ctxIn context.Context) { log.Warn("Failed to get latest nonce", "err", err) return minWait } + latestUnconfirmedNonceGauge.Update(int64(unconfirmedNonce)) // We use unconfirmedNonce here to replace-by-fee transactions that aren't in a block, // excluding those that are in an unconfirmed block. If a reorg occurs, we'll continue // replacing them by fee. @@ -1169,13 +1183,27 @@ func (p *DataPoster) Start(ctxIn context.Context) { if latestQueued != nil { latestCumulativeWeight = latestQueued.CumulativeWeight() latestNonce = latestQueued.FullTx.Nonce() + + var confirmedWeight uint64 + confirmedNonce := unconfirmedNonce - 1 + confirmedMeta, err := p.queue.Get(ctx, confirmedNonce) + if err != nil { + log.Error("Failed to fetxh latest confirmed tx from queue", "err", err) + return minWait + } + if confirmedMeta != nil { + confirmedWeight = confirmedMeta.CumulativeWeight() + } + totalQueueWeightGauge.Update(int64(arbmath.SaturatingUSub(latestCumulativeWeight, confirmedWeight))) + totalQueueLengthGauge.Update(int64(arbmath.SaturatingUSub(latestNonce, confirmedNonce))) } + for _, tx := range queueContents { previouslyUnsent := !tx.Sent sendAttempted := false if now.After(tx.NextReplacement) { - nonceBacklog := arbmath.SaturatingUSub(latestNonce, tx.FullTx.Nonce()) weightBacklog := arbmath.SaturatingUSub(latestCumulativeWeight, tx.CumulativeWeight()) + nonceBacklog := arbmath.SaturatingUSub(latestNonce, tx.FullTx.Nonce()) err := p.replaceTx(ctx, tx, arbmath.MaxInt(nonceBacklog, weightBacklog)) sendAttempted = true p.maybeLogError(err, tx, "failed to replace-by-fee transaction") From 2823d6688e5af86f8918ebd19dd7529c88e0f633 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Thu, 25 Jul 2024 17:41:32 +0200 Subject: [PATCH 223/268] Remove some dynamically generated metrics from DAS This removes some infrequently used dynamically generated metrics from the DAS aggregator. The arb/das/rpc/aggregator/store/backend/error/total metrics should be monitored and then drilling down into the error cause can be done by looking at logs. --- das/aggregator.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/das/aggregator.go b/das/aggregator.go index 9aa558b92c..d944f8d48a 100644 --- a/das/aggregator.go +++ b/das/aggregator.go @@ -193,11 +193,7 @@ func (a *Aggregator) Store(ctx context.Context, message []byte, timeout uint64) cert, err := d.service.Store(storeCtx, message, timeout) if err != nil { incFailureMetric() - if errors.Is(err, context.DeadlineExceeded) { - metrics.GetOrRegisterCounter(metricWithServiceName+"/error/timeout/total", nil).Inc(1) - } else { - metrics.GetOrRegisterCounter(metricWithServiceName+"/error/client/total", nil).Inc(1) - } + log.Warn("DAS Aggregator failed to store batch to backend", "backend", d.metricName, "err", err) responses <- storeResponse{d, nil, err} return } @@ -207,13 +203,13 @@ func (a *Aggregator) Store(ctx context.Context, message []byte, timeout uint64) ) if err != nil { incFailureMetric() - metrics.GetOrRegisterCounter(metricWithServiceName+"/error/bad_response/total", nil).Inc(1) + log.Warn("DAS Aggregator couldn't parse backend's store response signature", "backend", d.metricName, "err", err) responses <- storeResponse{d, nil, err} return } if !verified { incFailureMetric() - metrics.GetOrRegisterCounter(metricWithServiceName+"/error/bad_response/total", nil).Inc(1) + log.Warn("DAS Aggregator failed to verify backend's store response signature", "backend", d.metricName, "err", err) responses <- storeResponse{d, nil, errors.New("signature verification failed")} return } @@ -222,13 +218,13 @@ func (a *Aggregator) Store(ctx context.Context, message []byte, timeout uint64) if cert.DataHash != expectedHash { incFailureMetric() - metrics.GetOrRegisterCounter(metricWithServiceName+"/error/bad_response/total", nil).Inc(1) + log.Warn("DAS Aggregator got a store response with a data hash not matching the expected hash", "backend", d.metricName, "dataHash", cert.DataHash, "expectedHash", expectedHash, "err", err) responses <- storeResponse{d, nil, errors.New("hash verification failed")} return } if cert.Timeout != timeout { incFailureMetric() - metrics.GetOrRegisterCounter(metricWithServiceName+"/error/bad_response/total", nil).Inc(1) + log.Warn("DAS Aggregator got a store response with any expiry time not matching the expected expiry time", "backend", d.metricName, "dataHash", cert.DataHash, "expectedHash", expectedHash, "err", err) responses <- storeResponse{d, nil, fmt.Errorf("timeout was %d, expected %d", cert.Timeout, timeout)} return } From c3206696ae0bf12a8eff8b4d0eb2cac86d0bf4a7 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 25 Jul 2024 17:13:38 -0300 Subject: [PATCH 224/268] Adds .nvmrc --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000000..3c032078a4 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18 From 02b4c32fca4c612f76434dcf8d55d7f145238f08 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 26 Jul 2024 07:44:52 -0600 Subject: [PATCH 225/268] system_tests: use leveldb by default --- util/testhelpers/stackconfig.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/testhelpers/stackconfig.go b/util/testhelpers/stackconfig.go index a3c794ff28..45ab653a1c 100644 --- a/util/testhelpers/stackconfig.go +++ b/util/testhelpers/stackconfig.go @@ -18,6 +18,6 @@ func CreateStackConfigForTest(dataDir string) *node.Config { stackConf.P2P.NoDial = true stackConf.P2P.ListenAddr = "" stackConf.P2P.NAT = nil - stackConf.DBEngine = "pebble" + stackConf.DBEngine = "leveldb" return &stackConf } From 095c5c8128f0772d65cedeed22b3df381c3334c6 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 10 Jun 2024 17:13:59 -0300 Subject: [PATCH 226/268] replay fills batchcost inside msg --- cmd/replay/main.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmd/replay/main.go b/cmd/replay/main.go index 5723b4a030..0fe56eb4c9 100644 --- a/cmd/replay/main.go +++ b/cmd/replay/main.go @@ -203,6 +203,13 @@ func main() { panic(fmt.Sprintf("Error opening state db: %v", err.Error())) } + batchFetcher := func(batchNum uint64) ([]byte, error) { + currentBatch := wavmio.GetInboxPosition() + if batchNum > currentBatch { + return nil, fmt.Errorf("invalid batch fetch request %d, max %d", batchNum, currentBatch) + } + return wavmio.ReadInboxMessage(batchNum), nil + } readMessage := func(dasEnabled bool) *arbostypes.MessageWithMetadata { var delayedMessagesRead uint64 if lastBlockHeader != nil { @@ -232,6 +239,10 @@ func main() { panic(fmt.Sprintf("Error reading from inbox multiplexer: %v", err.Error())) } + err = message.Message.FillInBatchGasCost(batchFetcher) + if err != nil { + message.Message = arbostypes.InvalidL1Message + } return message } @@ -280,14 +291,10 @@ func main() { message := readMessage(chainConfig.ArbitrumChainParams.DataAvailabilityCommittee) chainContext := WavmChainContext{} - batchFetcher := func(batchNum uint64) ([]byte, error) { - return wavmio.ReadInboxMessage(batchNum), nil - } - newBlock, _, err = arbos.ProduceBlock(message.Message, message.DelayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, batchFetcher, false) + newBlock, _, err = arbos.ProduceBlock(message.Message, message.DelayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, false) if err != nil { panic(err) } - } else { // Initialize ArbOS with this init message and create the genesis block. From 4ca023e185d2f2768a0baae9f6a5172994fa590d Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 10 Jun 2024 17:28:45 -0300 Subject: [PATCH 227/268] ProduceBlock doesn't needs to fetch batch --- arbos/block_processor.go | 20 +------------------- arbos/incomingmessage_test.go | 2 +- arbos/parse_l2.go | 13 +++++-------- execution/gethexec/block_recorder.go | 5 ++++- execution/gethexec/executionengine.go | 9 +-------- gethhook/geth_test.go | 2 +- system_tests/retryable_test.go | 2 +- system_tests/state_fuzz_test.go | 7 ++++++- 8 files changed, 20 insertions(+), 40 deletions(-) diff --git a/arbos/block_processor.go b/arbos/block_processor.go index 9d6c420a57..b180405c43 100644 --- a/arbos/block_processor.go +++ b/arbos/block_processor.go @@ -22,7 +22,6 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/trie" @@ -144,26 +143,9 @@ func ProduceBlock( statedb *state.StateDB, chainContext core.ChainContext, chainConfig *params.ChainConfig, - batchFetcher arbostypes.FallibleBatchFetcher, isMsgForPrefetch bool, ) (*types.Block, types.Receipts, error) { - var batchFetchErr error - txes, err := ParseL2Transactions(message, chainConfig.ChainID, func(batchNum uint64, batchHash common.Hash) []byte { - data, err := batchFetcher(batchNum) - if err != nil { - batchFetchErr = err - return nil - } - dataHash := crypto.Keccak256Hash(data) - if dataHash != batchHash { - batchFetchErr = fmt.Errorf("expecting batch %v hash %v but got data with hash %v", batchNum, batchHash, dataHash) - return nil - } - return data - }) - if batchFetchErr != nil { - return nil, nil, batchFetchErr - } + txes, err := ParseL2Transactions(message, chainConfig.ChainID) if err != nil { log.Warn("error parsing incoming message", "err", err) txes = types.Transactions{} diff --git a/arbos/incomingmessage_test.go b/arbos/incomingmessage_test.go index 14726a419f..2933f6a719 100644 --- a/arbos/incomingmessage_test.go +++ b/arbos/incomingmessage_test.go @@ -36,7 +36,7 @@ func TestSerializeAndParseL1Message(t *testing.T) { if err != nil { t.Error(err) } - txes, err := ParseL2Transactions(newMsg, chainId, nil) + txes, err := ParseL2Transactions(newMsg, chainId) if err != nil { t.Error(err) } diff --git a/arbos/parse_l2.go b/arbos/parse_l2.go index d2df3bdf89..06722e4063 100644 --- a/arbos/parse_l2.go +++ b/arbos/parse_l2.go @@ -17,9 +17,7 @@ import ( "github.com/offchainlabs/nitro/util/arbmath" ) -type InfallibleBatchFetcher func(batchNum uint64, batchHash common.Hash) []byte - -func ParseL2Transactions(msg *arbostypes.L1IncomingMessage, chainId *big.Int, batchFetcher InfallibleBatchFetcher) (types.Transactions, error) { +func ParseL2Transactions(msg *arbostypes.L1IncomingMessage, chainId *big.Int) (types.Transactions, error) { if len(msg.L2msg) > arbostypes.MaxL2MessageSize { // ignore the message if l2msg is too large return nil, errors.New("message too large") @@ -71,7 +69,7 @@ func ParseL2Transactions(msg *arbostypes.L1IncomingMessage, chainId *big.Int, ba log.Debug("ignoring rollup event message") return types.Transactions{}, nil case arbostypes.L1MessageType_BatchPostingReport: - tx, err := parseBatchPostingReportMessage(bytes.NewReader(msg.L2msg), chainId, msg.BatchGasCost, batchFetcher) + tx, err := parseBatchPostingReportMessage(bytes.NewReader(msg.L2msg), chainId, msg.BatchGasCost) if err != nil { return nil, err } @@ -370,8 +368,8 @@ func parseSubmitRetryableMessage(rd io.Reader, header *arbostypes.L1IncomingMess return types.NewTx(tx), err } -func parseBatchPostingReportMessage(rd io.Reader, chainId *big.Int, msgBatchGasCost *uint64, batchFetcher InfallibleBatchFetcher) (*types.Transaction, error) { - batchTimestamp, batchPosterAddr, batchHash, batchNum, l1BaseFee, extraGas, err := arbostypes.ParseBatchPostingReportMessageFields(rd) +func parseBatchPostingReportMessage(rd io.Reader, chainId *big.Int, msgBatchGasCost *uint64) (*types.Transaction, error) { + batchTimestamp, batchPosterAddr, _, batchNum, l1BaseFee, extraGas, err := arbostypes.ParseBatchPostingReportMessageFields(rd) if err != nil { return nil, err } @@ -379,8 +377,7 @@ func parseBatchPostingReportMessage(rd io.Reader, chainId *big.Int, msgBatchGasC if msgBatchGasCost != nil { batchDataGas = *msgBatchGasCost } else { - batchData := batchFetcher(batchNum, batchHash) - batchDataGas = arbostypes.ComputeBatchGasCost(batchData) + return nil, errors.New("cannot compute batch gas cost") } batchDataGas = arbmath.SaturatingUAdd(batchDataGas, extraGas) diff --git a/execution/gethexec/block_recorder.go b/execution/gethexec/block_recorder.go index 5b509b97fc..f4f4a4d415 100644 --- a/execution/gethexec/block_recorder.go +++ b/execution/gethexec/block_recorder.go @@ -137,6 +137,10 @@ func (r *BlockRecorder) RecordBlockCreation( // Re-fetch the batch instead of using our cached cost, // as the replay binary won't have the cache populated. msg.Message.BatchGasCost = nil + err := msg.Message.FillInBatchGasCost(batchFetcher) + if err != nil { + return nil, err + } block, _, err := arbos.ProduceBlock( msg.Message, msg.DelayedMessagesRead, @@ -144,7 +148,6 @@ func (r *BlockRecorder) RecordBlockCreation( recordingdb, chaincontext, chainConfig, - batchFetcher, false, ) if err != nil { diff --git a/execution/gethexec/executionengine.go b/execution/gethexec/executionengine.go index 95b865df5a..d8a592736c 100644 --- a/execution/gethexec/executionengine.go +++ b/execution/gethexec/executionengine.go @@ -355,8 +355,7 @@ func (s *ExecutionEngine) resequenceReorgedMessages(messages []*arbostypes.Messa log.Warn("skipping non-standard sequencer message found from reorg", "header", header) continue } - // We don't need a batch fetcher as this is an L2 message - txes, err := arbos.ParseL2Transactions(msg.Message, s.bc.Config().ChainID, nil) + txes, err := arbos.ParseL2Transactions(msg.Message, s.bc.Config().ChainID) if err != nil { log.Warn("failed to parse sequencer message found from reorg", "err", err) continue @@ -625,11 +624,6 @@ func (s *ExecutionEngine) createBlockFromNextMessage(msg *arbostypes.MessageWith statedb.StartPrefetcher("TransactionStreamer") defer statedb.StopPrefetcher() - batchFetcher := func(num uint64) ([]byte, error) { - data, _, err := s.consensus.FetchBatch(s.GetContext(), num) - return data, err - } - block, receipts, err := arbos.ProduceBlock( msg.Message, msg.DelayedMessagesRead, @@ -637,7 +631,6 @@ func (s *ExecutionEngine) createBlockFromNextMessage(msg *arbostypes.MessageWith statedb, s.bc, s.bc.Config(), - batchFetcher, isMsgForPrefetch, ) diff --git a/gethhook/geth_test.go b/gethhook/geth_test.go index 99bfa4ae1c..57ce2ddec0 100644 --- a/gethhook/geth_test.go +++ b/gethhook/geth_test.go @@ -123,7 +123,7 @@ func RunMessagesThroughAPI(t *testing.T, msgs [][]byte, statedb *state.StateDB) if err != nil { t.Error(err) } - txes, err := arbos.ParseL2Transactions(msg, chainId, nil) + txes, err := arbos.ParseL2Transactions(msg, chainId) if err != nil { t.Error(err) } diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index 8f9507aea2..339346efc0 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -75,7 +75,7 @@ func retryableSetup(t *testing.T, modifyNodeConfig ...func(*NodeBuilder)) ( if !msgTypes[message.Message.Header.Kind] { continue } - txs, err := arbos.ParseL2Transactions(message.Message, params.ArbitrumDevTestChainConfig().ChainID, nil) + txs, err := arbos.ParseL2Transactions(message.Message, params.ArbitrumDevTestChainConfig().ChainID) Require(t, err) for _, tx := range txs { if txTypes[tx.Type()] { diff --git a/system_tests/state_fuzz_test.go b/system_tests/state_fuzz_test.go index 713aefcfba..24140e480d 100644 --- a/system_tests/state_fuzz_test.go +++ b/system_tests/state_fuzz_test.go @@ -57,8 +57,13 @@ func BuildBlock( batchFetcher := func(uint64) ([]byte, error) { return seqBatch, nil } + err = l1Message.FillInBatchGasCost(batchFetcher) + if err != nil { + return nil, err + } + block, _, err := arbos.ProduceBlock( - l1Message, delayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, batchFetcher, false, + l1Message, delayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, false, ) return block, err } From 3fca09b8b86f24cdcbe8f930c270ddea84259768 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 10 Jun 2024 17:50:55 -0300 Subject: [PATCH 228/268] block recorder doesn't supply batch info --- execution/gethexec/block_recorder.go | 22 --------------- execution/interface.go | 2 -- staker/block_validator.go | 19 ------------- staker/stateless_block_validator.go | 41 +++++++++++++++++++++++++++- 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/execution/gethexec/block_recorder.go b/execution/gethexec/block_recorder.go index f4f4a4d415..8879c90702 100644 --- a/execution/gethexec/block_recorder.go +++ b/execution/gethexec/block_recorder.go @@ -16,7 +16,6 @@ import ( "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution" - "github.com/offchainlabs/nitro/validator" ) // BlockRecorder uses a separate statedatabase from the blockchain. @@ -120,27 +119,7 @@ func (r *BlockRecorder) RecordBlockCreation( } var blockHash common.Hash - var readBatchInfo []validator.BatchInfo if msg != nil { - batchFetcher := func(batchNum uint64) ([]byte, error) { - data, blockHash, err := r.execEngine.consensus.FetchBatch(ctx, batchNum) - if err != nil { - return nil, err - } - readBatchInfo = append(readBatchInfo, validator.BatchInfo{ - Number: batchNum, - BlockHash: blockHash, - Data: data, - }) - return data, nil - } - // Re-fetch the batch instead of using our cached cost, - // as the replay binary won't have the cache populated. - msg.Message.BatchGasCost = nil - err := msg.Message.FillInBatchGasCost(batchFetcher) - if err != nil { - return nil, err - } block, _, err := arbos.ProduceBlock( msg.Message, msg.DelayedMessagesRead, @@ -175,7 +154,6 @@ func (r *BlockRecorder) RecordBlockCreation( Pos: pos, BlockHash: blockHash, Preimages: preimages, - BatchInfo: readBatchInfo, UserWasms: recordingdb.UserWasms(), }, err } diff --git a/execution/interface.go b/execution/interface.go index ddf30b4b2a..a3e9fb2c20 100644 --- a/execution/interface.go +++ b/execution/interface.go @@ -9,7 +9,6 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" - "github.com/offchainlabs/nitro/validator" ) type MessageResult struct { @@ -21,7 +20,6 @@ type RecordResult struct { Pos arbutil.MessageIndex BlockHash common.Hash Preimages map[common.Hash][]byte - BatchInfo []validator.BatchInfo UserWasms state.UserWasms } diff --git a/staker/block_validator.go b/staker/block_validator.go index bfb7c24ac6..89b82f7988 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -509,25 +509,6 @@ func (v *BlockValidator) SetCurrentWasmModuleRoot(hash common.Hash) error { ) } -func (v *BlockValidator) readBatch(ctx context.Context, batchNum uint64) (bool, []byte, common.Hash, arbutil.MessageIndex, error) { - batchCount, err := v.inboxTracker.GetBatchCount() - if err != nil { - return false, nil, common.Hash{}, 0, err - } - if batchCount <= batchNum { - return false, nil, common.Hash{}, 0, nil - } - batchMsgCount, err := v.inboxTracker.GetBatchMessageCount(batchNum) - if err != nil { - return false, nil, common.Hash{}, 0, err - } - batch, batchBlockHash, err := v.inboxReader.GetSequencerMessageBytes(ctx, batchNum) - if err != nil { - return false, nil, common.Hash{}, 0, err - } - return true, batch, batchBlockHash, batchMsgCount, nil -} - func (v *BlockValidator) createNextValidationEntry(ctx context.Context) (bool, error) { v.reorgMutex.RLock() defer v.reorgMutex.RUnlock() diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index ec235c4bf5..a0d008e862 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -231,6 +231,25 @@ func NewStatelessBlockValidator( }, nil } +func (v *StatelessBlockValidator) readBatch(ctx context.Context, batchNum uint64) (bool, []byte, common.Hash, arbutil.MessageIndex, error) { + batchCount, err := v.inboxTracker.GetBatchCount() + if err != nil { + return false, nil, common.Hash{}, 0, err + } + if batchCount <= batchNum { + return false, nil, common.Hash{}, 0, nil + } + batchMsgCount, err := v.inboxTracker.GetBatchMessageCount(batchNum) + if err != nil { + return false, nil, common.Hash{}, 0, err + } + batch, batchBlockHash, err := v.inboxReader.GetSequencerMessageBytes(ctx, batchNum) + if err != nil { + return false, nil, common.Hash{}, 0, err + } + return true, batch, batchBlockHash, batchMsgCount, nil +} + func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e *validationEntry) error { if e.Stage != ReadyForRecord { return fmt.Errorf("validation entry should be ReadyForRecord, is: %v", e.Stage) @@ -244,7 +263,27 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e * if recording.BlockHash != e.End.BlockHash { return fmt.Errorf("recording failed: pos %d, hash expected %v, got %v", e.Pos, e.End.BlockHash, recording.BlockHash) } - e.BatchInfo = append(e.BatchInfo, recording.BatchInfo...) + // record any additional batch fetching + batchFetcher := func(batchNum uint64) ([]byte, error) { + found, data, hash, _, err := v.readBatch(ctx, batchNum) + if err != nil { + return nil, err + } + if !found { + return nil, errors.New("batch not found") + } + e.BatchInfo = append(e.BatchInfo, validator.BatchInfo{ + Number: batchNum, + BlockHash: hash, + Data: data, + }) + return data, nil + } + e.msg.Message.BatchGasCost = nil + err = e.msg.Message.FillInBatchGasCost(batchFetcher) + if err != nil { + return err + } if recording.Preimages != nil { e.Preimages[arbutil.Keccak256PreimageType] = recording.Preimages From c6bd24adda18add217d1c6a1e41eac0db1e943ad Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 10 Jun 2024 17:54:48 -0300 Subject: [PATCH 229/268] remove FetchBatch from consensus --- arbnode/delayed_sequencer.go | 9 +++++++++ arbnode/node.go | 4 ---- arbnode/transaction_streamer.go | 12 ++++++++++++ execution/interface.go | 1 - 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/arbnode/delayed_sequencer.go b/arbnode/delayed_sequencer.go index 8cbb094c16..13cd5af11f 100644 --- a/arbnode/delayed_sequencer.go +++ b/arbnode/delayed_sequencer.go @@ -26,6 +26,7 @@ type DelayedSequencer struct { l1Reader *headerreader.HeaderReader bridge *DelayedBridge inbox *InboxTracker + reader *InboxReader exec execution.ExecutionSequencer coordinator *SeqCoordinator waitingForFinalizedBlock uint64 @@ -68,6 +69,7 @@ func NewDelayedSequencer(l1Reader *headerreader.HeaderReader, reader *InboxReade l1Reader: l1Reader, bridge: reader.DelayedBridge(), inbox: reader.Tracker(), + reader: reader, coordinator: coordinator, exec: exec, config: config, @@ -165,6 +167,13 @@ func (d *DelayedSequencer) sequenceWithoutLockout(ctx context.Context, lastBlock } } lastDelayedAcc = acc + err = msg.FillInBatchGasCost(func(batchNum uint64) ([]byte, error) { + data, _, err := d.reader.GetSequencerMessageBytes(ctx, batchNum) + return data, err + }) + if err != nil { + return err + } messages = append(messages, msg) pos++ } diff --git a/arbnode/node.go b/arbnode/node.go index ac18a6c7d4..e235ef9839 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -990,10 +990,6 @@ func (n *Node) StopAndWait() { } } -func (n *Node) FetchBatch(ctx context.Context, batchNum uint64) ([]byte, common.Hash, error) { - return n.InboxReader.GetSequencerMessageBytes(ctx, batchNum) -} - func (n *Node) FindInboxBatchContainingMessage(message arbutil.MessageIndex) (uint64, bool, error) { return n.InboxTracker.FindInboxBatchContainingMessage(message) } diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 116092383a..90e7feddc6 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -432,6 +432,18 @@ func (s *TransactionStreamer) GetMessage(seqNum arbutil.MessageIndex) (*arbostyp return nil, err } + err = message.Message.FillInBatchGasCost(func(batchNum uint64) ([]byte, error) { + ctx, err := s.GetContextSafe() + if err != nil { + return nil, err + } + data, _, err := s.inboxReader.GetSequencerMessageBytes(ctx, batchNum) + return data, err + }) + if err != nil { + return nil, err + } + return &message, nil } diff --git a/execution/interface.go b/execution/interface.go index a3e9fb2c20..2a3d79c697 100644 --- a/execution/interface.go +++ b/execution/interface.go @@ -75,7 +75,6 @@ type FullExecutionClient interface { // not implemented in execution, used as input // BatchFetcher is required for any execution node type BatchFetcher interface { - FetchBatch(ctx context.Context, batchNum uint64) ([]byte, common.Hash, error) FindInboxBatchContainingMessage(message arbutil.MessageIndex) (uint64, bool, error) GetBatchParentChainBlock(seqNum uint64) (uint64, error) } From 89fd178233932265da2580f35944da23252f2cfb Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 17 Jun 2024 18:18:13 -0300 Subject: [PATCH 230/268] FillInBatchGasCost in legacyGetDelayedMessageAndAccumulator and GetDelayedMessageAccumulatorAndParentChainBlockNumber --- arbnode/delayed_sequencer.go | 2 +- arbnode/inbox_reader.go | 12 +++++++---- arbnode/inbox_tracker.go | 33 ++++++++++++++++++++++------- staker/stateless_block_validator.go | 4 ++-- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/arbnode/delayed_sequencer.go b/arbnode/delayed_sequencer.go index 13cd5af11f..4f18531a76 100644 --- a/arbnode/delayed_sequencer.go +++ b/arbnode/delayed_sequencer.go @@ -146,7 +146,7 @@ func (d *DelayedSequencer) sequenceWithoutLockout(ctx context.Context, lastBlock var lastDelayedAcc common.Hash var messages []*arbostypes.L1IncomingMessage for pos < dbDelayedCount { - msg, acc, parentChainBlockNumber, err := d.inbox.GetDelayedMessageAccumulatorAndParentChainBlockNumber(pos) + msg, acc, parentChainBlockNumber, err := d.inbox.GetDelayedMessageAccumulatorAndParentChainBlockNumber(ctx, pos) if err != nil { return err } diff --git a/arbnode/inbox_reader.go b/arbnode/inbox_reader.go index 78b4db1929..77a0b6e7a2 100644 --- a/arbnode/inbox_reader.go +++ b/arbnode/inbox_reader.go @@ -143,7 +143,11 @@ func (r *InboxReader) Start(ctxIn context.Context) error { break } // Validate the init message matches our L2 blockchain - message, err := r.tracker.GetDelayedMessage(0) + ctx, err := r.StopWaiter.GetContextSafe() + if err != nil { + return err + } + message, err := r.tracker.GetDelayedMessage(ctx, 0) if err != nil { return err } @@ -226,7 +230,7 @@ func (r *InboxReader) CaughtUp() chan struct{} { func (r *InboxReader) run(ctx context.Context, hadError bool) error { readMode := r.config().ReadMode - from, err := r.getNextBlockToRead() + from, err := r.getNextBlockToRead(ctx) if err != nil { return err } @@ -584,7 +588,7 @@ func (r *InboxReader) getPrevBlockForReorg(from *big.Int) (*big.Int, error) { return newFrom, nil } -func (r *InboxReader) getNextBlockToRead() (*big.Int, error) { +func (r *InboxReader) getNextBlockToRead(ctx context.Context) (*big.Int, error) { delayedCount, err := r.tracker.GetDelayedCount() if err != nil { return nil, err @@ -592,7 +596,7 @@ func (r *InboxReader) getNextBlockToRead() (*big.Int, error) { if delayedCount == 0 { return new(big.Int).Set(r.firstMessageBlock), nil } - _, _, parentChainBlockNumber, err := r.tracker.GetDelayedMessageAccumulatorAndParentChainBlockNumber(delayedCount - 1) + _, _, parentChainBlockNumber, err := r.tracker.GetDelayedMessageAccumulatorAndParentChainBlockNumber(ctx, delayedCount-1) if err != nil { return nil, err } diff --git a/arbnode/inbox_tracker.go b/arbnode/inbox_tracker.go index b950c1e1ef..b621b12650 100644 --- a/arbnode/inbox_tracker.go +++ b/arbnode/inbox_tracker.go @@ -316,7 +316,7 @@ func (t *InboxTracker) PopulateFeedBacklog(broadcastServer *broadcaster.Broadcas return nil } -func (t *InboxTracker) legacyGetDelayedMessageAndAccumulator(seqNum uint64) (*arbostypes.L1IncomingMessage, common.Hash, error) { +func (t *InboxTracker) legacyGetDelayedMessageAndAccumulator(ctx context.Context, seqNum uint64) (*arbostypes.L1IncomingMessage, common.Hash, error) { key := dbKey(legacyDelayedMessagePrefix, seqNum) data, err := t.db.Get(key) if err != nil { @@ -328,17 +328,26 @@ func (t *InboxTracker) legacyGetDelayedMessageAndAccumulator(seqNum uint64) (*ar var acc common.Hash copy(acc[:], data[:32]) msg, err := arbostypes.ParseIncomingL1Message(bytes.NewReader(data[32:]), nil) + if err != nil { + return nil, common.Hash{}, err + } + + err = msg.FillInBatchGasCost(func(batchNum uint64) ([]byte, error) { + data, _, err := t.txStreamer.inboxReader.GetSequencerMessageBytes(ctx, batchNum) + return data, err + }) + return msg, acc, err } -func (t *InboxTracker) GetDelayedMessageAccumulatorAndParentChainBlockNumber(seqNum uint64) (*arbostypes.L1IncomingMessage, common.Hash, uint64, error) { +func (t *InboxTracker) GetDelayedMessageAccumulatorAndParentChainBlockNumber(ctx context.Context, seqNum uint64) (*arbostypes.L1IncomingMessage, common.Hash, uint64, error) { delayedMessageKey := dbKey(rlpDelayedMessagePrefix, seqNum) exists, err := t.db.Has(delayedMessageKey) if err != nil { return nil, common.Hash{}, 0, err } if !exists { - msg, acc, err := t.legacyGetDelayedMessageAndAccumulator(seqNum) + msg, acc, err := t.legacyGetDelayedMessageAndAccumulator(ctx, seqNum) return msg, acc, 0, err } data, err := t.db.Get(delayedMessageKey) @@ -356,6 +365,14 @@ func (t *InboxTracker) GetDelayedMessageAccumulatorAndParentChainBlockNumber(seq return msg, acc, 0, err } + err = msg.FillInBatchGasCost(func(batchNum uint64) ([]byte, error) { + data, _, err := t.txStreamer.inboxReader.GetSequencerMessageBytes(ctx, batchNum) + return data, err + }) + if err != nil { + return msg, acc, 0, err + } + parentChainBlockNumberKey := dbKey(parentChainBlockNumberPrefix, seqNum) exists, err = t.db.Has(parentChainBlockNumberKey) if err != nil { @@ -373,13 +390,13 @@ func (t *InboxTracker) GetDelayedMessageAccumulatorAndParentChainBlockNumber(seq } -func (t *InboxTracker) GetDelayedMessage(seqNum uint64) (*arbostypes.L1IncomingMessage, error) { - msg, _, _, err := t.GetDelayedMessageAccumulatorAndParentChainBlockNumber(seqNum) +func (t *InboxTracker) GetDelayedMessage(ctx context.Context, seqNum uint64) (*arbostypes.L1IncomingMessage, error) { + msg, _, _, err := t.GetDelayedMessageAccumulatorAndParentChainBlockNumber(ctx, seqNum) return msg, err } -func (t *InboxTracker) GetDelayedMessageBytes(seqNum uint64) ([]byte, error) { - msg, err := t.GetDelayedMessage(seqNum) +func (t *InboxTracker) GetDelayedMessageBytes(ctx context.Context, seqNum uint64) ([]byte, error) { + msg, err := t.GetDelayedMessage(ctx, seqNum) if err != nil { return nil, err } @@ -617,7 +634,7 @@ func (b *multiplexerBackend) ReadDelayedInbox(seqNum uint64) (*arbostypes.L1Inco if len(b.batches) == 0 || seqNum >= b.batches[0].AfterDelayedCount { return nil, errors.New("attempted to read past end of sequencer batch delayed messages") } - return b.inbox.GetDelayedMessage(seqNum) + return b.inbox.GetDelayedMessage(b.ctx, seqNum) } var delayedMessagesMismatch = errors.New("sequencer batch delayed messages missing or different") diff --git a/staker/stateless_block_validator.go b/staker/stateless_block_validator.go index a0d008e862..9fad900f63 100644 --- a/staker/stateless_block_validator.go +++ b/staker/stateless_block_validator.go @@ -49,7 +49,7 @@ type BlockValidatorRegistrer interface { type InboxTrackerInterface interface { BlockValidatorRegistrer - GetDelayedMessageBytes(uint64) ([]byte, error) + GetDelayedMessageBytes(context.Context, uint64) ([]byte, error) GetBatchMessageCount(seqNum uint64) (arbutil.MessageIndex, error) GetBatchAcc(seqNum uint64) (common.Hash, error) GetBatchCount() (uint64, error) @@ -291,7 +291,7 @@ func (v *StatelessBlockValidator) ValidationEntryRecord(ctx context.Context, e * e.UserWasms = recording.UserWasms } if e.HasDelayedMsg { - delayedMsg, err := v.inboxTracker.GetDelayedMessageBytes(e.DelayedMsgNr) + delayedMsg, err := v.inboxTracker.GetDelayedMessageBytes(ctx, e.DelayedMsgNr) if err != nil { log.Error( "error while trying to read delayed msg for proving", From 17d04ecf6cd0fc117b4824f89e0051aeae56c970 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 17 Jun 2024 19:22:15 -0300 Subject: [PATCH 231/268] Skips L1MessageType_BatchPostingReport when resequencing delayed messages --- execution/gethexec/executionengine.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/execution/gethexec/executionengine.go b/execution/gethexec/executionengine.go index d8a592736c..9f928719c8 100644 --- a/execution/gethexec/executionengine.go +++ b/execution/gethexec/executionengine.go @@ -343,6 +343,10 @@ func (s *ExecutionEngine) resequenceReorgedMessages(messages []*arbostypes.Messa log.Info("not resequencing delayed message due to unexpected index", "expected", nextDelayedSeqNum, "found", delayedSeqNum) continue } + if header.Kind == arbostypes.L1MessageType_BatchPostingReport { + log.Debug("skipping L1MessageType_BatchPostingReport message", "header", header) + continue + } _, err := s.sequenceDelayedMessageWithBlockMutex(msg.Message, delayedSeqNum) if err != nil { log.Error("failed to re-sequence old delayed message removed by reorg", "err", err) From 4b71218b646200d6dfd35622d3c723eb19d9b3d4 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 26 Jul 2024 12:49:11 -0300 Subject: [PATCH 232/268] Revert "Skips L1MessageType_BatchPostingReport when resequencing delayed messages" This reverts commit 17d04ecf6cd0fc117b4824f89e0051aeae56c970. --- execution/gethexec/executionengine.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/execution/gethexec/executionengine.go b/execution/gethexec/executionengine.go index 9f928719c8..d8a592736c 100644 --- a/execution/gethexec/executionengine.go +++ b/execution/gethexec/executionengine.go @@ -343,10 +343,6 @@ func (s *ExecutionEngine) resequenceReorgedMessages(messages []*arbostypes.Messa log.Info("not resequencing delayed message due to unexpected index", "expected", nextDelayedSeqNum, "found", delayedSeqNum) continue } - if header.Kind == arbostypes.L1MessageType_BatchPostingReport { - log.Debug("skipping L1MessageType_BatchPostingReport message", "header", header) - continue - } _, err := s.sequenceDelayedMessageWithBlockMutex(msg.Message, delayedSeqNum) if err != nil { log.Error("failed to re-sequence old delayed message removed by reorg", "err", err) From 3d89382e774c383fb6525c9ca45c93077a8089d0 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 26 Jul 2024 14:49:10 -0300 Subject: [PATCH 233/268] Adds cionly tag to TestReorgResequencing and improves comments about why it is a flaky test. --- system_tests/reorg_resequencing_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/system_tests/reorg_resequencing_test.go b/system_tests/reorg_resequencing_test.go index 81e226ea18..70ab63bec1 100644 --- a/system_tests/reorg_resequencing_test.go +++ b/system_tests/reorg_resequencing_test.go @@ -1,6 +1,9 @@ // Copyright 2021-2022, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE +//go:build cionly +// +build cionly + package arbtest import ( @@ -17,11 +20,12 @@ import ( // This is a flaky test. // During a reorg: -// - TransactionStreamer, holding insertionMutex lock, calls ExecutionEngine, -// which then adds old messages to a channel, so they can be resequenced asynchronously by ExecutionEngine. +// 1. TransactionStreamer, holding insertionMutex lock, calls ExecutionEngine, which then adds old messages to a channel. // After that, and before releasing the lock, TransactionStreamer does more computations. -// - Asynchronously, ExecutionEngine reads from this channel and calls TransactionStreamer, -// which expects that insertionMutex is free in order to succeed. When that happens this error generated: +// 2. Asynchronously, ExecutionEngine reads from this channel and calls TransactionStreamer, +// which expects that insertionMutex is free in order to succeed. +// +// If step 1 is still executing when Execution calls TransactionStreamer in step 2 then this error happens: // 'failed to re-sequence old user message removed by reorg err="insert lock taken"' func TestReorgResequencing(t *testing.T) { t.Parallel() From a8284d5238a9732e4fe8731f23d0782cf8c528d5 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 26 Jul 2024 11:54:25 -0600 Subject: [PATCH 234/268] block_validator: update profiling --- staker/block_validator.go | 73 +++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index 13ece78405..03367a50b0 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -31,18 +31,18 @@ import ( ) var ( - validatorPendingValidationsGauge = metrics.NewRegisteredGauge("arb/validator/validations/pending", nil) - validatorValidValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/valid", nil) - validatorFailedValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/failed", nil) - validatorValidationWaitToRecordHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRecord", nil, metrics.NewBoundedHistogramSample()) - validatorValidationRecordingHist = metrics.NewRegisteredHistogram("arb/validator/validations/recording", nil, metrics.NewBoundedHistogramSample()) - validatorValidationWaitToLaunchHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToLaunch", nil, metrics.NewBoundedHistogramSample()) - validatorValidationLaunchingHist = metrics.NewRegisteredHistogram("arb/validator/validations/launching", nil, metrics.NewBoundedHistogramSample()) - validatorValidationRunningHist = metrics.NewRegisteredHistogram("arb/validator/validations/running", nil, metrics.NewBoundedHistogramSample()) - validatorMsgCountCurrentBatch = metrics.NewRegisteredGauge("arb/validator/msg_count_current_batch", nil) - validatorMsgCountCreatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_created", nil) - validatorMsgCountRecordSentGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_record_sent", nil) - validatorMsgCountValidatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_validated", nil) + validatorPendingValidationsGauge = metrics.NewRegisteredGauge("arb/validator/validations/pending", nil) + validatorValidValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/valid", nil) + validatorFailedValidationsCounter = metrics.NewRegisteredCounter("arb/validator/validations/failed", nil) + validatorProfileWaitToRecordHist = metrics.NewRegisteredHistogram("arb/validator/profile/wait_to_record", nil, metrics.NewBoundedHistogramSample()) + validatorProfileRecordingHist = metrics.NewRegisteredHistogram("arb/validator/profile/recording", nil, metrics.NewBoundedHistogramSample()) + validatorProfileWaitToLaunchHist = metrics.NewRegisteredHistogram("arb/validator/profile/wait_to_launch", nil, metrics.NewBoundedHistogramSample()) + validatorProfileLaunchingHist = metrics.NewRegisteredHistogram("arb/validator/profile/launching", nil, metrics.NewBoundedHistogramSample()) + validatorProfileRunningHist = metrics.NewRegisteredHistogram("arb/validator/profile/running", nil, metrics.NewBoundedHistogramSample()) + validatorMsgCountCurrentBatch = metrics.NewRegisteredGauge("arb/validator/msg_count_current_batch", nil) + validatorMsgCountCreatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_created", nil) + validatorMsgCountRecordSentGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_record_sent", nil) + validatorMsgCountValidatedGauge = metrics.NewRegisteredGauge("arb/validator/msg_count_validated", nil) ) type BlockValidator struct { @@ -215,11 +215,11 @@ const ( ) type validationStatus struct { - Status atomic.Uint32 // atomic: value is one of validationStatus* - Cancel func() // non-atomic: only read/written to with reorg mutex - Entry *validationEntry // non-atomic: only read if Status >= validationStatusPrepared - Runs []validator.ValidationRun // if status >= ValidationSent - tsMilli int64 + Status atomic.Uint32 // atomic: value is one of validationStatus* + Cancel func() // non-atomic: only read/written to with reorg mutex + Entry *validationEntry // non-atomic: only read if Status >= validationStatusPrepared + Runs []validator.ValidationRun // if status >= ValidationSent + profileTS int64 // time-stamp for profiling } func (s *validationStatus) getStatus() valStatusField { @@ -231,10 +231,11 @@ func (s *validationStatus) replaceStatus(old, new valStatusField) bool { return s.Status.CompareAndSwap(uint32(old), uint32(new)) } -func (s *validationStatus) timeStampInterval() int64 { - start := s.tsMilli - s.tsMilli = time.Now().UnixMilli() - return s.tsMilli - start +// gets how many miliseconds last step took, and starts measuring a new step +func (s *validationStatus) profileStep() int64 { + start := s.profileTS + s.profileTS = time.Now().UnixMilli() + return s.profileTS - start } func NewBlockValidator( @@ -460,7 +461,7 @@ func (v *BlockValidator) sendRecord(s *validationStatus) error { return fmt.Errorf("failed status check for send record. Status: %v", s.getStatus()) } - validatorValidationWaitToRecordHist.Update(s.timeStampInterval()) + validatorProfileWaitToRecordHist.Update(s.profileStep()) v.LaunchThread(func(ctx context.Context) { err := v.ValidationEntryRecord(ctx, s.Entry) if ctx.Err() != nil { @@ -471,11 +472,12 @@ func (v *BlockValidator) sendRecord(s *validationStatus) error { log.Error("Error while recording", "err", err, "status", s.getStatus()) return } - validatorValidationRecordingHist.Update(s.timeStampInterval()) + validatorProfileRecordingHist.Update(s.profileStep()) if !s.replaceStatus(RecordSent, Prepared) { log.Error("Fault trying to update validation with recording", "entry", s.Entry, "status", s.getStatus()) return } + nonBlockingTrigger(v.progressValidationsChan) }) return nil } @@ -599,8 +601,8 @@ func (v *BlockValidator) createNextValidationEntry(ctx context.Context) (bool, e return false, err } status := &validationStatus{ - Entry: entry, - tsMilli: time.Now().UnixMilli(), + Entry: entry, + profileTS: time.Now().UnixMilli(), } status.Status.Store(uint32(Created)) v.validations.Store(pos, status) @@ -807,12 +809,13 @@ validationsLoop: continue } for _, moduleRoot := range wasmRoots { - if v.chosenValidator[moduleRoot] == nil { + spawner := v.chosenValidator[moduleRoot] + if spawner == nil { notFoundErr := fmt.Errorf("did not find spawner for moduleRoot :%v", moduleRoot) v.possiblyFatal(notFoundErr) return nil, notFoundErr } - if v.chosenValidator[moduleRoot].Room() == 0 { + if spawner.Room() == 0 { log.Trace("advanceValidations: no more room", "moduleRoot", moduleRoot) return nil, nil } @@ -826,27 +829,31 @@ validationsLoop: if !replaced { v.possiblyFatal(errors.New("failed to set SendingValidation status")) } - validatorValidationWaitToLaunchHist.Update(validationStatus.timeStampInterval()) + validatorProfileWaitToLaunchHist.Update(validationStatus.profileStep()) validatorPendingValidationsGauge.Inc(1) var runs []validator.ValidationRun for _, moduleRoot := range wasmRoots { - input, err := validationStatus.Entry.ToInput(v.chosenValidator[moduleRoot].StylusArchs()) + spawner := v.chosenValidator[moduleRoot] + input, err := validationStatus.Entry.ToInput(spawner.StylusArchs()) if err != nil && ctx.Err() == nil { v.possiblyFatal(fmt.Errorf("%w: error preparing validation", err)) continue } - run := v.chosenValidator[moduleRoot].Launch(input, moduleRoot) + if ctx.Err() != nil { + return nil, ctx.Err() + } + run := spawner.Launch(input, moduleRoot) log.Trace("advanceValidations: launched", "pos", validationStatus.Entry.Pos, "moduleRoot", moduleRoot) runs = append(runs, run) } - validatorValidationLaunchingHist.Update(validationStatus.timeStampInterval()) + validatorProfileLaunchingHist.Update(validationStatus.profileStep()) validationCtx, cancel := context.WithCancel(ctx) validationStatus.Runs = runs validationStatus.Cancel = cancel v.LaunchUntrackedThread(func() { defer validatorPendingValidationsGauge.Dec(1) defer cancel() - startTsMilli := validationStatus.tsMilli + startTsMilli := validationStatus.profileTS replaced = validationStatus.replaceStatus(SendingValidation, ValidationSent) if !replaced { v.possiblyFatal(errors.New("failed to set status to ValidationSent")) @@ -860,7 +867,7 @@ validationsLoop: return } } - validatorValidationRunningHist.Update(time.Now().UnixMilli() - startTsMilli) + validatorProfileRunningHist.Update(time.Now().UnixMilli() - startTsMilli) nonBlockingTrigger(v.progressValidationsChan) }) } From b7b2dd6b92522f7d0f3170b8f94d361f1b6494a5 Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Fri, 26 Jul 2024 13:10:41 -0600 Subject: [PATCH 235/268] validation_client: start after reading data --- validator/client/validation_client.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index 43231b913e..d6743b109e 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -55,9 +55,7 @@ func (c *ValidationClient) Launch(entry *validator.ValidationInput, moduleRoot c return server_common.NewValRun(promise, moduleRoot) } -func (c *ValidationClient) Start(ctx_in context.Context) error { - c.StopWaiter.Start(ctx_in, c) - ctx := c.GetContext() +func (c *ValidationClient) Start(ctx context.Context) error { if err := c.client.Start(ctx); err != nil { return err } @@ -101,6 +99,7 @@ func (c *ValidationClient) Start(ctx_in context.Context) error { c.wasmModuleRoots = moduleRoots c.name = name c.stylusArchs = stylusArchs + c.StopWaiter.Start(ctx, c) return nil } From 97e4a81f0fe5da2adf240f320cdd6de595fdd71f Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Mon, 29 Jul 2024 16:22:05 -0600 Subject: [PATCH 236/268] remove errcheck lint from syscal.Sync --- das/local_file_storage_service.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/das/local_file_storage_service.go b/das/local_file_storage_service.go index 66a08d0d95..65ca6fe15c 100644 --- a/das/local_file_storage_service.go +++ b/das/local_file_storage_service.go @@ -737,6 +737,8 @@ func (l *trieLayout) commitMigration() error { return err } + // in OSX - syscall.Sync() returns an error, but in linux it does not. + // nolint:errcheck syscall.Sync() // Done migrating From 14c6386de9ed7e86057aba604a118b16eaa93e85 Mon Sep 17 00:00:00 2001 From: Mathis Antony Date: Tue, 30 Jul 2024 14:03:38 +0200 Subject: [PATCH 237/268] Check all "not found" errors Currently only the leveldb not found errors are handled. If a pebble not found error is returned by the backend it is propagated, causing the batchposter to fail to send transactions. With this change all DB not found errors are handled the same way. (cherry picked from commit 85068866fb3f409cebfc0a5c446bdab05e655d03) --- arbnode/dataposter/dbstorage/storage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbnode/dataposter/dbstorage/storage.go b/arbnode/dataposter/dbstorage/storage.go index 4c49d695c5..caa8385452 100644 --- a/arbnode/dataposter/dbstorage/storage.go +++ b/arbnode/dataposter/dbstorage/storage.go @@ -61,7 +61,7 @@ func (s *Storage) Get(_ context.Context, index uint64) (*storage.QueuedTransacti key := idxToKey(index) value, err := s.db.Get(key) if err != nil { - if errors.Is(err, leveldb.ErrNotFound) { + if isErrNotFound(err) { return nil, nil } return nil, err From 79441185b2688149bc9ba5a7df33d7719e934d0a Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Tue, 30 Jul 2024 18:04:20 +0200 Subject: [PATCH 238/268] Make 3 troublesome tests not run in parallel with others. These tests sometimes fail when they are run in parallel with others on a Mac. With this change a `make clean && make all && make test-go` actually works on my Mac. Related to NIT-2696 --- system_tests/full_challenge_mock_test.go | 2 -- system_tests/program_test.go | 1 - 2 files changed, 3 deletions(-) diff --git a/system_tests/full_challenge_mock_test.go b/system_tests/full_challenge_mock_test.go index 82f57dd7ad..b7f484210f 100644 --- a/system_tests/full_challenge_mock_test.go +++ b/system_tests/full_challenge_mock_test.go @@ -7,7 +7,6 @@ package arbtest import "testing" func TestMockChallengeManagerAsserterIncorrect(t *testing.T) { - t.Parallel() defaultWasmRootDir := "" for i := int64(1); i <= makeBatch_MsgsPerBatch*3; i++ { RunChallengeTest(t, false, true, i, defaultWasmRootDir) @@ -15,7 +14,6 @@ func TestMockChallengeManagerAsserterIncorrect(t *testing.T) { } func TestMockChallengeManagerAsserterCorrect(t *testing.T) { - t.Parallel() defaultWasmRootDir := "" for i := int64(1); i <= makeBatch_MsgsPerBatch*3; i++ { RunChallengeTest(t, true, true, i, defaultWasmRootDir) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 20bc873adc..5fa5db95c2 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -397,7 +397,6 @@ func storageTest(t *testing.T, jit bool) { } func TestProgramTransientStorage(t *testing.T) { - t.Parallel() transientStorageTest(t, true) } From c227bab1812a003e9b0303912d5b8889cb31bc48 Mon Sep 17 00:00:00 2001 From: Mathis Antony Date: Tue, 30 Jul 2024 20:45:34 +0200 Subject: [PATCH 239/268] Use dbutil.IsErrNotFound --- arbnode/dataposter/dbstorage/storage.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arbnode/dataposter/dbstorage/storage.go b/arbnode/dataposter/dbstorage/storage.go index caa8385452..97055193a6 100644 --- a/arbnode/dataposter/dbstorage/storage.go +++ b/arbnode/dataposter/dbstorage/storage.go @@ -7,14 +7,12 @@ import ( "bytes" "context" "encoding/hex" - "errors" "fmt" "strconv" "github.com/ethereum/go-ethereum/ethdb" "github.com/offchainlabs/nitro/arbnode/dataposter/storage" "github.com/offchainlabs/nitro/util/dbutil" - "github.com/syndtr/goleveldb/leveldb" ) // Storage implements db based storage for batch poster. @@ -61,7 +59,7 @@ func (s *Storage) Get(_ context.Context, index uint64) (*storage.QueuedTransacti key := idxToKey(index) value, err := s.db.Get(key) if err != nil { - if isErrNotFound(err) { + if dbutil.IsErrNotFound(err) { return nil, nil } return nil, err From c9faa232822d1b590aa7db92979168047e84c603 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 20:57:47 +0000 Subject: [PATCH 240/268] Bump golang.org/x/net from 0.21.0 to 0.23.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.21.0 to 0.23.0. - [Commits](https://github.com/golang/net/compare/v0.21.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d0c8d5e719..bce1a0654a 100644 --- a/go.mod +++ b/go.mod @@ -161,7 +161,7 @@ require ( github.com/yuin/gopher-lua v1.1.1 // indirect go.opencensus.io v0.22.5 // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.21.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/sync v0.5.0 golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect diff --git a/go.sum b/go.sum index ff4726b22f..c5364d2d9f 100644 --- a/go.sum +++ b/go.sum @@ -827,8 +827,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= From 618a465216400979b35aca471ee3802c355a0715 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 21:44:28 +0000 Subject: [PATCH 241/268] Bump google.golang.org/protobuf from 1.30.0 to 1.33.0 Bumps google.golang.org/protobuf from 1.30.0 to 1.33.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index bce1a0654a..b6ad80cb21 100644 --- a/go.mod +++ b/go.mod @@ -165,6 +165,6 @@ require ( golang.org/x/sync v0.5.0 golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index c5364d2d9f..236a4e592d 100644 --- a/go.sum +++ b/go.sum @@ -1089,8 +1089,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 5520c136a0c2659f1cf2bac4c983a0ab7fcd7201 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 30 Jul 2024 18:13:43 -0500 Subject: [PATCH 242/268] Fix reorg on init flags --- arbnode/transaction_streamer.go | 12 ++++++-- cmd/conf/init.go | 16 ++++++++-- cmd/nitro/nitro.go | 54 ++++++++++++++++++++++++--------- execution/gethexec/node.go | 18 ++--------- execution/interface.go | 1 + 5 files changed, 66 insertions(+), 35 deletions(-) diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index 90e7feddc6..b143506b74 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -268,6 +268,14 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde if count == 0 { return errors.New("cannot reorg out init message") } + + // If not started, use a background context. + // This can happening when reorging on startup using the init flag. + ctx := context.Background() + if s.Started() { + ctx = s.GetContext() + } + lastDelayedSeqNum, err := s.getPrevPrevDelayedRead(count) if err != nil { return err @@ -324,7 +332,7 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde continue } msgBlockNum := new(big.Int).SetUint64(oldMessage.Message.Header.BlockNumber) - delayedInBlock, err := s.delayedBridge.LookupMessagesInRange(s.GetContext(), msgBlockNum, msgBlockNum, nil) + delayedInBlock, err := s.delayedBridge.LookupMessagesInRange(ctx, msgBlockNum, msgBlockNum, nil) if err != nil { log.Error("reorg-resequence: failed to serialize old delayed message from database", "err", err) continue @@ -368,7 +376,7 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde s.broadcastMessages(messagesWithComputedBlockHash, count) if s.validator != nil { - err = s.validator.Reorg(s.GetContext(), count) + err = s.validator.Reorg(ctx, count) if err != nil { return err } diff --git a/cmd/conf/init.go b/cmd/conf/init.go index 4bea00f9f2..352fb16427 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -30,9 +30,11 @@ type InitConfig struct { PruneBloomSize uint64 `koanf:"prune-bloom-size"` PruneThreads int `koanf:"prune-threads"` PruneTrieCleanCache int `koanf:"prune-trie-clean-cache"` - ResetToMessage int64 `koanf:"reset-to-message"` RecreateMissingStateFrom uint64 `koanf:"recreate-missing-state-from"` RebuildLocalWasm bool `koanf:"rebuild-local-wasm"` + ReorgToBatch int64 `koanf:"reorg-to-batch"` + ReorgToMessageBatch int64 `koanf:"reorg-to-message-batch"` + ReorgToBlockBatch int64 `koanf:"reorg-to-block-batch"` } var InitConfigDefault = InitConfig{ @@ -54,9 +56,11 @@ var InitConfigDefault = InitConfig{ PruneBloomSize: 2048, PruneThreads: runtime.NumCPU(), PruneTrieCleanCache: gethexec.DefaultCachingConfig.TrieCleanCache, - ResetToMessage: -1, RecreateMissingStateFrom: 0, // 0 = disabled RebuildLocalWasm: true, + ReorgToBatch: -1, + ReorgToMessageBatch: -1, + ReorgToBlockBatch: -1, } func InitConfigAddOptions(prefix string, f *pflag.FlagSet) { @@ -78,9 +82,11 @@ func InitConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Uint64(prefix+".prune-bloom-size", InitConfigDefault.PruneBloomSize, "the amount of memory in megabytes to use for the pruning bloom filter (higher values prune better)") f.Int(prefix+".prune-threads", InitConfigDefault.PruneThreads, "the number of threads to use when pruning") f.Int(prefix+".prune-trie-clean-cache", InitConfigDefault.PruneTrieCleanCache, "amount of memory in megabytes to cache unchanged state trie nodes with when traversing state database during pruning") - f.Int64(prefix+".reset-to-message", InitConfigDefault.ResetToMessage, "forces a reset to an old message height. Also set max-reorg-resequence-depth=0 to force re-reading messages") f.Uint64(prefix+".recreate-missing-state-from", InitConfigDefault.RecreateMissingStateFrom, "block number to start recreating missing states from (0 = disabled)") f.Bool(prefix+".rebuild-local-wasm", InitConfigDefault.RebuildLocalWasm, "rebuild local wasm database on boot if needed (otherwise-will be done lazily)") + f.Int64(prefix+".reorg-to-batch", InitConfigDefault.ReorgToBatch, "rolls back the blockchain to a specified batch number") + f.Int64(prefix+".reorg-to-message-batch", InitConfigDefault.ReorgToMessageBatch, "rolls back the blockchain to the first batch at or before a given message index") + f.Int64(prefix+".reorg-to-block-batch", InitConfigDefault.ReorgToBlockBatch, "rolls back the blockchain to the first batch at or before a given block number") } func (c *InitConfig) Validate() error { @@ -99,6 +105,10 @@ func (c *InitConfig) Validate() error { return nil } +func (c *InitConfig) IsReorgRequested() bool { + return c.ReorgToBatch >= 0 || c.ReorgToBlockBatch >= 0 || c.ReorgToMessageBatch >= 0 +} + var ( acceptedSnapshotKinds = []string{"archive", "pruned", "genesis"} acceptedSnapshotKindsStr = "(accepted values: \"" + strings.Join(acceptedSnapshotKinds, "\" | \"") + "\")" diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 9861bb673e..8a71c26d2f 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -513,7 +513,7 @@ func mainImpl() int { } } - if nodeConfig.Init.ThenQuit && nodeConfig.Init.ResetToMessage < 0 { + if nodeConfig.Init.ThenQuit && !nodeConfig.Init.IsReorgRequested() { return 0 } @@ -669,29 +669,53 @@ func mainImpl() int { sigint := make(chan os.Signal, 1) signal.Notify(sigint, os.Interrupt, syscall.SIGTERM) - exitCode := 0 - - if err == nil && nodeConfig.Init.ResetToMessage > 0 { - err = currentNode.TxStreamer.ReorgTo(arbutil.MessageIndex(nodeConfig.Init.ResetToMessage)) - if err != nil { - fatalErrChan <- fmt.Errorf("error reseting message: %w", err) - exitCode = 1 + if err == nil && nodeConfig.Init.IsReorgRequested() { + var batchCount uint64 + if nodeConfig.Init.ReorgToBatch >= 0 { + batchCount = uint64(nodeConfig.Init.ReorgToBatch) + 1 + } else { + var messageIndex arbutil.MessageIndex + if nodeConfig.Init.ReorgToMessageBatch >= 0 { + messageIndex = arbutil.MessageIndex(nodeConfig.Init.ReorgToMessageBatch) + } else { + messageIndex, err = currentNode.Execution.BlockNumberToMessageIndex(uint64(nodeConfig.Init.ReorgToBlockBatch)) + } + // Reorg out the batch containing the next message + var missing bool + batchCount, missing, err = currentNode.InboxTracker.FindInboxBatchContainingMessage(messageIndex + 1) + if err == nil && missing { + err = fmt.Errorf("cannot reorg to unknown message index %v", messageIndex) + } } - if nodeConfig.Init.ThenQuit { - return exitCode + if err == nil { + err = currentNode.InboxTracker.ReorgBatchesTo(batchCount) + } + if err != nil { + fatalErrChan <- fmt.Errorf("error reorging per init config: %w", err) + } else if nodeConfig.Init.ThenQuit { + return 0 } } + err = nil select { - case err := <-fatalErrChan: + case err = <-fatalErrChan: + case <-sigint: + // If there was both a sigint and a fatal error, we want to log the fatal error + select { + case err = <-fatalErrChan: + default: + log.Info("shutting down because of sigint") + } + } + + if err != nil { log.Error("shutting down due to fatal error", "err", err) defer log.Error("shut down due to fatal error", "err", err) - exitCode = 1 - case <-sigint: - log.Info("shutting down because of sigint") + return 1 } - return exitCode + return 0 } type NodeConfig struct { diff --git a/execution/gethexec/node.go b/execution/gethexec/node.go index 93f643b8a1..3acb98b782 100644 --- a/execution/gethexec/node.go +++ b/execution/gethexec/node.go @@ -26,18 +26,6 @@ import ( flag "github.com/spf13/pflag" ) -type DangerousConfig struct { - ReorgToBlock int64 `koanf:"reorg-to-block"` -} - -var DefaultDangerousConfig = DangerousConfig{ - ReorgToBlock: -1, -} - -func DangerousConfigAddOptions(prefix string, f *flag.FlagSet) { - f.Int64(prefix+".reorg-to-block", DefaultDangerousConfig.ReorgToBlock, "DANGEROUS! forces a reorg to an old block height. To be used for testing only. -1 to disable") -} - type Config struct { ParentChainReader headerreader.Config `koanf:"parent-chain-reader" reload:"hot"` Sequencer SequencerConfig `koanf:"sequencer" reload:"hot"` @@ -49,7 +37,6 @@ type Config struct { Caching CachingConfig `koanf:"caching"` RPC arbitrum.Config `koanf:"rpc"` TxLookupLimit uint64 `koanf:"tx-lookup-limit"` - Dangerous DangerousConfig `koanf:"dangerous"` EnablePrefetchBlock bool `koanf:"enable-prefetch-block"` SyncMonitor SyncMonitorConfig `koanf:"sync-monitor"` @@ -89,7 +76,6 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet) { CachingConfigAddOptions(prefix+".caching", f) SyncMonitorConfigAddOptions(prefix+".sync-monitor", f) f.Uint64(prefix+".tx-lookup-limit", ConfigDefault.TxLookupLimit, "retain the ability to lookup transactions by hash for the past N blocks (0 = all blocks)") - DangerousConfigAddOptions(prefix+".dangerous", f) f.Bool(prefix+".enable-prefetch-block", ConfigDefault.EnablePrefetchBlock, "enable prefetching of blocks") } @@ -103,7 +89,6 @@ var ConfigDefault = Config{ TxPreChecker: DefaultTxPreCheckerConfig, TxLookupLimit: 126_230_400, // 1 year at 4 blocks per second Caching: DefaultCachingConfig, - Dangerous: DefaultDangerousConfig, Forwarder: DefaultNodeForwarderConfig, EnablePrefetchBlock: true, } @@ -348,6 +333,9 @@ func (n *ExecutionNode) ResultAtPos(pos arbutil.MessageIndex) (*execution.Messag func (n *ExecutionNode) ArbOSVersionForMessageNumber(messageNum arbutil.MessageIndex) (uint64, error) { return n.ExecEngine.ArbOSVersionForMessageNumber(messageNum) } +func (n *ExecutionNode) BlockNumberToMessageIndex(blockNum uint64) (arbutil.MessageIndex, error) { + return n.ExecEngine.BlockNumberToMessageIndex(blockNum) +} func (n *ExecutionNode) RecordBlockCreation( ctx context.Context, diff --git a/execution/interface.go b/execution/interface.go index 2a3d79c697..8047391051 100644 --- a/execution/interface.go +++ b/execution/interface.go @@ -70,6 +70,7 @@ type FullExecutionClient interface { Maintenance() error ArbOSVersionForMessageNumber(messageNum arbutil.MessageIndex) (uint64, error) + BlockNumberToMessageIndex(blockNum uint64) (arbutil.MessageIndex, error) } // not implemented in execution, used as input From 9afd01f445d79116b93c03c1bcb702973a9239f1 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 31 Jul 2024 16:34:25 +0200 Subject: [PATCH 243/268] Remove compiler warnings in test code. Mostly removing unused arguments from functions, but also explicitly setting a 1 nanosecond sleep which was implicit before. --- system_tests/common_test.go | 2 +- system_tests/das_test.go | 8 ++++---- system_tests/forwarder_test.go | 6 +++--- system_tests/program_recursive_test.go | 2 +- system_tests/recreatestate_rpc_test.go | 2 -- system_tests/retryable_test.go | 20 ++++++++++---------- system_tests/triedb_race_test.go | 2 +- 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index c0ef6f5a92..d170173cc0 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -1304,7 +1304,7 @@ func setupConfigWithDAS( URL: "http://" + rpcLis.Addr().String(), Pubkey: blsPubToBase64(dasSignerKey), } - l1NodeConfigA.DataAvailability.RPCAggregator = aggConfigForBackend(t, beConfigA) + l1NodeConfigA.DataAvailability.RPCAggregator = aggConfigForBackend(beConfigA) l1NodeConfigA.DataAvailability.Enable = true l1NodeConfigA.DataAvailability.RestAggregator = das.DefaultRestfulClientAggregatorConfig l1NodeConfigA.DataAvailability.RestAggregator.Enable = true diff --git a/system_tests/das_test.go b/system_tests/das_test.go index 3dfe38b7af..9f4d153b6f 100644 --- a/system_tests/das_test.go +++ b/system_tests/das_test.go @@ -89,7 +89,7 @@ func blsPubToBase64(pubkey *blsSignatures.PublicKey) string { return string(encodedPubkey) } -func aggConfigForBackend(t *testing.T, backendConfig das.BackendConfig) das.AggregatorConfig { +func aggConfigForBackend(backendConfig das.BackendConfig) das.AggregatorConfig { return das.AggregatorConfig{ Enable: true, AssumedHonest: 1, @@ -115,7 +115,7 @@ func TestDASRekey(t *testing.T) { // Setup DAS config builder.nodeConfig.DataAvailability.Enable = true - builder.nodeConfig.DataAvailability.RPCAggregator = aggConfigForBackend(t, backendConfigA) + builder.nodeConfig.DataAvailability.RPCAggregator = aggConfigForBackend(backendConfigA) builder.nodeConfig.DataAvailability.RestAggregator = das.DefaultRestfulClientAggregatorConfig builder.nodeConfig.DataAvailability.RestAggregator.Enable = true builder.nodeConfig.DataAvailability.RestAggregator.Urls = []string{restServerUrlA} @@ -153,7 +153,7 @@ func TestDASRekey(t *testing.T) { authorizeDASKeyset(t, ctx, pubkeyB, builder.L1Info, builder.L1.Client) // Restart the node on the new keyset against the new DAS server running on the same disk as the first with new keys - builder.nodeConfig.DataAvailability.RPCAggregator = aggConfigForBackend(t, backendConfigB) + builder.nodeConfig.DataAvailability.RPCAggregator = aggConfigForBackend(backendConfigB) builder.l2StackConfig = testhelpers.CreateStackConfigForTest(builder.dataDir) cleanup := builder.BuildL2OnL1(t) defer cleanup() @@ -268,7 +268,7 @@ func TestDASComplexConfigAndRestMirror(t *testing.T) { URL: "http://" + rpcLis.Addr().String(), Pubkey: blsPubToBase64(pubkey), } - builder.nodeConfig.DataAvailability.RPCAggregator = aggConfigForBackend(t, beConfigA) + builder.nodeConfig.DataAvailability.RPCAggregator = aggConfigForBackend(beConfigA) builder.nodeConfig.DataAvailability.RestAggregator = das.DefaultRestfulClientAggregatorConfig builder.nodeConfig.DataAvailability.RestAggregator.Enable = true builder.nodeConfig.DataAvailability.RestAggregator.Urls = []string{"http://" + restLis.Addr().String()} diff --git a/system_tests/forwarder_test.go b/system_tests/forwarder_test.go index 2919377d6f..9fe419593e 100644 --- a/system_tests/forwarder_test.go +++ b/system_tests/forwarder_test.go @@ -199,7 +199,7 @@ func user(suffix string, idx int) string { } // tryWithTimeout calls function f() repeatedly foruntil it succeeds. -func tryWithTimeout(ctx context.Context, f func() error, duration time.Duration) error { +func tryWithTimeout(f func() error, duration time.Duration) error { for { select { case <-time.After(duration): @@ -263,7 +263,7 @@ func TestRedisForwarder(t *testing.T) { tx := builder.L2Info.PrepareTx(userA, userB, builder.L2Info.TransferGas, transferAmount, nil) sendFunc := func() error { return forwardingClient.SendTransaction(ctx, tx) } - if err := tryWithTimeout(ctx, sendFunc, DefaultTestForwarderConfig.UpdateInterval*10); err != nil { + if err := tryWithTimeout(sendFunc, DefaultTestForwarderConfig.UpdateInterval*10); err != nil { t.Fatalf("Client: %v, error sending transaction: %v", i, err) } _, err := EnsureTxSucceeded(ctx, seqClients[i], tx) @@ -308,7 +308,7 @@ func TestRedisForwarderFallbackNoRedis(t *testing.T) { builder.L2Info.GenerateAccount(user) tx := builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, transferAmount, nil) sendFunc := func() error { return forwardingClient.SendTransaction(ctx, tx) } - err := tryWithTimeout(ctx, sendFunc, DefaultTestForwarderConfig.UpdateInterval*10) + err := tryWithTimeout(sendFunc, DefaultTestForwarderConfig.UpdateInterval*10) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) diff --git a/system_tests/program_recursive_test.go b/system_tests/program_recursive_test.go index 245d62fc0c..68d307948d 100644 --- a/system_tests/program_recursive_test.go +++ b/system_tests/program_recursive_test.go @@ -31,7 +31,7 @@ func testProgramRecursiveCall(t *testing.T, builder *NodeBuilder, slotVals map[s ctx := builder.ctx slot := common.HexToHash("0x11223344556677889900aabbccddeeff") val := common.Hash{} - args := []byte{} + var args []byte if recurse[0].opcode == vm.SSTORE { // send event from storage on sstore val = rander.GetHash() diff --git a/system_tests/recreatestate_rpc_test.go b/system_tests/recreatestate_rpc_test.go index 985ca09f19..09d53669ee 100644 --- a/system_tests/recreatestate_rpc_test.go +++ b/system_tests/recreatestate_rpc_test.go @@ -361,10 +361,8 @@ func testSkippingSavingStateAndRecreatingAfterRestart(t *testing.T, cacheConfig Require(t, err) l2info.GenerateAccount("User2") - var txs []*types.Transaction for i := genesis; i < uint64(txCount)+genesis; i++ { tx := l2info.PrepareTx("Owner", "User2", l2info.TransferGas, common.Big1, nil) - txs = append(txs, tx) err := client.SendTransaction(ctx, tx) Require(t, err) receipt, err := EnsureTxSucceeded(ctx, client, tx) diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index daf065806f..106dfc6d46 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -223,7 +223,7 @@ func TestSubmitRetryableImmediateSuccess(t *testing.T) { Fatal(t, "l1Receipt indicated failure") } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) receipt, err := builder.L2.EnsureTxSucceeded(lookupL2Tx(l1Receipt)) Require(t, err) @@ -295,7 +295,7 @@ func testSubmitRetryableEmptyEscrow(t *testing.T, arbosVersion uint64) { Fatal(t, "l1Receipt indicated failure") } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) l2Tx := lookupL2Tx(l1Receipt) receipt, err := builder.L2.EnsureTxSucceeded(l2Tx) @@ -362,7 +362,7 @@ func TestSubmitRetryableFailThenRetry(t *testing.T) { Fatal(t, "l1Receipt indicated failure") } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) receipt, err := builder.L2.EnsureTxSucceeded(lookupL2Tx(l1Receipt)) Require(t, err) @@ -480,7 +480,7 @@ func TestSubmissionGasCosts(t *testing.T) { Fatal(t, "l1Receipt indicated failure") } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) submissionTxOuter := lookupL2Tx(l1Receipt) submissionReceipt, err := builder.L2.EnsureTxSucceeded(submissionTxOuter) @@ -586,7 +586,7 @@ func TestSubmissionGasCosts(t *testing.T) { } } -func waitForL1DelayBlocks(t *testing.T, ctx context.Context, builder *NodeBuilder) { +func waitForL1DelayBlocks(t *testing.T, builder *NodeBuilder) { // sending l1 messages creates l1 blocks.. make enough to get that delayed inbox message in for i := 0; i < 30; i++ { builder.L1.SendWaitTestTransactions(t, []*types.Transaction{ @@ -622,7 +622,7 @@ func TestDepositETH(t *testing.T) { if l1Receipt.Status != types.ReceiptStatusSuccessful { t.Errorf("Got transaction status: %v, want: %v", l1Receipt.Status, types.ReceiptStatusSuccessful) } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) l2Receipt, err := builder.L2.EnsureTxSucceeded(lookupL2Tx(l1Receipt)) if err != nil { @@ -681,7 +681,7 @@ func TestArbitrumContractTx(t *testing.T) { if receipt.Status != types.ReceiptStatusSuccessful { t.Errorf("L1 transaction: %v has failed", l1tx.Hash()) } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) _, err = builder.L2.EnsureTxSucceeded(lookupL2Tx(receipt)) if err != nil { t.Fatalf("EnsureTxSucceeded(%v) unexpected error: %v", unsignedTx.Hash(), err) @@ -750,7 +750,7 @@ func TestL1FundedUnsignedTransaction(t *testing.T) { if receipt.Status != types.ReceiptStatusSuccessful { t.Errorf("L1 transaction: %v has failed", l1tx.Hash()) } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) receipt, err = builder.L2.EnsureTxSucceeded(unsignedTx) if err != nil { t.Fatalf("EnsureTxSucceeded(%v) unexpected error: %v", unsignedTx.Hash(), err) @@ -802,7 +802,7 @@ func TestRetryableSubmissionAndRedeemFees(t *testing.T) { Fatal(t, "l1Receipt indicated failure") } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) submissionTxOuter := lookupL2Tx(l1Receipt) submissionReceipt, err := builder.L2.EnsureTxSucceeded(submissionTxOuter) @@ -971,7 +971,7 @@ func TestRetryableRedeemBlockGasUsage(t *testing.T) { if l1Receipt.Status != types.ReceiptStatusSuccessful { Fatal(t, "l1Receipt indicated failure") } - waitForL1DelayBlocks(t, ctx, builder) + waitForL1DelayBlocks(t, builder) submissionReceipt, err := EnsureTxSucceeded(ctx, l2client, lookupL2Tx(l1Receipt)) Require(t, err) if len(submissionReceipt.Logs) != 2 { diff --git a/system_tests/triedb_race_test.go b/system_tests/triedb_race_test.go index 609a4c0b60..7828cf386d 100644 --- a/system_tests/triedb_race_test.go +++ b/system_tests/triedb_race_test.go @@ -75,7 +75,7 @@ func TestTrieDBCommitRace(t *testing.T) { for _, root := range roots { err := bc.TrieDB().Dereference(root) Require(t, err) - time.Sleep(1) + time.Sleep(time.Nanosecond) } } close(quit) From 3e4ef9afa881c46fc4379774c719e21c87d90ab9 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 31 Jul 2024 10:28:21 -0500 Subject: [PATCH 244/268] Clarify ApproxExpBasisPoints degree parameter --- util/arbmath/math.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/arbmath/math.go b/util/arbmath/math.go index 7413955409..62af1e26e0 100644 --- a/util/arbmath/math.go +++ b/util/arbmath/math.go @@ -387,7 +387,7 @@ func DivCeil[T Unsigned](value, divisor T) T { // ApproxExpBasisPoints return the Maclaurin series approximation of e^x, where x is denominated in basis points. // The quartic polynomial will underestimate e^x by about 5% as x approaches 20000 bips. -func ApproxExpBasisPoints(value Bips, degree uint64) Bips { +func ApproxExpBasisPoints(value Bips, accuracy uint64) Bips { input := value negative := value < 0 if negative { @@ -396,9 +396,9 @@ func ApproxExpBasisPoints(value Bips, degree uint64) Bips { x := uint64(input) bips := uint64(OneInBips) - res := bips + x/degree - for i := uint64(1); i < degree; i++ { - res = bips + SaturatingUMul(res, x)/((degree-i)*bips) + res := bips + x/accuracy + for i := uint64(1); i < accuracy; i++ { + res = bips + SaturatingUMul(res, x)/((accuracy-i)*bips) } if negative { From b1a97b70854790602069419fbd19abf79fd5398c Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 31 Jul 2024 16:04:29 -0500 Subject: [PATCH 245/268] Bump nitro-testnode pin to include blockscout ABI change --- nitro-testnode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nitro-testnode b/nitro-testnode index 9dc0588c50..f328006579 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit 9dc0588c5066e2efd25c09adf12df7b28ef18cb6 +Subproject commit f328006579cbefe22c6c57de3d6b86397fde4438 From 5e0f780387633601a60fbf2304df7fb11ef48429 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 31 Jul 2024 20:37:40 -0500 Subject: [PATCH 246/268] Also try to fast confirm past nodes when inactive --- go.mod | 5 ++- go.sum | 3 ++ staker/staker.go | 97 ++++++++++++++++++++++++++++++++---------------- 3 files changed, 73 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index b6ad80cb21..123d7ea59a 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,10 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 ) -require github.com/google/go-querystring v1.1.0 // indirect +require ( + github.com/google/btree v1.1.2 // indirect + github.com/google/go-querystring v1.1.0 // indirect +) require ( github.com/DataDog/zstd v1.4.5 // indirect diff --git a/go.sum b/go.sum index 236a4e592d..f0580a6c1d 100644 --- a/go.sum +++ b/go.sum @@ -340,7 +340,10 @@ github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXi github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= +github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= diff --git a/staker/staker.go b/staker/staker.go index 1b1317948a..3eb941c6dd 100644 --- a/staker/staker.go +++ b/staker/staker.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rpc" + "github.com/google/btree" flag "github.com/spf13/pflag" "github.com/offchainlabs/nitro/arbnode/dataposter" @@ -246,6 +247,11 @@ type LatestConfirmedNotifier interface { UpdateLatestConfirmed(count arbutil.MessageIndex, globalState validator.GoGlobalState) } +type validatedNode struct { + number uint64 + hash common.Hash +} + type Staker struct { *L1Validator stopwaiter.StopWaiter @@ -258,6 +264,7 @@ type Staker struct { highGasBlocksBuffer *big.Int lastActCalledBlock *big.Int inactiveLastCheckedNode *nodeAndHash + inactiveValidatedNodes *btree.BTreeG[validatedNode] bringActiveUntilNode uint64 inboxReader InboxReaderInterface statelessBlockValidator *StatelessBlockValidator @@ -326,6 +333,9 @@ func NewStaker( return nil, err } } + inactiveValidatedNodes := btree.NewG(2, func(a, b validatedNode) bool { + return a.number < b.number || (a.number == b.number && a.hash.Cmp(b.hash) < 0) + }) return &Staker{ L1Validator: val, l1Reader: l1Reader, @@ -339,6 +349,7 @@ func NewStaker( statelessBlockValidator: statelessBlockValidator, fatalErr: fatalErr, fastConfirmSafe: fastConfirmSafe, + inactiveValidatedNodes: inactiveValidatedNodes, }, nil } @@ -683,12 +694,40 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { StakeExists: rawInfo != nil, } + effectiveStrategy := s.config.strategy + nodesLinear, err := s.validatorUtils.AreUnresolvedNodesLinear(callOpts, s.rollupAddress) + if err != nil { + return nil, fmt.Errorf("error checking for rollup assertion fork: %w", err) + } + if !nodesLinear { + log.Warn("rollup assertion fork detected") + if effectiveStrategy == DefensiveStrategy { + effectiveStrategy = StakeLatestStrategy + } + s.inactiveLastCheckedNode = nil + } + if s.bringActiveUntilNode != 0 { + if info.LatestStakedNode < s.bringActiveUntilNode { + if effectiveStrategy == DefensiveStrategy { + effectiveStrategy = StakeLatestStrategy + } + } else { + log.Info("defensive validator staked past incorrect node; waiting here") + s.bringActiveUntilNode = 0 + } + s.inactiveLastCheckedNode = nil + } + if effectiveStrategy <= DefensiveStrategy && s.inactiveLastCheckedNode != nil { + info.LatestStakedNode = s.inactiveLastCheckedNode.id + info.LatestStakedNodeHash = s.inactiveLastCheckedNode.hash + } + if s.config.EnableFastConfirmation { firstUnresolvedNode, err := s.rollup.FirstUnresolvedNode(callOpts) if err != nil { return nil, err } - if latestStakedNodeNum >= firstUnresolvedNode { + if info.LatestStakedNode >= firstUnresolvedNode { lastHeader, err := s.l1Reader.LastHeader(ctx) if err != nil { return nil, err @@ -698,15 +737,23 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { // To keep this call consistent with the GetNode call, we pin a specific parent chain block hash. checkNodeCorrectCallOpts := s.getCallOpts(ctx) checkNodeCorrectCallOpts.BlockHash = lastHeader.ParentHash - stakedOnNode, err := s.rollup.NodeHasStaker(checkNodeCorrectCallOpts, firstUnresolvedNode, walletAddressOrZero) + nodeInfo, err := s.rollup.GetNode(checkNodeCorrectCallOpts, firstUnresolvedNode) if err != nil { return nil, err } - if stakedOnNode { - nodeInfo, err := s.rollup.GetNode(checkNodeCorrectCallOpts, firstUnresolvedNode) + validatedNode, haveValidated := s.inactiveValidatedNodes.Get(validatedNode{ + number: firstUnresolvedNode, + hash: nodeInfo.NodeHash, + }) + confirmedCorrect := haveValidated && validatedNode.hash == nodeInfo.NodeHash + if !confirmedCorrect { + stakedOnNode, err := s.rollup.NodeHasStaker(checkNodeCorrectCallOpts, firstUnresolvedNode, walletAddressOrZero) if err != nil { return nil, err } + confirmedCorrect = stakedOnNode + } + if confirmedCorrect { err = s.tryFastConfirmationNodeNumber(ctx, firstUnresolvedNode, nodeInfo.NodeHash) if err != nil { return nil, err @@ -720,37 +767,21 @@ func (s *Staker) Act(ctx context.Context) (*types.Transaction, error) { } } - effectiveStrategy := s.config.strategy - nodesLinear, err := s.validatorUtils.AreUnresolvedNodesLinear(callOpts, s.rollupAddress) + latestConfirmedNode, err := s.rollup.LatestConfirmed(callOpts) if err != nil { - return nil, fmt.Errorf("error checking for rollup assertion fork: %w", err) + return nil, fmt.Errorf("error getting latest confirmed node: %w", err) } - if !nodesLinear { - log.Warn("rollup assertion fork detected") - if effectiveStrategy == DefensiveStrategy { - effectiveStrategy = StakeLatestStrategy + + // Clear s.inactiveValidatedNodes of any entries before or equal to latestConfirmedNode + for { + validatedNode, ok := s.inactiveValidatedNodes.Min() + if !ok { + break } - s.inactiveLastCheckedNode = nil - } - if s.bringActiveUntilNode != 0 { - if info.LatestStakedNode < s.bringActiveUntilNode { - if effectiveStrategy == DefensiveStrategy { - effectiveStrategy = StakeLatestStrategy - } - } else { - log.Info("defensive validator staked past incorrect node; waiting here") - s.bringActiveUntilNode = 0 + if validatedNode.number > latestConfirmedNode { + break } - s.inactiveLastCheckedNode = nil - } - if effectiveStrategy <= DefensiveStrategy && s.inactiveLastCheckedNode != nil { - info.LatestStakedNode = s.inactiveLastCheckedNode.id - info.LatestStakedNodeHash = s.inactiveLastCheckedNode.hash - } - - latestConfirmedNode, err := s.rollup.LatestConfirmed(callOpts) - if err != nil { - return nil, fmt.Errorf("error getting latest confirmed node: %w", err) + s.inactiveValidatedNodes.DeleteMin() } requiredStakeElevated, err := s.isRequiredStakeElevated(ctx) @@ -992,6 +1023,10 @@ func (s *Staker) advanceStake(ctx context.Context, info *OurStakerInfo, effectiv id: action.number, hash: action.hash, } + s.inactiveValidatedNodes.ReplaceOrInsert(validatedNode{ + number: action.number, + hash: action.hash, + }) } return s.tryFastConfirmationNodeNumber(ctx, action.number, action.hash) } From 12626722a4400ec8b503eb1a59970129fb93a020 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 31 Jul 2024 20:40:33 -0500 Subject: [PATCH 247/268] Address PR review --- arbnode/transaction_streamer.go | 12 ++---------- cmd/conf/init.go | 9 +++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index b143506b74..90e7feddc6 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -268,14 +268,6 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde if count == 0 { return errors.New("cannot reorg out init message") } - - // If not started, use a background context. - // This can happening when reorging on startup using the init flag. - ctx := context.Background() - if s.Started() { - ctx = s.GetContext() - } - lastDelayedSeqNum, err := s.getPrevPrevDelayedRead(count) if err != nil { return err @@ -332,7 +324,7 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde continue } msgBlockNum := new(big.Int).SetUint64(oldMessage.Message.Header.BlockNumber) - delayedInBlock, err := s.delayedBridge.LookupMessagesInRange(ctx, msgBlockNum, msgBlockNum, nil) + delayedInBlock, err := s.delayedBridge.LookupMessagesInRange(s.GetContext(), msgBlockNum, msgBlockNum, nil) if err != nil { log.Error("reorg-resequence: failed to serialize old delayed message from database", "err", err) continue @@ -376,7 +368,7 @@ func (s *TransactionStreamer) reorg(batch ethdb.Batch, count arbutil.MessageInde s.broadcastMessages(messagesWithComputedBlockHash, count) if s.validator != nil { - err = s.validator.Reorg(ctx, count) + err = s.validator.Reorg(s.GetContext(), count) if err != nil { return err } diff --git a/cmd/conf/init.go b/cmd/conf/init.go index 352fb16427..5559cf322f 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -102,6 +102,15 @@ func (c *InitConfig) Validate() error { if c.PruneTrieCleanCache < 0 { return fmt.Errorf("invalid trie clean cache size: %d, has to be greater or equal 0", c.PruneTrieCleanCache) } + numReorgOptionsSpecified := 0 + for _, reorgOption := range []int64{c.ReorgToBatch, c.ReorgToMessageBatch, c.ReorgToBlockBatch} { + if reorgOption >= 0 { + numReorgOptionsSpecified++ + if numReorgOptionsSpecified > 1 { + return fmt.Errorf("only one init reorg option can be specified") + } + } + } return nil } From ac6ea2144c84dfa4157b40e37b1bfca7b2a03854 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 31 Jul 2024 20:41:50 -0500 Subject: [PATCH 248/268] Clarify init reorg option error --- cmd/conf/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/conf/init.go b/cmd/conf/init.go index 5559cf322f..a3b5504077 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -107,7 +107,7 @@ func (c *InitConfig) Validate() error { if reorgOption >= 0 { numReorgOptionsSpecified++ if numReorgOptionsSpecified > 1 { - return fmt.Errorf("only one init reorg option can be specified") + return fmt.Errorf("at most one init reorg option can be specified") } } } From ebb78487cba2719475d256a0fe81c3df1bd28656 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 31 Jul 2024 20:50:51 -0500 Subject: [PATCH 249/268] Get rid of BlockNumberToMessageIndex --- cmd/nitro/nitro.go | 55 ++++++++++++++++++++++++-------------- execution/gethexec/node.go | 3 --- execution/interface.go | 1 - 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 8a71c26d2f..2c7d07cf3b 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -41,6 +41,7 @@ import ( "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/metrics/exp" "github.com/ethereum/go-ethereum/node" + "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/resourcemanager" @@ -670,26 +671,7 @@ func mainImpl() int { signal.Notify(sigint, os.Interrupt, syscall.SIGTERM) if err == nil && nodeConfig.Init.IsReorgRequested() { - var batchCount uint64 - if nodeConfig.Init.ReorgToBatch >= 0 { - batchCount = uint64(nodeConfig.Init.ReorgToBatch) + 1 - } else { - var messageIndex arbutil.MessageIndex - if nodeConfig.Init.ReorgToMessageBatch >= 0 { - messageIndex = arbutil.MessageIndex(nodeConfig.Init.ReorgToMessageBatch) - } else { - messageIndex, err = currentNode.Execution.BlockNumberToMessageIndex(uint64(nodeConfig.Init.ReorgToBlockBatch)) - } - // Reorg out the batch containing the next message - var missing bool - batchCount, missing, err = currentNode.InboxTracker.FindInboxBatchContainingMessage(messageIndex + 1) - if err == nil && missing { - err = fmt.Errorf("cannot reorg to unknown message index %v", messageIndex) - } - } - if err == nil { - err = currentNode.InboxTracker.ReorgBatchesTo(batchCount) - } + err = initReorg(nodeConfig.Init, chainInfo.ChainConfig, currentNode.InboxTracker) if err != nil { fatalErrChan <- fmt.Errorf("error reorging per init config: %w", err) } else if nodeConfig.Init.ThenQuit { @@ -1027,6 +1009,39 @@ func applyChainParameters(ctx context.Context, k *koanf.Koanf, chainId uint64, c return nil } +func initReorg(initConfig conf.InitConfig, chainConfig *params.ChainConfig, inboxTracker *arbnode.InboxTracker) error { + var batchCount uint64 + if initConfig.ReorgToBatch >= 0 { + batchCount = uint64(initConfig.ReorgToBatch) + 1 + } else { + var messageIndex arbutil.MessageIndex + if initConfig.ReorgToMessageBatch >= 0 { + messageIndex = arbutil.MessageIndex(initConfig.ReorgToMessageBatch) + } else if initConfig.ReorgToBlockBatch > 0 { + genesis := chainConfig.ArbitrumChainParams.GenesisBlockNum + blockNum := uint64(initConfig.ReorgToBlockBatch) + if blockNum < genesis { + return fmt.Errorf("ReorgToBlockBatch %d before genesis %d", blockNum, genesis) + } + messageIndex = arbutil.MessageIndex(blockNum - genesis) + } else { + log.Warn("Tried to do init reorg, but no init reorg options specified") + return nil + } + // Reorg out the batch containing the next message + var missing bool + var err error + batchCount, missing, err = inboxTracker.FindInboxBatchContainingMessage(messageIndex + 1) + if err != nil { + return err + } + if missing { + return fmt.Errorf("cannot reorg to unknown message index %v", messageIndex) + } + } + return inboxTracker.ReorgBatchesTo(batchCount) +} + type NodeConfigFetcher struct { *genericconf.LiveConfig[*NodeConfig] } diff --git a/execution/gethexec/node.go b/execution/gethexec/node.go index 3acb98b782..6624188cbd 100644 --- a/execution/gethexec/node.go +++ b/execution/gethexec/node.go @@ -333,9 +333,6 @@ func (n *ExecutionNode) ResultAtPos(pos arbutil.MessageIndex) (*execution.Messag func (n *ExecutionNode) ArbOSVersionForMessageNumber(messageNum arbutil.MessageIndex) (uint64, error) { return n.ExecEngine.ArbOSVersionForMessageNumber(messageNum) } -func (n *ExecutionNode) BlockNumberToMessageIndex(blockNum uint64) (arbutil.MessageIndex, error) { - return n.ExecEngine.BlockNumberToMessageIndex(blockNum) -} func (n *ExecutionNode) RecordBlockCreation( ctx context.Context, diff --git a/execution/interface.go b/execution/interface.go index 8047391051..2a3d79c697 100644 --- a/execution/interface.go +++ b/execution/interface.go @@ -70,7 +70,6 @@ type FullExecutionClient interface { Maintenance() error ArbOSVersionForMessageNumber(messageNum arbutil.MessageIndex) (uint64, error) - BlockNumberToMessageIndex(blockNum uint64) (arbutil.MessageIndex, error) } // not implemented in execution, used as input From 36d0b8bb75e8e409e08461d60f36372ac40dd88d Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 10:31:10 -0500 Subject: [PATCH 250/268] Target WASM MVP spec for rust builds --- Makefile | 2 +- arbitrator/prover/src/value.rs | 1 - arbitrator/prover/test-cases/rust/.cargo/config.toml | 8 ++++++++ arbitrator/stylus/tests/.cargo/config.toml | 2 ++ arbitrator/stylus/tests/create/.cargo/config | 2 -- arbitrator/stylus/tests/create/.cargo/config.toml | 8 ++++++++ arbitrator/stylus/tests/evm-data/.cargo/config | 2 -- arbitrator/stylus/tests/evm-data/.cargo/config.toml | 8 ++++++++ arbitrator/stylus/tests/fallible/.cargo/config | 2 -- arbitrator/stylus/tests/fallible/.cargo/config.toml | 8 ++++++++ arbitrator/stylus/tests/log/.cargo/config | 2 -- arbitrator/stylus/tests/log/.cargo/config.toml | 8 ++++++++ arbitrator/stylus/tests/multicall/.cargo/config | 2 -- arbitrator/stylus/tests/multicall/.cargo/config.toml | 8 ++++++++ .../stylus/tests/read-return-data/.cargo/config | 3 --- .../stylus/tests/read-return-data/.cargo/config.toml | 8 ++++++++ arbitrator/stylus/tests/sdk-storage/.cargo/config | 2 -- .../stylus/tests/sdk-storage/.cargo/config.toml | 8 ++++++++ arbitrator/stylus/tests/storage/.cargo/config | 2 -- arbitrator/stylus/tests/storage/.cargo/config.toml | 8 ++++++++ arbitrator/wasm-libraries/.cargo/config.toml | 11 +++++++++++ 21 files changed, 86 insertions(+), 19 deletions(-) create mode 100644 arbitrator/prover/test-cases/rust/.cargo/config.toml delete mode 100644 arbitrator/stylus/tests/create/.cargo/config create mode 100644 arbitrator/stylus/tests/create/.cargo/config.toml delete mode 100644 arbitrator/stylus/tests/evm-data/.cargo/config create mode 100644 arbitrator/stylus/tests/evm-data/.cargo/config.toml delete mode 100644 arbitrator/stylus/tests/fallible/.cargo/config create mode 100644 arbitrator/stylus/tests/fallible/.cargo/config.toml delete mode 100644 arbitrator/stylus/tests/log/.cargo/config create mode 100644 arbitrator/stylus/tests/log/.cargo/config.toml delete mode 100644 arbitrator/stylus/tests/multicall/.cargo/config create mode 100644 arbitrator/stylus/tests/multicall/.cargo/config.toml delete mode 100644 arbitrator/stylus/tests/read-return-data/.cargo/config create mode 100644 arbitrator/stylus/tests/read-return-data/.cargo/config.toml delete mode 100644 arbitrator/stylus/tests/sdk-storage/.cargo/config create mode 100644 arbitrator/stylus/tests/sdk-storage/.cargo/config.toml delete mode 100644 arbitrator/stylus/tests/storage/.cargo/config create mode 100644 arbitrator/stylus/tests/storage/.cargo/config.toml create mode 100644 arbitrator/wasm-libraries/.cargo/config.toml diff --git a/Makefile b/Makefile index 977044da59..c2f89915de 100644 --- a/Makefile +++ b/Makefile @@ -288,7 +288,7 @@ $(arbitrator_jit): $(DEP_PREDICATE) $(jit_files) install arbitrator/target/release/jit $@ $(arbitrator_cases)/rust/$(wasm32_wasi)/%.wasm: $(arbitrator_cases)/rust/src/bin/%.rs $(arbitrator_cases)/rust/src/lib.rs - cargo build --manifest-path $(arbitrator_cases)/rust/Cargo.toml --release --target wasm32-wasi --bin $(patsubst $(arbitrator_cases)/rust/$(wasm32_wasi)/%.wasm,%, $@) + cargo build --manifest-path $(arbitrator_cases)/rust/Cargo.toml --release --bin $(patsubst $(arbitrator_cases)/rust/$(wasm32_wasi)/%.wasm,%, $@) $(arbitrator_cases)/go/testcase.wasm: $(arbitrator_cases)/go/*.go .make/solgen cd $(arbitrator_cases)/go && GOOS=wasip1 GOARCH=wasm go build -o testcase.wasm diff --git a/arbitrator/prover/src/value.rs b/arbitrator/prover/src/value.rs index 4ec02f5463..5243472638 100644 --- a/arbitrator/prover/src/value.rs +++ b/arbitrator/prover/src/value.rs @@ -136,7 +136,6 @@ pub struct ProgramCounter { #[cfg(not(any( target_pointer_width = "32", target_pointer_width = "64", - target_pointer_width = "128" )))] compile_error!("Architectures with less than a 32 bit pointer width are not supported"); diff --git a/arbitrator/prover/test-cases/rust/.cargo/config.toml b/arbitrator/prover/test-cases/rust/.cargo/config.toml new file mode 100644 index 0000000000..e08c1895f0 --- /dev/null +++ b/arbitrator/prover/test-cases/rust/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-wasi" + +[target.wasm32-wasi] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/stylus/tests/.cargo/config.toml b/arbitrator/stylus/tests/.cargo/config.toml index ff01b66852..b0e9bafaa8 100644 --- a/arbitrator/stylus/tests/.cargo/config.toml +++ b/arbitrator/stylus/tests/.cargo/config.toml @@ -3,6 +3,8 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", "-C", "link-arg=-zstack-size=8192", # "-C", "link-arg=--export=__heap_base", # "-C", "link-arg=--export=__data_end", diff --git a/arbitrator/stylus/tests/create/.cargo/config b/arbitrator/stylus/tests/create/.cargo/config deleted file mode 100644 index f4e8c002fc..0000000000 --- a/arbitrator/stylus/tests/create/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" diff --git a/arbitrator/stylus/tests/create/.cargo/config.toml b/arbitrator/stylus/tests/create/.cargo/config.toml new file mode 100644 index 0000000000..9bd005dca0 --- /dev/null +++ b/arbitrator/stylus/tests/create/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-unknown-unknown" + +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/stylus/tests/evm-data/.cargo/config b/arbitrator/stylus/tests/evm-data/.cargo/config deleted file mode 100644 index f4e8c002fc..0000000000 --- a/arbitrator/stylus/tests/evm-data/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" diff --git a/arbitrator/stylus/tests/evm-data/.cargo/config.toml b/arbitrator/stylus/tests/evm-data/.cargo/config.toml new file mode 100644 index 0000000000..9bd005dca0 --- /dev/null +++ b/arbitrator/stylus/tests/evm-data/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-unknown-unknown" + +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/stylus/tests/fallible/.cargo/config b/arbitrator/stylus/tests/fallible/.cargo/config deleted file mode 100644 index f4e8c002fc..0000000000 --- a/arbitrator/stylus/tests/fallible/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" diff --git a/arbitrator/stylus/tests/fallible/.cargo/config.toml b/arbitrator/stylus/tests/fallible/.cargo/config.toml new file mode 100644 index 0000000000..9bd005dca0 --- /dev/null +++ b/arbitrator/stylus/tests/fallible/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-unknown-unknown" + +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/stylus/tests/log/.cargo/config b/arbitrator/stylus/tests/log/.cargo/config deleted file mode 100644 index f4e8c002fc..0000000000 --- a/arbitrator/stylus/tests/log/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" diff --git a/arbitrator/stylus/tests/log/.cargo/config.toml b/arbitrator/stylus/tests/log/.cargo/config.toml new file mode 100644 index 0000000000..9bd005dca0 --- /dev/null +++ b/arbitrator/stylus/tests/log/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-unknown-unknown" + +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/stylus/tests/multicall/.cargo/config b/arbitrator/stylus/tests/multicall/.cargo/config deleted file mode 100644 index f4e8c002fc..0000000000 --- a/arbitrator/stylus/tests/multicall/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" diff --git a/arbitrator/stylus/tests/multicall/.cargo/config.toml b/arbitrator/stylus/tests/multicall/.cargo/config.toml new file mode 100644 index 0000000000..9bd005dca0 --- /dev/null +++ b/arbitrator/stylus/tests/multicall/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-unknown-unknown" + +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/stylus/tests/read-return-data/.cargo/config b/arbitrator/stylus/tests/read-return-data/.cargo/config deleted file mode 100644 index aa59d2ee1c..0000000000 --- a/arbitrator/stylus/tests/read-return-data/.cargo/config +++ /dev/null @@ -1,3 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" - diff --git a/arbitrator/stylus/tests/read-return-data/.cargo/config.toml b/arbitrator/stylus/tests/read-return-data/.cargo/config.toml new file mode 100644 index 0000000000..9bd005dca0 --- /dev/null +++ b/arbitrator/stylus/tests/read-return-data/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-unknown-unknown" + +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/stylus/tests/sdk-storage/.cargo/config b/arbitrator/stylus/tests/sdk-storage/.cargo/config deleted file mode 100644 index f4e8c002fc..0000000000 --- a/arbitrator/stylus/tests/sdk-storage/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" diff --git a/arbitrator/stylus/tests/sdk-storage/.cargo/config.toml b/arbitrator/stylus/tests/sdk-storage/.cargo/config.toml new file mode 100644 index 0000000000..9bd005dca0 --- /dev/null +++ b/arbitrator/stylus/tests/sdk-storage/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-unknown-unknown" + +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/stylus/tests/storage/.cargo/config b/arbitrator/stylus/tests/storage/.cargo/config deleted file mode 100644 index f4e8c002fc..0000000000 --- a/arbitrator/stylus/tests/storage/.cargo/config +++ /dev/null @@ -1,2 +0,0 @@ -[build] -target = "wasm32-unknown-unknown" diff --git a/arbitrator/stylus/tests/storage/.cargo/config.toml b/arbitrator/stylus/tests/storage/.cargo/config.toml new file mode 100644 index 0000000000..9bd005dca0 --- /dev/null +++ b/arbitrator/stylus/tests/storage/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "wasm32-unknown-unknown" + +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] diff --git a/arbitrator/wasm-libraries/.cargo/config.toml b/arbitrator/wasm-libraries/.cargo/config.toml new file mode 100644 index 0000000000..b6268ea246 --- /dev/null +++ b/arbitrator/wasm-libraries/.cargo/config.toml @@ -0,0 +1,11 @@ +[target.wasm32-unknown-unknown] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] + +[target.wasm32-wasi] +rustflags = [ + "-C", "target-cpu=mvp", + "-C", "lto", +] From 0b5b5527fe5d35aef42f8b39581e9f07667c7bde Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 10:41:45 -0500 Subject: [PATCH 251/268] Update rust in arbitrator CI --- .github/workflows/arbitrator-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/arbitrator-ci.yml b/.github/workflows/arbitrator-ci.yml index 3ec3327392..09b9cc05e1 100644 --- a/.github/workflows/arbitrator-ci.yml +++ b/.github/workflows/arbitrator-ci.yml @@ -71,14 +71,14 @@ jobs: - name: Install rust stable uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.76" + toolchain: 'stable' components: 'llvm-tools-preview, rustfmt, clippy' - name: Install rust nightly uses: dtolnay/rust-toolchain@nightly id: install-rust-nightly with: - toolchain: "nightly-2024-02-04" + toolchain: 'nightly-2024-02-04' targets: 'wasm32-wasi, wasm32-unknown-unknown' components: 'rust-src, rustfmt, clippy' From 8dfb1fb231101281f0bec7a43540e8179af590d1 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 10:50:10 -0500 Subject: [PATCH 252/268] Update rust nightly in arbitrator CI --- .github/workflows/arbitrator-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/arbitrator-ci.yml b/.github/workflows/arbitrator-ci.yml index 09b9cc05e1..adbf562e31 100644 --- a/.github/workflows/arbitrator-ci.yml +++ b/.github/workflows/arbitrator-ci.yml @@ -78,7 +78,7 @@ jobs: uses: dtolnay/rust-toolchain@nightly id: install-rust-nightly with: - toolchain: 'nightly-2024-02-04' + toolchain: 'nightly' targets: 'wasm32-wasi, wasm32-unknown-unknown' components: 'rust-src, rustfmt, clippy' @@ -156,7 +156,7 @@ jobs: run: echo "$HOME/wabt-prefix/bin" >> "$GITHUB_PATH" - name: Make arbitrator libraries - run: make -j wasm-ci-build STYLUS_NIGHTLY_VER="+nightly-2024-02-04" + run: make -j wasm-ci-build - name: Clippy check run: cargo clippy --all --manifest-path arbitrator/Cargo.toml -- -D warnings From d3bb616a7f377f692b1878e4bd2ab697558a2b9c Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 10:58:31 -0500 Subject: [PATCH 253/268] Drop -Clto --- arbitrator/prover/test-cases/rust/.cargo/config.toml | 1 - arbitrator/stylus/tests/.cargo/config.toml | 1 - arbitrator/stylus/tests/create/.cargo/config.toml | 1 - arbitrator/stylus/tests/evm-data/.cargo/config.toml | 1 - arbitrator/stylus/tests/fallible/.cargo/config.toml | 1 - arbitrator/stylus/tests/log/.cargo/config.toml | 1 - arbitrator/stylus/tests/multicall/.cargo/config.toml | 1 - arbitrator/stylus/tests/read-return-data/.cargo/config.toml | 1 - arbitrator/stylus/tests/sdk-storage/.cargo/config.toml | 1 - arbitrator/stylus/tests/storage/.cargo/config.toml | 1 - arbitrator/wasm-libraries/.cargo/config.toml | 2 -- 11 files changed, 12 deletions(-) diff --git a/arbitrator/prover/test-cases/rust/.cargo/config.toml b/arbitrator/prover/test-cases/rust/.cargo/config.toml index e08c1895f0..ac75d66caa 100644 --- a/arbitrator/prover/test-cases/rust/.cargo/config.toml +++ b/arbitrator/prover/test-cases/rust/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-wasi" [target.wasm32-wasi] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/stylus/tests/.cargo/config.toml b/arbitrator/stylus/tests/.cargo/config.toml index b0e9bafaa8..702a5c04b3 100644 --- a/arbitrator/stylus/tests/.cargo/config.toml +++ b/arbitrator/stylus/tests/.cargo/config.toml @@ -4,7 +4,6 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", "-C", "link-arg=-zstack-size=8192", # "-C", "link-arg=--export=__heap_base", # "-C", "link-arg=--export=__data_end", diff --git a/arbitrator/stylus/tests/create/.cargo/config.toml b/arbitrator/stylus/tests/create/.cargo/config.toml index 9bd005dca0..ea2ec38b12 100644 --- a/arbitrator/stylus/tests/create/.cargo/config.toml +++ b/arbitrator/stylus/tests/create/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/stylus/tests/evm-data/.cargo/config.toml b/arbitrator/stylus/tests/evm-data/.cargo/config.toml index 9bd005dca0..ea2ec38b12 100644 --- a/arbitrator/stylus/tests/evm-data/.cargo/config.toml +++ b/arbitrator/stylus/tests/evm-data/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/stylus/tests/fallible/.cargo/config.toml b/arbitrator/stylus/tests/fallible/.cargo/config.toml index 9bd005dca0..ea2ec38b12 100644 --- a/arbitrator/stylus/tests/fallible/.cargo/config.toml +++ b/arbitrator/stylus/tests/fallible/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/stylus/tests/log/.cargo/config.toml b/arbitrator/stylus/tests/log/.cargo/config.toml index 9bd005dca0..ea2ec38b12 100644 --- a/arbitrator/stylus/tests/log/.cargo/config.toml +++ b/arbitrator/stylus/tests/log/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/stylus/tests/multicall/.cargo/config.toml b/arbitrator/stylus/tests/multicall/.cargo/config.toml index 9bd005dca0..ea2ec38b12 100644 --- a/arbitrator/stylus/tests/multicall/.cargo/config.toml +++ b/arbitrator/stylus/tests/multicall/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/stylus/tests/read-return-data/.cargo/config.toml b/arbitrator/stylus/tests/read-return-data/.cargo/config.toml index 9bd005dca0..ea2ec38b12 100644 --- a/arbitrator/stylus/tests/read-return-data/.cargo/config.toml +++ b/arbitrator/stylus/tests/read-return-data/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/stylus/tests/sdk-storage/.cargo/config.toml b/arbitrator/stylus/tests/sdk-storage/.cargo/config.toml index 9bd005dca0..ea2ec38b12 100644 --- a/arbitrator/stylus/tests/sdk-storage/.cargo/config.toml +++ b/arbitrator/stylus/tests/sdk-storage/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/stylus/tests/storage/.cargo/config.toml b/arbitrator/stylus/tests/storage/.cargo/config.toml index 9bd005dca0..ea2ec38b12 100644 --- a/arbitrator/stylus/tests/storage/.cargo/config.toml +++ b/arbitrator/stylus/tests/storage/.cargo/config.toml @@ -4,5 +4,4 @@ target = "wasm32-unknown-unknown" [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] diff --git a/arbitrator/wasm-libraries/.cargo/config.toml b/arbitrator/wasm-libraries/.cargo/config.toml index b6268ea246..f13dbab7ed 100644 --- a/arbitrator/wasm-libraries/.cargo/config.toml +++ b/arbitrator/wasm-libraries/.cargo/config.toml @@ -1,11 +1,9 @@ [target.wasm32-unknown-unknown] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] [target.wasm32-wasi] rustflags = [ "-C", "target-cpu=mvp", - "-C", "lto", ] From d36cbe44fae86c4960692dd821889157547866db Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 11:32:42 -0500 Subject: [PATCH 254/268] Fix Makefile --- Makefile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index c2f89915de..c05249466a 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,8 @@ prover_dir = arbitrator/prover/ rust_prover_files = $(wildcard $(prover_dir)/src/*.* $(prover_dir)/src/*/*.* $(prover_dir)/*.toml $(prover_dir)/*.rs) $(rust_arbutil_files) $(prover_direct_includes) $(arb_brotli_files) wasm_lib = arbitrator/wasm-libraries -wasm_lib_deps = $(wildcard $(wasm_lib)/$(1)/*.toml $(wasm_lib)/$(1)/src/*.rs $(wasm_lib)/$(1)/*.rs) $(rust_arbutil_files) $(arb_brotli_files) .make/machines +wasm_lib_cargo = $(wasm_lib)/.cargo/config.toml +wasm_lib_deps = $(wildcard $(wasm_lib)/$(1)/*.toml $(wasm_lib)/$(1)/src/*.rs $(wasm_lib)/$(1)/*.rs) $(wasm_lib_cargo) $(rust_arbutil_files) $(arb_brotli_files) .make/machines wasm_lib_go_abi = $(call wasm_lib_deps,go-abi) wasm_lib_forward = $(call wasm_lib_deps,forward) wasm_lib_user_host_trait = $(call wasm_lib_deps,user-host-trait) @@ -287,8 +288,8 @@ $(arbitrator_jit): $(DEP_PREDICATE) $(jit_files) cargo build --manifest-path arbitrator/Cargo.toml --release -p jit ${CARGOFLAGS} install arbitrator/target/release/jit $@ -$(arbitrator_cases)/rust/$(wasm32_wasi)/%.wasm: $(arbitrator_cases)/rust/src/bin/%.rs $(arbitrator_cases)/rust/src/lib.rs - cargo build --manifest-path $(arbitrator_cases)/rust/Cargo.toml --release --bin $(patsubst $(arbitrator_cases)/rust/$(wasm32_wasi)/%.wasm,%, $@) +$(arbitrator_cases)/rust/$(wasm32_wasi)/%.wasm: $(arbitrator_cases)/rust/src/bin/%.rs $(arbitrator_cases)/rust/src/lib.rs $(arbitrator_cases)/rust/.cargo/config.toml + cargo build --manifest-path $(arbitrator_cases)/rust/Cargo.toml --release --target wasm32-wasi --config $(arbitrator_cases)/rust/.cargo/config.toml --bin $(patsubst $(arbitrator_cases)/rust/$(wasm32_wasi)/%.wasm,%, $@) $(arbitrator_cases)/go/testcase.wasm: $(arbitrator_cases)/go/*.go .make/solgen cd $(arbitrator_cases)/go && GOOS=wasip1 GOARCH=wasm go build -o testcase.wasm @@ -300,7 +301,7 @@ $(arbitrator_generated_header): $(DEP_PREDICATE) $(stylus_files) @touch -c $@ # cargo might decide to not rebuild the header $(output_latest)/wasi_stub.wasm: $(DEP_PREDICATE) $(call wasm_lib_deps,wasi-stub) - cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-unknown-unknown --package wasi-stub + cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-unknown-unknown --config $(wasm_lib_cargo) --package wasi-stub install arbitrator/wasm-libraries/$(wasm32_unknown)/wasi_stub.wasm $@ arbitrator/wasm-libraries/soft-float/SoftFloat/build/Wasm-Clang/softfloat.a: $(DEP_PREDICATE) \ @@ -342,23 +343,23 @@ $(output_latest)/soft-float.wasm: $(DEP_PREDICATE) \ --export wavm__f64_promote_f32 $(output_latest)/host_io.wasm: $(DEP_PREDICATE) $(call wasm_lib_deps,host-io) $(wasm_lib_go_abi) - cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --package host-io + cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --config $(wasm_lib_cargo) --package host-io install arbitrator/wasm-libraries/$(wasm32_wasi)/host_io.wasm $@ $(output_latest)/user_host.wasm: $(DEP_PREDICATE) $(wasm_lib_user_host) $(rust_prover_files) $(output_latest)/forward_stub.wasm .make/machines - cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --package user-host + cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --config $(wasm_lib_cargo) --package user-host install arbitrator/wasm-libraries/$(wasm32_wasi)/user_host.wasm $@ $(output_latest)/program_exec.wasm: $(DEP_PREDICATE) $(call wasm_lib_deps,program-exec) $(rust_prover_files) .make/machines - cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --package program-exec + cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --config $(wasm_lib_cargo) --package program-exec install arbitrator/wasm-libraries/$(wasm32_wasi)/program_exec.wasm $@ $(output_latest)/user_test.wasm: $(DEP_PREDICATE) $(call wasm_lib_deps,user-test) $(rust_prover_files) .make/machines - cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --package user-test + cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --config $(wasm_lib_cargo) --package user-test install arbitrator/wasm-libraries/$(wasm32_wasi)/user_test.wasm $@ $(output_latest)/arbcompress.wasm: $(DEP_PREDICATE) $(call wasm_lib_deps,brotli) $(wasm_lib_go_abi) - cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --package arbcompress + cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasi --config $(wasm_lib_cargo) --package arbcompress install arbitrator/wasm-libraries/$(wasm32_wasi)/arbcompress.wasm $@ $(output_latest)/forward.wasm: $(DEP_PREDICATE) $(wasm_lib_forward) .make/machines From 99173a9141900172f4802ffaa6737307ad9ff17c Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 11:45:21 -0500 Subject: [PATCH 255/268] Update dependencies --- arbitrator/Cargo.lock | 386 ++++---- arbitrator/langs/bf | 2 +- arbitrator/wasm-libraries/Cargo.lock | 318 +++---- arbitrator/wasm-testsuite/Cargo.lock | 1240 ++++++++++++++++++-------- 4 files changed, 1245 insertions(+), 701 deletions(-) diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 01774c0c4d..79a9117a31 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -37,7 +37,7 @@ dependencies = [ "cfg-if 1.0.0", "once_cell", "version_check", - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -87,9 +87,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -102,33 +102,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -184,16 +184,16 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", "cfg-if 1.0.0", "libc", "miniz_oxide", - "object 0.35.0", + "object 0.36.2", "rustc-demangle", ] @@ -208,14 +208,14 @@ name = "bench" version = "0.1.0" dependencies = [ "arbutil", - "clap 4.5.4", + "clap 4.5.13", "eyre", "gperftools", "hex", "prover", "serde", "serde_json", - "serde_with 3.8.1", + "serde_with 3.9.0", ] [[package]] @@ -235,9 +235,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -279,9 +279,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "blst" -version = "0.3.11" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +checksum = "4378725facc195f1a538864863f6de233b500a8862747e7f165078a419d5e874" dependencies = [ "cc", "glob", @@ -344,9 +344,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "fca2be1d5c43812bae364ee3f30b3afcb7877cf59f4aeb94c66f313a41d2fac9" [[package]] name = "c-kzg" @@ -381,13 +381,12 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.98" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" dependencies = [ "jobserver", "libc", - "once_cell", ] [[package]] @@ -459,9 +458,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", "clap_derive", @@ -469,9 +468,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -481,27 +480,27 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "convert_case" @@ -629,7 +628,7 @@ dependencies = [ "anes", "cast", "ciborium", - "clap 4.5.4", + "clap 4.5.13", "criterion-plot", "is-terminal", "itertools", @@ -718,12 +717,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "darling_core 0.20.9", - "darling_macro 0.20.9", + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -742,16 +741,16 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -767,13 +766,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "darling_core 0.20.9", + "darling_core 0.20.10", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -812,15 +811,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] @@ -870,9 +869,9 @@ dependencies = [ [[package]] name = "either" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "enum-iterator" @@ -911,28 +910,28 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "enumset" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d" +checksum = "d07a4b049558765cef5f0c1a273c3fc57084d768b44d2f98127aef4cceb17293" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" +checksum = "59c3b24c345d8c314966bdc1832f6c2635bfcce8e7cf363bd115987bba2ee242" dependencies = [ - "darling 0.20.9", + "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1159,9 +1158,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -1206,9 +1205,9 @@ dependencies = [ [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -1251,9 +1250,9 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] @@ -1278,9 +1277,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "leb128" @@ -1307,9 +1306,9 @@ dependencies = [ [[package]] name = "llvm-sys" -version = "150.1.3" +version = "150.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd60e740af945d99c2446a52e3ab8cdba2f740a40a16c51f6871bdea2abc687" +checksum = "88d6891afbe90a8be244f769dfe1db0b3c4880b8c44b12a6d0f7ab848d89b26d" dependencies = [ "cc", "lazy_static", @@ -1330,15 +1329,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ "hashbrown 0.14.5", ] @@ -1363,9 +1362,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -1408,9 +1407,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -1458,9 +1457,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -1489,7 +1488,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1544,23 +1543,23 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -1574,9 +1573,9 @@ dependencies = [ [[package]] name = "object" -version = "0.35.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] @@ -1589,9 +1588,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "opaque-debug" @@ -1636,9 +1635,9 @@ checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" dependencies = [ "num-traits", "plotters-backend", @@ -1649,15 +1648,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" dependencies = [ "plotters-backend", ] @@ -1670,9 +1669,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +dependencies = [ + "zerocopy 0.6.6", +] [[package]] name = "proc-macro-crate" @@ -1709,9 +1711,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1857,11 +1859,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -1878,9 +1880,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -1890,9 +1892,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -1901,9 +1903,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "region" @@ -2030,9 +2032,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -2050,22 +2052,23 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -2082,19 +2085,19 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_derive", "serde_json", - "serde_with_macros 3.8.1", + "serde_with_macros 3.9.0", "time", ] @@ -2112,14 +2115,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ - "darling 0.20.9", + "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2301,9 +2304,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -2318,9 +2321,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "textwrap" @@ -2333,22 +2336,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2412,9 +2415,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -2427,9 +2430,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" @@ -2437,7 +2440,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "toml_datetime", "winnow", ] @@ -2461,7 +2464,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -2493,9 +2496,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "user-host-trait" @@ -2510,15 +2513,15 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" [[package]] name = "vec_map" @@ -2528,9 +2531,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" @@ -2569,7 +2572,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -2591,7 +2594,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2775,8 +2778,8 @@ version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ - "bitflags 2.5.0", - "indexmap 2.2.6", + "bitflags 2.6.0", + "indexmap 2.3.0", "semver", ] @@ -2887,25 +2890,25 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.52.5", + "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2915,9 +2918,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2927,15 +2930,15 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2945,9 +2948,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2957,15 +2960,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2975,9 +2978,9 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -2999,22 +3002,43 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" +dependencies = [ + "byteorder", + "zerocopy-derive 0.6.6", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy-derive" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" dependencies = [ - "zerocopy-derive", + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] [[package]] @@ -3034,5 +3058,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.72", ] diff --git a/arbitrator/langs/bf b/arbitrator/langs/bf index cb5750580f..92420f8f34 160000 --- a/arbitrator/langs/bf +++ b/arbitrator/langs/bf @@ -1 +1 @@ -Subproject commit cb5750580f6990b5166ffce83de11b766a25ca31 +Subproject commit 92420f8f34b53f3c1d47047f9f894820d506c565 diff --git a/arbitrator/wasm-libraries/Cargo.lock b/arbitrator/wasm-libraries/Cargo.lock index 88525ececa..7620ff538b 100644 --- a/arbitrator/wasm-libraries/Cargo.lock +++ b/arbitrator/wasm-libraries/Cargo.lock @@ -27,9 +27,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "ansi_term" @@ -87,9 +87,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bincode" @@ -108,9 +108,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitvec" @@ -161,9 +161,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytecheck" @@ -189,9 +189,9 @@ dependencies = [ [[package]] name = "bytes" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "fca2be1d5c43812bae364ee3f30b3afcb7877cf59f4aeb94c66f313a41d2fac9" [[package]] name = "caller-env" @@ -273,12 +273,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "darling_core 0.20.8", - "darling_macro 0.20.8", + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -297,15 +297,15 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -321,13 +321,13 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.8" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "darling_core 0.20.8", + "darling_core 0.20.10", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -343,15 +343,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] @@ -375,9 +375,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "enum-iterator" @@ -390,11 +390,11 @@ dependencies = [ [[package]] name = "enum-iterator" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0b48d2b80ff6b002339547442496ea29d66a8c66ce8e1a6bd8c58b9cec7cf3" +checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" dependencies = [ - "enum-iterator-derive 1.3.1", + "enum-iterator-derive 1.4.0", ] [[package]] @@ -410,34 +410,34 @@ dependencies = [ [[package]] name = "enum-iterator-derive" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19cbb53d33b57ac4df1f0af6b92c38c107cded663c4aea9fae1189dcfc17cf5" +checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] name = "enumset" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d" +checksum = "d07a4b049558765cef5f0c1a273c3fc57084d768b44d2f98127aef4cceb17293" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" +checksum = "59c3b24c345d8c314966bdc1832f6c2635bfcce8e7cf363bd115987bba2ee242" dependencies = [ - "darling 0.20.8", + "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -488,9 +488,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if 1.0.0", "libc", @@ -508,9 +508,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -572,12 +572,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -591,9 +591,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "keccak" @@ -606,9 +606,9 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "leb128" @@ -618,15 +618,15 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -634,18 +634,18 @@ dependencies = [ [[package]] name = "lru" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memory_units" @@ -688,9 +688,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -702,20 +702,19 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ - "autocfg", "num-integer", "num-traits", ] [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] @@ -728,7 +727,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -742,9 +741,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -753,11 +752,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -765,32 +763,32 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "num_enum" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -807,9 +805,9 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -817,9 +815,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if 1.0.0", "libc", @@ -830,9 +828,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "proc-macro-crate" @@ -869,9 +867,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -890,7 +888,7 @@ dependencies = [ "brotli", "derivative", "digest 0.9.0", - "enum-iterator 2.0.1", + "enum-iterator 2.1.0", "eyre", "fnv", "hex", @@ -941,9 +939,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -980,11 +978,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", ] [[package]] @@ -1046,9 +1044,9 @@ checksum = "89dc553bc0cf4512a8b96caa2e21ed5f6e4b66bf28a1bd08fd9eb07c0b39b28c" [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc_version" @@ -1061,9 +1059,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "scopeguard" @@ -1079,37 +1077,38 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1196,9 +1195,9 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" dependencies = [ "serde", ] @@ -1258,9 +1257,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -1275,9 +1274,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "textwrap" @@ -1290,22 +1289,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] [[package]] @@ -1319,9 +1318,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -1334,9 +1333,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" @@ -1344,7 +1343,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.3.0", "toml_datetime", "winnow", ] @@ -1369,9 +1368,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "user-host" @@ -1415,9 +1414,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.7.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" [[package]] name = "vec_map" @@ -1427,9 +1426,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -1448,9 +1447,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.201.0" +version = "0.215.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9c7d2731df60006819b013f64ccc2019691deccf6e11a1804bc850cd6748f1a" +checksum = "4fb56df3e06b8e6b77e37d2969a50ba51281029a9aeb3855e76b7f49b6418847" dependencies = [ "leb128", ] @@ -1475,16 +1474,16 @@ version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ - "bitflags 2.5.0", - "indexmap 2.2.5", + "bitflags 2.6.0", + "indexmap 2.3.0", "semver", ] [[package]] name = "wast" -version = "201.0.0" +version = "215.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ef6e1ef34d7da3e2b374fd2b1a9c0227aff6cad596e1b24df9b58d0f6222faa" +checksum = "1ff1d00d893593249e60720be04a7c1f42f1c4dc3806a2869f4e66ab61eb54cb" dependencies = [ "bumpalo", "leb128", @@ -1495,9 +1494,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.201.0" +version = "1.215.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453d5b37a45b98dee4f4cb68015fc73634d7883bbef1c65e6e9c78d454cf3f32" +checksum = "670bf4d9c8cf76ae242d70ded47c546525b6dafaa6871f9bcb065344bf2b4e3d" dependencies = [ "wast", ] @@ -1538,13 +1537,14 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-targets" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -1553,45 +1553,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -1613,20 +1619,20 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.72", ] diff --git a/arbitrator/wasm-testsuite/Cargo.lock b/arbitrator/wasm-testsuite/Cargo.lock index c6f946b8ea..465464479f 100644 --- a/arbitrator/wasm-testsuite/Cargo.lock +++ b/arbitrator/wasm-testsuite/Cargo.lock @@ -4,11 +4,11 @@ version = 3 [[package]] name = "addr2line" -version = "0.19.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ - "gimli 0.27.0", + "gimli 0.29.0", ] [[package]] @@ -19,15 +19,33 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom", "once_cell", "version_check", ] +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if 1.0.0", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "ansi_term" version = "0.12.1" @@ -41,15 +59,26 @@ dependencies = [ name = "arbutil" version = "0.1.0" dependencies = [ - "sha3 0.10.6", + "digest 0.10.7", + "eyre", + "fnv", + "hex", + "num-traits", + "num_enum", + "ruint2", + "serde", + "sha2 0.10.8", + "sha3 0.10.8", "siphasher", + "tiny-keccak", + "wasmparser", ] [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "atty" @@ -57,26 +86,26 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", "winapi", ] [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", "object", @@ -98,6 +127,25 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "serde", + "tap", + "wyz", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -110,9 +158,9 @@ dependencies = [ [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] @@ -124,69 +172,92 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] -name = "brotli-sys" -version = "0.3.2" +name = "blst" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" +checksum = "4378725facc195f1a538864863f6de233b500a8862747e7f165078a419d5e874" dependencies = [ "cc", - "libc", + "glob", + "threadpool", + "zeroize", ] [[package]] -name = "brotli2" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" +name = "brotli" +version = "0.1.0" dependencies = [ - "brotli-sys", - "libc", + "lazy_static", + "num_enum", + "wasmer", + "wee_alloc", ] [[package]] name = "bumpalo" -version = "3.11.1" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytecheck" -version = "0.6.9" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f" +checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2" dependencies = [ "bytecheck_derive", "ptr_meta", + "simdutf8", ] [[package]] name = "bytecheck_derive" -version = "0.6.9" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" +checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.3.0" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fca2be1d5c43812bae364ee3f30b3afcb7877cf59f4aeb94c66f313a41d2fac9" + +[[package]] +name = "c-kzg" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" +checksum = "94a4bc5367b6284358d2a6a6a1dc2d92ec4b86034561c3b9d3341909752fd848" +dependencies = [ + "blst", + "cc", + "glob", + "hex", + "libc", + "serde", +] [[package]] name = "cc" -version = "1.0.73" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" + +[[package]] +name = "cfg-if" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cfg-if" @@ -202,44 +273,62 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", ] +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "corosensei" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9847f90f32a50b0dcbd68bc23ff242798b13080b97b0569f6ed96a45ce4cf2cd" +checksum = "80128832c58ea9cbd041d2a759ec449224487b2c1e400453d99d244eead87a8e" dependencies = [ "autocfg", - "cfg-if", + "cfg-if 1.0.0", "libc", "scopeguard", "windows-sys 0.33.0", ] +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + [[package]] name = "cranelift-bforest" -version = "0.86.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "529ffacce2249ac60edba2941672dfedf3d96558b415d0d8083cd007456e0f55" +checksum = "2a2ab4512dfd3a6f4be184403a195f76e81a8a9f9e6c898e19d2dc3ce20e0115" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.86.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427d105f617efc8cb55f8d036a7fded2e227892d8780b4985e5551f8d27c4a92" +checksum = "98b022ed2a5913a38839dfbafe6cf135342661293b08049843362df4301261dc" dependencies = [ + "arrayvec", + "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", + "cranelift-egraph", "cranelift-entity", "cranelift-isle", "gimli 0.26.2", @@ -251,30 +340,44 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.86.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551674bed85b838d45358e3eab4f0ffaa6790c70dc08184204b9a54b41cdb7d1" +checksum = "639307b45434ad112a98f8300c0f0ab085cbefcd767efcdef9ef19d4c0756e74" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.86.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b3a63ae57498c3eb495360944a33571754241e15e47e3bcae6082f40fec5866" +checksum = "278e52e29c53fcf32431ef08406c295699a70306d05a0715c5b1bf50e33a9ab7" + +[[package]] +name = "cranelift-egraph" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" +dependencies = [ + "cranelift-entity", + "fxhash", + "hashbrown 0.12.3", + "indexmap 1.9.3", + "log", + "smallvec", +] [[package]] name = "cranelift-entity" -version = "0.86.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11aa8aa624c72cc1c94ea3d0739fa61248260b5b14d3646f51593a88d67f3e6e" +checksum = "9a59bcbca89c3f1b70b93ab3cbba5e5e0cbf3e63dadb23c7525cb142e21a9d4c" [[package]] name = "cranelift-frontend" -version = "0.86.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "544ee8f4d1c9559c9aa6d46e7aaeac4a13856d620561094f35527356c7d21bd0" +checksum = "0d70abacb8cfef3dc8ff7e8836e9c1d70f7967dfdac824a4cd5e30223415aca6" dependencies = [ "cranelift-codegen", "log", @@ -284,54 +387,49 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.86.1" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed16b14363d929b8c37e3c557d0a7396791b383ecc302141643c054343170aad" +checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" [[package]] -name = "crossbeam-channel" -version = "0.5.4" +name = "crossbeam-deque" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", + "crossbeam-epoch", "crossbeam-utils", ] [[package]] -name = "crossbeam-deque" -version = "0.8.1" +name = "crossbeam-epoch" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "cfg-if", - "crossbeam-epoch", "crossbeam-utils", ] [[package]] -name = "crossbeam-epoch" -version = "0.9.8" +name = "crossbeam-queue" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "lazy_static", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.8" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" -dependencies = [ - "cfg-if", - "lazy_static", -] +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-common" @@ -355,12 +453,12 @@ dependencies = [ [[package]] name = "darling" -version = "0.14.2" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "darling_core 0.14.2", - "darling_macro 0.14.2", + "darling_core 0.20.10", + "darling_macro 0.20.10", ] [[package]] @@ -374,20 +472,20 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn", + "syn 1.0.109", ] [[package]] name = "darling_core" -version = "0.14.2" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] [[package]] @@ -398,18 +496,55 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core 0.13.4", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "darling_macro" -version = "0.14.2" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "darling_core 0.14.2", + "darling_core 0.20.10", "quote", - "syn", + "syn 2.0.72", +] + +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if 1.0.0", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.72", ] [[package]] @@ -423,11 +558,11 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", ] @@ -437,13 +572,13 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "add9a102807b524ec050363f09e06f1504214b0e1c7797f64261c891022dce8b" dependencies = [ - "bitflags", + "bitflags 1.3.2", "byteorder", "lazy_static", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -454,14 +589,14 @@ checksum = "64fba5a42bd76a17cad4bfa00de168ee1cbfa06a5e8ce992ae880218c05641a9" dependencies = [ "byteorder", "dynasm", - "memmap2", + "memmap2 0.5.10", ] [[package]] name = "either" -version = "1.6.1" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "enum-iterator" @@ -469,7 +604,16 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4eeac5c5edb79e4e39fe8439ef35207780a11f69c52cbe424ce3dfad4cb78de6" dependencies = [ - "enum-iterator-derive", + "enum-iterator-derive 0.7.0", +] + +[[package]] +name = "enum-iterator" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635" +dependencies = [ + "enum-iterator-derive 1.4.0", ] [[package]] @@ -480,35 +624,52 @@ checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "enum-iterator-derive" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", ] [[package]] name = "enumset" -version = "1.0.12" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" +checksum = "d07a4b049558765cef5f0c1a273c3fc57084d768b44d2f98127aef4cceb17293" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.6.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" +checksum = "59c3b24c345d8c314966bdc1832f6c2635bfcce8e7cf363bd115987bba2ee242" dependencies = [ - "darling 0.14.2", + "darling 0.20.10", "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "eyre" -version = "0.6.8" +version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" dependencies = [ "indenter", "once_cell", @@ -526,6 +687,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "fxhash" version = "0.2.1" @@ -537,9 +704,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -547,11 +714,11 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "wasi", ] @@ -563,21 +730,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" dependencies = [ "fallible-iterator", - "indexmap", + "indexmap 1.9.3", "stable_deref_trait", ] [[package]] name = "gimli" -version = "0.27.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec7af912d60cdbd3677c1af9352ebae6fb8394d165568a2234df0fa00f87793" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] -name = "hashbrown" -version = "0.11.2" +name = "glob" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" @@ -585,7 +752,17 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.8", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash 0.8.11", + "allocator-api2", ] [[package]] @@ -606,6 +783,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "hex" version = "0.4.3" @@ -626,40 +809,62 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "1.8.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown 0.11.2", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", ] [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.60" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "keccak" -version = "0.1.0" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "leb128" @@ -669,15 +874,15 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -685,11 +890,17 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "lru" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" dependencies = [ - "cfg-if", + "hashbrown 0.14.5", ] [[package]] @@ -701,30 +912,54 @@ dependencies = [ "libc", ] +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memmap2" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] [[package]] name = "memmap2" -version = "0.5.8" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" +checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872" dependencies = [ "libc", ] [[package]] name = "memoffset" -version = "0.6.5" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -733,9 +968,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -748,9 +983,9 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" [[package]] name = "nom" -version = "7.1.1" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", @@ -769,9 +1004,9 @@ dependencies = [ [[package]] name = "num" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -783,39 +1018,48 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ - "autocfg", "num-integer", "num-traits", ] [[package]] name = "num-complex" -version = "0.4.1" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fbc387afefefd5e9e39493299f3069e14a140dd34dc19b4c1c1a8fddb6a790" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -824,11 +1068,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -836,49 +1079,70 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] +[[package]] +name = "num_enum" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "object" -version = "0.30.0" +version = "0.36.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239da7f290cfa979f43f85a8efeee9a8a76d0827c356d37f9d3d7254d6b537fb" +checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.16.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -886,22 +1150,31 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.5" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", - "windows-sys 0.42.0", + "windows-targets", ] [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "proc-macro-crate" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit", +] [[package]] name = "proc-macro-error" @@ -912,7 +1185,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -929,11 +1202,11 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.38" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] @@ -942,22 +1215,32 @@ version = "0.1.0" dependencies = [ "arbutil", "bincode", - "brotli2", + "bitvec", + "brotli", + "c-kzg", + "derivative", "digest 0.9.0", + "enum-iterator 2.1.0", "eyre", "fnv", "hex", + "itertools", "lazy_static", "libc", + "lru", "nom", "nom-leb128", "num", + "num-derive", + "num-traits", + "once_cell", "parking_lot", "rayon", "rustc-demangle", "serde", "serde_json", "serde_with", + "sha2 0.9.9", "sha3 0.9.1", "smallvec", "static_assertions", @@ -966,6 +1249,7 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-types", "wasmparser", + "wat", ] [[package]] @@ -985,56 +1269,58 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "quote" -version = "1.0.18" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rayon" -version = "1.5.2" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ - "bitflags", + "bitflags 2.6.0", ] [[package]] name = "regalloc2" -version = "0.3.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d43a209257d978ef079f3d446331d0f1794f5e0fc19b306a199983857833a779" +checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" dependencies = [ "fxhash", "log", @@ -1044,74 +1330,99 @@ dependencies = [ [[package]] name = "region" -version = "3.0.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "e6b6ebd13bc009aef9cd476c1310d49ac354d36e240cf1bd753290f3dc7199a7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", - "mach", - "winapi", + "mach2", + "windows-sys 0.52.0", ] [[package]] name = "rend" -version = "0.3.6" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95" +checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c" dependencies = [ "bytecheck", ] [[package]] name = "rkyv" -version = "0.7.39" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15" +checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0" dependencies = [ + "bitvec", "bytecheck", + "bytes", "hashbrown 0.12.3", - "indexmap", + "indexmap 1.9.3", "ptr_meta", "rend", "rkyv_derive", "seahash", + "tinyvec", + "uuid", ] [[package]] name = "rkyv_derive" -version = "0.7.39" +version = "0.7.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eaedadc88b53e36dd32d940ed21ae4d850d5916f2581526921f553a72ac34c4" +checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] +[[package]] +name = "ruint2" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b066b8e4fcea7fae86b6932d2449670b6b5545b7e8407841b2d3a916ff2a9f86" +dependencies = [ + "derive_more", + "ruint2-macro", + "rustc_version", + "thiserror", +] + +[[package]] +name = "ruint2-macro" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89dc553bc0cf4512a8b96caa2e21ed5f6e4b66bf28a1bd08fd9eb07c0b39b28c" + [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] -name = "rustversion" -version = "1.0.6" +name = "rustc_version" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "seahash" @@ -1119,11 +1430,23 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "self_cell" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + [[package]] name = "serde" -version = "1.0.137" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -1141,33 +1464,33 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.81" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] [[package]] name = "serde_with" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b827f2113224f3f19a665136f006709194bdfdcb1fdc1e4b2b5cbac8e0cced54" +checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ - "rustversion", "serde", "serde_with_macros", ] @@ -1181,7 +1504,31 @@ dependencies = [ "darling 0.13.4", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.7", ] [[package]] @@ -1198,31 +1545,47 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "keccak", ] +[[package]] +name = "shared-buffer" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6c99835bad52957e7aa241d3975ed17c1e5f8c92026377d117a606f36b84b16" +dependencies = [ + "bytes", + "memmap2 0.6.2", +] + +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slice-group-by" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" dependencies = [ "serde", ] @@ -1272,25 +1635,42 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] name = "syn" -version = "1.0.94" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a07e33e919ebcd69113d5be0e4d70c5707004ff45188910106854f38b960df4a" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "textwrap" @@ -1303,31 +1683,80 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap 2.3.0", + "toml_datetime", + "winnow", ] [[package]] name = "tracing" -version = "0.1.36" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1335,47 +1764,53 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.22" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "typenum" -version = "1.15.0" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" -version = "1.9.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] -name = "unicode-xid" -version = "0.2.3" +name = "uuid" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" [[package]] name = "vec_map" @@ -1385,9 +1820,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasi" @@ -1397,57 +1832,34 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.72", "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-downcast" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dac026d43bcca6e7ce1c0956ba68f59edf6403e8e930a5d891be72c31a44340" -dependencies = [ - "js-sys", - "once_cell", - "wasm-bindgen", - "wasm-bindgen-downcast-macros", -] - -[[package]] -name = "wasm-bindgen-downcast-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5020cfa87c7cecefef118055d44e3c1fc122c7ec25701d528ee458a0b45f38f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1455,28 +1867,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-encoder" -version = "0.20.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05632e0a66a6ed8cca593c24223aabd6262f256c3693ad9822c315285f010614" +checksum = "1ba64e81215916eaeb48fee292f29401d69235d62d8b8fd92a7b2844ec5ae5f7" dependencies = [ "leb128", ] @@ -1496,19 +1908,22 @@ dependencies = [ [[package]] name = "wasmer" -version = "3.1.0" +version = "4.2.8" dependencies = [ "bytes", - "cfg-if", - "indexmap", + "cfg-if 1.0.0", + "derivative", + "indexmap 1.9.3", "js-sys", "more-asserts", + "rustc-demangle", "serde", "serde-wasm-bindgen", + "shared-buffer", "target-lexicon", "thiserror", + "tracing", "wasm-bindgen", - "wasm-bindgen-downcast", "wasmer-compiler", "wasmer-compiler-cranelift", "wasmer-derive", @@ -1520,18 +1935,21 @@ dependencies = [ [[package]] name = "wasmer-compiler" -version = "3.1.0" +version = "4.2.8" dependencies = [ "backtrace", - "cfg-if", - "enum-iterator", + "bytes", + "cfg-if 1.0.0", + "enum-iterator 0.7.0", "enumset", "lazy_static", "leb128", - "memmap2", + "memmap2 0.5.10", "more-asserts", "region", - "rustc-demangle", + "rkyv", + "self_cell", + "shared-buffer", "smallvec", "thiserror", "wasmer-types", @@ -1542,7 +1960,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-cranelift" -version = "3.1.0" +version = "4.2.8" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1559,7 +1977,7 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "3.1.0" +version = "4.2.8" dependencies = [ "byteorder", "dynasm", @@ -1576,21 +1994,22 @@ dependencies = [ [[package]] name = "wasmer-derive" -version = "3.1.0" +version = "4.2.8" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "wasmer-types" -version = "3.1.0" +version = "4.2.8" dependencies = [ - "enum-iterator", + "bytecheck", + "enum-iterator 0.7.0", "enumset", - "indexmap", + "indexmap 1.9.3", "more-asserts", "rkyv", "target-lexicon", @@ -1599,14 +2018,18 @@ dependencies = [ [[package]] name = "wasmer-vm" -version = "3.1.0" +version = "4.2.8" dependencies = [ "backtrace", "cc", - "cfg-if", + "cfg-if 1.0.0", "corosensei", - "enum-iterator", - "indexmap", + "crossbeam-queue", + "dashmap", + "derivative", + "enum-iterator 0.7.0", + "fnv", + "indexmap 1.9.3", "lazy_static", "libc", "mach", @@ -1621,15 +2044,20 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.83.0" +version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718ed7c55c2add6548cca3ddd6383d738cd73b892df400e96b9aa876f0141d7a" +checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" +dependencies = [ + "bitflags 2.6.0", + "indexmap 2.3.0", + "semver", +] [[package]] name = "wast" -version = "50.0.0" +version = "64.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2cbb59d4ac799842791fe7e806fa5dbbf6b5554d538e51cc8e176db6ff0ae34" +checksum = "a259b226fd6910225aa7baeba82f9d9933b6d00f2ce1b49b80fa4214328237cc" dependencies = [ "leb128", "memchr", @@ -1639,13 +2067,25 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.52" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "584aaf7a1ecf4d383bbe1a25eeab0cbb8ff96acc6796707ff65cde48f4632f15" +checksum = "53253d920ab413fca1c7dc2161d601c79b4fdf631d0ba51dd4343bf9b556c3f6" dependencies = [ "wast", ] +[[package]] +name = "wee_alloc" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "memory_units", + "winapi", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1683,24 +2123,34 @@ dependencies = [ [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", - "windows_aarch64_msvc 0.42.0", - "windows_i686_gnu 0.42.0", - "windows_i686_msvc 0.42.0", - "windows_x86_64_gnu 0.42.0", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm", - "windows_x86_64_msvc 0.42.0", + "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -1710,9 +2160,9 @@ checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" [[package]] name = "windows_aarch64_msvc" -version = "0.42.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -1722,9 +2172,15 @@ checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" [[package]] name = "windows_i686_gnu" -version = "0.42.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -1734,9 +2190,9 @@ checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" [[package]] name = "windows_i686_msvc" -version = "0.42.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -1746,15 +2202,15 @@ checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" [[package]] name = "windows_x86_64_gnu" -version = "0.42.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -1764,6 +2220,64 @@ checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" [[package]] name = "windows_x86_64_msvc" -version = "0.42.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + +[[package]] +name = "wyz" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] From b2820949a2abe581f99b8670ab4e1abbda42f445 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 12:03:13 -0500 Subject: [PATCH 256/268] Add type annotations to fix new clippy lint --- arbitrator/brotli/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arbitrator/brotli/src/lib.rs b/arbitrator/brotli/src/lib.rs index 5bc2e8dcf6..b2c808b1a4 100644 --- a/arbitrator/brotli/src/lib.rs +++ b/arbitrator/brotli/src/lib.rs @@ -192,7 +192,7 @@ pub fn compress_fixed<'a>( BrotliEncoderDestroyInstance(state); // SAFETY: brotli initialized this span of bytes - let output = mem::transmute(&output[..out_len]); + let output = mem::transmute::<&[MaybeUninit], &[u8]>(&output[..out_len]); Ok(output) } } @@ -304,7 +304,7 @@ pub fn decompress_fixed<'a>( BrotliDecoderDestroyInstance(state); // SAFETY: brotli initialized this span of bytes - let output = mem::transmute(&output[..out_len]); + let output = mem::transmute::<&[MaybeUninit], &[u8]>(&output[..out_len]); Ok(output) } } From 7015530b10a12e6837820b2e8e001cbc3e14f094 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 12:07:09 -0500 Subject: [PATCH 257/268] Update rust pin in Dockerfile --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6383a2c0cb..ea473055aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,8 +45,8 @@ FROM wasm-base AS wasm-libs-builder # clang / lld used by soft-float wasm RUN apt-get update && \ apt-get install -y clang=1:14.0-55.7~deb12u1 lld=1:14.0-55.7~deb12u1 wabt - # pinned rust 1.75.0 -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.75.0 --target x86_64-unknown-linux-gnu wasm32-unknown-unknown wasm32-wasi + # pinned rust 1.80.0 +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.80.0 --target x86_64-unknown-linux-gnu wasm32-unknown-unknown wasm32-wasi COPY ./Makefile ./ COPY arbitrator/Cargo.* arbitrator/ COPY arbitrator/arbutil arbitrator/arbutil @@ -94,7 +94,7 @@ COPY --from=contracts-builder workspace/contracts/node_modules/@offchainlabs/upg COPY --from=contracts-builder workspace/.make/ .make/ RUN PATH="$PATH:/usr/local/go/bin" NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-wasm-bin -FROM rust:1.75-slim-bookworm AS prover-header-builder +FROM rust:1.80-slim-bookworm AS prover-header-builder WORKDIR /workspace RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ @@ -120,7 +120,7 @@ RUN NITRO_BUILD_IGNORE_TIMESTAMPS=1 make build-prover-header FROM scratch AS prover-header-export COPY --from=prover-header-builder /workspace/target/ / -FROM rust:1.75-slim-bookworm AS prover-builder +FROM rust:1.80-slim-bookworm AS prover-builder WORKDIR /workspace RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ From 7cf4e9b6eed6a79ec26666180321be5e1a847f0b Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 12:38:27 -0500 Subject: [PATCH 258/268] Add type parameters to remaining transmute calls --- arbitrator/jit/src/caller_env.rs | 2 +- arbitrator/prover/src/utils.rs | 4 ++-- arbitrator/stylus/src/host.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arbitrator/jit/src/caller_env.rs b/arbitrator/jit/src/caller_env.rs index f4fbff10ae..746f427e36 100644 --- a/arbitrator/jit/src/caller_env.rs +++ b/arbitrator/jit/src/caller_env.rs @@ -102,7 +102,7 @@ impl MemAccess for JitMemAccess<'_> { self.view() .read_uninit(ptr.into(), &mut data) .expect("bad read"); - mem::transmute(data) + mem::transmute::>, Vec>(data) } } diff --git a/arbitrator/prover/src/utils.rs b/arbitrator/prover/src/utils.rs index 49b4ea0c3d..48889e1199 100644 --- a/arbitrator/prover/src/utils.rs +++ b/arbitrator/prover/src/utils.rs @@ -82,13 +82,13 @@ struct RemoteRefType(pub [u8; 3]); impl From for RemoteRefType { fn from(value: RefType) -> Self { - unsafe { std::mem::transmute(value) } + unsafe { std::mem::transmute::(value) } } } impl From for RefType { fn from(value: RemoteRefType) -> Self { - unsafe { std::mem::transmute(value) } + unsafe { std::mem::transmute::(value) } } } diff --git a/arbitrator/stylus/src/host.rs b/arbitrator/stylus/src/host.rs index 7854386e23..1afc1b4e51 100644 --- a/arbitrator/stylus/src/host.rs +++ b/arbitrator/stylus/src/host.rs @@ -64,7 +64,7 @@ where unsafe { data.set_len(len); self.view().read_uninit(ptr.into(), &mut data)?; - Ok(mem::transmute(data)) + Ok(mem::transmute::>, Vec>(data)) } } From 25f38e515bef81960fb2723cc692908b34779703 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 12:57:18 -0500 Subject: [PATCH 259/268] Fix never type fallback usage --- arbitrator/stylus/src/native.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrator/stylus/src/native.rs b/arbitrator/stylus/src/native.rs index 2858d59fdc..a7b996edf0 100644 --- a/arbitrator/stylus/src/native.rs +++ b/arbitrator/stylus/src/native.rs @@ -367,7 +367,7 @@ pub fn module(wasm: &[u8], compile: CompileConfig) -> Result> { Function::new_typed(&mut store, $($types)+ -> f64 { panic!("incomplete import") }) }; ($($types:tt)+) => { - Function::new_typed(&mut store, $($types)+ panic!("incomplete import")) + Function::new_typed(&mut store, $($types)+ -> () { panic!("incomplete import") }) }; } let mut imports = imports! { From 46b944d0deec8431bd5465ca32a0cfebea6ad958 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 14:02:43 -0500 Subject: [PATCH 260/268] Remove unused fields --- arbitrator/jit/src/caller_env.rs | 9 --------- arbitrator/jit/src/machine.rs | 5 +---- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/arbitrator/jit/src/caller_env.rs b/arbitrator/jit/src/caller_env.rs index 746f427e36..41240d3d98 100644 --- a/arbitrator/jit/src/caller_env.rs +++ b/arbitrator/jit/src/caller_env.rs @@ -8,7 +8,6 @@ use rand::RngCore; use rand_pcg::Pcg32; use std::{ cmp::Ordering, - collections::{BTreeSet, BinaryHeap}, fmt::Debug, mem::{self, MaybeUninit}, }; @@ -175,11 +174,3 @@ impl PartialOrd for TimeoutInfo { Some(self.cmp(other)) } } - -#[derive(Default, Debug)] -pub struct TimeoutState { - /// Contains tuples of (time, id) - pub times: BinaryHeap, - pub pending_ids: BTreeSet, - pub next_id: u32, -} diff --git a/arbitrator/jit/src/machine.rs b/arbitrator/jit/src/machine.rs index f51970c6dd..2a3c5c5616 100644 --- a/arbitrator/jit/src/machine.rs +++ b/arbitrator/jit/src/machine.rs @@ -15,7 +15,7 @@ use std::{ io::{BufReader, BufWriter, ErrorKind, Read}, net::TcpStream, sync::Arc, - time::{Duration, Instant}, + time::Instant, }; use thiserror::Error; use wasmer::{ @@ -322,8 +322,6 @@ pub struct ProcessEnv { pub socket: Option<(BufWriter, BufReader)>, /// A timestamp that helps with printing at various moments pub timestamp: Instant, - /// How long to wait on any child threads to compute a result - pub child_timeout: Duration, /// Whether the machine has reached the first wavmio instruction pub reached_wavmio: bool, } @@ -335,7 +333,6 @@ impl Default for ProcessEnv { debug: false, socket: None, timestamp: Instant::now(), - child_timeout: Duration::from_secs(15), reached_wavmio: false, } } From 68e1941e80fecfef1e2922271f13e53e0b28ce1c Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 14:35:51 -0500 Subject: [PATCH 261/268] Try enabling build-std for cargo --- arbitrator/prover/test-cases/rust/.cargo/config.toml | 3 +++ arbitrator/wasm-libraries/.cargo/config.toml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/arbitrator/prover/test-cases/rust/.cargo/config.toml b/arbitrator/prover/test-cases/rust/.cargo/config.toml index ac75d66caa..23ffbe67c1 100644 --- a/arbitrator/prover/test-cases/rust/.cargo/config.toml +++ b/arbitrator/prover/test-cases/rust/.cargo/config.toml @@ -5,3 +5,6 @@ target = "wasm32-wasi" rustflags = [ "-C", "target-cpu=mvp", ] + +[unstable] +build-std = ["core", "panic_abort", "alloc", "std"] diff --git a/arbitrator/wasm-libraries/.cargo/config.toml b/arbitrator/wasm-libraries/.cargo/config.toml index f13dbab7ed..797b856fbf 100644 --- a/arbitrator/wasm-libraries/.cargo/config.toml +++ b/arbitrator/wasm-libraries/.cargo/config.toml @@ -7,3 +7,6 @@ rustflags = [ rustflags = [ "-C", "target-cpu=mvp", ] + +[unstable] +build-std = ["core", "panic_abort", "alloc", "std"] From 00ffcaceea9893375c94eb5f58a1060ca56fe989 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 14:49:34 -0500 Subject: [PATCH 262/268] Allow .wasm suffix in find_module --- arbitrator/prover/src/machine.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index c7550e642a..e4f1aecc99 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1725,7 +1725,7 @@ impl Machine { /// finds the first module with the given name pub fn find_module(&self, name: &str) -> Result { - let Some(module) = self.modules.iter().position(|m| m.name() == name) else { + let Some(module) = self.modules.iter().position(|m| m.name().trim_end_matches(".wasm") == name) else { let names: Vec<_> = self.modules.iter().map(|m| m.name()).collect(); let names = names.join(", "); bail!("module {} not found among: {names}", name.red()) From 1d8209eb6404b4bd77c827945eb0d7790a99b745 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 1 Aug 2024 15:02:56 -0500 Subject: [PATCH 263/268] Fix formatting --- arbitrator/prover/src/machine.rs | 6 +++++- arbitrator/prover/src/value.rs | 5 +---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arbitrator/prover/src/machine.rs b/arbitrator/prover/src/machine.rs index e4f1aecc99..358876bd25 100644 --- a/arbitrator/prover/src/machine.rs +++ b/arbitrator/prover/src/machine.rs @@ -1725,7 +1725,11 @@ impl Machine { /// finds the first module with the given name pub fn find_module(&self, name: &str) -> Result { - let Some(module) = self.modules.iter().position(|m| m.name().trim_end_matches(".wasm") == name) else { + let Some(module) = self + .modules + .iter() + .position(|m| m.name().trim_end_matches(".wasm") == name) + else { let names: Vec<_> = self.modules.iter().map(|m| m.name()).collect(); let names = names.join(", "); bail!("module {} not found among: {names}", name.red()) diff --git a/arbitrator/prover/src/value.rs b/arbitrator/prover/src/value.rs index 5243472638..6afffdf7a0 100644 --- a/arbitrator/prover/src/value.rs +++ b/arbitrator/prover/src/value.rs @@ -133,10 +133,7 @@ pub struct ProgramCounter { pub inst: u32, } -#[cfg(not(any( - target_pointer_width = "32", - target_pointer_width = "64", -)))] +#[cfg(not(any(target_pointer_width = "32", target_pointer_width = "64",)))] compile_error!("Architectures with less than a 32 bit pointer width are not supported"); impl ProgramCounter { From b2d7f0867a257de33b8073d8301645968cbda1fe Mon Sep 17 00:00:00 2001 From: Tsahi Zidenberg Date: Thu, 1 Aug 2024 16:49:52 -0600 Subject: [PATCH 264/268] testredisproduce: trigger trim --- pubsub/pubsub_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pubsub/pubsub_test.go b/pubsub/pubsub_test.go index a3140e32ac..9f774b6372 100644 --- a/pubsub/pubsub_test.go +++ b/pubsub/pubsub_test.go @@ -284,6 +284,8 @@ func TestRedisProduce(t *testing.T) { if cnt := producer.promisesLen(); cnt != 0 { t.Errorf("Producer still has %d unfullfilled promises", cnt) } + // Trigger a trim + producer.checkResponses(ctx) msgs, err := redisClient.XRange(ctx, streamName, "-", "+").Result() if err != nil { t.Errorf("XRange failed: %v", err) From ec1cbaebff9bad8bc8889db8c98eb76dc066ddfa Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Fri, 2 Aug 2024 12:05:04 +0200 Subject: [PATCH 265/268] Don't error if can't fetch metadata for metrics --- arbnode/dataposter/data_poster.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index ac76da276d..001fdab76e 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -1184,18 +1184,15 @@ func (p *DataPoster) Start(ctxIn context.Context) { latestCumulativeWeight = latestQueued.CumulativeWeight() latestNonce = latestQueued.FullTx.Nonce() - var confirmedWeight uint64 confirmedNonce := unconfirmedNonce - 1 confirmedMeta, err := p.queue.Get(ctx, confirmedNonce) - if err != nil { - log.Error("Failed to fetxh latest confirmed tx from queue", "err", err) - return minWait - } - if confirmedMeta != nil { - confirmedWeight = confirmedMeta.CumulativeWeight() + if err == nil && confirmedMeta != nil { + totalQueueWeightGauge.Update(int64(arbmath.SaturatingUSub(latestCumulativeWeight, confirmedMeta.CumulativeWeight()))) + totalQueueLengthGauge.Update(int64(arbmath.SaturatingUSub(latestNonce, confirmedNonce))) + } else { + log.Error("Failed to fetch latest confirmed tx from queue", "err", err, "confirmedMeta", confirmedMeta) } - totalQueueWeightGauge.Update(int64(arbmath.SaturatingUSub(latestCumulativeWeight, confirmedWeight))) - totalQueueLengthGauge.Update(int64(arbmath.SaturatingUSub(latestNonce, confirmedNonce))) + } for _, tx := range queueContents { From cf9450f4dab169766fb12cfe2b50b897832383e5 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Fri, 2 Aug 2024 15:26:19 +0200 Subject: [PATCH 266/268] Fix a bug with odd-length resize calls The dirty_parents bitvec was not being resized correctly when the leaves were resized to an odd length. This PR adds tests and the fix. --- arbitrator/prover/src/merkle.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arbitrator/prover/src/merkle.rs b/arbitrator/prover/src/merkle.rs index 98ba6591f0..4a1278b4cb 100644 --- a/arbitrator/prover/src/merkle.rs +++ b/arbitrator/prover/src/merkle.rs @@ -377,7 +377,7 @@ impl Merkle { // This will set one or no values depending on if the length was even or odd. layers.dirty_leaf_parents[(start >> 1)..].fill(true); // This then resizes and marks the dirty leaf parents as dirty. - layers.dirty_leaf_parents.resize(new_len >> 1, true); + layers.dirty_leaf_parents.resize((new_len + 1) >> 1, true); Ok(layers.data[0].len()) } } @@ -528,6 +528,20 @@ mod test { assert_eq!(merkle.capacity(), 1024); } + #[test] + fn resize_and_set_odd() { + let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 20); + merkle.resize(9).expect("resize failed"); + merkle.set(8, Bytes32::from([2; 32])); + } + + #[test] + fn resize_and_set_even() { + let merkle = Merkle::new_advanced(MerkleType::Value, vec![Bytes32::from([1; 32])], 20); + merkle.resize(10).expect("resize failed"); + merkle.set(9, Bytes32::from([2; 32])); + } + #[test] #[ignore = "This is just used for generating the zero hashes for the memory merkle trees."] fn emit_memory_zerohashes() { From 29e8d454a4d8067bb88bb0edcecad3ab5297e9b0 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 2 Aug 2024 17:39:38 -0300 Subject: [PATCH 267/268] Fixes blocks hashes retrieval in PopulateFeedBacklog --- arbnode/inbox_tracker.go | 2 +- system_tests/seqfeed_test.go | 59 ++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/arbnode/inbox_tracker.go b/arbnode/inbox_tracker.go index b621b12650..23b81bde62 100644 --- a/arbnode/inbox_tracker.go +++ b/arbnode/inbox_tracker.go @@ -300,7 +300,7 @@ func (t *InboxTracker) PopulateFeedBacklog(broadcastServer *broadcaster.Broadcas return fmt.Errorf("error getting message %v: %w", seqNum, err) } - msgResult, err := t.txStreamer.ResultAtCount(seqNum) + msgResult, err := t.txStreamer.ResultAtCount(seqNum + 1) var blockHash *common.Hash if err == nil { blockHash = &msgResult.BlockHash diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index 4a4dd3fee5..a628c2b496 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -431,3 +431,62 @@ func TestBlockHashFeedMismatch(t *testing.T) { func TestBlockHashFeedNil(t *testing.T) { testBlockHashComparison(t, nil, false) } + +func TestPopulateFeedBacklog(t *testing.T) { + logHandler := testhelpers.InitTestLog(t, log.LvlTrace) + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + builder := NewNodeBuilder(ctx).DefaultConfig(t, true) + builder.BuildL1(t) + + userAccount := "User2" + builder.L2Info.GenerateAccount(userAccount) + + // Guarantees that nodes will rely only on the feed to receive messages + builder.nodeConfig.BatchPoster.Enable = false + builder.BuildL2OnL1(t) + + dataDir := builder.l2StackConfig.DataDir + + // Sends a transaction + tx := builder.L2Info.PrepareTx("Owner", userAccount, builder.L2Info.TransferGas, big.NewInt(1e12), nil) + err := builder.L2.Client.SendTransaction(ctx, tx) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + // Shutdown node and starts a new one with same data dir and feed output enabled. + // The new node will populate the feedbacklog since already a message, related to the + // transaction previously sent, stored in disk. + builder.L2.cleanup() + builder.l2StackConfig.DataDir = dataDir + builder.nodeConfig.Feed.Output = *newBroadcasterConfigTest() + cleanup := builder.BuildL2OnL1(t) + defer cleanup() + + // Creates a sink node, that will read from the feed output of the previous node. + nodeConfigSink := builder.nodeConfig + port := builder.L2.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port + nodeConfigSink.Feed.Input = *newBroadcastClientConfigTest(port) + testClientSink, cleanupSink := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: nodeConfigSink}) + defer cleanupSink() + + // Waits for the transaction to be processed by the sink node. + _, err = WaitForTx(ctx, testClientSink.Client, tx.Hash(), time.Second*5) + if err != nil { + t.Fatal("error waiting for transaction to get to sink:", err) + } + balance, err := testClientSink.Client.BalanceAt(ctx, builder.L2Info.GetAddress(userAccount), nil) + if err != nil { + t.Fatal("error getting fraud balance:", err) + } + if balance.Cmp(big.NewInt(1e12)) != 0 { + t.Fatal("Unexpected balance:", balance) + } + + if logHandler.WasLogged(arbnode.BlockHashMismatchLogMsg) { + t.Fatal("BlockHashMismatchLogMsg was logged unexpectedly") + } +} From ee92f6bee0b3b1df8c8f2efb0c9f95418be36cc8 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 2 Aug 2024 19:14:34 -0300 Subject: [PATCH 268/268] Fixes comments --- system_tests/seqfeed_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index a628c2b496..5e70fdf098 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -457,8 +457,8 @@ func TestPopulateFeedBacklog(t *testing.T) { _, err = builder.L2.EnsureTxSucceeded(tx) Require(t, err) - // Shutdown node and starts a new one with same data dir and feed output enabled. - // The new node will populate the feedbacklog since already a message, related to the + // Shutdown node and starts a new one with same data dir and output feed enabled. + // The new node will populate the feedbacklog since already has a message, related to the // transaction previously sent, stored in disk. builder.L2.cleanup() builder.l2StackConfig.DataDir = dataDir @@ -466,7 +466,7 @@ func TestPopulateFeedBacklog(t *testing.T) { cleanup := builder.BuildL2OnL1(t) defer cleanup() - // Creates a sink node, that will read from the feed output of the previous node. + // Creates a sink node that will read from the output feed of the previous node. nodeConfigSink := builder.nodeConfig port := builder.L2.ConsensusNode.BroadcastServer.ListenerAddr().(*net.TCPAddr).Port nodeConfigSink.Feed.Input = *newBroadcastClientConfigTest(port)