From 733b1a2562fc4416f7d05d76d939ada144a56456 Mon Sep 17 00:00:00 2001 From: "Joshua J. Bouw" Date: Mon, 15 May 2023 16:53:25 +0400 Subject: [PATCH] Release v2.9.1 (#758) ## 2.9.1 2023-05-11 ### Changes - Removed unused state variable `bridge_prover_id` by @birchmd. (#749) - `modexp` has been improved to be greatly faster than before by @birchmd. (#757) ### Fixes - Fixed an issue where the owner could call `new` multiple times by @lempire123. (#733) - Fixed an issue with `deploy_upgrade` where the upgrade index isn't cleared by @lempire123. (#741) --------- Co-authored-by: lempire123 <61431140+lempire123@users.noreply.github.com> Co-authored-by: Oleksandr Anyshchenko Co-authored-by: Michael Birch --- CHANGES.md | 20 +- Cargo.lock | 2094 ++++++++++++----- Cargo.toml | 2 + Makefile.toml | 19 +- VERSION | 2 +- engine-modexp/Cargo.toml | 25 + engine-modexp/README.md | 32 + engine-modexp/src/arith.rs | 706 ++++++ engine-modexp/src/lib.rs | 50 + engine-modexp/src/maybe_std.rs | 8 + engine-modexp/src/mpnat.rs | 730 ++++++ engine-precompiles/Cargo.toml | 1 + engine-precompiles/src/modexp.rs | 37 +- engine-precompiles/src/xcc.rs | 2 +- engine-sdk/src/near_runtime.rs | 2 +- engine-standalone-storage/src/lib.rs | 10 +- .../src/relayer_db/mod.rs | 3 +- engine-standalone-storage/src/sync/mod.rs | 8 + engine-standalone-storage/src/sync/types.rs | 10 + engine-standalone-tracing/src/types/mod.rs | 6 +- engine-tests/Cargo.toml | 45 +- engine-tests/src/benches/eth_deploy_code.rs | 7 +- engine-tests/src/benches/eth_erc20.rs | 16 +- .../src/benches/eth_standard_precompiles.rs | 10 +- engine-tests/src/benches/eth_transfer.rs | 8 +- engine-tests/src/benches/nft_pagination.rs | 8 +- engine-tests/src/benches/uniswap.rs | 26 +- .../src/test_utils/exit_precompile.rs | 6 +- .../src/test_utils/mocked_external.rs | 3 +- engine-tests/src/test_utils/mod.rs | 269 +-- engine-tests/src/test_utils/rust.rs | 8 +- engine-tests/src/test_utils/self_destruct.rs | 2 +- engine-tests/src/test_utils/solidity.rs | 1 - .../src/test_utils/standalone/mocks/mod.rs | 5 +- engine-tests/src/test_utils/standalone/mod.rs | 31 +- engine-tests/src/tests/contract_call.rs | 4 +- engine-tests/src/tests/eip1559.rs | 9 +- engine-tests/src/tests/erc20.rs | 24 +- engine-tests/src/tests/erc20_connector.rs | 119 +- engine-tests/src/tests/eth_connector.rs | 7 +- engine-tests/src/tests/ghsa_3p69_m8gg_fwmf.rs | 7 +- engine-tests/src/tests/modexp.rs | 276 ++- engine-tests/src/tests/one_inch.rs | 8 +- .../src/tests/pausable_precompiles.rs | 58 +- .../src/tests/promise_results_precompile.rs | 2 +- engine-tests/src/tests/repro.rs | 41 +- engine-tests/src/tests/sanity.rs | 163 +- .../src/tests/standalone/json_snapshot.rs | 6 +- engine-tests/src/tests/standalone/sanity.rs | 1 - .../src/tests/standard_precompiles.rs | 2 +- engine-tests/src/tests/state_migration.rs | 24 +- engine-tests/src/tests/uniswap.rs | 6 +- engine-tests/src/tests/xcc.rs | 55 +- engine-types/src/storage.rs | 2 +- engine/Cargo.toml | 4 +- engine/src/engine.rs | 2 +- engine/src/lib.rs | 30 +- engine/src/parameters.rs | 37 +- engine/src/state.rs | 132 +- engine/src/xcc.rs | 2 +- etc/tests/modexp-bench/Cargo.toml | 20 + etc/tests/modexp-bench/res/evm_contract_1.hex | 1 + etc/tests/modexp-bench/res/evm_contract_2.hex | 1 + etc/tests/modexp-bench/src/lib.rs | 79 + etc/tests/state-migration-test/src/lib.rs | 12 +- rust-toolchain | 2 +- 66 files changed, 4213 insertions(+), 1135 deletions(-) create mode 100644 engine-modexp/Cargo.toml create mode 100644 engine-modexp/README.md create mode 100644 engine-modexp/src/arith.rs create mode 100644 engine-modexp/src/lib.rs create mode 100644 engine-modexp/src/maybe_std.rs create mode 100644 engine-modexp/src/mpnat.rs create mode 100644 etc/tests/modexp-bench/Cargo.toml create mode 100644 etc/tests/modexp-bench/res/evm_contract_1.hex create mode 100644 etc/tests/modexp-bench/res/evm_contract_2.hex create mode 100644 etc/tests/modexp-bench/src/lib.rs diff --git a/CHANGES.md b/CHANGES.md index 5dc010dcb..4630676fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.9.1] 2023-05-11 + +### Changes + +- Removed unused state variable `bridge_prover_id` by [@birchmd]. ([#749]) +- `modexp` has been improved to be greatly faster than before by [@birchmd]. ([#757]) + +### Fixes + +- Fixed an issue where the owner could call `new` multiple times by [@lempire123]. ([#733]) +- Fixed an issue with `deploy_upgrade` where the upgrade index isn't cleared by [@lempire123]. ([#741]) + +[#749]: https://github.com/aurora-is-near/aurora-engine/pull/749 +[#757]: https://github.com/aurora-is-near/aurora-engine/pull/757 +[#733]: https://github.com/aurora-is-near/aurora-engine/pull/733 +[#741]: https://github.com/aurora-is-near/aurora-engine/pull/741 + ## [2.9.0] 2023-04-05 ### Added @@ -396,7 +413,8 @@ struct SubmitResult { ## [1.0.0] - 2021-05-12 -[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/2.9.0...develop +[Unreleased]: https://github.com/aurora-is-near/aurora-engine/compare/2.9.1...develop +[2.9.1]: https://github.com/aurora-is-near/aurora-engine/compare/2.9.0...2.9.1 [2.9.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.8.0...2.9.0 [2.8.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.7.0...2.8.0 [2.7.0]: https://github.com/aurora-is-near/aurora-engine/compare/2.6.1...2.7.0 diff --git a/Cargo.lock b/Cargo.lock index b81ebf94c..d9501a39f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,62 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +[[package]] +name = "actix" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f728064aca1c318585bf4bb04ffcfac9e75e508ab4e8b1bd9ba5dfe04e2cbed5" +dependencies = [ + "actix-rt", + "actix_derive", + "bitflags", + "bytes", + "crossbeam-channel", + "futures-core", + "futures-sink", + "futures-task", + "futures-util", + "log", + "once_cell", + "parking_lot 0.12.1", + "pin-project-lite", + "smallvec", + "tokio", + "tokio-util 0.7.3", +] + +[[package]] +name = "actix-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "actix-rt" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" +dependencies = [ + "actix-macros", + "futures-core", + "tokio", +] + +[[package]] +name = "actix_derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "addr2line" version = "0.17.0" @@ -23,7 +79,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli 0.27.1", + "gimli 0.27.2", ] [[package]] @@ -38,16 +94,27 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if 1.0.0", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" dependencies = [ "memchr", ] @@ -67,17 +134,75 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + [[package]] name = "anyhow" -version = "1.0.69" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" + +[[package]] +name = "arbitrary" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" +dependencies = [ + "derive_arbitrary", +] [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -93,34 +218,35 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "async-stream" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ "async-stream-impl", "futures-core", + "pin-project-lite", ] [[package]] name = "async-stream-impl" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -136,7 +262,7 @@ dependencies = [ [[package]] name = "aurora-engine" -version = "2.9.0" +version = "2.9.1" dependencies = [ "aurora-engine-precompiles", "aurora-engine-sdk", @@ -144,7 +270,7 @@ dependencies = [ "aurora-engine-transactions", "aurora-engine-types", "bitflags", - "borsh 0.10.2", + "borsh 0.10.3", "byte-slice-cast", "digest 0.10.6", "ethabi", @@ -157,14 +283,24 @@ dependencies = [ "wee_alloc", ] +[[package]] +name = "aurora-engine-modexp" +version = "1.0.0" +dependencies = [ + "hex", + "ibig", + "num", +] + [[package]] name = "aurora-engine-precompiles" version = "1.0.0" dependencies = [ + "aurora-engine-modexp", "aurora-engine-sdk", "aurora-engine-test-doubles", "aurora-engine-types", - "borsh 0.10.2", + "borsh 0.10.3", "ethabi", "evm", "hex", @@ -185,7 +321,7 @@ version = "1.0.0" dependencies = [ "aurora-engine-types", "base64 0.21.0", - "borsh 0.10.2", + "borsh 0.10.3", "sha2 0.10.6", "sha3", ] @@ -211,7 +347,7 @@ dependencies = [ "aurora-engine-test-doubles", "aurora-engine-transactions", "aurora-engine-types", - "borsh 0.10.2", + "borsh 0.10.3", "bstr", "byte-slice-cast", "criterion", @@ -224,14 +360,13 @@ dependencies = [ "git2", "hex", "libsecp256k1", - "near-crypto", - "near-primitives", - "near-primitives-core", - "near-sdk", + "near-crypto 0.16.1", + "near-primitives 0.16.1", + "near-primitives-core 0.16.1", "near-sdk-sim", - "near-vm-errors", - "near-vm-logic", - "near-vm-runner", + "near-vm-errors 0.16.1", + "near-vm-logic 0.16.1", + "near-vm-runner 0.16.1", "rand 0.8.5", "rlp", "serde", @@ -258,7 +393,7 @@ dependencies = [ name = "aurora-engine-types" version = "1.0.0" dependencies = [ - "borsh 0.10.2", + "borsh 0.10.3", "borsh 0.9.3", "hex", "primitive-types 0.12.1", @@ -269,14 +404,14 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a8c1df849285fbacd587de7818cc7d13be6cd2cbcd47a04fb1801b0e2706e33" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -338,7 +473,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 1.0.109", ] [[package]] @@ -391,16 +526,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[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 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -415,12 +550,12 @@ dependencies = [ [[package]] name = "borsh" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40f9ca3698b2e4cb7c15571db0abc5551dca417a21ae8140460b50309bb2cc62" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" dependencies = [ - "borsh-derive 0.10.2", - "hashbrown 0.12.3", + "borsh-derive 0.10.3", + "hashbrown 0.13.2", ] [[package]] @@ -433,20 +568,20 @@ dependencies = [ "borsh-schema-derive-internal 0.9.3", "proc-macro-crate 0.1.5", "proc-macro2", - "syn", + "syn 1.0.109", ] [[package]] name = "borsh-derive" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598b3eacc6db9c3ee57b22707ad8f6a8d2f6d442bfe24ffeb8cbb70ca59e6a35" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" dependencies = [ - "borsh-derive-internal 0.10.2", - "borsh-schema-derive-internal 0.10.2", + "borsh-derive-internal 0.10.3", + "borsh-schema-derive-internal 0.10.3", "proc-macro-crate 0.1.5", "proc-macro2", - "syn", + "syn 1.0.109", ] [[package]] @@ -457,18 +592,18 @@ checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "borsh-derive-internal" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "186b734fa1c9f6743e90c95d7233c9faab6360d1a96d4ffa19d9cfd1e9350f8a" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -479,18 +614,18 @@ checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "borsh-schema-derive-internal" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99b7ff1008316626f485991b960ade129253d4034014616b94f309a15366cc49" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -501,9 +636,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f0778972c64420fdedc63f09919c8a88bda7b25135357fd25a5d9f3257e832" +checksum = "c3d4260bcc2e8fc9df1eac4919a720effeb63a3f0952f5bf4944adfa18897f09" dependencies = [ "memchr", "once_cell", @@ -513,9 +648,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "byte-slice-cast" @@ -525,23 +660,24 @@ checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "bytecheck" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f" +checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" dependencies = [ "bytecheck_derive", "ptr_meta", + "simdutf8", ] [[package]] name = "bytecheck_derive" -version = "0.6.9" +version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" +checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -558,9 +694,9 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "bytesize" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" +checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" dependencies = [ "serde", ] @@ -624,9 +760,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" dependencies = [ "iana-time-zone", "js-sys", @@ -671,14 +807,14 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] name = "clang-sys" -version = "1.4.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -687,14 +823,14 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.23" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", "bitflags", - "clap_derive", - "clap_lex", + "clap_derive 3.2.25", + "clap_lex 0.2.4", "indexmap", "once_cell", "strsim", @@ -702,17 +838,53 @@ dependencies = [ "textwrap", ] +[[package]] +name = "clap" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" +dependencies = [ + "clap_builder", + "clap_derive 4.2.0", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex 0.4.1", + "strsim", +] + [[package]] name = "clap_derive" -version = "3.2.18" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" dependencies = [ "heck 0.4.1", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "clap_derive" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 2.0.15", ] [[package]] @@ -724,6 +896,12 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "clap_lex" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" + [[package]] name = "cloudabi" version = "0.0.3" @@ -743,6 +921,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -757,9 +941,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "cpp_demangle" @@ -772,91 +956,115 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.84.0" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fa7c3188913c2d11a361e0431e135742372a2709a99b103e79758e11a0a797e" +checksum = "2a2ab4512dfd3a6f4be184403a195f76e81a8a9f9e6c898e19d2dc3ce20e0115" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.84.0" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29285f70fd396a8f64455a15a6e1d390322e4a5f5186de513141313211b0a23e" +checksum = "98b022ed2a5913a38839dfbafe6cf135342661293b08049843362df4301261dc" dependencies = [ + "arrayvec 0.7.2", + "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", "cranelift-codegen-shared", + "cranelift-egraph", "cranelift-entity", + "cranelift-isle", "gimli 0.26.2", "log", "regalloc2", "smallvec", - "target-lexicon 0.12.5", + "target-lexicon 0.12.7", ] [[package]] name = "cranelift-codegen-meta" -version = "0.84.0" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057eac2f202ec95aebfd8d495e88560ac085f6a415b3c6c28529dc5eb116a141" +checksum = "639307b45434ad112a98f8300c0f0ab085cbefcd767efcdef9ef19d4c0756e74" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.84.0" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "278e52e29c53fcf32431ef08406c295699a70306d05a0715c5b1bf50e33a9ab7" + +[[package]] +name = "cranelift-egraph" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75d93869efd18874a9341cfd8ad66bcb08164e86357a694a0e939d29e87410b9" +checksum = "624b54323b06e675293939311943ba82d323bb340468ce1889be5da7932c8d73" +dependencies = [ + "cranelift-entity", + "fxhash", + "hashbrown 0.12.3", + "indexmap", + "log", + "smallvec", +] [[package]] name = "cranelift-entity" -version = "0.84.0" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e34bd7a1fefa902c90a921b36323f17a398b788fa56a75f07a29d83b6e28808" +checksum = "9a59bcbca89c3f1b70b93ab3cbba5e5e0cbf3e63dadb23c7525cb142e21a9d4c" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.84.0" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "457018dd2d6ee300953978f63215b5edf3ae42dbdf8c7c038972f10394599f72" +checksum = "0d70abacb8cfef3dc8ff7e8836e9c1d70f7967dfdac824a4cd5e30223415aca6" dependencies = [ "cranelift-codegen", "log", "smallvec", - "target-lexicon 0.12.5", + "target-lexicon 0.12.7", ] +[[package]] +name = "cranelift-isle" +version = "0.91.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "393bc73c451830ff8dbb3a07f61843d6cb41a084f9996319917c0b291ed785bb" + [[package]] name = "cranelift-native" -version = "0.84.0" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba027cc41bf1d0eee2ddf16caba2ee1be682d0214520fff0129d2c6557fda89" +checksum = "ba392fd53b1bf6d45bf1d97f7e13bb8ba8424f19d66d80e60a0d594c2bb2636e" dependencies = [ "cranelift-codegen", "libc", - "target-lexicon 0.12.5", + "target-lexicon 0.12.7", ] [[package]] name = "cranelift-wasm" -version = "0.84.0" +version = "0.91.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b17639ced10b9916c9be120d38c872ea4f9888aa09248568b10056ef0559bfa" +checksum = "016abecc42cc114b924fa3fc306267f566076cefd3e43b891c510c8085c0811e" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -864,7 +1072,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.84.0", + "wasmparser 0.95.0", "wasmtime-types", ] @@ -887,7 +1095,7 @@ dependencies = [ "atty", "cast", "ciborium", - "clap", + "clap 3.2.25", "criterion-plot", "itertools", "lazy_static", @@ -929,9 +1137,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -939,9 +1147,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if 1.0.0", "crossbeam-epoch", @@ -950,14 +1158,14 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.13" +version = "0.9.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" dependencies = [ "autocfg", "cfg-if 1.0.0", "crossbeam-utils", - "memoffset 0.7.1", + "memoffset 0.8.0", "scopeguard", ] @@ -973,9 +1181,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" dependencies = [ "cfg-if 1.0.0", ] @@ -992,7 +1200,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "typenum", ] @@ -1002,7 +1210,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -1021,9 +1229,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.89" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc831ee6a32dd495436e317595e639a587aa9907bef96fe6e6abc290ab6204e9" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ "cc", "cxxbridge-flags", @@ -1033,9 +1241,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.89" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94331d54f1b1a8895cd81049f7eaaaef9d05a7dcb4d1fd08bf3ff0806246789d" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" dependencies = [ "cc", "codespan-reporting", @@ -1043,31 +1251,31 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 2.0.15", ] [[package]] name = "cxxbridge-flags" -version = "1.0.89" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48dcd35ba14ca9b40d6e4b4b39961f23d835dbb8eed74565ded361d93e1feb8a" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.89" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bbeb29798b407ccd82a3324ade1a7286e0d29851475990b612670f6f5124d2" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "darling" -version = "0.14.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" dependencies = [ "darling_core", "darling_macro", @@ -1075,26 +1283,37 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "darling_macro" -version = "0.14.3" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.15", +] + +[[package]] +name = "derive_arbitrary" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cdeb9ec472d588e539a818b2dee436825730da08ad0017c4b1a17676bdc8b7" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -1107,7 +1326,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn", + "syn 1.0.109", ] [[package]] @@ -1125,7 +1344,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -1134,11 +1353,17 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "crypto-common", "subtle", ] +[[package]] +name = "dissimilar" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "210ec60ae7d710bed8683e333e9d2855a8a56a3e9892b38bad3bb0d4d29b0d5e" + [[package]] name = "dynasm" version = "1.2.3" @@ -1151,7 +1376,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1218,7 +1443,7 @@ dependencies = [ "aurora-engine-sdk", "aurora-engine-transactions", "aurora-engine-types", - "borsh 0.10.2", + "borsh 0.10.3", "evm-core", "hex", "postgres", @@ -1242,9 +1467,9 @@ dependencies = [ [[package]] name = "enum-map" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c25992259941eb7e57b936157961b217a4fc8597829ddef0596d6c3cd86e1a" +checksum = "988f0d17a0fa38291e5f41f71ea8d46a5d5497b9054d5a759fae2cbb819f2356" dependencies = [ "enum-map-derive", ] @@ -1257,28 +1482,28 @@ checksum = "2a4da76b3b6116d758c7ba93f7ec6a35d2e2cf24feda76c6e38a375f4d5c59f2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "enumset" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" +checksum = "65bbba26593df6fc35b9200ac7ad2f92e6bcf589fbafdf0ae532a004fc4f14ae" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.6.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" +checksum = "93b15496585fddd368466056b314fbb7e826a9ef1cf17b563d30dd2665846be2" dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -1298,6 +1523,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -1436,13 +1672,29 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] +[[package]] +name = "finite-wasm" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d393fee07818ceda80e844cdcbd191b16a7be290a994210ea30c4677a39db0e8" +dependencies = [ + "bitvec", + "dissimilar", + "num-traits", + "prefix-sum-vec", + "thiserror", + "wasm-encoder", + "wasmparser 0.99.0", + "wasmprinter", +] + [[package]] name = "fixed-hash" version = "0.7.0" @@ -1509,9 +1761,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -1523,9 +1775,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -1533,15 +1785,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -1550,38 +1802,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-macro" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -1615,9 +1867,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -1636,9 +1888,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if 1.0.0", "libc", @@ -1658,15 +1910,15 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.1" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec" +checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" [[package]] name = "git2" -version = "0.16.1" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf7f68c2995f392c49fffb4f95ae2c873297830eb25c6bc4c114ce8f4562acc" +checksum = "8b7905cdfe33d31a88bb2e8419ddd054451f5432d1da9eaf2ac7804ee1ea12d5" dependencies = [ "bitflags", "libc", @@ -1685,9 +1937,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "h2" -version = "0.3.15" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" dependencies = [ "bytes", "fnv", @@ -1698,7 +1950,7 @@ dependencies = [ "indexmap", "slab", "tokio", - "tokio-util 0.7.5", + "tokio-util 0.7.3", "tracing", ] @@ -1729,7 +1981,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash", + "ahash 0.7.6", ] [[package]] @@ -1738,7 +1990,16 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", ] [[package]] @@ -1783,6 +2044,12 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + [[package]] name = "hex" version = "0.4.3" @@ -1818,15 +2085,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "hmac 0.8.1", ] [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -1858,9 +2125,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.24" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e011372fa0b68db8350aa7a248930ecc7839bf46d8485577d69f117a75f164c" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -1894,16 +2161,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows", ] [[package]] @@ -1916,6 +2183,17 @@ dependencies = [ "cxx-build", ] +[[package]] +name = "ibig" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1fcc7f316b2c079dde77564a1360639c1a956a23fa96122732e416cb10717bb" +dependencies = [ + "cfg-if 1.0.0", + "num-traits", + "static_assertions", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -1973,14 +2251,14 @@ checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -1998,9 +2276,26 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "0.5.3" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix 0.37.19", + "windows-sys 0.48.0", +] [[package]] name = "itertools" @@ -2013,15 +2308,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] @@ -2035,24 +2330,30 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "json_comments" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ee439ee368ba4a77ac70d04f14015415af8600d6c894dc1f11bd79758c57d5" + [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" dependencies = [ "cpufeatures", ] [[package]] name = "lazy-static-include" -version = "3.1.3" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c2e13f42790900c1a0736b66f8bfbf99d02ee9fb9c54571c9f2d1d4891bfb0" +checksum = "b111244b70d4cf22aaaf8e0461ede19d623880f0f4779ee33dc35850a825bec3" dependencies = [ "lazy_static", "manifest-dir-macros", - "syn", + "syn 2.0.15", ] [[package]] @@ -2078,15 +2379,15 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libgit2-sys" -version = "0.14.2+1.5.1" +version = "0.15.1+1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f3d95f6b51075fe9810a7ae22c7095f12b98005ab364d8544797a825ce946a4" +checksum = "fb4577bde8cdfc7d6a2a4bcb7b049598597de33ffd337276e9c7db6cd4a2cee7" dependencies = [ "cc", "libc", @@ -2172,9 +2473,9 @@ dependencies = [ [[package]] name = "libssh2-sys" -version = "0.2.23" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" +checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee" dependencies = [ "cc", "libc", @@ -2186,9 +2487,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" dependencies = [ "cc", "libc", @@ -2207,9 +2508,15 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.0.42" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "linux-raw-sys" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "lock_api" @@ -2256,7 +2563,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2279,14 +2586,14 @@ dependencies = [ [[package]] name = "manifest-dir-macros" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08150cf2bab1fc47c2196f4f41173a27fcd0f684165e5458c0046b53a472e2f" +checksum = "450e5ef583bc05177c4975b9ea907047091a9f62e74e81fcafb99dbffac51e7e" dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -2313,6 +2620,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memfd" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" +dependencies = [ + "rustix 0.37.19", +] + [[package]] name = "memmap" version = "0.7.0" @@ -2325,9 +2641,9 @@ dependencies = [ [[package]] name = "memmap2" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" dependencies = [ "libc", ] @@ -2343,9 +2659,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" dependencies = [ "autocfg", ] @@ -2373,14 +2689,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -2398,16 +2714,36 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "near-account-id" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ - "borsh 0.9.3", + "borsh 0.10.3", + "serde", +] + +[[package]] +name = "near-account-id" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12791d0f273e04609010d68deb6e1cd940659ad420edfa2e48238117154f1d5b" +dependencies = [ + "arbitrary", + "borsh 0.10.3", "serde", ] [[package]] name = "near-cache" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "lru", +] + +[[package]] +name = "near-cache" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa597590d8615c2aef880a55cf70701d0c6348a90b9806297591d81f2acef35" dependencies = [ "lru", ] @@ -2415,14 +2751,17 @@ dependencies = [ [[package]] name = "near-chain-configs" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ "anyhow", "chrono", "derive_more", - "near-crypto", - "near-primitives", + "near-config-utils 0.0.0", + "near-crypto 0.0.0", + "near-o11y 0.0.0", + "near-primitives 0.0.0", "num-rational 0.3.2", + "once_cell", "serde", "serde_json", "sha2 0.10.6", @@ -2430,38 +2769,126 @@ dependencies = [ "tracing", ] +[[package]] +name = "near-config-utils" +version = "0.0.0" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "anyhow", + "json_comments", + "thiserror", + "tracing", +] + +[[package]] +name = "near-config-utils" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "137b6bbd477dc0ff1149e22c5e1f3f168a1f37d9d67f1519f058a5db81df3506" +dependencies = [ + "anyhow", + "json_comments", + "thiserror", + "tracing", +] + [[package]] name = "near-crypto" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ - "arrayref", "blake2", - "borsh 0.9.3", + "borsh 0.10.3", "bs58", "c2-chacha", "curve25519-dalek", "derive_more", "ed25519-dalek", - "near-account-id", + "hex", + "near-account-id 0.0.0", + "near-config-utils 0.0.0", + "near-stdx", "once_cell", "primitive-types 0.10.1", "rand 0.7.3", - "secp256k1", + "secp256k1 0.27.0", "serde", "serde_json", "subtle", "thiserror", ] +[[package]] +name = "near-crypto" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "659a96750c4d933e4f00a50c66ba9948a32b862e5ecd6a952beee881b1cd2aaf" +dependencies = [ + "blake2", + "borsh 0.10.3", + "bs58", + "c2-chacha", + "curve25519-dalek", + "derive_more", + "ed25519-dalek", + "hex", + "near-account-id 0.16.1", + "near-config-utils 0.16.1", + "near-stdx", + "once_cell", + "primitive-types 0.10.1", + "rand 0.7.3", + "secp256k1 0.24.3", + "serde", + "serde_json", + "subtle", + "thiserror", +] + +[[package]] +name = "near-fmt" +version = "0.0.0" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "near-primitives-core 0.0.0", +] + [[package]] name = "near-o11y" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ + "actix", "atty", - "backtrace", - "clap", + "clap 4.2.7", + "near-crypto 0.0.0", + "near-primitives-core 0.0.0", + "once_cell", + "opentelemetry", + "opentelemetry-otlp", + "opentelemetry-semantic-conventions", + "prometheus", + "serde", + "strum", + "thiserror", + "tokio", + "tracing", + "tracing-appender", + "tracing-opentelemetry", + "tracing-subscriber", +] + +[[package]] +name = "near-o11y" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445cbd86499dbabf68d34d95d9a45c680da5446e226f4982ce488fcf8556b23f" +dependencies = [ + "actix", + "atty", + "clap 3.2.25", + "near-crypto 0.16.1", + "near-primitives-core 0.16.1", "once_cell", "opentelemetry", "opentelemetry-otlp", @@ -2480,12 +2907,12 @@ dependencies = [ [[package]] name = "near-pool" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ - "borsh 0.9.3", - "near-crypto", - "near-o11y", - "near-primitives", + "borsh 0.10.3", + "near-crypto 0.0.0", + "near-o11y 0.0.0", + "near-primitives 0.0.0", "once_cell", "rand 0.8.5", ] @@ -2493,20 +2920,59 @@ dependencies = [ [[package]] name = "near-primitives" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ - "borsh 0.9.3", - "byteorder", + "arbitrary", + "borsh 0.10.3", + "bytesize", + "cfg-if 1.0.0", + "chrono", + "derive_more", + "easy-ext", + "enum-map", + "hex", + "near-crypto 0.0.0", + "near-fmt", + "near-primitives-core 0.0.0", + "near-rpc-error-macro 0.0.0", + "near-stdx", + "near-vm-errors 0.0.0", + "num-rational 0.3.2", + "once_cell", + "primitive-types 0.10.1", + "rand 0.8.5", + "reed-solomon-erasure", + "serde", + "serde_json", + "serde_yaml", + "smart-default", + "strum", + "thiserror", + "time 0.3.21", + "tracing", +] + +[[package]] +name = "near-primitives" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4c030f28e8f988698145e7753b83bb54c05838c3afdd44835cc7c32c327ea1e" +dependencies = [ + "arbitrary", + "borsh 0.10.3", "bytesize", "cfg-if 1.0.0", "chrono", "derive_more", "easy-ext", + "enum-map", "hex", - "near-crypto", - "near-primitives-core", - "near-rpc-error-macro", - "near-vm-errors", + "near-crypto 0.16.1", + "near-o11y 0.16.1", + "near-primitives-core 0.16.1", + "near-rpc-error-macro 0.16.1", + "near-stdx", + "near-vm-errors 0.16.1", "num-rational 0.3.2", "once_cell", "primitive-types 0.10.1", @@ -2514,59 +2980,111 @@ dependencies = [ "reed-solomon-erasure", "serde", "serde_json", + "serde_yaml", "smart-default", "strum", "thiserror", + "time 0.3.21", + "tokio", + "tracing", ] [[package]] name = "near-primitives-core" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ + "arbitrary", "base64 0.13.1", - "borsh 0.9.3", + "borsh 0.10.3", "bs58", "derive_more", - "near-account-id", + "enum-map", + "near-account-id 0.0.0", "num-rational 0.3.2", "serde", "serde_repr", "sha2 0.10.6", "strum", + "thiserror", +] + +[[package]] +name = "near-primitives-core" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe2059d16efc42ef7f9514f30910d32b67c01fee9b70c1fd28d50545ca145d88" +dependencies = [ + "arbitrary", + "base64 0.13.1", + "borsh 0.10.3", + "bs58", + "derive_more", + "enum-map", + "near-account-id 0.16.1", + "num-rational 0.3.2", + "serde", + "serde_repr", + "sha2 0.10.6", + "strum", + "thiserror", ] [[package]] name = "near-rpc-error-core" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ "quote", "serde", - "syn", + "syn 2.0.15", +] + +[[package]] +name = "near-rpc-error-core" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28f8f38dcfeba3d0d3bc60ce292ddb1f76a428a590e32de7fc3d5d431b9635ea" +dependencies = [ + "quote", + "serde", + "syn 1.0.109", ] [[package]] name = "near-rpc-error-macro" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "fs2", + "near-rpc-error-core 0.0.0", + "serde", + "syn 2.0.15", +] + +[[package]] +name = "near-rpc-error-macro" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca4e8d6887b344f3e2f8281c1ad2cc93dcbcb683b546726a4ce1ab1dfa623a" dependencies = [ - "near-rpc-error-core", + "fs2", + "near-rpc-error-core 0.16.1", "serde", - "syn", + "syn 1.0.109", ] [[package]] name = "near-sdk" version = "3.1.0" -source = "git+https://github.com/aurora-is-near/near-sdk-rs.git?rev=a4634850023fd115053970f17e10861779d5167d#a4634850023fd115053970f17e10861779d5167d" +source = "git+https://github.com/aurora-is-near/near-sdk-rs.git?rev=cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003#cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003" dependencies = [ "base64 0.13.1", "borsh 0.9.3", "bs58", - "near-primitives-core", + "near-primitives-core 0.0.0", "near-sdk-macros", - "near-vm-logic", + "near-vm-logic 0.0.0", "serde", "serde_json", "wee_alloc", @@ -2575,67 +3093,83 @@ dependencies = [ [[package]] name = "near-sdk-core" version = "3.1.0" -source = "git+https://github.com/aurora-is-near/near-sdk-rs.git?rev=a4634850023fd115053970f17e10861779d5167d#a4634850023fd115053970f17e10861779d5167d" +source = "git+https://github.com/aurora-is-near/near-sdk-rs.git?rev=cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003#cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003" dependencies = [ "Inflector", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "near-sdk-macros" version = "3.1.0" -source = "git+https://github.com/aurora-is-near/near-sdk-rs.git?rev=a4634850023fd115053970f17e10861779d5167d#a4634850023fd115053970f17e10861779d5167d" +source = "git+https://github.com/aurora-is-near/near-sdk-rs.git?rev=cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003#cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003" dependencies = [ "near-sdk-core", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "near-sdk-sim" version = "3.2.0" -source = "git+https://github.com/aurora-is-near/near-sdk-rs.git?rev=a4634850023fd115053970f17e10861779d5167d#a4634850023fd115053970f17e10861779d5167d" +source = "git+https://github.com/aurora-is-near/near-sdk-rs.git?rev=cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003#cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003" dependencies = [ "chrono", "funty 1.1.0", "lazy-static-include", "near-chain-configs", - "near-crypto", + "near-crypto 0.0.0", "near-pool", - "near-primitives", + "near-primitives 0.0.0", "near-sdk", "near-store", - "near-vm-logic", + "near-vm-logic 0.0.0", "node-runtime", ] [[package]] name = "near-stable-hasher" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" + +[[package]] +name = "near-stable-hasher" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfcd68760c75c35b958e5d243878375996f9203747c5e057b8ae513096b6edf4" + +[[package]] +name = "near-stdx" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc1279be274b9a49c2cb4b62541241a1ff6745cb77ca81ece7f949cfbc229bff" [[package]] name = "near-store" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ + "actix", + "actix-rt", "anyhow", - "borsh 0.9.3", - "byteorder", + "borsh 0.10.3", "bytesize", "crossbeam", "derive_more", "elastic-array", "enum-map", "fs2", + "itertools", "itoa", "lru", - "near-crypto", - "near-o11y", - "near-primitives", + "near-crypto 0.0.0", + "near-fmt", + "near-o11y 0.0.0", + "near-primitives 0.0.0", + "near-stdx", "num_cpus", "once_cell", "rand 0.8.5", @@ -2646,36 +3180,153 @@ dependencies = [ "strum", "tempfile", "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "near-vm-compiler" +version = "0.0.0" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "enumset", + "finite-wasm", + "near-vm-types", + "near-vm-vm", + "rkyv", + "smallvec", + "target-lexicon 0.12.7", + "thiserror", + "tracing", + "wasmparser 0.99.0", +] + +[[package]] +name = "near-vm-compiler-singlepass" +version = "0.0.0" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "dynasm", + "dynasmrt", + "enumset", + "finite-wasm", + "lazy_static", + "memoffset 0.6.5", + "more-asserts", + "near-vm-compiler", + "near-vm-types", + "near-vm-vm", + "rayon", + "smallvec", + "strum", + "tracing", +] + +[[package]] +name = "near-vm-engine" +version = "0.0.0" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "backtrace", + "enumset", + "finite-wasm", + "lazy_static", + "memmap2", + "more-asserts", + "near-vm-compiler", + "near-vm-types", + "near-vm-vm", + "rustc-demangle", + "target-lexicon 0.12.7", + "thiserror", +] + +[[package]] +name = "near-vm-engine-universal" +version = "0.0.0" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "cfg-if 1.0.0", + "enumset", + "finite-wasm", + "leb128", + "near-vm-compiler", + "near-vm-engine", + "near-vm-types", + "near-vm-vm", + "prefix-sum-vec", + "region", + "rkyv", + "thiserror", "tracing", + "wasmparser 0.99.0", + "winapi", ] [[package]] name = "near-vm-errors" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ - "borsh 0.9.3", - "near-account-id", - "near-rpc-error-macro", + "borsh 0.10.3", + "near-account-id 0.0.0", + "near-rpc-error-macro 0.0.0", "serde", "strum", + "thiserror", +] + +[[package]] +name = "near-vm-errors" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2d3eab1e050fdc3e036c803784cf45582661ae2dd07bac3bd373ba9c049715" +dependencies = [ + "borsh 0.10.3", + "near-account-id 0.16.1", + "near-rpc-error-macro 0.16.1", + "serde", + "strum", + "thiserror", ] [[package]] name = "near-vm-logic" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ - "borsh 0.9.3", - "bs58", - "byteorder", + "borsh 0.10.3", + "ed25519-dalek", + "near-account-id 0.0.0", + "near-crypto 0.0.0", + "near-fmt", + "near-o11y 0.0.0", + "near-primitives 0.0.0", + "near-primitives-core 0.0.0", + "near-stdx", + "near-vm-errors 0.0.0", + "ripemd", + "serde", + "sha2 0.10.6", + "sha3", + "zeropool-bn", +] + +[[package]] +name = "near-vm-logic" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85068a639fca198f88d1693f5f37011acdb6dd0368670c4812db5e338b498d8e" +dependencies = [ + "borsh 0.10.3", "ed25519-dalek", - "near-account-id", - "near-crypto", - "near-o11y", - "near-primitives", - "near-primitives-core", - "near-vm-errors", + "near-account-id 0.16.1", + "near-crypto 0.16.1", + "near-o11y 0.16.1", + "near-primitives 0.16.1", + "near-primitives-core 0.16.1", + "near-stdx", + "near-vm-errors 0.16.1", "ripemd", "serde", "sha2 0.10.6", @@ -2686,20 +3337,28 @@ dependencies = [ [[package]] name = "near-vm-runner" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ "anyhow", - "borsh 0.9.3", + "borsh 0.10.3", + "finite-wasm", "loupe", "memoffset 0.6.5", - "near-cache", - "near-primitives", - "near-stable-hasher", - "near-vm-errors", - "near-vm-logic", + "near-cache 0.0.0", + "near-primitives 0.0.0", + "near-stable-hasher 0.0.0", + "near-vm-compiler", + "near-vm-compiler-singlepass", + "near-vm-engine", + "near-vm-engine-universal", + "near-vm-errors 0.0.0", + "near-vm-logic 0.0.0", + "near-vm-types", + "near-vm-vm", "once_cell", "parity-wasm 0.41.0", "parity-wasm 0.42.2", + "prefix-sum-vec", "pwasm-utils", "serde", "tracing", @@ -2715,6 +3374,70 @@ dependencies = [ "wasmtime", ] +[[package]] +name = "near-vm-runner" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e927881ee82340d67a6aefb2ecd778f43a3984728cc2af94516737cd0a96e5d9" +dependencies = [ + "anyhow", + "borsh 0.10.3", + "loupe", + "memoffset 0.6.5", + "near-cache 0.16.1", + "near-primitives 0.16.1", + "near-stable-hasher 0.16.1", + "near-vm-errors 0.16.1", + "near-vm-logic 0.16.1", + "once_cell", + "parity-wasm 0.41.0", + "parity-wasm 0.42.2", + "pwasm-utils", + "serde", + "tracing", + "wasmer-compiler-near", + "wasmer-compiler-singlepass-near", + "wasmer-engine-near", + "wasmer-engine-universal-near", + "wasmer-types-near", + "wasmer-vm-near", + "wasmparser 0.78.2", + "wasmtime", +] + +[[package]] +name = "near-vm-types" +version = "0.0.0" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "indexmap", + "num-traits", + "rkyv", + "thiserror", +] + +[[package]] +name = "near-vm-vm" +version = "0.0.0" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" +dependencies = [ + "backtrace", + "cc", + "cfg-if 1.0.0", + "finite-wasm", + "indexmap", + "libc", + "memoffset 0.6.5", + "more-asserts", + "near-vm-types", + "region", + "rkyv", + "thiserror", + "tracing", + "wasmparser 0.99.0", + "winapi", +] + [[package]] name = "nix" version = "0.15.0" @@ -2731,19 +3454,18 @@ dependencies = [ [[package]] name = "node-runtime" version = "0.0.0" -source = "git+https://github.com/birchmd/nearcore.git?rev=6033903be2037d67510188450f289b2d6e033f04#6033903be2037d67510188450f289b2d6e033f04" +source = "git+https://github.com/birchmd/nearcore.git?rev=71c9b3f4c62f1bff24982a179be64e6d03df0e16#71c9b3f4c62f1bff24982a179be64e6d03df0e16" dependencies = [ - "borsh 0.9.3", - "byteorder", + "borsh 0.10.3", "hex", "near-chain-configs", - "near-crypto", - "near-o11y", - "near-primitives", + "near-crypto 0.0.0", + "near-o11y 0.0.0", + "near-primitives 0.0.0", "near-store", - "near-vm-errors", - "near-vm-logic", - "near-vm-runner", + "near-vm-errors 0.0.0", + "near-vm-logic 0.0.0", + "near-vm-runner 0.0.0", "num-bigint 0.3.3", "num-rational 0.3.2", "num-traits", @@ -2767,15 +3489,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nom8" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" -dependencies = [ - "memchr", -] - [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2898,12 +3611,12 @@ dependencies = [ [[package]] name = "object" -version = "0.28.4" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", - "hashbrown 0.11.2", + "hashbrown 0.12.3", "indexmap", "memchr", ] @@ -2919,9 +3632,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "oorandom" @@ -2943,11 +3656,10 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.80" +version = "0.9.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7" +checksum = "8e17f59264b2809d77ae94f0e1ebabc434773f370d6ca667bd223ea10e06cc7e" dependencies = [ - "autocfg", "cc", "libc", "pkg-config", @@ -3004,9 +3716,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" [[package]] name = "overload" @@ -3026,9 +3738,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3840933452adf7b3b9145e27086a5a3376c619dca1a21b1e5a5af0d54979bed" +checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -3044,10 +3756,10 @@ version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86b26a931f824dd4eca30b3e43bb4f31cd5f0d3a403c5f5ff27106b805bfde7b" dependencies = [ - "proc-macro-crate 1.3.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3111,9 +3823,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "peeking_take_while" @@ -3172,7 +3884,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3189,9 +3901,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "plotters" @@ -3237,11 +3949,11 @@ dependencies = [ [[package]] name = "postgres-protocol" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878c6cbf956e03af9aa8204b407b9cbf47c072164800aa918c516cd4b056c50c" +checksum = "78b7fa9f396f51dffd61546fd8573ee20592287996568e6175ceb0f8699ad75d" dependencies = [ - "base64 0.13.1", + "base64 0.21.0", "byteorder", "bytes", "fallible-iterator", @@ -3255,9 +3967,9 @@ dependencies = [ [[package]] name = "postgres-types" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73d946ec7d256b04dfadc4e6a3292324e6f417124750fc5c0950f981b703a0f1" +checksum = "f028f05971fe20f512bcc679e2c10227e57809a3af86a7606304435bc8896cd6" dependencies = [ "bytes", "fallible-iterator", @@ -3270,6 +3982,12 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "prefix-sum-vec" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa06bd51638b6e76ac9ba9b6afb4164fa647bd2916d722f2623fbb6d1ed8bdba" + [[package]] name = "primitive-types" version = "0.10.1" @@ -3305,9 +4023,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", "toml_edit", @@ -3322,7 +4040,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -3339,9 +4057,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -3401,7 +4119,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3446,7 +4164,7 @@ checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3462,9 +4180,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -3534,7 +4252,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -3548,9 +4266,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ "either", "rayon-core", @@ -3558,9 +4276,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.10.2" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -3576,9 +4294,18 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -3594,9 +4321,9 @@ dependencies = [ [[package]] name = "regalloc2" -version = "0.1.3" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904196c12c9f55d3aea578613219f493ced8e05b3d0c6a42d11cb4142d8b4879" +checksum = "300d4fbfb40c1c66a78ba3ddd41c1110247cf52f97b87d0f2fc9209bd49b030c" dependencies = [ "fxhash", "log", @@ -3606,13 +4333,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.1", ] [[package]] @@ -3621,26 +4348,20 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", ] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "region" -version = "2.2.0" +name = "regex-syntax" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" -dependencies = [ - "bitflags", - "libc", - "mach", - "winapi", -] +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "region" @@ -3654,20 +4375,11 @@ dependencies = [ "winapi", ] -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - [[package]] name = "rend" -version = "0.3.6" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95" +checksum = "581008d2099240d37fb08d77ad713bcaec2c4d89d50b5b21a8bb1996bbab68ab" dependencies = [ "bytecheck", ] @@ -3683,9 +4395,9 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.39" +version = "0.7.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15" +checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" dependencies = [ "bytecheck", "hashbrown 0.12.3", @@ -3697,13 +4409,13 @@ dependencies = [ [[package]] name = "rkyv_derive" -version = "0.7.39" +version = "0.7.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eaedadc88b53e36dd32d940ed21ae4d850d5916f2581526921f553a72ac34c4" +checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3734,7 +4446,7 @@ checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3749,9 +4461,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -3780,34 +4492,48 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.16", + "semver 1.0.17", ] [[package]] name = "rustix" -version = "0.33.7" +version = "0.36.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" +checksum = "3a38f9520be93aba504e8ca974197f46158de5dcaa9fa04b57c57cd6a679d658" dependencies = [ "bitflags", - "errno", + "errno 0.3.1", "io-lifetimes", "libc", - "linux-raw-sys", - "winapi", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", +] + +[[package]] +name = "rustix" +version = "0.37.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +dependencies = [ + "bitflags", + "errno 0.3.1", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.7", + "windows-sys 0.48.0", ] [[package]] name = "rustversion" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" [[package]] name = "same-file" @@ -3820,9 +4546,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.3.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +checksum = "dfdef77228a4c05dc94211441595746732131ad7f6530c6c18f045da7b7ab937" dependencies = [ "bitvec", "cfg-if 1.0.0", @@ -3833,14 +4559,14 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.3.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" dependencies = [ - "proc-macro-crate 1.3.0", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3851,9 +4577,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "seahash" @@ -3868,7 +4594,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" dependencies = [ "rand 0.8.5", - "secp256k1-sys", + "secp256k1-sys 0.6.1", +] + +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "rand 0.8.5", + "secp256k1-sys 0.8.1", ] [[package]] @@ -3880,6 +4616,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + [[package]] name = "semver" version = "0.9.0" @@ -3891,9 +4636,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "semver-parser" @@ -3903,9 +4648,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.152" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" dependencies = [ "serde_derive", ] @@ -3931,20 +4676,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -3953,13 +4698,26 @@ dependencies = [ [[package]] name = "serde_repr" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e" +checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", +] + +[[package]] +name = "serde_yaml" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9d684e3ec7de3bf5466b32bd75303ac16f0736426e5a4e0d6e489559ce1249c" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", ] [[package]] @@ -3988,9 +4746,9 @@ 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", "keccak", @@ -4013,9 +4771,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -4026,6 +4784,12 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +[[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" @@ -4034,18 +4798,18 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] [[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" @@ -4061,14 +4825,14 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "socket2" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", @@ -4127,7 +4891,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.109", ] [[package]] @@ -4138,9 +4902,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -4148,15 +4912,14 @@ dependencies = [ ] [[package]] -name = "synstructure" -version = "0.12.6" +name = "syn" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", - "syn", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -4173,22 +4936,21 @@ checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if 1.0.0", "fastrand", - "libc", - "redox_syscall 0.2.16", - "remove_dir_all", - "winapi", + "redox_syscall 0.3.5", + "rustix 0.37.19", + "windows-sys 0.45.0", ] [[package]] @@ -4202,24 +4964,37 @@ dependencies = [ [[package]] name = "test-case" -version = "2.2.2" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21d6cf5a7dffb3f9dceec8e6b8ca528d9bd71d36c9f074defb548ce161f598c0" +checksum = "2a1d6e7bde536b0412f20765b76e921028059adfd1b90d8974d33fd3c91b25df" dependencies = [ "test-case-macros", ] [[package]] -name = "test-case-macros" -version = "2.2.2" +name = "test-case-core" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e45b7bf6e19353ddd832745c8fcf77a17a93171df7151187f26623f2b75b5b26" +checksum = "d10394d5d1e27794f772b6fc854c7e91a2dc26e2cbf807ad523370c2a59c0cee" dependencies = [ "cfg-if 1.0.0", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "test-case-macros" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb9a44b1c6a54c1ba58b152797739dba2a83ca74e18168a68c980eb142f9404" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "test-case-core", ] [[package]] @@ -4230,30 +5005,31 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if 1.0.0", "once_cell", ] @@ -4280,9 +5056,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.17" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ "itoa", "serde", @@ -4292,15 +5068,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.6" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -4341,22 +5117,22 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" dependencies = [ - "autocfg", "bytes", "libc", "memchr", "mio", "num_cpus", + "once_cell", "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.42.0", + "winapi", ] [[package]] @@ -4377,7 +5153,7 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4401,14 +5177,14 @@ dependencies = [ "postgres-types", "socket2", "tokio", - "tokio-util 0.7.5", + "tokio-util 0.7.3", ] [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite", @@ -4431,9 +5207,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.5" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e267c18a719545b481171952a79f8c25c80361463ba44bc7fa9eba7c742ef4f" +checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" dependencies = [ "bytes", "futures-core", @@ -4454,19 +5230,19 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] name = "toml_edit" -version = "0.18.1" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", - "nom8", "toml_datetime", + "winnow", ] [[package]] @@ -4509,7 +5285,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4526,7 +5302,7 @@ dependencies = [ "rand 0.8.5", "slab", "tokio", - "tokio-util 0.7.5", + "tokio-util 0.7.3", "tower-layer", "tower-service", "tracing", @@ -4564,19 +5340,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09d48f71a791638519505cefafe162606f706c25592e4bde4d97600c0195312e" dependencies = [ "crossbeam-channel", - "time 0.3.17", + "time 0.3.21", "tracing-subscriber", ] [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.15", ] [[package]] @@ -4626,9 +5402,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" dependencies = [ "matchers", "nu-ansi-term", @@ -4678,15 +5454,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" @@ -4710,10 +5486,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] -name = "unicode-xid" -version = "0.2.4" +name = "unsafe-libyaml" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "1865806a559042e51ab5414598446a5871b561d21b6764f2eabb0dd481d880a6" [[package]] name = "url" @@ -4726,6 +5502,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "valuable" version = "0.1.0" @@ -4752,12 +5534,11 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] @@ -4784,7 +5565,7 @@ dependencies = [ "heck 0.3.3", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4836,7 +5617,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -4858,7 +5639,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4869,6 +5650,15 @@ version = "0.2.84" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +[[package]] +name = "wasm-encoder" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a584273ccc2d9311f1dd19dc3fb26054661fa3e373d53ede5d1144ba07a9acd" +dependencies = [ + "leb128", +] + [[package]] name = "wasmer-compiler-near" version = "2.4.0" @@ -4878,7 +5668,7 @@ dependencies = [ "enumset", "rkyv", "smallvec", - "target-lexicon 0.12.5", + "target-lexicon 0.12.7", "thiserror", "wasmer-types-near", "wasmer-vm-near", @@ -4916,7 +5706,7 @@ dependencies = [ "memmap2", "more-asserts", "rustc-demangle", - "target-lexicon 0.12.5", + "target-lexicon 0.12.7", "thiserror", "wasmer-compiler-near", "wasmer-types-near", @@ -4932,7 +5722,7 @@ dependencies = [ "cfg-if 1.0.0", "enumset", "leb128", - "region 3.0.0", + "region", "rkyv", "thiserror", "wasmer-compiler-near", @@ -4953,7 +5743,7 @@ dependencies = [ "borsh 0.9.3", "cc", "digest 0.8.1", - "errno", + "errno 0.2.8", "hex", "indexmap", "lazy_static", @@ -5030,7 +5820,7 @@ dependencies = [ "libc", "memoffset 0.6.5", "more-asserts", - "region 3.0.0", + "region", "rkyv", "thiserror", "wasmer-types-near", @@ -5057,47 +5847,84 @@ checksum = "52144d4c78e5cf8b055ceab8e5fa22814ce4315d6002ad32cfd914f37c12fd65" [[package]] name = "wasmparser" -version = "0.84.0" +version = "0.95.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" +dependencies = [ + "indexmap", + "url", +] + +[[package]] +name = "wasmparser" +version = "0.99.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef3b717afc67f848f412d4f02c127dd3e35a0eecd58c684580414df4fde01d3" +dependencies = [ + "indexmap", + "url", +] + +[[package]] +name = "wasmparser" +version = "0.104.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77dc97c22bb5ce49a47b745bed8812d30206eff5ef3af31424f2c1820c0974b2" +checksum = "6a396af81a7c56ad976131d6a35e4b693b78a1ea0357843bd436b4577e254a7d" dependencies = [ "indexmap", + "url", +] + +[[package]] +name = "wasmprinter" +version = "0.2.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "731da2505d5437cd5d6feb09457835f76186be13be7677fe00781ae99d5bbe8a" +dependencies = [ + "anyhow", + "wasmparser 0.104.0", ] [[package]] name = "wasmtime" -version = "0.37.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfdd1101bdfa0414a19018ec0a091951a20b695d4d04f858d49f6c4cc53cd8dd" +checksum = "a556932766120e2969c94a2d26ce47005451ac27236d418a11118c3ad5459905" dependencies = [ "anyhow", - "backtrace", "bincode", "cfg-if 1.0.0", "indexmap", - "lazy_static", "libc", "log", - "object 0.28.4", + "object 0.29.0", "once_cell", "paste", "psm", - "region 2.2.0", "serde", - "target-lexicon 0.12.5", - "wasmparser 0.84.0", + "target-lexicon 0.12.7", + "wasmparser 0.95.0", "wasmtime-cranelift", "wasmtime-environ", "wasmtime-jit", "wasmtime-runtime", - "winapi", + "windows-sys 0.42.0", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0aa5d2ec8e75db6907b46bfdd4980aefc6666854c4693a20f89b8417fe9c80d8" +dependencies = [ + "cfg-if 1.0.0", ] [[package]] name = "wasmtime-cranelift" -version = "0.37.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e78edcfb0daa9a9579ac379d00e2d5a5b2a60c0d653c8c95e8412f2166acb9" +checksum = "b7a9ec65dec790ec8602c263a1da12de073cc46cb07ffa3fc28295d2238365b6" dependencies = [ "anyhow", "cranelift-codegen", @@ -5107,39 +5934,37 @@ dependencies = [ "cranelift-wasm", "gimli 0.26.2", "log", - "more-asserts", - "object 0.28.4", - "target-lexicon 0.12.5", + "object 0.29.0", + "target-lexicon 0.12.7", "thiserror", - "wasmparser 0.84.0", + "wasmparser 0.95.0", "wasmtime-environ", ] [[package]] name = "wasmtime-environ" -version = "0.37.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4201389132ec467981980549574b33fc70d493b40f2c045c8ce5c7b54fbad97e" +checksum = "2137f0cdc6eed2f734c0d6f6a024af0e7a7208fa95e88501b72ca3c957bd0ba1" dependencies = [ "anyhow", "cranelift-entity", "gimli 0.26.2", "indexmap", "log", - "more-asserts", - "object 0.28.4", + "object 0.29.0", "serde", - "target-lexicon 0.12.5", + "target-lexicon 0.12.7", "thiserror", - "wasmparser 0.84.0", + "wasmparser 0.95.0", "wasmtime-types", ] [[package]] name = "wasmtime-jit" -version = "0.37.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1587ca7752d00862faa540d00fd28e5ccf1ac61ba19756449193f1153cb2b127" +checksum = "a5fbaffeaba705c0bfd681402e7629c9b611451e4c6ca3373a06293e846bb062" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -5148,62 +5973,70 @@ dependencies = [ "cpp_demangle", "gimli 0.26.2", "log", - "object 0.28.4", - "region 2.2.0", + "object 0.29.0", "rustc-demangle", - "rustix", "serde", - "target-lexicon 0.12.5", - "thiserror", + "target-lexicon 0.12.7", "wasmtime-environ", + "wasmtime-jit-icache-coherence", "wasmtime-runtime", - "winapi", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-jit-debug" -version = "0.37.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b27233ab6c8934b23171c64f215f902ef19d18c1712b46a0674286d1ef28d5dd" +checksum = "17981d189925fcb3a449a18b330141865df3aa025c030c4572962e10daa9707f" dependencies = [ - "lazy_static", + "once_cell", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f32b3f9e2b3b65fc9551240c81d69db8636b267ea5750ffc75e8a16d01680b0" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-runtime" -version = "0.37.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d3b0b8f13db47db59d616e498fe45295819d04a55f9921af29561827bdb816" +checksum = "b1a777df20249db2c4c54a4a709b5620c9021fda238f4c9b03fe7f77feac9cff" dependencies = [ "anyhow", - "backtrace", "cc", "cfg-if 1.0.0", "indexmap", "libc", "log", "mach", + "memfd", "memoffset 0.6.5", - "more-asserts", + "paste", "rand 0.8.5", - "region 2.2.0", - "rustix", - "thiserror", + "rustix 0.36.13", + "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", - "winapi", + "windows-sys 0.42.0", ] [[package]] name = "wasmtime-types" -version = "0.37.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1630d9dca185299bec7f557a7e73b28742fe5590caf19df001422282a0a98ad1" +checksum = "6410892daeb7e69d5af6055c9c07d9f5d1e159539a6e3f649e932fe0d9008a5b" dependencies = [ "cranelift-entity", "serde", "thiserror", - "wasmparser 0.84.0", + "wasmparser 0.95.0", ] [[package]] @@ -5270,19 +6103,28 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] @@ -5291,65 +6133,140 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winnow" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +dependencies = [ + "memchr", +] [[package]] name = "wyz" @@ -5371,14 +6288,13 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn", - "synstructure", + "syn 2.0.15", ] [[package]] @@ -5397,9 +6313,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.6+zstd.1.5.2" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a3f9792c0c3dc6c165840a75f47ae1f4da402c2d006881129579f6597e801b" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", diff --git a/Cargo.toml b/Cargo.toml index dee3a9cf7..f15a0cb47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ resolver = "2" members = [ "engine", "engine-test-doubles", + "engine-modexp", "engine-precompiles", "engine-sdk", "engine-standalone-storage", @@ -46,5 +47,6 @@ exclude = [ "etc/tests/benchmark-contract", "etc/tests/self-contained-5bEgfRQ", "etc/tests/fibonacci", + "etc/tests/modexp-bench", "etc/xcc-router", ] diff --git a/Makefile.toml b/Makefile.toml index 9d08a28aa..cf3c8e760 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -300,7 +300,7 @@ run_task = "build-engine-flow-docker" [tasks.build-docker] category = "Build" script = ''' -docker run --volume $PWD:/host -w /host -i --rm nearprotocol/contract-builder:master-b8fc60809b907543d909ee75fcc1bd7b68cbe2fd-amd64 ./scripts/docker-entrypoint.sh ${PROFILE} +docker run --volume $PWD:/host -w /host -i --rm nearprotocol/contract-builder:master-66f060ef807b2f323f7527e7e7f983299f9c2b16-amd64 ./scripts/docker-entrypoint.sh ${PROFILE} ''' [tasks.build-xcc-router-docker-inner] @@ -312,7 +312,7 @@ run_task = "build-xcc-router-flow-docker" [tasks.build-xcc-docker] category = "Build" script = ''' -docker run --volume $PWD:/host -w /host -i --rm nearprotocol/contract-builder:master-b8fc60809b907543d909ee75fcc1bd7b68cbe2fd-amd64 ./scripts/docker-xcc-router-entrypoint.sh ${PROFILE} +docker run --volume $PWD:/host -w /host -i --rm nearprotocol/contract-builder:master-66f060ef807b2f323f7527e7e7f983299f9c2b16-amd64 ./scripts/docker-xcc-router-entrypoint.sh ${PROFILE} ''' [tasks.test-contracts] @@ -333,12 +333,27 @@ args = [ "${CARGO_FEATURES_TEST}", ] +[tasks.bench-modexp] +condition = { profiles = ["mainnet", "testnet", "custom"] } +category = "Test" +command = "${CARGO}" +args = [ + "test", + "--release", + "--features", + "${CARGO_FEATURES_TEST}", + "bench_modexp_standalone", + "--", + "--ignored", +] + [tasks.test-flow] category = "Test" dependencies = [ "build-test", "test-contracts", "test-workspace", + "bench-modexp", ] [tasks.test] diff --git a/VERSION b/VERSION index c8e38b614..dedcc7d43 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.9.0 +2.9.1 diff --git a/engine-modexp/Cargo.toml b/engine-modexp/Cargo.toml new file mode 100644 index 000000000..f8f24fe9a --- /dev/null +++ b/engine-modexp/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "aurora-engine-modexp" +version = "1.0.0" +authors = ["Aurora Labs "] +edition = "2021" +description = "" +documentation = "" +readme = true +homepage = "https://github.com/aurora-is-near/aurora-engine" +repository = "https://github.com/aurora-is-near/aurora-engine" +license = "CC0-1.0" +publish = false +autobenches = false + +[dependencies] +ibig = { version = "0.3.6", default-features = false, features = ["num-traits"], optional = true } +num = { version = "0.4.0", default-features = false, features = ["alloc"] } +hex = { version = "0.4", default-features = false, features = ["alloc"] } + +[dev-dependencies] + +[features] +default = ["std"] +std = ["num/std", "hex/std"] +bench = ["ibig"] diff --git a/engine-modexp/README.md b/engine-modexp/README.md new file mode 100644 index 000000000..8e9e2081d --- /dev/null +++ b/engine-modexp/README.md @@ -0,0 +1,32 @@ +# Aurora `modexp` implementation + +## What this crate is + +This crate is an efficient implementation of the EVM `modexp` precompile. +This crate exposes a single public function + +```rust +pub fn modexp(base: &[u8], exp: &[u8], modulus: &[u8]) -> Vec +``` + +This function takes the base, exponent and modulus as big-endian encoded bytes and returns the result in big-endian as well. + +This crate is meant to be an efficient implementation, using as little memory as possible (for example, it does not copy the exponent slice). +The exponentiation is done using the ["binary method"](https://en.wikipedia.org/wiki/Exponentiation_by_squaring). +The multiplication steps within the exponentiation use ["Montgomery multiplication"](https://en.wikipedia.org/wiki/Montgomery_modular_multiplication). +In the case of even modulus, Montgomery multiplication does not apply directly. +However we can reduce the problem to one involving an odd modulus and one where the modulus is a power of two. +These two sub-problems can be solved efficiently (the former using Montgomery multiplication, the latter the modular arithmetic is trivial on a binary computer), +then the results are combined using the [Chinese remainder theorem](https://en.wikipedia.org/wiki/Chinese_remainder_theorem). + +The primary academic references for this implementation are: + +1. [Analyzing and Comparing Montgomery Multiplication Algorithms](https://www.microsoft.com/en-us/research/wp-content/uploads/1996/01/j37acmon.pdf) +2. [Montgomery Reduction with Even Modulus](http://www.people.vcu.edu/~jwang3/CMSC691/j34monex.pdf) +3. [A Cryptographic Library for the Motorola DSP56000](https://link.springer.com/content/pdf/10.1007/3-540-46877-3_21.pdf) +4. [The Art of Computer Programming Volume 2](https://www-cs-faculty.stanford.edu/~knuth/taocp.html) + +## What this crate is NOT + +This crate is not a general purpose big integer library. +If you need anything other than `modexp`, then you should use something like [num-bigint](https://crates.io/crates/num-bigint) or [ibig](https://crates.io/crates/ibig). diff --git a/engine-modexp/src/arith.rs b/engine-modexp/src/arith.rs new file mode 100644 index 000000000..ca0c7de69 --- /dev/null +++ b/engine-modexp/src/arith.rs @@ -0,0 +1,706 @@ +use crate::{ + maybe_std::vec, + mpnat::{DoubleWord, MPNat, Word, BASE, WORD_BITS}, +}; + +// Computes the "Montgomery Product" of two numbers. +// See Coarsely Integrated Operand Scanning (CIOS) Method in +// https://www.microsoft.com/en-us/research/wp-content/uploads/1996/01/j37acmon.pdf +// In short, computes `xy (r^-1) mod n`, where `r = 2^(8*4*s)` and `s` is the number of +// digits needs to represent `n`. `n_prime` has the property that `r(r^(-1)) - nn' = 1`. +// Note: This algorithm only works if `xy < rn` (generally we will either have both `x < n`, `y < n` +// or we will have `x < r`, `y < n`). +pub fn monpro(x: &MPNat, y: &MPNat, n: &MPNat, n_prime: Word, out: &mut [Word]) { + debug_assert!( + n.is_odd(), + "Montgomery multiplication only makes sense with odd modulus" + ); + debug_assert!( + out.len() >= n.digits.len() + 2, + "Output needs 2 extra words over the size needed to represent n" + ); + let s = out.len() - 2; + // Using a range loop as opposed to `out.iter_mut().enumerate().take(s)` + // does make a meaningful performance difference in this case. + #[allow(clippy::needless_range_loop)] + for i in 0..s { + let mut c = 0; + for j in 0..s { + let (prod, carry) = shifted_carrying_mul( + out[j], + x.digits.get(j).copied().unwrap_or(0), + y.digits.get(i).copied().unwrap_or(0), + c, + ); + out[j] = prod; + c = carry; + } + let (sum, carry) = carrying_add(out[s], c, false); + out[s] = sum; + out[s + 1] = carry as Word; + let m = out[0].wrapping_mul(n_prime); + let (_, carry) = shifted_carrying_mul(out[0], m, n.digits.first().copied().unwrap_or(0), 0); + c = carry; + for j in 1..s { + let (prod, carry) = + shifted_carrying_mul(out[j], m, n.digits.get(j).copied().unwrap_or(0), c); + out[j - 1] = prod; + c = carry; + } + let (sum, carry) = carrying_add(out[s], c, false); + out[s - 1] = sum; + out[s] = out[s + 1] + (carry as Word); // overflow impossible at this stage + } + // Result is only in the first s + 1 words of the output. + out[s + 1] = 0; + + // Check if we need to do the final subtraction + for i in (0..=s).rev() { + match out[i].cmp(n.digits.get(i).unwrap_or(&0)) { + core::cmp::Ordering::Less => return, // No subtraction needed + core::cmp::Ordering::Greater => break, + core::cmp::Ordering::Equal => (), + } + } + + let mut b = false; + for (i, out_digit) in out.iter_mut().enumerate().take(s) { + let (diff, borrow) = borrowing_sub(*out_digit, n.digits.get(i).copied().unwrap_or(0), b); + *out_digit = diff; + b = borrow; + } + let (diff, borrow) = borrowing_sub(out[s], 0, b); + out[s] = diff; + + debug_assert!(!borrow, "No borrow needed since out < n"); +} + +// Equivalent to `monpro(x, x, n, n_prime, out)`, but more efficient. +pub fn monsq(x: &MPNat, n: &MPNat, n_prime: Word, out: &mut [Word]) { + debug_assert!( + n.is_odd(), + "Montgomery multiplication only makes sense with odd modulus" + ); + debug_assert!( + x.digits.len() <= n.digits.len(), + "x cannot be larger than n" + ); + debug_assert!( + out.len() > 2 * n.digits.len(), + "Output needs double the digits to hold the value of x^2 plus an extra word" + ); + let s = n.digits.len(); + + big_sq(x, out); + for i in 0..s { + let mut c: Word = 0; + let m = out[i].wrapping_mul(n_prime); + for j in 0..s { + let (prod, carry) = + shifted_carrying_mul(out[i + j], m, n.digits.get(j).copied().unwrap_or(0), c); + out[i + j] = prod; + c = carry; + } + let mut j = i + s; + while c > 0 { + let (sum, carry) = carrying_add(out[j], c, false); + out[j] = sum; + c = carry as Word; + j += 1; + } + } + // Only keep the last `s + 1` digits in `out`. + for i in 0..(s + 1) { + out[i] = out[i + s]; + } + out[(s + 1)..].fill(0); + + // Check if we need to do the final subtraction + for i in (0..=s).rev() { + match out[i].cmp(n.digits.get(i).unwrap_or(&0)) { + core::cmp::Ordering::Less => return, + core::cmp::Ordering::Greater => break, + core::cmp::Ordering::Equal => (), + } + } + + let mut b = false; + for (i, out_digit) in out.iter_mut().enumerate().take(s) { + let (diff, borrow) = borrowing_sub(*out_digit, n.digits.get(i).copied().unwrap_or(0), b); + *out_digit = diff; + b = borrow; + } + let (diff, borrow) = borrowing_sub(out[s], 0, b); + out[s] = diff; + + debug_assert!(!borrow, "No borrow needed since out < n"); +} + +// Given x odd, computes `x^(-1) mod 2^32`. +// See `MODULAR-INVERSE` in https://link.springer.com/content/pdf/10.1007/3-540-46877-3_21.pdf +pub fn mod_inv(x: Word) -> Word { + debug_assert_eq!(x & 1, 1, "Algorithm only valid for odd n"); + + let mut y = 1; + for i in 2..WORD_BITS { + let mask = (1 << i) - 1; + let xy = x.wrapping_mul(y) & mask; + let q = 1 << (i - 1); + if xy >= q { + y += q; + } + } + let xy = x.wrapping_mul(y); + let q = 1 << (WORD_BITS - 1); + if xy >= q { + y += q; + } + y +} + +// Given x odd, computes `x^(-1) mod 2^(WORD_BYTES*out.digits.len())`. +// See `MODULAR-INVERSE` in https://link.springer.com/content/pdf/10.1007/3-540-46877-3_21.pdf +pub fn big_mod_inv(x: &MPNat, out: &mut MPNat, scratch: &mut [Word]) { + let s = out.digits.len(); + out.digits[0] = mod_inv(x.digits[0]); + + for digit_index in 1..s { + for i in 1..WORD_BITS { + let mask = (1 << i) - 1; + big_wrapping_mul(x, out, scratch); + scratch[digit_index] &= mask; + let q = 1 << (i - 1); + if scratch[digit_index] >= q { + out.digits[digit_index] += q; + } + scratch.fill(0); + } + big_wrapping_mul(x, out, scratch); + let q = 1 << (WORD_BITS - 1); + if scratch[digit_index] >= q { + out.digits[digit_index] += q; + } + scratch.fill(0); + } +} + +/// Computes R mod n, where R = 2^(WORD_BITS*k) and k = n.digits.len() +/// Note that if R = qn + r, q must be smaller than 2^WORD_BITS since `2^(WORD_BITS) * n > R` +/// (adding a whole additional word to n is too much). +/// Uses the two most significant digits of n to approximate the quotient, +/// then computes the difference to get the remainder. It is possible that this +/// quotient is too big by 1; we can catch that case by looking for overflow +/// in the subtraction. +pub fn compute_r_mod_n(n: &MPNat, out: &mut [Word]) { + let k = n.digits.len(); + + if k == 1 { + let r = BASE; + let result = r % (n.digits[0] as DoubleWord); + out[0] = result as Word; + return; + } + + debug_assert!(n.is_odd(), "This algorithm only works for odd numbers"); + debug_assert!( + out.len() >= k, + "Output must be able to hold numbers of the same size as n" + ); + + let approx_n = join_as_double(n.digits[k - 1], n.digits[k - 2]); + let approx_q = DoubleWord::MAX / approx_n; + debug_assert!( + approx_q <= (Word::MAX as DoubleWord), + "quotient must fit in a single digit" + ); + let mut approx_q = approx_q as Word; + + loop { + let mut c = 0; + let mut b = false; + for (n_digit, out_digit) in n.digits.iter().zip(out.iter_mut()) { + let (prod, carry) = carrying_mul(approx_q, *n_digit, c); + c = carry; + let (diff, borrow) = borrowing_sub(0, prod, b); + b = borrow; + *out_digit = diff; + } + let (diff, borrow) = borrowing_sub(1, c, b); + if borrow { + // approx_q was too large so `R - approx_q*n` overflowed. + // try again with approx_q -= 1 + approx_q -= 1; + } else { + debug_assert_eq!( + diff, 0, + "R - qn must be smaller than n, hence fit in k digits" + ); + break; + } + } +} + +/// Computes `base ^ exp`, ignoring overflow. +pub fn big_wrapping_pow(base: &MPNat, exp: &[u8], scratch_space: &mut [Word]) -> MPNat { + // Compute result via the "binary method", see Knuth The Art of Computer Programming + let mut result = MPNat { + digits: vec![0; scratch_space.len()], + }; + result.digits[0] = 1; + for &b in exp { + let mut mask: u8 = 1 << 7; + while mask > 0 { + big_wrapping_mul(&result, &result, scratch_space); + result.digits.copy_from_slice(scratch_space); + scratch_space.fill(0); // zero-out the scratch space + if b & mask != 0 { + big_wrapping_mul(&result, base, scratch_space); + result.digits.copy_from_slice(scratch_space); + scratch_space.fill(0); // zero-out the scratch space + } + mask >>= 1; + } + } + result +} + +/// Computes `(x * y) mod 2^(WORD_BITS*out.len())`. +pub fn big_wrapping_mul(x: &MPNat, y: &MPNat, out: &mut [Word]) { + let s = out.len(); + for i in 0..s { + let mut c: Word = 0; + for j in 0..(s - i) { + let (prod, carry) = shifted_carrying_mul( + out[i + j], + x.digits.get(j).copied().unwrap_or(0), + y.digits.get(i).copied().unwrap_or(0), + c, + ); + c = carry; + out[i + j] = prod; + } + } +} + +/// Computes `x^2`, storing the result in `out`. +pub fn big_sq(x: &MPNat, out: &mut [Word]) { + debug_assert!( + out.len() > 2 * x.digits.len(), + "Output needs double the digits to hold the value of x^2" + ); + let s = x.digits.len(); + for i in 0..s { + let (product, carry) = shifted_carrying_mul(out[i + i], x.digits[i], x.digits[i], 0); + out[i + i] = product; + let mut c = carry as DoubleWord; + for j in (i + 1)..s { + let product = (x.digits[i] as DoubleWord) * (x.digits[j] as DoubleWord); + let (product, overflow) = product.overflowing_add(product); + let sum = (out[i + j] as DoubleWord) + product + c; + out[i + j] = sum as Word; + c = (sum >> WORD_BITS) as DoubleWord; + if overflow { + c += BASE; + } + } + let (sum, carry) = carrying_add(out[i + s], c as Word, false); + out[i + s] = sum; + out[i + s + 1] = ((c >> WORD_BITS) as Word) + (carry as Word); + } +} + +// Performs `a <<= shift`, returning the overflow +pub fn in_place_shl(a: &mut [Word], shift: u32) -> Word { + let mut c: Word = 0; + let carry_shift = (WORD_BITS as u32) - shift; + for a_digit in a.iter_mut() { + let carry = a_digit.overflowing_shr(carry_shift).0; + *a_digit = a_digit.overflowing_shl(shift).0 | c; + c = carry; + } + c +} + +// Performs `a >>= shift`, returning the overflow +pub fn in_place_shr(a: &mut [Word], shift: u32) -> Word { + let mut b: Word = 0; + let borrow_shift = (WORD_BITS as u32) - shift; + for a_digit in a.iter_mut().rev() { + let borrow = a_digit.overflowing_shl(borrow_shift).0; + *a_digit = a_digit.overflowing_shr(shift).0 | b; + b = borrow; + } + b +} + +// Performs a += b, returning if there was overflow +pub fn in_place_add(a: &mut [Word], b: &[Word]) -> bool { + debug_assert!(a.len() == b.len()); + + let mut c = false; + for (a_digit, b_digit) in a.iter_mut().zip(b) { + let (sum, carry) = carrying_add(*a_digit, *b_digit, c); + *a_digit = sum; + c = carry; + } + + c +} + +// Performs `a -= xy`, returning the "borrow". +pub fn in_place_mul_sub(a: &mut [Word], x: &[Word], y: Word) -> Word { + debug_assert!(a.len() == x.len()); + + // carry is between -big_digit::MAX and 0, so to avoid overflow we store + // offset_carry = carry + big_digit::MAX + let mut offset_carry = Word::MAX; + + for (a_digit, x_digit) in a.iter_mut().zip(x) { + // We want to calculate sum = x - y * c + carry. + // sum >= -(big_digit::MAX * big_digit::MAX) - big_digit::MAX + // sum <= big_digit::MAX + // Offsetting sum by (big_digit::MAX << big_digit::BITS) puts it in DoubleBigDigit range. + let offset_sum = join_as_double(Word::MAX, *a_digit) - Word::MAX as DoubleWord + + offset_carry as DoubleWord + - ((*x_digit as DoubleWord) * (y as DoubleWord)); + + let new_offset_carry = (offset_sum >> WORD_BITS) as Word; + let new_x = offset_sum as Word; + offset_carry = new_offset_carry; + *a_digit = new_x; + } + + // Return the borrow. + Word::MAX - offset_carry +} + +/// Computes `a + xy + c` where any overflow is captured as the "carry", +/// the second part of the output. The arithmetic in this function is +/// guaranteed to never overflow because even when all 4 variables are +/// equal to `Word::MAX` the output is smaller than `DoubleWord::MAX`. +pub fn shifted_carrying_mul(a: Word, x: Word, y: Word, c: Word) -> (Word, Word) { + let wide = { (a as DoubleWord) + ((x as DoubleWord) * (y as DoubleWord)) + (c as DoubleWord) }; + (wide as Word, (wide >> WORD_BITS) as Word) +} + +/// Computes `xy + c` where any overflow is captured as the "carry", +/// the second part of the output. The arithmetic in this function is +/// guaranteed to never overflow because even when all 3 variables are +/// equal to `Word::MAX` the output is smaller than `DoubleWord::MAX`. +pub fn carrying_mul(x: Word, y: Word, c: Word) -> (Word, Word) { + let wide = { ((x as DoubleWord) * (y as DoubleWord)) + (c as DoubleWord) }; + (wide as Word, (wide >> WORD_BITS) as Word) +} + +// Computes `x + y` with "carry the 1" semantics +pub fn carrying_add(x: Word, y: Word, carry: bool) -> (Word, bool) { + let (a, b) = x.overflowing_add(y); + let (c, d) = a.overflowing_add(carry as Word); + (c, b | d) +} + +// Computes `x - y` with "borrow from your neighbour" semantics +pub fn borrowing_sub(x: Word, y: Word, borrow: bool) -> (Word, bool) { + let (a, b) = x.overflowing_sub(y); + let (c, d) = a.overflowing_sub(borrow as Word); + (c, b | d) +} + +pub fn join_as_double(hi: Word, lo: Word) -> DoubleWord { + DoubleWord::from(lo) | (DoubleWord::from(hi) << WORD_BITS) +} + +#[test] +fn test_monsq() { + check_monsq(1, 31); + check_monsq(6, 31); + // This example is intentionally chosen because 5 * 5 = 25 = 0 mod 25, + // therefore it requires the final subtraction step in the algorithm. + check_monsq(5, 25); + check_monsq(0x1FFF_FFFF_FFFF_FFF0, 0x1FFF_FFFF_FFFF_FFF1); + check_monsq(0x16FF_221F_CB7D, 0x011E_842B_6BAA_5017_EBF2_8293); + check_monsq(0x0A2D_63F5_CFF9, 0x1F3B_3BD9_43EF); + check_monsq( + 0xa6b0ce71a380dea7c83435bc, + 0xc4550871a1cfc67af3e77eceb2ecfce5, + ); + + fn check_monsq(x: u128, n: u128) { + let a = MPNat::from_big_endian(&x.to_be_bytes()); + let m = MPNat::from_big_endian(&n.to_be_bytes()); + let n_prime = Word::MAX - mod_inv(m.digits[0]) + 1; + + let mut output = vec![0; 2 * m.digits.len() + 1]; + monsq(&a, &m, n_prime, &mut output); + let result = MPNat { digits: output }; + + let mut output = vec![0; m.digits.len() + 2]; + monpro(&a, &a, &m, n_prime, &mut output); + let expected = MPNat { digits: output }; + + assert_eq!( + num::BigUint::from_bytes_be(&result.to_big_endian()), + num::BigUint::from_bytes_be(&expected.to_big_endian()), + "{x}^2 failed monsq check" + ); + } +} + +#[test] +fn test_monpro() { + use num::Integer; + + check_monpro(1, 1, 31); + check_monpro(6, 7, 31); + // This example is intentionally chosen because 5 * 7 = 35 = 0 mod 35, + // therefore it requires the final subtraction step in the algorithm. + check_monpro(5, 7, 35); + check_monpro(0x1FFF_FFFF_FFFF_FFF0, 0x1234, 0x1FFF_FFFF_FFFF_FFF1); + check_monpro( + 0x16FF_221F_CB7D, + 0x0C75_8535_434F, + 0x011E_842B_6BAA_5017_EBF2_8293, + ); + check_monpro(0x0A2D_63F5_CFF9, 0x1B21_FF3C_FA8E, 0x1F3B_3BD9_43EF); + + fn check_monpro(x: u128, y: u128, n: u128) { + let a = MPNat::from_big_endian(&x.to_be_bytes()); + let b = MPNat::from_big_endian(&y.to_be_bytes()); + let m = MPNat::from_big_endian(&n.to_be_bytes()); + let n_prime = Word::MAX - mod_inv(m.digits[0]) + 1; + + let mut output = vec![0; m.digits.len() + 2]; + monpro(&a, &b, &m, n_prime, &mut output); + let result = MPNat { digits: output }; + + let r = num::BigInt::from(2).pow((WORD_BITS * m.digits.len()) as u32); + let r_inv = r.extended_gcd(&num::BigInt::from(n as i128)).x; + let r_inv: u128 = r_inv.try_into().unwrap(); + + let expected = (((x * y) % n) * r_inv) % n; + let actual = mp_nat_to_u128(&result); + assert_eq!(actual, expected, "{x}*{y} failed monpro check"); + } +} + +#[test] +fn test_r_mod_n() { + check_r_mod_n(0x01_00_00_00_01); + check_r_mod_n(0x80_00_00_00_01); + check_r_mod_n(0xFFFF_FFFF_FFFF_FFFF); + check_r_mod_n(0x0001_0000_0000_0000_0001); + check_r_mod_n(0x8000_0000_0000_0000_0001); + check_r_mod_n(0xbf2d_c9a3_82c5_6e85_b033_7651); + check_r_mod_n(0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF); + + fn check_r_mod_n(n: u128) { + let x = MPNat::from_big_endian(&n.to_be_bytes()); + let mut out = vec![0; x.digits.len()]; + compute_r_mod_n(&x, &mut out); + let result = mp_nat_to_u128(&MPNat { digits: out }); + let expected = num::BigUint::from(2_u32).pow((WORD_BITS * x.digits.len()) as u32) + % num::BigUint::from(n); + assert_eq!(num::BigUint::from(result), expected); + } +} + +#[test] +fn test_big_mod_inv() { + check_big_mod_inv(0x02_FF_FF_FF); + check_big_mod_inv(0x1234_0000_DDDD_FFFF); + check_big_mod_inv(0x52DA_9A91_F82D_6E17_FDF8_6743_2B58_7917); + + fn check_big_mod_inv(n: u128) { + let x = MPNat::from_big_endian(&n.to_be_bytes()); + let s = x.digits.len(); + let mut result = MPNat { digits: vec![0; s] }; + let mut scratch = vec![0; s]; + big_mod_inv(&x, &mut result, &mut scratch); + let n_inv = mp_nat_to_u128(&result); + if WORD_BITS * s < u128::BITS as usize { + assert_eq!( + n.wrapping_mul(n_inv) % (1 << (WORD_BITS * s)), + 1, + "{n} failed big_mod_inv check" + ); + } else { + assert_eq!(n.wrapping_mul(n_inv), 1, "{n} failed big_mod_inv check"); + } + } +} + +#[test] +fn test_in_place_shl() { + check_in_place_shl(0, 0); + check_in_place_shl(1, 10); + check_in_place_shl(Word::MAX as u128, 5); + check_in_place_shl(u128::MAX, 16); + + fn check_in_place_shl(n: u128, shift: u32) { + let mut x = MPNat::from_big_endian(&n.to_be_bytes()); + in_place_shl(&mut x.digits, shift); + let result = mp_nat_to_u128(&x); + let mask = BASE + .overflowing_pow(x.digits.len() as u32) + .0 + .wrapping_sub(1); + assert_eq!(result, n.overflowing_shl(shift).0 & mask); + } +} + +#[test] +fn test_in_place_shr() { + check_in_place_shr(0, 0); + check_in_place_shr(1, 10); + check_in_place_shr(0x1234_5678, 10); + check_in_place_shr(Word::MAX as u128, 5); + check_in_place_shr(u128::MAX, 16); + + fn check_in_place_shr(n: u128, shift: u32) { + let mut x = MPNat::from_big_endian(&n.to_be_bytes()); + in_place_shr(&mut x.digits, shift); + let result = mp_nat_to_u128(&x); + assert_eq!(result, n.overflowing_shr(shift).0); + } +} + +#[test] +fn test_mod_inv() { + for i in 1..1025 { + check_mod_inv(2 * i - 1); + } + for i in 0..1025 { + check_mod_inv(0xFF_FF_FF_FF - 2 * i); + } + + fn check_mod_inv(n: Word) { + let n_inv = mod_inv(n); + assert_eq!(n.wrapping_mul(n_inv), 1, "{n} failed mod_inv check"); + } +} + +#[test] +fn test_big_wrapping_pow() { + check_big_wrapping_pow(1, 1); + check_big_wrapping_pow(10, 2); + check_big_wrapping_pow(2, 32); + check_big_wrapping_pow(2, 64); + check_big_wrapping_pow(2766, 844); + + fn check_big_wrapping_pow(a: u128, b: u32) { + let expected = num::BigUint::from(a).pow(b); + let x = MPNat::from_big_endian(&a.to_be_bytes()); + let y = b.to_be_bytes(); + let mut scratch = vec![0; 1 + (expected.to_bytes_be().len() / crate::mpnat::WORD_BYTES)]; + let result = big_wrapping_pow(&x, &y, &mut scratch); + let result = { + let result = result.to_big_endian(); + num::BigUint::from_bytes_be(&result) + }; + assert_eq!(result, expected, "{a} ^ {b} != {expected}"); + } +} + +#[test] +fn test_big_wrapping_mul() { + check_big_wrapping_mul(0, 0, 1); + check_big_wrapping_mul(1, 1, 1); + check_big_wrapping_mul(7, 6, 1); + check_big_wrapping_mul(Word::MAX.into(), Word::MAX.into(), 2); + check_big_wrapping_mul(Word::MAX.into(), Word::MAX.into(), 1); + check_big_wrapping_mul(DoubleWord::MAX - 5, DoubleWord::MAX - 6, 2); + check_big_wrapping_mul(0xa945_aa5e_429a_6d1a, 0x4072_d45d_3355_237b, 3); + check_big_wrapping_mul( + 0x8ae1_5515_fc92_b1c0_b473_8ce8_6bbf_7218, + 0x43e9_8b77_1f7c_aa93_6c4c_85e9_7fd0_504f, + 3, + ); + + fn check_big_wrapping_mul(a: u128, b: u128, output_digits: usize) { + let expected = (num::BigUint::from(a) * num::BigUint::from(b)) + % num::BigUint::from(2_u32).pow((output_digits * WORD_BITS) as u32); + let x = MPNat::from_big_endian(&a.to_be_bytes()); + let y = MPNat::from_big_endian(&b.to_be_bytes()); + let mut out = vec![0; output_digits]; + big_wrapping_mul(&x, &y, &mut out); + let result = { + let result = MPNat { digits: out }.to_big_endian(); + num::BigUint::from_bytes_be(&result) + }; + assert_eq!(result, expected, "{a}*{b} != {expected}"); + } +} + +#[test] +fn test_big_sq() { + check_big_sq(0); + check_big_sq(1); + check_big_sq(Word::MAX.into()); + check_big_sq(2 * (Word::MAX as u128)); + check_big_sq(0x8e67904953db9a2bf6da64bf8bda866d); + check_big_sq(0x9f8dc1c3fc0bf50fe75ac3bbc03124c9); + check_big_sq(0x9c9a17378f3d064e5eaa80eeb3850cd7); + check_big_sq(0xc7f03fbb1c186c05e54b3ee19106baa4); + check_big_sq(0xcf2025cee03025d247ad190e9366d926); + check_big_sq(u128::MAX); + + fn check_big_sq(a: u128) { + let expected = num::BigUint::from(a).pow(2_u32); + let x = MPNat::from_big_endian(&a.to_be_bytes()); + let mut out = vec![0; 2 * x.digits.len() + 1]; + big_sq(&x, &mut out); + let result = { + let result = MPNat { digits: out }.to_big_endian(); + num::BigUint::from_bytes_be(&result) + }; + assert_eq!(result, expected, "{a}^2 != {expected}"); + } +} + +#[test] +fn test_borrowing_sub() { + assert_eq!(borrowing_sub(0, 0, false), (0, false)); + assert_eq!(borrowing_sub(1, 0, false), (1, false)); + assert_eq!(borrowing_sub(47, 5, false), (42, false)); + assert_eq!(borrowing_sub(101, 7, true), (93, false)); + assert_eq!( + borrowing_sub(0x00_00_01_00, 0x00_00_02_00, false), + (Word::MAX - 0xFF, true) + ); + assert_eq!( + borrowing_sub(0x00_00_01_00, 0x00_00_10_00, true), + (Word::MAX - 0x0F_00, true) + ); +} + +// These examples are correctly stated +#[allow(clippy::mistyped_literal_suffixes)] +#[test] +fn test_shifted_carrying_mul() { + assert_eq!(shifted_carrying_mul(0, 0, 0, 0), (0, 0)); + assert_eq!(shifted_carrying_mul(0, 6, 7, 0), (42, 0)); + assert_eq!(shifted_carrying_mul(0, 6, 7, 8), (50, 0)); + assert_eq!(shifted_carrying_mul(5, 6, 7, 8), (55, 0)); + assert_eq!( + shifted_carrying_mul( + Word::MAX - 0x11, + Word::MAX - 0x1234, + Word::MAX - 0xABCD, + Word::MAX - 0xFF + ), + (0x0C_38_0C_94, Word::MAX - 0xBE00) + ); + assert_eq!( + shifted_carrying_mul(Word::MAX, Word::MAX, Word::MAX, Word::MAX), + (Word::MAX, Word::MAX) + ); +} + +#[cfg(test)] +pub fn mp_nat_to_u128(x: &MPNat) -> u128 { + let mut buf = [0u8; 16]; + let result = x.to_big_endian(); + let k = result.len(); + buf[(16 - k)..].copy_from_slice(&result); + u128::from_be_bytes(buf) +} diff --git a/engine-modexp/src/lib.rs b/engine-modexp/src/lib.rs new file mode 100644 index 000000000..fbcfec2fc --- /dev/null +++ b/engine-modexp/src/lib.rs @@ -0,0 +1,50 @@ +#![cfg_attr(not(feature = "std"), no_std)] +// All `as` conversions in this code base have been carefully reviewed +// and are safe. +#![allow(clippy::as_conversions)] + +mod arith; +mod maybe_std; +mod mpnat; + +use maybe_std::Vec; + +/// Computes `(base ^ exp) % modulus`, where all values are given as big-endian +/// encoded bytes. +pub fn modexp(base: &[u8], exp: &[u8], modulus: &[u8]) -> Vec { + let mut x = mpnat::MPNat::from_big_endian(base); + let m = mpnat::MPNat::from_big_endian(modulus); + if m.digits.len() == 1 && m.digits[0] == 0 { + return Vec::new(); + } + let result = x.modpow(exp, &m); + result.to_big_endian() +} + +#[cfg(feature = "bench")] +pub fn modexp_ibig(base: &[u8], exp: &[u8], modulus: &[u8]) -> Vec { + use num::Zero; + + let base = ibig::UBig::from_be_bytes(base); + let modulus = ibig::UBig::from_be_bytes(modulus); + if modulus.is_zero() { + return Vec::new(); + } + let exponent = ibig::UBig::from_be_bytes(exp); + let ring = ibig::modular::ModuloRing::new(&modulus); + let result = ring.from(base).pow(&exponent); + result.residue().to_be_bytes() +} + +#[cfg(feature = "bench")] +pub fn modexp_num(base: &[u8], exp: &[u8], modulus: &[u8]) -> Vec { + use num::Zero; + + let base = num::BigUint::from_bytes_be(base); + let modulus = num::BigUint::from_bytes_be(modulus); + if modulus.is_zero() { + return Vec::new(); + } + let exponent = num::BigUint::from_bytes_be(exp); + base.modpow(&exponent, &modulus).to_bytes_be() +} diff --git a/engine-modexp/src/maybe_std.rs b/engine-modexp/src/maybe_std.rs new file mode 100644 index 000000000..34871ad08 --- /dev/null +++ b/engine-modexp/src/maybe_std.rs @@ -0,0 +1,8 @@ +#[cfg(not(feature = "std"))] +extern crate alloc; + +#[cfg(feature = "std")] +pub use std::{vec, vec::Vec}; + +#[cfg(not(feature = "std"))] +pub use alloc::{vec, vec::Vec}; diff --git a/engine-modexp/src/mpnat.rs b/engine-modexp/src/mpnat.rs new file mode 100644 index 000000000..81b6780b4 --- /dev/null +++ b/engine-modexp/src/mpnat.rs @@ -0,0 +1,730 @@ +use crate::{ + arith::{ + big_mod_inv, big_wrapping_mul, big_wrapping_pow, borrowing_sub, carrying_add, + compute_r_mod_n, in_place_add, in_place_mul_sub, in_place_shl, in_place_shr, + join_as_double, mod_inv, monpro, monsq, + }, + maybe_std::{vec, Vec}, +}; + +pub type Word = u64; +pub type DoubleWord = u128; +pub const WORD_BYTES: usize = core::mem::size_of::(); +pub const WORD_BITS: usize = Word::BITS as usize; +pub const BASE: DoubleWord = (Word::MAX as DoubleWord) + 1; + +/// Multi-precision natural number, represented in base `Word::MAX + 1 = 2^WORD_BITS`. +/// The digits are stored in little-endian order, i.e. digits[0] is the least +/// significant digit. +#[derive(Debug)] +pub struct MPNat { + pub digits: Vec, +} + +impl MPNat { + pub fn from_big_endian(bytes: &[u8]) -> Self { + if bytes.is_empty() { + return Self { digits: vec![0] }; + } + // Remainder on division by WORD_BYTES + let r = bytes.len() & (WORD_BYTES - 1); + let n_digits = if r == 0 { + bytes.len() / WORD_BYTES + } else { + // Need an extra digit for the remainder + (bytes.len() / WORD_BYTES) + 1 + }; + let mut digits = vec![0; n_digits]; + // buffer to hold Word-sized slices of the input bytes + let mut buf = [0u8; WORD_BYTES]; + let mut i = n_digits - 1; + if r != 0 { + buf[(WORD_BYTES - r)..].copy_from_slice(&bytes[0..r]); + digits[i] = Word::from_be_bytes(buf); + if i == 0 { + // Special case where there is just one digit + return Self { digits }; + } + i -= 1; + } + let mut j = r; + loop { + let next_j = j + WORD_BYTES; + buf.copy_from_slice(&bytes[j..next_j]); + digits[i] = Word::from_be_bytes(buf); + if i == 0 { + break; + } else { + i -= 1; + j = next_j; + } + } + // throw away leading zeros + while digits.len() > 1 && digits[digits.len() - 1] == 0 { + digits.pop(); + } + Self { digits } + } + + pub fn is_power_of_two(&self) -> bool { + // A multi-precision number is a power of 2 iff exactly one digit + // is a power of 2 and all others are zero. + let mut found_power_of_two = false; + for &d in self.digits.iter() { + let is_p2 = d.is_power_of_two(); + if (!is_p2 && d != 0) || (is_p2 && found_power_of_two) { + return false; + } else if is_p2 { + found_power_of_two = true; + } + } + found_power_of_two + } + + pub fn is_odd(&self) -> bool { + // A binary number is odd iff its lowest order bit is set. + self.digits[0] & 1 == 1 + } + + /// Computes `self ^ exp mod modulus`. `exp` must be given as big-endian bytes. + pub fn modpow(&mut self, exp: &[u8], modulus: &Self) -> Self { + if exp.len() <= core::mem::size_of::() { + let exp_as_number = { + let mut tmp: usize = 0; + for d in exp { + tmp *= 256; + tmp += (*d) as usize; + } + tmp + }; + + if let Some(max_output_digits) = self.digits.len().checked_mul(exp_as_number) { + if modulus.digits.len() > max_output_digits { + // Special case: modulus is larger than `base ^ exp`, so division is not relevant + let mut scratch_space = vec![0; max_output_digits]; + return big_wrapping_pow(self, exp, &mut scratch_space); + } + } + } + + if modulus.is_power_of_two() { + return self.modpow_with_power_of_two(exp, modulus); + } else if modulus.is_odd() { + return self.modpow_montgomery(exp, modulus); + } + + // If the modulus is not a power of two and not an odd number then + // it is a product of some power of two with an odd number. In this + // case we will use the Chinese remainder theorem to get the result. + // See http://www.people.vcu.edu/~jwang3/CMSC691/j34monex.pdf + + let trailing_zeros = modulus.digits.iter().take_while(|x| x == &&0).count(); + let additional_zero_bits = modulus.digits[trailing_zeros].trailing_zeros() as usize; + let power_of_two = { + let mut tmp = MPNat { + digits: vec![0; trailing_zeros + 1], + }; + tmp.digits[trailing_zeros] = 1 << additional_zero_bits; + tmp + }; + let power_of_two_mask = *power_of_two.digits.last().unwrap() - 1; + let odd = { + let num_digits = modulus.digits.len() - trailing_zeros; + let mut tmp = MPNat { + digits: vec![0; num_digits], + }; + if additional_zero_bits > 0 { + tmp.digits[0] = modulus.digits[trailing_zeros] >> additional_zero_bits; + for i in 1..num_digits { + let d = modulus.digits[trailing_zeros + i]; + tmp.digits[i - 1] += + (d & power_of_two_mask) << (WORD_BITS - additional_zero_bits); + tmp.digits[i] = d >> additional_zero_bits; + } + } else { + tmp.digits + .copy_from_slice(&modulus.digits[trailing_zeros..]); + } + while tmp.digits.last() == Some(&0) { + tmp.digits.pop(); + } + tmp + }; + debug_assert!(power_of_two.is_power_of_two(), "Factored out power of two"); + debug_assert!( + odd.is_odd(), + "Remaining number is odd after factoring out powers of two" + ); + debug_assert!( + { + let mut tmp = vec![0; modulus.digits.len()]; + big_wrapping_mul(&power_of_two, &odd, &mut tmp); + tmp == modulus.digits + }, + "modulus is factored" + ); + + let mut base_copy = MPNat { + digits: self.digits.clone(), + }; + let x1 = base_copy.modpow_montgomery(exp, &odd); + let x2 = self.modpow_with_power_of_two(exp, &power_of_two); + + let s = power_of_two.digits.len(); + let mut scratch = vec![0; s]; + let odd_inv = { + let mut tmp = MPNat { digits: vec![0; s] }; + big_mod_inv(&odd, &mut tmp, &mut scratch); + *tmp.digits.last_mut().unwrap() &= power_of_two_mask; + tmp + }; + let diff = { + scratch.fill(0); + let mut b = false; + for (i, scratch_digit) in scratch.iter_mut().enumerate().take(s) { + let (diff, borrow) = borrowing_sub( + x2.digits.get(i).copied().unwrap_or(0), + x1.digits.get(i).copied().unwrap_or(0), + b, + ); + *scratch_digit = diff; + b = borrow; + } + MPNat { digits: scratch } + }; + let y = { + let mut out = vec![0; s]; + big_wrapping_mul(&diff, &odd_inv, &mut out); + *out.last_mut().unwrap() &= power_of_two_mask; + MPNat { digits: out } + }; + + // Re-use allocation for efficiency + let mut digits = diff.digits; + let s = modulus.digits.len(); + digits.fill(0); + digits.resize(s, 0); + big_wrapping_mul(&odd, &y, &mut digits); + let mut c = false; + for (i, out_digit) in digits.iter_mut().enumerate() { + let (sum, carry) = carrying_add(x1.digits.get(i).copied().unwrap_or(0), *out_digit, c); + c = carry; + *out_digit = sum; + } + MPNat { digits } + } + + // Computes `self ^ exp mod modulus` using Montgomery multiplication. + // See https://www.microsoft.com/en-us/research/wp-content/uploads/1996/01/j37acmon.pdf + fn modpow_montgomery(&mut self, exp: &[u8], modulus: &Self) -> Self { + // The montgomery method only works with odd modulus. + debug_assert!(modulus.is_odd()); + + // n_prime satisfies `r * (r^(-1)) - modulus * n' = 1`, where + // `r = 2^(WORD_BITS*modulus.digits.len())`. + let n_prime = Word::MAX - mod_inv(modulus.digits[0]) + 1; + let s = modulus.digits.len(); + + let mut x_bar = MPNat { digits: vec![0; s] }; + // Initialize result as `r mod modulus` (Montgomery form of 1) + compute_r_mod_n(modulus, &mut x_bar.digits); + + // Reduce base mod modulus + self.sub_to_same_size(modulus); + + // Need to compute a_bar = base * r mod modulus; + // First directly multiply base * r to get a 2s-digit number, + // then reduce mod modulus. + let a_bar = { + let mut tmp = MPNat { + digits: vec![0; 2 * s], + }; + big_wrapping_mul(self, &x_bar, &mut tmp.digits); + tmp.sub_to_same_size(modulus); + tmp + }; + + // scratch space for monpro algorithm + let mut scratch = vec![0; 2 * s + 1]; + let monpro_len = s + 2; + + // Use binary method for computing exp, but with monpro as the multiplication + for &b in exp { + let mut mask: u8 = 1 << 7; + while mask > 0 { + monsq(&x_bar, modulus, n_prime, &mut scratch); + x_bar.digits.copy_from_slice(&scratch[0..s]); + scratch.fill(0); + if b & mask != 0 { + monpro( + &x_bar, + &a_bar, + modulus, + n_prime, + &mut scratch[0..monpro_len], + ); + x_bar.digits.copy_from_slice(&scratch[0..s]); + scratch.fill(0); + } + mask >>= 1; + } + } + + // Convert out of Montgomery form by computing monpro with 1 + let one = { + // We'll reuse the memory space from a_bar for efficiency. + let mut digits = a_bar.digits; + digits.fill(0); + digits[0] = 1; + MPNat { digits } + }; + monpro(&x_bar, &one, modulus, n_prime, &mut scratch[0..monpro_len]); + scratch.resize(s, 0); + MPNat { digits: scratch } + } + + fn modpow_with_power_of_two(&mut self, exp: &[u8], modulus: &Self) -> Self { + debug_assert!(modulus.is_power_of_two()); + // We know `modulus` is a power of 2. So reducing is as easy as bit shifting. + // We also know the modulus is non-zero because 0 is not a power of 2. + + // First reduce self to be the same size as the modulus + self.force_same_size(modulus); + // The modulus is a power of 2 but that power may not be a multiple of a whole word. + // We can clear out any higher order bits to fix this. + let modulus_mask = *modulus.digits.last().unwrap() - 1; + *self.digits.last_mut().unwrap() &= modulus_mask; + + // We know that `totient(2^k) = 2^(k-1)`, therefore by Euler's theorem + // we can also reduce the exponent mod `2^(k-1)`. Effectively this means + // throwing away bytes to make `exp` shorter. Note: Euler's theorem only applies + // if the base and modulus are coprime (which in this case means the base is odd). + let exp = if self.is_odd() && (exp.len() > WORD_BYTES * modulus.digits.len()) { + &exp[(exp.len() - WORD_BYTES * modulus.digits.len())..] + } else { + exp + }; + + let mut scratch_space = vec![0; modulus.digits.len()]; + let mut result = big_wrapping_pow(self, exp, &mut scratch_space); + + // The modulus is a power of 2 but that power may not be a multiple of a whole word. + // We can clear out any higher order bits to fix this. + *result.digits.last_mut().unwrap() &= modulus_mask; + + result + } + + /// Makes `self` have the same number of digits as `other` by + /// pushing 0s or dropping higher order digits as needed. + /// This is equivalent to reducing `self` modulo `2^(WORD_BITS*k)` where + /// `k` is the number of digits in `other`. + fn force_same_size(&mut self, other: &Self) { + self.digits.resize(other.digits.len(), 0); + + // This is here to just drive the point home about what the + // invariant is after calling this function. + debug_assert_eq!(self.digits.len(), other.digits.len()); + } + + /// Assumes `self` has more digits than `other`. + /// Makes `self` have the same number of digits as `other` by subtracting off multiples + /// of `other`. This is a partial reduction of `self` modulo `other`, but rather + /// than doing the full division, the goal is simply to make the two numbers have the + /// same number of digits. + fn sub_to_same_size(&mut self, other: &Self) { + // Remove leading zeros before starting + while self.digits.len() > 1 && self.digits.last() == Some(&0) { + self.digits.pop(); + } + + let n = other.digits.len(); + let m = self.digits.len().saturating_sub(n); + if m == 0 { + return; + } + + let other_most_sig = *other.digits.last().unwrap(); + + if self.digits.len() == 2 { + // This is the smallest case since `n >= 1` and `m > 0` + // implies that `self.digits.len() >= 2`. + // In this case we can use DoubleWord-sized arithmetic + // to get the answer directly. + let self_most_sig = self.digits.pop().unwrap(); + let a = join_as_double(self_most_sig, self.digits[0]); + let b = other_most_sig as DoubleWord; + self.digits[0] = (a % b) as Word; + return; + } + + if n == 1 { + // The divisor is only 1 digit, so the long-division + // algorithm is easy. + let k = self.digits.len() - 1; + for j in (0..k).rev() { + let self_most_sig = self.digits.pop().unwrap(); + let self_second_sig = self.digits[j]; + let r = + join_as_double(self_most_sig, self_second_sig) % (other_most_sig as DoubleWord); + self.digits[j] = r as Word; + } + return; + } + + // At this stage we know that `n >= 2` and `self.digits.len() >= 3`. + // The smaller cases are covered in the if-statements above. + + // The algorithm below only works well when the divisor's + // most significant digit is at least `BASE / 2`. + // If it is too small then we "normalize" by multiplying + // both numerator and denominator by a common factor + // and run the algorithm on those numbers. + // See Knuth The Art of Computer Programming vol. 2 section 4.3 for details. + let shift = other_most_sig.leading_zeros(); + if shift > 0 { + // Normalize self + let overflow = in_place_shl(&mut self.digits, shift); + self.digits.push(overflow); + + // Normalize other + let mut normalized = other.digits.clone(); + let overflow = in_place_shl(&mut normalized, shift); + debug_assert_eq!(overflow, 0, "Normalizing modulus cannot overflow"); + debug_assert_eq!( + normalized[n - 1].leading_zeros(), + 0, + "Most significant bit is set" + ); + + // Run algorithm on normalized values + self.sub_to_same_size(&MPNat { digits: normalized }); + + // need to de-normalize to get the correct result + in_place_shr(&mut self.digits, shift); + + return; + } + + let other_second_sig = other.digits[n - 2]; + let mut self_most_sig: Word = 0; + for j in (0..=m).rev() { + let self_second_sig = *self.digits.last().unwrap(); + let self_third_sig = self.digits[self.digits.len() - 2]; + + let (mut q_hat, mut r_hat) = { + let a = join_as_double(self_most_sig, self_second_sig); + let mut q_hat = a / (other_most_sig as DoubleWord); + let mut r_hat = a % (other_most_sig as DoubleWord); + + if q_hat == BASE { + q_hat -= 1; + r_hat += other_most_sig as DoubleWord; + } + + (q_hat as Word, r_hat) + }; + + while r_hat < BASE + && join_as_double(r_hat as Word, self_third_sig) + < (q_hat as DoubleWord) * (other_second_sig as DoubleWord) + { + q_hat -= 1; + r_hat += other_most_sig as DoubleWord; + } + + let mut borrow = in_place_mul_sub(&mut self.digits[j..], &other.digits, q_hat); + if borrow > self_most_sig { + // q_hat was too large, add back one multiple of the modulus + let carry = in_place_add(&mut self.digits[j..], &other.digits); + debug_assert!( + carry, + "Adding back should cause overflow to cancel the borrow" + ); + borrow -= 1; + } + // Most significant digit of self has been cancelled out + debug_assert_eq!(borrow, self_most_sig); + self_most_sig = self.digits.pop().unwrap(); + } + + self.digits.push(self_most_sig); + debug_assert!(self.digits.len() <= n); + } + + pub fn to_big_endian(&self) -> Vec { + if self.digits.iter().all(|x| x == &0) { + return vec![0]; + } + + // Safety: unwrap is safe since `self.digits` is always non-empty. + let most_sig_bytes: [u8; WORD_BYTES] = self.digits.last().unwrap().to_be_bytes(); + // The most significant digit may not need 4 bytes. + // Only include as many bytes as needed in the output. + let be_initial_bytes = { + let mut tmp: &[u8] = &most_sig_bytes; + while !tmp.is_empty() && tmp[0] == 0 { + tmp = &tmp[1..]; + } + tmp + }; + + let mut result = vec![0u8; (self.digits.len() - 1) * WORD_BYTES + be_initial_bytes.len()]; + result[0..be_initial_bytes.len()].copy_from_slice(be_initial_bytes); + for (i, d) in self.digits.iter().take(self.digits.len() - 1).enumerate() { + let bytes = d.to_be_bytes(); + let j = result.len() - WORD_BYTES * i; + result[(j - WORD_BYTES)..j].copy_from_slice(&bytes); + } + result + } +} + +#[test] +fn test_modpow_even() { + check_modpow_even(3, 5, 500, 243); + check_modpow_even(3, 5, 20, 3); + + check_modpow_even( + 0x2ff4f4df4c518867207c84b57a77aa50, + 0xca83c2925d17c577c9a03598b6f360, + 0xf863d4f17a5405d84814f54c92f803c8, + 0x8d216c9a1fb275ed18eb340ed43cacc0, + ); + check_modpow_even( + 0x13881e1614244c56d15ac01096b070e7, + 0x336df5b4567cbe4c093271dc151e6c72, + 0x7540f399a0b6c220f1fc60d2451a1ff0, + 0x1251d64c552e8f831f5b841d2811f9c1, + ); + check_modpow_even( + 0x774d5b2494a449d8f22b22ea542d4ddf, + 0xd2f602e1688f271853e7794503c2837e, + 0xa80d20ebf75f92192159197b60f36e8e, + 0x3fbbba42489b27fc271fb39f54aae2e1, + ); + check_modpow_even( + 0x756e409cc3583a6b68ae27ccd9eb3d50, + 0x16dafb38a334288954d038bedbddc970, + 0x1f9b2237f09413d1fc44edf9bd02b8bc, + 0x9347445ac61536a402723cd07a3f5a4, + ); + check_modpow_even( + 0x6dcb8405e2cc4dcebee3e2b14861b47d, + 0xe6c1e5251d6d5deb8dddd0198481d671, + 0xe34a31d814536e8b9ff6cc5300000000, + 0xaa86af638386880334694967564d0c3d, + ); + check_modpow_even( + 0x9c12fe4a1a97d17c1e4573247a43b0e5, + 0x466f3e0a2e8846b8c48ecbf612b96412, + 0x710d7b9d5718acff0000000000000000, + 0x569bf65929e71cd10a553a8623bdfc99, + ); + check_modpow_even( + 0x6d018fdeaa408222cb10ff2c36124dcf, + 0x8e35fc05d490bb138f73c2bc284a67a7, + 0x6c237160750d78400000000000000000, + 0x3fe14e11392c6c6be8efe956c965d5af, + ); + + let base: Vec = vec![ + 0x36, 0xAB, 0xD4, 0x52, 0x4E, 0x89, 0xA3, 0x4C, 0x89, 0xC4, 0x20, 0x94, 0x25, 0x47, 0xE1, + 0x2C, 0x7B, 0xE1, + ]; + let exponent: Vec = vec![0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x17, 0xEA, 0x78]; + let modulus: Vec = vec![ + 0x02, 0xF0, 0x75, 0x8C, 0x6A, 0x04, 0x20, 0x09, 0x55, 0xB6, 0x49, 0xC3, 0x57, 0x22, 0xB8, + 0x00, 0x00, 0x00, 0x00, + ]; + let result = crate::modexp(&base, &exponent, &modulus); + assert_eq!( + result, + vec![2, 63, 79, 118, 41, 54, 235, 9, 115, 212, 107, 110, 173, 181, 157, 104, 208, 97, 1] + ); + + let base = hex::decode("36abd4524e89a34c89c420942547e12c7be1").unwrap(); + let exponent = hex::decode("01000000000517ea78").unwrap(); + let modulus = hex::decode("02f0758c6a04200955b649c35722b800000000").unwrap(); + let result = crate::modexp(&base, &exponent, &modulus); + assert_eq!( + hex::encode(result), + "023f4f762936eb0973d46b6eadb59d68d06101" + ); + + fn check_modpow_even(base: u128, exp: u128, modulus: u128, expected: u128) { + let mut x = MPNat::from_big_endian(&base.to_be_bytes()); + let m = MPNat::from_big_endian(&modulus.to_be_bytes()); + let result = x.modpow(&exp.to_be_bytes(), &m); + let result = crate::arith::mp_nat_to_u128(&result); + assert_eq!(result, expected); + } +} + +#[test] +fn test_modpow_montgomery() { + check_modpow_montgomery(3, 5, 0x9346_9d50_1f74_d1c1, 243); + check_modpow_montgomery(3, 5, 19, 15); + check_modpow_montgomery( + 0x5c4b74ec760dfb021499f5c5e3c69222, + 0x62b2a34b21cf4cc036e880b3fb59fe09, + 0x7b799c4502cd69bde8bb12601ce3ff15, + 0x10c9d9071d0b86d6a59264d2f461200, + ); + check_modpow_montgomery( + 0xadb5ce8589030e3a9112123f4558f69c, + 0xb002827068f05b84a87431a70fb763ab, + 0xc4550871a1cfc67af3e77eceb2ecfce5, + 0x7cb78c0e1c1b43f6412e9d1155ea96d2, + ); + check_modpow_montgomery( + 0x26eb51a5d9bf15a536b6e3c67867b492, + 0xddf007944a79bf55806003220a58cc6, + 0xc96275a80c694a62330872b2690f8773, + 0x23b75090ead913def3a1e0bde863eda7, + ); + check_modpow_montgomery( + 0xb93fa81979e597f548c78f2ecb6800f3, + 0x5fad650044963a271898d644984cb9f0, + 0xbeb60d6bd0439ea39d447214a4f8d3ab, + 0x354e63e6a5e007014acd3e5ea88dc3ad, + ); + check_modpow_montgomery( + 0x1993163e4f578869d04949bc005c878f, + 0x8cb960f846475690259514af46868cf5, + 0x52e104dc72423b534d8e49d878f29e3b, + 0x2aa756846258d5cfa6a3f8b9b181a11c, + ); + + fn check_modpow_montgomery(base: u128, exp: u128, modulus: u128, expected: u128) { + let mut x = MPNat::from_big_endian(&base.to_be_bytes()); + let m = MPNat::from_big_endian(&modulus.to_be_bytes()); + let result = x.modpow_montgomery(&exp.to_be_bytes(), &m); + let result = crate::arith::mp_nat_to_u128(&result); + assert_eq!( + result, expected, + "({base} ^ {exp}) % {modulus} failed check_modpow_montgomery" + ); + } +} + +#[test] +fn test_modpow_with_power_of_two() { + check_modpow_with_power_of_two(3, 2, 1 << 30, 9); + check_modpow_with_power_of_two(3, 5, 1 << 30, 243); + check_modpow_with_power_of_two(3, 1_000_000, 1 << 30, 641836289); + check_modpow_with_power_of_two(3, 1_000_000, 1 << 31, 1715578113); + check_modpow_with_power_of_two(3, 1_000_000, 1 << 32, 3863061761); + check_modpow_with_power_of_two( + 0xabcd_ef01_2345_6789_1111, + 0x1234_5678_90ab_cdef, + 1 << 5, + 17, + ); + check_modpow_with_power_of_two( + 0x3f47_9dc0_d5b9_6003, + 0xa180_e045_e314_8581, + 1 << 118, + 0x0028_3d19_e6cc_b8a0_e050_6abb_b9b1_1a03, + ); + + fn check_modpow_with_power_of_two(base: u128, exp: u128, modulus: u128, expected: u128) { + let mut x = MPNat::from_big_endian(&base.to_be_bytes()); + let m = MPNat::from_big_endian(&modulus.to_be_bytes()); + let result = x.modpow_with_power_of_two(&exp.to_be_bytes(), &m); + let result = crate::arith::mp_nat_to_u128(&result); + assert_eq!(result, expected); + } +} + +#[test] +fn test_sub_to_same_size() { + check_sub_to_same_size(0x10_00_00_00_00, 0xFF_00_00_00); + check_sub_to_same_size(0x10_00_00_00_00, 0x01_00_00_00); + check_sub_to_same_size(0x35_00_00_00_00, 0x01_00_00_00); + check_sub_to_same_size(0xEF_00_00_00_00_00_00, 0x02_FF_FF_FF); + + let n = 10; + let a = 57 + 2 * n + 0x1234_0000_0000 * n + 0x000b_0000_0000_0000_0000 * n; + check_sub_to_same_size(a, n); + + fn check_sub_to_same_size(a: u128, n: u128) { + let mut x = MPNat::from_big_endian(&a.to_be_bytes()); + let y = MPNat::from_big_endian(&n.to_be_bytes()); + x.sub_to_same_size(&y); + assert!(x.digits.len() <= y.digits.len()); + let result = crate::arith::mp_nat_to_u128(&x); + assert_eq!(result % n, a % n, "{a} % {n} failed sub_to_same_size check"); + } +} + +#[test] +fn test_mp_nat_is_odd() { + for n in 0..1025 { + check_is_odd(n); + } + for n in 0xFF_FF_FF_FF_00_00_00_00..0xFF_FF_FF_FF_00_00_04_01 { + check_is_odd(n); + } + + fn check_is_odd(n: u128) { + let mp = MPNat::from_big_endian(&n.to_be_bytes()); + assert_eq!(mp.is_odd(), n % 2 == 1, "{n} failed is_odd test"); + } +} + +#[test] +fn test_mp_nat_is_power_of_two() { + check_is_p2(0, false); + check_is_p2(1, true); + check_is_p2(1327, false); + check_is_p2((1 << 1) + (1 << 35), false); + check_is_p2(1 << 1, true); + check_is_p2(1 << 2, true); + check_is_p2(1 << 3, true); + check_is_p2(1 << 4, true); + check_is_p2(1 << 5, true); + check_is_p2(1 << 31, true); + check_is_p2(1 << 32, true); + check_is_p2(1 << 64, true); + check_is_p2(1 << 65, true); + check_is_p2(1 << 127, true); + + fn check_is_p2(n: u128, expected_result: bool) { + let mp = MPNat::from_big_endian(&n.to_be_bytes()); + assert_eq!( + mp.is_power_of_two(), + expected_result, + "{n} failed is_power_of_two test" + ); + } +} + +#[test] +fn test_mp_nat_be() { + be_round_trip(""); + be_round_trip("00"); + be_round_trip("77"); + be_round_trip("abcd"); + be_round_trip("00000000abcd"); + be_round_trip("abcdef"); + be_round_trip("abcdef00"); + be_round_trip("abcdef0011"); + be_round_trip("abcdef001122"); + be_round_trip("abcdef00112233"); + be_round_trip("abcdef0011223344"); + be_round_trip("abcdef001122334455"); + be_round_trip("abcdef01234567891011121314151617181920"); + + fn be_round_trip(hex_input: &str) { + let bytes = hex::decode(hex_input).unwrap(); + let mp = MPNat::from_big_endian(&bytes); + let output = mp.to_big_endian(); + let hex_output = hex::encode(output); + let trimmed = match hex_input.trim_start_matches('0') { + x if x.is_empty() => "00", + x => x, + }; + assert_eq!(hex_output, trimmed) + } +} diff --git a/engine-precompiles/Cargo.toml b/engine-precompiles/Cargo.toml index d65442216..e3bb8e747 100644 --- a/engine-precompiles/Cargo.toml +++ b/engine-precompiles/Cargo.toml @@ -13,6 +13,7 @@ publish = false autobenches = false [dependencies] +aurora-engine-modexp = { path = "../engine-modexp", default-features = false } aurora-engine-types = { path = "../engine-types", default-features = false } aurora-engine-sdk = { path = "../engine-sdk", default-features = false } borsh = { version = "0.10", default-features = false } diff --git a/engine-precompiles/src/modexp.rs b/engine-precompiles/src/modexp.rs index 57af4b0a2..47eb9dd1b 100644 --- a/engine-precompiles/src/modexp.rs +++ b/engine-precompiles/src/modexp.rs @@ -1,10 +1,10 @@ use crate::prelude::types::{Address, EthGas}; -use crate::prelude::{PhantomData, Vec, U256}; +use crate::prelude::{Cow, PhantomData, Vec, U256}; use crate::{ utils, Berlin, Byzantium, EvmPrecompileResult, HardFork, Precompile, PrecompileOutput, }; use evm::{Context, ExitError}; -use num::{BigUint, Integer}; +use num::{Integer, Zero}; #[derive(Default)] pub struct ModExp(PhantomData); @@ -55,17 +55,15 @@ impl ModExp { let mod_start = exp_end; - let base = parse_bytes(input, base_start, base_len, BigUint::from_bytes_be); - let modulus = parse_bytes(input, mod_start, mod_len, BigUint::from_bytes_be); - - let computed_result = if modulus == BigUint::from(0u32) { + let modulus = parse_input_range_to_slice(input, mod_start, mod_len); + let computed_result = if modulus.iter().all(Zero::is_zero) { Vec::new() } else { - // The OOM panic is no longer possible because if the modulus is non-zero - // then the required gas prevents passing a huge exponent. - let exponent = parse_bytes(input, exp_start, exp_len, BigUint::from_bytes_be); - base.modpow(&exponent, &modulus).to_bytes_be() + let base = parse_input_range_to_slice(input, base_start, base_len); + let exponent = parse_input_range_to_slice(input, exp_start, exp_len); + aurora_engine_modexp::modexp(&base, &exponent, &modulus) }; + // The result must be the same length as the input modulus. // To ensure this we pad on the left with zeros. if mod_len > computed_result.len() { @@ -177,6 +175,25 @@ impl Precompile for ModExp { } } +fn parse_input_range_to_slice(input: &[u8], start: usize, size: usize) -> Cow<[u8]> { + let len = input.len(); + if start >= len { + return Cow::Owned(Vec::new()); + } + let end = start.saturating_add(size); + if end > len { + let bytes: Vec = input[start..] + .iter() + .copied() + .chain(core::iter::repeat(0u8)) + .take(size) + .collect(); + Cow::Owned(bytes) + } else { + Cow::Borrowed(&input[start..end]) + } +} + fn parse_bytes T>(input: &[u8], start: usize, size: usize, f: F) -> T { let len = input.len(); if start >= len { diff --git a/engine-precompiles/src/xcc.rs b/engine-precompiles/src/xcc.rs index 0f768b42d..64d61fa24 100644 --- a/engine-precompiles/src/xcc.rs +++ b/engine-precompiles/src/xcc.rs @@ -31,7 +31,7 @@ pub mod costs { /// /// This process is done in the `test_xcc_eth_gas_cost` test in /// `engine-tests/src/tests/xcc.rs`. - pub const CROSS_CONTRACT_CALL_BASE: EthGas = EthGas::new(323_000); + pub const CROSS_CONTRACT_CALL_BASE: EthGas = EthGas::new(343_650); /// Additional EVM gas cost per bytes of input given. /// See `CROSS_CONTRACT_CALL_BASE` for estimation methodology. pub const CROSS_CONTRACT_CALL_BYTE: EthGas = EthGas::new(3); diff --git a/engine-sdk/src/near_runtime.rs b/engine-sdk/src/near_runtime.rs index 6ec665e6a..4ab76e780 100644 --- a/engine-sdk/src/near_runtime.rs +++ b/engine-sdk/src/near_runtime.rs @@ -78,7 +78,7 @@ impl Runtime { /// by a previous call. fn read_account_id() -> AccountId { let bytes = Self::ENV_REGISTER_ID.to_vec(); - AccountId::try_from(bytes).map_or_else(|_| unreachable!(), |account_id| account_id) + AccountId::try_from(bytes).expect("Invalid Account Id") } /// Convenience wrapper around `exports::promise_batch_action_function_call` diff --git a/engine-standalone-storage/src/lib.rs b/engine-standalone-storage/src/lib.rs index 5bb24183a..c4dd5d302 100644 --- a/engine-standalone-storage/src/lib.rs +++ b/engine-standalone-storage/src/lib.rs @@ -318,15 +318,17 @@ impl Storage { while iter.valid() { // unwrap is safe because the iterator is valid let db_key = iter.key().unwrap().to_vec(); - if db_key[0..engine_prefix_len] != engine_prefix { + if db_key.get(0..engine_prefix_len) != Some(&engine_prefix) { break; } // raw engine key skips the 2-byte prefix and the block+position suffix - let engine_key = &db_key[engine_prefix_len..(db_key.len() - ENGINE_KEY_SUFFIX_LEN)]; + let engine_key = &db_key + .get(engine_prefix_len..(db_key.len() - ENGINE_KEY_SUFFIX_LEN)) + .expect("index out of bounds"); let key_block_height = { let n = engine_prefix_len + engine_key.len(); let mut buf = [0u8; 8]; - buf.copy_from_slice(&db_key[n..(n + 8)]); + buf.copy_from_slice(db_key.get(n..(n + 8)).expect("index out of bounds")); u64::from_be_bytes(buf) }; // If the key was created after the block height we want then we can skip it @@ -359,7 +361,7 @@ impl Storage { && iter.key().map_or(false, |db_key| { db_key[0..engine_prefix_len] == engine_prefix && &db_key[engine_prefix_len..(db_key.len() - ENGINE_KEY_SUFFIX_LEN)] - == engine_key + == *engine_key }) { iter.next(); diff --git a/engine-standalone-storage/src/relayer_db/mod.rs b/engine-standalone-storage/src/relayer_db/mod.rs index b4fe7e86f..09baa4a73 100644 --- a/engine-standalone-storage/src/relayer_db/mod.rs +++ b/engine-standalone-storage/src/relayer_db/mod.rs @@ -218,7 +218,6 @@ mod test { let engine_state = state::EngineState { chain_id: aurora_engine_types::types::u256_to_arr(&1_313_161_555.into()), owner_id: "aurora".parse().unwrap(), - bridge_prover_id: "prover.bridge.near".parse().unwrap(), upgrade_delay_blocks: 0, }; @@ -241,7 +240,7 @@ mod test { io, &engine_state.owner_id, parameters::InitCallArgs { - prover_account: engine_state.bridge_prover_id.clone(), + prover_account: "prover.bridge.near".parse().unwrap(), eth_custodian_address: "6bfad42cfc4efc96f529d786d643ff4a8b89fa52" .to_string(), metadata: FungibleTokenMetadata::default(), diff --git a/engine-standalone-storage/src/sync/mod.rs b/engine-standalone-storage/src/sync/mod.rs index 63d5241d4..cd3775ce3 100644 --- a/engine-standalone-storage/src/sync/mod.rs +++ b/engine-standalone-storage/src/sync/mod.rs @@ -444,6 +444,14 @@ fn non_submit_execute<'db>( prev.owner_id = args.clone().new_owner; state::set_state(&mut io, &prev)?; + None + } + TransactionKind::SetUpgradeDelayBlocks(args) => { + let mut prev = state::get_state(&io)?; + + prev.upgrade_delay_blocks = args.upgrade_delay_blocks; + state::set_state(&mut io, &prev)?; + None } }; diff --git a/engine-standalone-storage/src/sync/types.rs b/engine-standalone-storage/src/sync/types.rs index b4087dbf4..9f171df32 100644 --- a/engine-standalone-storage/src/sync/types.rs +++ b/engine-standalone-storage/src/sync/types.rs @@ -111,6 +111,8 @@ pub enum TransactionKind { StorageWithdraw(parameters::StorageWithdrawCallArgs), /// Admin only method; used to transfer administration SetOwner(parameters::SetOwnerArgs), + /// Admin only method; used to change upgrade delay blocks + SetUpgradeDelayBlocks(parameters::SetUpgradeDelayBlocksArgs), /// Admin only method SetPausedFlags(parameters::PauseEthConnectorCallArgs), /// Ad entry mapping from address to relayer NEAR account @@ -350,6 +352,7 @@ impl TransactionKind { Self::PausePrecompiles(_) => Self::no_evm_execution("pause_precompiles"), Self::ResumePrecompiles(_) => Self::no_evm_execution("resume_precompiles"), Self::SetOwner(_) => Self::no_evm_execution("set_owner"), + Self::SetUpgradeDelayBlocks(_) => Self::no_evm_execution("set_upgrade_delay_blocks"), Self::FundXccSubAccound(_) => Self::no_evm_execution("fund_xcc_sub_account"), } } @@ -519,6 +522,7 @@ enum BorshableTransactionKind<'a> { SetOwner(Cow<'a, parameters::SetOwnerArgs>), SubmitWithArgs(Cow<'a, parameters::SubmitArgs>), FundXccSubAccound(Cow<'a, FundXccArgs>), + SetUpgradeDelayBlocks(Cow<'a, parameters::SetUpgradeDelayBlocksArgs>), } impl<'a> From<&'a TransactionKind> for BorshableTransactionKind<'a> { @@ -562,6 +566,9 @@ impl<'a> From<&'a TransactionKind> for BorshableTransactionKind<'a> { TransactionKind::ResumePrecompiles(x) => Self::ResumePrecompiles(Cow::Borrowed(x)), TransactionKind::SetOwner(x) => Self::SetOwner(Cow::Borrowed(x)), TransactionKind::FundXccSubAccound(x) => Self::FundXccSubAccound(Cow::Borrowed(x)), + TransactionKind::SetUpgradeDelayBlocks(x) => { + Self::SetUpgradeDelayBlocks(Cow::Borrowed(x)) + } } } } @@ -624,6 +631,9 @@ impl<'a> TryFrom> for TransactionKind { BorshableTransactionKind::FundXccSubAccound(x) => { Ok(Self::FundXccSubAccound(x.into_owned())) } + BorshableTransactionKind::SetUpgradeDelayBlocks(x) => { + Ok(Self::SetUpgradeDelayBlocks(x.into_owned())) + } } } } diff --git a/engine-standalone-tracing/src/types/mod.rs b/engine-standalone-tracing/src/types/mod.rs index 096389d8c..65a5c9c18 100644 --- a/engine-standalone-tracing/src/types/mod.rs +++ b/engine-standalone-tracing/src/types/mod.rs @@ -233,7 +233,7 @@ impl Index for Logs { type Output = TraceLog; fn index(&self, index: usize) -> &Self::Output { - &self.0[index] + self.0.get(index).expect("index out of bounds") } } @@ -319,7 +319,9 @@ impl StepTransactionTrace { /// `None`. #[allow(dead_code)] pub fn step(&mut self) -> Option<&TraceLog> { - if self.step > self.inner.struct_logs.len() { + // We subtract 2 from the length to avoid "index out of bounds" error, + // given the else block increments the step by 1. + if self.step > self.inner.struct_logs.len() - 2 { None } else { self.step += 1; diff --git a/engine-tests/Cargo.toml b/engine-tests/Cargo.toml index 5b083b1f7..f6c3a3d93 100644 --- a/engine-tests/Cargo.toml +++ b/engine-tests/Cargo.toml @@ -16,38 +16,37 @@ autobenches = false [dev-dependencies] aurora-engine = { path = "../engine", default-features = false, features = ["std", "tracing", "impl-serde"] } -aurora-engine-test-doubles = { path = "../engine-test-doubles", default-features = false } -aurora-engine-types = { path = "../engine-types", default-features = false, features = ["std", "impl-serde"] } -aurora-engine-sdk = { path = "../engine-sdk", default-features = false, features = ["std"] } aurora-engine-precompiles = { path = "../engine-precompiles", default-features = false, features = ["std"] } +aurora-engine-sdk = { path = "../engine-sdk", default-features = false, features = ["std"] } +aurora-engine-test-doubles = { path = "../engine-test-doubles", default-features = false } aurora-engine-transactions = { path = "../engine-transactions", default-features = false, features = ["std", "impl-serde"] } -engine-standalone-storage = { path = "../engine-standalone-storage" } -engine-standalone-tracing = { path = "../engine-standalone-tracing", default-features = false, features = ["impl-serde"] } +aurora-engine-types = { path = "../engine-types", default-features = false, features = ["std", "impl-serde"] } borsh = { version = "0.10", default-features = false } -sha3 = { version = "0.10.2", default-features = false } -evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.37.4-aurora", default-features = false, features = ["std", "tracing"] } -evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.37.4-aurora", default-features = false, features = ["std", "tracing"] } -evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.37.4-aurora", default-features = false, features = ["std", "tracing"] } -rlp = { version = "0.5.0", default-features = false } bstr = "1.0.1" byte-slice-cast = { version = "1.0", default-features = false } +criterion = "0.4.0" +engine-standalone-storage = { path = "../engine-standalone-storage" } +engine-standalone-tracing = { path = "../engine-standalone-tracing", default-features = false, features = ["impl-serde"] } ethabi = "18.0" -serde = { version = "1", features = ["derive"] } -serde_json = "1" +evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.37.4-aurora", default-features = false, features = ["std", "tracing"] } +evm-gasometer = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.37.4-aurora", default-features = false, features = ["std", "tracing"] } +evm-runtime = { git = "https://github.com/aurora-is-near/sputnikvm.git", tag = "v0.37.4-aurora", default-features = false, features = ["std", "tracing"] } +git2 = "0.17" hex = { version = "0.4.3", default-features = false } -near-sdk = { git = "https://github.com/aurora-is-near/near-sdk-rs.git", rev = "a4634850023fd115053970f17e10861779d5167d" } -near-sdk-sim = { git = "https://github.com/aurora-is-near/near-sdk-rs.git", rev = "a4634850023fd115053970f17e10861779d5167d" } -near-crypto = { git = "https://github.com/birchmd/nearcore.git", rev = "6033903be2037d67510188450f289b2d6e033f04" } -near-vm-errors = { git = "https://github.com/birchmd/nearcore.git", rev = "6033903be2037d67510188450f289b2d6e033f04" } -near-vm-runner = { git = "https://github.com/birchmd/nearcore.git", rev = "6033903be2037d67510188450f289b2d6e033f04", default-features = false, features = [ "wasmer2_vm" ] } -near-vm-logic = { git = "https://github.com/birchmd/nearcore.git", rev = "6033903be2037d67510188450f289b2d6e033f04" } -near-primitives-core = { git = "https://github.com/birchmd/nearcore.git", rev = "6033903be2037d67510188450f289b2d6e033f04" } -near-primitives = { git = "https://github.com/birchmd/nearcore.git", rev = "6033903be2037d67510188450f289b2d6e033f04", default-features = false, features = [ "nightly_protocol" ] } libsecp256k1 = { version = "0.7.0", default-features = false } +near-crypto = "0.16" +near-primitives = "0.16" +near-primitives-core = "0.16" +near-sdk-sim = { git = "https://github.com/aurora-is-near/near-sdk-rs.git", rev = "cc4d4aaf2e1f7297aa060b342ca3ef3ff8e67003" } +near-vm-errors = "0.16" +near-vm-logic = "0.16" +near-vm-runner = { version = "0.16", default-features = false, features = [ "wasmer2_vm", "wasmtime_vm" ] } rand = "0.8.5" -criterion = "0.4.0" -git2 = "0.16" -tempfile = "3.2.0" +rlp = { version = "0.5.0", default-features = false } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +sha3 = { version = "0.10.2", default-features = false } +tempfile = "3" walrus = "0.19" [features] diff --git a/engine-tests/src/benches/eth_deploy_code.rs b/engine-tests/src/benches/eth_deploy_code.rs index 1e7a01e64..625bfb149 100644 --- a/engine-tests/src/benches/eth_deploy_code.rs +++ b/engine-tests/src/benches/eth_deploy_code.rs @@ -35,11 +35,10 @@ pub fn eth_deploy_code_benchmark(c: &mut Criterion) { // measure gas usage for input in &inputs { let input_size = input.len(); - let (output, maybe_err) = runner + let output = runner .one_shot() - .call(SUBMIT, calling_account_id, input.clone()); - assert!(maybe_err.is_none()); - let output = output.unwrap(); + .call(SUBMIT, calling_account_id, input.clone()) + .unwrap(); let gas = output.burnt_gas; let eth_gas = crate::test_utils::parse_eth_gas(&output); // TODO(#45): capture this in a file diff --git a/engine-tests/src/benches/eth_erc20.rs b/engine-tests/src/benches/eth_erc20.rs index cc6d0f947..8853e6e66 100644 --- a/engine-tests/src/benches/eth_erc20.rs +++ b/engine-tests/src/benches/eth_erc20.rs @@ -62,9 +62,9 @@ pub fn eth_erc20_benchmark(c: &mut Criterion) { // Measure mint gas usage; don't use `one_shot` because we want to keep this state change for // the next benchmark where we transfer some of the minted tokens. - let (output, maybe_error) = runner.call(SUBMIT, calling_account_id, mint_tx_bytes.clone()); - assert!(maybe_error.is_none()); - let output = output.unwrap(); + let output = runner + .call(SUBMIT, calling_account_id, mint_tx_bytes.clone()) + .unwrap(); let gas = output.burnt_gas; let eth_gas = crate::test_utils::parse_eth_gas(&output); // TODO(#45): capture this in a file @@ -72,12 +72,10 @@ pub fn eth_erc20_benchmark(c: &mut Criterion) { println!("ETH_ERC20_MINT ETH GAS: {eth_gas:?}"); // Measure transfer gas usage - let (output, maybe_err) = - runner - .one_shot() - .call(SUBMIT, calling_account_id, transfer_tx_bytes.clone()); - assert!(maybe_err.is_none()); - let output = output.unwrap(); + let output = runner + .one_shot() + .call(SUBMIT, calling_account_id, transfer_tx_bytes.clone()) + .unwrap(); let gas = output.burnt_gas; let eth_gas = crate::test_utils::parse_eth_gas(&output); // TODO(#45): capture this in a file diff --git a/engine-tests/src/benches/eth_standard_precompiles.rs b/engine-tests/src/benches/eth_standard_precompiles.rs index dbd5130ed..76ebd301a 100644 --- a/engine-tests/src/benches/eth_standard_precompiles.rs +++ b/engine-tests/src/benches/eth_standard_precompiles.rs @@ -43,12 +43,10 @@ pub fn eth_standard_precompiles_benchmark(c: &mut Criterion) { // measure gas usage for (tx_bytes, name) in transactions.iter().zip(test_names.iter()) { - let (output, maybe_err) = - runner - .one_shot() - .call(SUBMIT, calling_account_id, tx_bytes.clone()); - assert!(maybe_err.is_none()); - let output = output.unwrap(); + let output = runner + .one_shot() + .call(SUBMIT, calling_account_id, tx_bytes.clone()) + .unwrap(); let gas = output.burnt_gas; let eth_gas = crate::test_utils::parse_eth_gas(&output); // TODO(#45): capture this in a file diff --git a/engine-tests/src/benches/eth_transfer.rs b/engine-tests/src/benches/eth_transfer.rs index 1cfcbfd21..3c9f5e750 100644 --- a/engine-tests/src/benches/eth_transfer.rs +++ b/engine-tests/src/benches/eth_transfer.rs @@ -29,11 +29,11 @@ pub fn eth_transfer_benchmark(c: &mut Criterion) { let calling_account_id = "some-account.near"; // measure gas usage - let (output, maybe_err) = runner + let output = runner .one_shot() - .call(SUBMIT, calling_account_id, input.clone()); - assert!(maybe_err.is_none()); - let gas = output.unwrap().burnt_gas; + .call(SUBMIT, calling_account_id, input.clone()) + .unwrap(); + let gas = output.burnt_gas; // TODO(#45): capture this in a file println!("ETH_TRANSFER NEAR GAS: {gas:?}"); println!("ETH_TRANSFER ETH GAS: 21_000"); diff --git a/engine-tests/src/benches/nft_pagination.rs b/engine-tests/src/benches/nft_pagination.rs index ff24b8b7b..cf366786c 100644 --- a/engine-tests/src/benches/nft_pagination.rs +++ b/engine-tests/src/benches/nft_pagination.rs @@ -1,6 +1,7 @@ use crate::prelude::{Address, Wei, U256}; use crate::test_utils::{self, solidity}; use aurora_engine_transactions::legacy::TransactionLegacy; +use aurora_engine_types::parameters::engine::TransactionStatus; use libsecp256k1::SecretKey; use std::path::{Path, PathBuf}; use std::process::Command; @@ -42,10 +43,11 @@ pub fn measure_gas_usage(total_tokens: usize, data_size: usize, tokens_per_page: // show them let nonce = source_account.nonce; let tx = marketplace.get_page(tokens_per_page, 0, nonce.into()); - let (result, profile) = runner.profiled_view_call(&test_utils::as_view_call(tx, dest_address)); + let (status, profile) = runner + .profiled_view_call(&test_utils::as_view_call(tx, dest_address)) + .unwrap(); - let status = result.unwrap(); - assert!(status.is_ok()); + assert!(matches!(status, TransactionStatus::Succeed(_))); profile.all_gas() } diff --git a/engine-tests/src/benches/uniswap.rs b/engine-tests/src/benches/uniswap.rs index 0a94a97d9..b25f2ba54 100644 --- a/engine-tests/src/benches/uniswap.rs +++ b/engine-tests/src/benches/uniswap.rs @@ -58,28 +58,24 @@ pub fn uniswap_benchmark(c: &mut Criterion, context: &mut UniswapTestContext) { // Measure add_liquidity gas usage; don't use `one_shot` because we want to keep // this state change for the next benchmark where we swap some tokens in the pool. - let (output, maybe_error) = - context - .runner - .call(SUBMIT, calling_account_id, liquidity_tx_bytes.clone()); - assert!(maybe_error.is_none()); - let output = output.unwrap(); + let result = context + .runner + .call(SUBMIT, calling_account_id, liquidity_tx_bytes.clone()); + let output = result.unwrap(); let gas = output.burnt_gas; - let eth_gas = crate::test_utils::parse_eth_gas(&output); + let eth_gas = test_utils::parse_eth_gas(&output); // TODO(#45): capture this in a file println!("UNISWAP_ADD_LIQUIDITY NEAR GAS: {gas:?}"); println!("UNISWAP_ADD_LIQUIDITY ETH GAS: {eth_gas:?}"); // Measure swap gas usage - let (output, maybe_error) = - context - .runner - .one_shot() - .call(SUBMIT, calling_account_id, swap_tx_bytes.clone()); - assert!(maybe_error.is_none()); - let output = output.unwrap(); + let output = context + .runner + .one_shot() + .call(SUBMIT, calling_account_id, swap_tx_bytes.clone()) + .unwrap(); let gas = output.burnt_gas; - let eth_gas = crate::test_utils::parse_eth_gas(&output); + let eth_gas = test_utils::parse_eth_gas(&output); // TODO(#45): capture this in a file println!("UNISWAP_SWAP NEAR GAS: {gas:?}"); println!("UNISWAP_SWAP ETH GAS: {eth_gas:?}"); diff --git a/engine-tests/src/test_utils/exit_precompile.rs b/engine-tests/src/test_utils/exit_precompile.rs index a14bfb4f9..4f86544da 100644 --- a/engine-tests/src/test_utils/exit_precompile.rs +++ b/engine-tests/src/test_utils/exit_precompile.rs @@ -2,7 +2,7 @@ use crate::prelude::{ parameters::SubmitResult, transactions::legacy::TransactionLegacy, Address, Wei, U256, }; use crate::test_utils::{self, solidity, AuroraRunner, Signer}; -use near_vm_errors::VMError; +use aurora_engine::engine::EngineError; pub struct TesterConstructor(pub solidity::ContractConstructor); @@ -69,7 +69,7 @@ impl Tester { method: &str, value: Wei, params: &[ethabi::Token], - ) -> Result { + ) -> Result { let data = self .contract .abi @@ -128,7 +128,7 @@ impl Tester { runner: &mut AuroraRunner, signer: &mut Signer, flag: bool, - ) -> Result { + ) -> Result { self.call_function( runner, signer, diff --git a/engine-tests/src/test_utils/mocked_external.rs b/engine-tests/src/test_utils/mocked_external.rs index becd8d875..003257832 100644 --- a/engine-tests/src/test_utils/mocked_external.rs +++ b/engine-tests/src/test_utils/mocked_external.rs @@ -53,10 +53,11 @@ impl near_vm_logic::External for MockedExternalWithTrie { fn storage_get<'a>( &'a self, key: &[u8], + mode: near_vm_logic::StorageGetMode, ) -> Result>, near_vm_logic::VMLogicError> { self.increment_new_trie_node_count(MAINNET_AVERAGE_TOUCHED_TRIE_PER_READ); self.increment_cached_trie_node_count(MAINNET_AVERAGE_READ_CACHED_TRIE_PER_READ); - self.underlying.storage_get(key) + self.underlying.storage_get(key, mode) } fn storage_remove(&mut self, key: &[u8]) -> Result<(), near_vm_logic::VMLogicError> { diff --git a/engine-tests/src/test_utils/mod.rs b/engine-tests/src/test_utils/mod.rs index 223c61ae6..54e261fe2 100644 --- a/engine-tests/src/test_utils/mod.rs +++ b/engine-tests/src/test_utils/mod.rs @@ -1,22 +1,28 @@ +use aurora_engine::engine::{EngineError, EngineErrorKind, GasPaymentError}; use aurora_engine::parameters::{SubmitArgs, ViewCallArgs}; use aurora_engine_types::account_id::AccountId; use aurora_engine_types::types::{NEP141Wei, PromiseResult}; use borsh::{BorshDeserialize, BorshSerialize}; +use evm::ExitFatal; use libsecp256k1::{self, Message, PublicKey, SecretKey}; use near_primitives::runtime::config_store::RuntimeConfigStore; use near_primitives::version::PROTOCOL_VERSION; use near_primitives_core::config::VMConfig; use near_primitives_core::contract::ContractCode; -use near_primitives_core::profile::ProfileData; +use near_primitives_core::profile::ProfileDataV3; use near_primitives_core::runtime::fees::RuntimeFeesConfig; +use near_vm_errors::{FunctionCallError, HostError}; use near_vm_logic::mocks::mock_external::MockedExternal; use near_vm_logic::types::ReturnData; use near_vm_logic::{VMContext, VMOutcome, ViewConfig}; -use near_vm_runner::{MockCompiledContractCache, VMError}; +use near_vm_runner::MockCompiledContractCache; use rlp::RlpStream; +use std::borrow::Cow; use crate::prelude::fungible_token::{FungibleToken, FungibleTokenMetadata}; -use crate::prelude::parameters::{InitCallArgs, NewCallArgs, SubmitResult, TransactionStatus}; +use crate::prelude::parameters::{ + InitCallArgs, LegacyNewCallArgs, SubmitResult, TransactionStatus, +}; use crate::prelude::transactions::{ eip_1559::{self, SignedTransaction1559, Transaction1559}, eip_2930::{self, SignedTransaction2930, Transaction2930}, @@ -35,6 +41,7 @@ pub const PAUSE_PRECOMPILES: &str = "pause_precompiles"; pub const PAUSED_PRECOMPILES: &str = "paused_precompiles"; pub const RESUME_PRECOMPILES: &str = "resume_precompiles"; pub const SET_OWNER: &str = "set_owner"; +pub const SET_UPGRADE_DELAY_BLOCKS: &str = "set_upgrade_delay_blocks"; const CALLER_ACCOUNT_ID: &str = "some-account.near"; @@ -111,13 +118,12 @@ impl<'a> OneShotAuroraRunner<'a> { method_name: &str, caller_account_id: &str, input: Vec, - ) -> (Option, Option, ExecutionProfile) { - let (outcome, error) = self.call(method_name, caller_account_id, input); - let profile = outcome - .as_ref() - .map(ExecutionProfile::new) - .unwrap_or_default(); - (outcome, error, profile) + ) -> Result<(VMOutcome, ExecutionProfile), EngineError> { + self.call(method_name, caller_account_id, input) + .map(|outcome| { + let profile = ExecutionProfile::new(&outcome); + (outcome, profile) + }) } pub fn call( @@ -125,7 +131,7 @@ impl<'a> OneShotAuroraRunner<'a> { method_name: &str, caller_account_id: &str, input: Vec, - ) -> (Option, Option) { + ) -> Result { AuroraRunner::update_context( &mut self.context, caller_account_id, @@ -133,7 +139,7 @@ impl<'a> OneShotAuroraRunner<'a> { input, ); - match near_vm_runner::run( + let outcome = near_vm_runner::run( &self.base.code, method_name, &mut self.ext, @@ -143,9 +149,13 @@ impl<'a> OneShotAuroraRunner<'a> { &[], self.base.current_protocol_version, Some(&self.base.cache), - ) { - near_vm_runner::VMResult::Aborted(outcome, error) => (Some(outcome), Some(error)), - near_vm_runner::VMResult::Ok(outcome) => (Some(outcome), None), + ) + .unwrap(); + + if let Some(aborted) = outcome.aborted.as_ref() { + Err(into_engine_error(outcome.used_gas, aborted)) + } else { + Ok(outcome) } } } @@ -165,7 +175,7 @@ impl AuroraRunner { signer_account_id: &str, input: Vec, ) { - context.block_index += 1; + context.block_height += 1; context.block_timestamp += 1_000_000_000; context.input = input; context.signer_account_id = as_account_id(signer_account_id); @@ -177,7 +187,7 @@ impl AuroraRunner { method_name: &str, caller_account_id: &str, input: Vec, - ) -> (Option, Option) { + ) -> Result { self.call_with_signer(method_name, caller_account_id, caller_account_id, input) } @@ -187,7 +197,7 @@ impl AuroraRunner { caller_account_id: &str, signer_account_id: &str, input: Vec, - ) -> (Option, Option) { + ) -> Result { Self::update_context( &mut self.context, caller_account_id, @@ -206,7 +216,7 @@ impl AuroraRunner { } }) .collect(); - let (maybe_outcome, maybe_error) = match near_vm_runner::run( + let outcome = near_vm_runner::run( &self.code, method_name, &mut self.ext, @@ -216,33 +226,32 @@ impl AuroraRunner { &vm_promise_results, self.current_protocol_version, Some(&self.cache), - ) { - near_vm_runner::VMResult::Aborted(outcome, error) => (Some(outcome), Some(error)), - near_vm_runner::VMResult::Ok(outcome) => (Some(outcome), None), - }; - if let Some(outcome) = &maybe_outcome { - self.context.storage_usage = outcome.storage_usage; - self.previous_logs = outcome.logs.clone(); + ) + .unwrap(); + + if let Some(error) = outcome.aborted.as_ref() { + return Err(into_engine_error(outcome.used_gas, error)); } + self.context.storage_usage = outcome.storage_usage; + self.previous_logs = outcome.logs.clone(); + if let Some(standalone_runner) = &mut self.standalone_runner { - if maybe_error.is_none() - && (method_name == SUBMIT - || method_name == SUBMIT_WITH_ARGS - || method_name == CALL - || method_name == DEPLOY_ERC20 - || method_name == PAUSE_PRECOMPILES - || method_name == RESUME_PRECOMPILES - || method_name == SET_OWNER) + if method_name == SUBMIT + || method_name == SUBMIT_WITH_ARGS + || method_name == CALL + || method_name == DEPLOY_ERC20 + || method_name == PAUSE_PRECOMPILES + || method_name == RESUME_PRECOMPILES + || method_name == SET_OWNER + || method_name == SET_UPGRADE_DELAY_BLOCKS { - standalone_runner - .submit_raw(method_name, &self.context, &self.promise_results) - .unwrap(); + standalone_runner.submit_raw(method_name, &self.context, &self.promise_results)?; self.validate_standalone(); } } - (maybe_outcome, maybe_error) + Ok(outcome) } pub fn consume_json_snapshot( @@ -257,19 +266,14 @@ impl AuroraRunner { } } - pub fn create_address( - &mut self, - address: Address, - init_balance: crate::prelude::Wei, - init_nonce: U256, - ) { + pub fn create_address(&mut self, address: Address, init_balance: Wei, init_nonce: U256) { self.internal_create_address(address, init_balance, init_nonce, None); } pub fn create_address_with_code( &mut self, address: Address, - init_balance: crate::prelude::Wei, + init_balance: Wei, init_nonce: U256, code: Vec, ) { @@ -279,7 +283,7 @@ impl AuroraRunner { fn internal_create_address( &mut self, address: Address, - init_balance: crate::prelude::Wei, + init_balance: Wei, init_nonce: U256, code: Option>, ) { @@ -352,19 +356,19 @@ impl AuroraRunner { ); if let Some(standalone_runner) = &mut self.standalone_runner { - standalone_runner.env.block_height = self.context.block_index; + standalone_runner.env.block_height = self.context.block_height; standalone_runner.mint_account(address, init_balance, init_nonce, code); self.validate_standalone(); } - self.context.block_index += 1; + self.context.block_height += 1; } pub fn submit_with_signer TransactionLegacy>( &mut self, signer: &mut Signer, make_tx: F, - ) -> Result { + ) -> Result { self.submit_with_signer_profiled(signer, make_tx) .map(|(result, _)| result) } @@ -373,7 +377,7 @@ impl AuroraRunner { &mut self, signer: &mut Signer, make_tx: F, - ) -> Result<(SubmitResult, ExecutionProfile), VMError> { + ) -> Result<(SubmitResult, ExecutionProfile), EngineError> { let nonce = signer.use_nonce(); let tx = make_tx(nonce.into()); self.submit_transaction_profiled(&signer.secret_key, tx) @@ -383,7 +387,7 @@ impl AuroraRunner { &mut self, account: &SecretKey, transaction: TransactionLegacy, - ) -> Result { + ) -> Result { self.submit_transaction_profiled(account, transaction) .map(|(result, _)| result) } @@ -392,12 +396,10 @@ impl AuroraRunner { &mut self, account: &SecretKey, transaction: TransactionLegacy, - ) -> Result<(SubmitResult, ExecutionProfile), VMError> { + ) -> Result<(SubmitResult, ExecutionProfile), EngineError> { let signed_tx = sign_transaction(transaction, Some(self.chain_id), account); - let (output, maybe_err) = - self.call(SUBMIT, CALLER_ACCOUNT_ID, rlp::encode(&signed_tx).to_vec()); - - Self::profile_outcome(output, maybe_err) + self.call(SUBMIT, CALLER_ACCOUNT_ID, rlp::encode(&signed_tx).to_vec()) + .map(Self::profile_outcome) } pub fn submit_transaction_with_args( @@ -406,7 +408,7 @@ impl AuroraRunner { transaction: TransactionLegacy, max_gas_price: u128, gas_token_address: Option
, - ) -> Result { + ) -> Result { self.submit_transaction_with_args_profiled( account, transaction, @@ -422,36 +424,28 @@ impl AuroraRunner { transaction: TransactionLegacy, max_gas_price: u128, gas_token_address: Option
, - ) -> Result<(SubmitResult, ExecutionProfile), VMError> { + ) -> Result<(SubmitResult, ExecutionProfile), EngineError> { let signed_tx = sign_transaction(transaction, Some(self.chain_id), account); let args = SubmitArgs { tx_data: rlp::encode(&signed_tx).to_vec(), max_gas_price: Some(max_gas_price), gas_token_address, }; - let (output, maybe_err) = self.call( + + self.call( SUBMIT_WITH_ARGS, CALLER_ACCOUNT_ID, args.try_to_vec().unwrap(), - ); - - Self::profile_outcome(output, maybe_err) + ) + .map(Self::profile_outcome) } - fn profile_outcome( - output: Option, - error: Option, - ) -> Result<(SubmitResult, ExecutionProfile), VMError> { - error.map_or_else( - || { - let output = output.unwrap(); - let profile = ExecutionProfile::new(&output); - let submit_result = - SubmitResult::try_from_slice(&output.return_data.as_value().unwrap()).unwrap(); - Ok((submit_result, profile)) - }, - Err, - ) + fn profile_outcome(outcome: VMOutcome) -> (SubmitResult, ExecutionProfile) { + let profile = ExecutionProfile::new(&outcome); + let submit_result = + SubmitResult::try_from_slice(&outcome.return_data.as_value().unwrap()).unwrap(); + + (submit_result, profile) } pub fn deploy_contract TransactionLegacy, T: Into>( @@ -462,11 +456,10 @@ impl AuroraRunner { ) -> DeployedContract { let tx = constructor_tx(&contract_constructor); let signed_tx = sign_transaction(tx, Some(self.chain_id), account); - let (output, maybe_err) = - self.call(SUBMIT, CALLER_ACCOUNT_ID, rlp::encode(&signed_tx).to_vec()); - assert!(maybe_err.is_none()); + let outcome = self.call(SUBMIT, CALLER_ACCOUNT_ID, rlp::encode(&signed_tx).to_vec()); let submit_result = - SubmitResult::try_from_slice(&output.unwrap().return_data.as_value().unwrap()).unwrap(); + SubmitResult::try_from_slice(&outcome.unwrap().return_data.as_value().unwrap()) + .unwrap(); let address = Address::try_from_slice(&unwrap_success(submit_result)).unwrap(); let contract_constructor: ContractConstructor = contract_constructor.into(); DeployedContract { @@ -475,33 +468,32 @@ impl AuroraRunner { } } - pub fn view_call(&self, args: &ViewCallArgs) -> Result { + pub fn view_call(&self, args: &ViewCallArgs) -> Result { let input = args.try_to_vec().unwrap(); let mut runner = self.one_shot(); runner.context.view_config = Some(ViewConfig { max_gas_burnt: u64::MAX, }); - let (outcome, maybe_error) = runner.call("view", "viewer", input); - Ok( - TransactionStatus::try_from_slice(&Self::bytes_from_outcome(outcome, maybe_error)?) - .unwrap(), - ) + + runner.call("view", "viewer", input).map(|outcome| { + TransactionStatus::try_from_slice(&outcome.return_data.as_value().unwrap()).unwrap() + }) } pub fn profiled_view_call( &self, args: &ViewCallArgs, - ) -> (Result, ExecutionProfile) { + ) -> Result<(TransactionStatus, ExecutionProfile), EngineError> { let input = args.try_to_vec().unwrap(); let mut runner = self.one_shot(); runner.context.view_config = Some(ViewConfig { max_gas_burnt: u64::MAX, }); - let (outcome, maybe_error, profile) = runner.profiled_call("view", "viewer", input); - let status = Self::bytes_from_outcome(outcome, maybe_error) - .map(|bytes| TransactionStatus::try_from_slice(&bytes).unwrap()); + let (outcome, profile) = runner.profiled_call("view", "viewer", input)?; + let status = + TransactionStatus::try_from_slice(&outcome.return_data.as_value().unwrap()).unwrap(); - (status, profile) + Ok((status, profile)) } pub fn get_balance(&self, address: Address) -> Wei { @@ -521,11 +513,11 @@ impl AuroraRunner { address, key: key.0, }; - let (outcome, maybe_error) = - self.one_shot() - .call("get_storage_at", "getter", input.try_to_vec().unwrap()); - assert!(maybe_error.is_none()); - let output = outcome.unwrap().return_data.as_value().unwrap(); + let outcome = self + .one_shot() + .call("get_storage_at", "getter", input.try_to_vec().unwrap()) + .unwrap(); + let output = outcome.return_data.as_value().unwrap(); let mut result = [0u8; 32]; result.copy_from_slice(&output); H256(result) @@ -539,24 +531,11 @@ impl AuroraRunner { // Used in `get_balance` and `get_nonce`. This function exists to avoid code duplication // since the contract's `get_nonce` and `get_balance` have the same type signature. fn getter_method_call(&self, method_name: &str, address: Address) -> Vec { - let (outcome, maybe_error) = - self.one_shot() - .call(method_name, "getter", address.as_bytes().to_vec()); - assert!(maybe_error.is_none()); - outcome.unwrap().return_data.as_value().unwrap() - } - - fn bytes_from_outcome( - maybe_outcome: Option, - maybe_error: Option, - ) -> Result, VMError> { - maybe_error.map_or_else( - || { - let bytes = maybe_outcome.unwrap().return_data.as_value().unwrap(); - Ok(bytes) - }, - Err, - ) + let outcome = self + .one_shot() + .call(method_name, "getter", address.as_bytes().to_vec()) + .unwrap(); + outcome.return_data.as_value().unwrap() } pub fn with_random_seed(mut self, random_seed: H256) -> Self { @@ -609,7 +588,7 @@ impl Default for AuroraRunner { signer_account_pk: vec![], predecessor_account_id: as_account_id(ORIGIN), input: vec![], - block_index: 0, + block_height: 0, block_timestamp: 0, epoch_height: 0, account_balance: 10u128.pow(25), @@ -635,32 +614,30 @@ impl Default for AuroraRunner { /// (which was removed in `https://github.com/near/nearcore/pull/4438`). #[derive(Debug, Default, Clone)] pub struct ExecutionProfile { - pub host_breakdown: ProfileData, - wasm_gas: u64, + pub host_breakdown: ProfileDataV3, + total_gas_cost: u64, } impl ExecutionProfile { pub fn new(outcome: &VMOutcome) -> Self { - let wasm_gas = - outcome.burnt_gas - outcome.profile.host_gas() - outcome.profile.action_gas(); Self { host_breakdown: outcome.profile.clone(), - wasm_gas, + total_gas_cost: outcome.burnt_gas, } } - pub const fn wasm_gas(&self) -> u64 { - self.wasm_gas + pub fn wasm_gas(&self) -> u64 { + self.host_breakdown.get_wasm_cost() } - pub fn all_gas(&self) -> u64 { - self.wasm_gas + self.host_breakdown.host_gas() + self.host_breakdown.action_gas() + pub const fn all_gas(&self) -> u64 { + self.total_gas_cost } } pub fn deploy_evm() -> AuroraRunner { let mut runner = AuroraRunner::default(); - let args = NewCallArgs { + let args = LegacyNewCallArgs { chain_id: crate::prelude::u256_to_arr(&U256::from(runner.chain_id)), owner_id: str_to_account_id(runner.aurora_account_id.as_str()), bridge_prover_id: str_to_account_id("bridge_prover.near"), @@ -668,19 +645,18 @@ pub fn deploy_evm() -> AuroraRunner { }; let account_id = runner.aurora_account_id.clone(); - let (_, maybe_error) = runner.call("new", &account_id, args.try_to_vec().unwrap()); + let result = runner.call("new", &account_id, args.try_to_vec().unwrap()); - assert!(maybe_error.is_none()); + assert!(result.is_ok()); let args = InitCallArgs { prover_account: str_to_account_id("prover.near"), eth_custodian_address: "d045f7e19B2488924B97F9c145b5E51D0D895A65".to_string(), metadata: FungibleTokenMetadata::default(), }; - let (_, maybe_error) = - runner.call("new_eth_connector", &account_id, args.try_to_vec().unwrap()); + let result = runner.call("new_eth_connector", &account_id, args.try_to_vec().unwrap()); - assert!(maybe_error.is_none()); + assert!(result.is_ok()); let mut standalone_runner = standalone::StandaloneRunner::default(); standalone_runner.init_evm(); @@ -898,12 +874,18 @@ pub fn panic_on_fail(status: TransactionStatus) { } } +/// Checks if `total_gas` is within 1 Tgas of `tgas_bound`. pub fn assert_gas_bound(total_gas: u64, tgas_bound: u64) { - // Add 1 to round up - let tgas_used = (total_gas / 1_000_000_000_000) + 1; + const TERA: i128 = 1_000_000_000_000; + let total_gas: i128 = total_gas.into(); + let tgas_bound: i128 = i128::from(tgas_bound) * TERA; + let diff = (total_gas - tgas_bound).abs() / TERA; assert_eq!( - tgas_used, tgas_bound, - "{tgas_used} Tgas is not equal to {tgas_bound} Tgas", + diff, + 0, + "{} Tgas is not equal to {} Tgas", + total_gas / TERA, + tgas_bound / TERA, ); } @@ -914,3 +896,22 @@ pub const fn within_x_percent(x: u64, a: u64, b: u64) -> bool { (100 / x) * (larger - smaller) <= larger } + +fn into_engine_error(gas_used: u64, aborted: &FunctionCallError) -> EngineError { + let kind = match aborted { + FunctionCallError::HostError(HostError::GuestPanic { panic_msg }) => { + match panic_msg.as_str() { + "ERR_INVALID_CHAIN_ID" => EngineErrorKind::InvalidChainId, + "ERR_OUT_OF_FUND" => EngineErrorKind::GasPayment(GasPaymentError::OutOfFund), + "ERR_GAS_OVERFLOW" => EngineErrorKind::GasOverflow, + "ERR_INTRINSIC_GAS" => EngineErrorKind::IntrinsicGasNotMet, + "ERR_INCORRECT_NONCE" => EngineErrorKind::IncorrectNonce, + "ERR_PAUSED" => EngineErrorKind::EvmFatal(ExitFatal::Other("ERR_PAUSED".into())), + msg => EngineErrorKind::EvmFatal(ExitFatal::Other(Cow::Owned(msg.into()))), + } + } + other => panic!("Other FunctionCallError: {other:?}"), + }; + + EngineError { kind, gas_used } +} diff --git a/engine-tests/src/test_utils/rust.rs b/engine-tests/src/test_utils/rust.rs index 1e0a0c85c..e252b6d7b 100644 --- a/engine-tests/src/test_utils/rust.rs +++ b/engine-tests/src/test_utils/rust.rs @@ -9,7 +9,9 @@ pub fn compile>(source_path: P) { .output() .unwrap(); - if !output.status.success() { - panic!("{}", String::from_utf8(output.stderr).unwrap()); - } + assert!( + output.status.success(), + "{}", + String::from_utf8(output.stderr).unwrap() + ); } diff --git a/engine-tests/src/test_utils/self_destruct.rs b/engine-tests/src/test_utils/self_destruct.rs index 6bac496f0..ec1e7acf1 100644 --- a/engine-tests/src/test_utils/self_destruct.rs +++ b/engine-tests/src/test_utils/self_destruct.rs @@ -181,7 +181,7 @@ impl SelfDestruct { .try_to_vec() .unwrap(); - runner.call("call", "anyone", input); + runner.call("call", "anyone", input).unwrap(); } } diff --git a/engine-tests/src/test_utils/solidity.rs b/engine-tests/src/test_utils/solidity.rs index f0e9b23ca..16e860d02 100644 --- a/engine-tests/src/test_utils/solidity.rs +++ b/engine-tests/src/test_utils/solidity.rs @@ -1,6 +1,5 @@ use crate::prelude::{transactions::legacy::TransactionLegacy, Address, U256}; use aurora_engine_types::types::Wei; -use near_sdk::serde_json; use serde::Deserialize; use std::fs; use std::path::Path; diff --git a/engine-tests/src/test_utils/standalone/mocks/mod.rs b/engine-tests/src/test_utils/standalone/mocks/mod.rs index 9a0a6b96a..6ea5caf90 100644 --- a/engine-tests/src/test_utils/standalone/mocks/mod.rs +++ b/engine-tests/src/test_utils/standalone/mocks/mod.rs @@ -1,7 +1,7 @@ use crate::test_utils; use aurora_engine::fungible_token::FungibleTokenMetadata; use aurora_engine::parameters::{ - FinishDepositCallArgs, InitCallArgs, NEP141FtOnTransferArgs, NewCallArgs, + FinishDepositCallArgs, InitCallArgs, NEP141FtOnTransferArgs, NewCallArgsV2, }; use aurora_engine::{engine, state}; use aurora_engine_sdk::env::{Env, DEFAULT_PREPAID_GAS}; @@ -49,10 +49,9 @@ pub fn default_env(block_height: u64) -> aurora_engine_sdk::env::Fixed { } pub fn init_evm(mut io: I, env: &E, chain_id: u64) { - let new_args = NewCallArgs { + let new_args = NewCallArgsV2 { chain_id: aurora_engine_types::types::u256_to_arr(&U256::from(chain_id)), owner_id: env.current_account_id(), - bridge_prover_id: test_utils::str_to_account_id("bridge_prover.near"), upgrade_delay_blocks: 1, }; diff --git a/engine-tests/src/test_utils/standalone/mod.rs b/engine-tests/src/test_utils/standalone/mod.rs index 0543fe4d8..be6541968 100644 --- a/engine-tests/src/test_utils/standalone/mod.rs +++ b/engine-tests/src/test_utils/standalone/mod.rs @@ -1,7 +1,7 @@ use aurora_engine::engine; use aurora_engine::parameters::{ - CallArgs, DeployErc20TokenArgs, PausePrecompilesCallArgs, SetOwnerArgs, SubmitArgs, - SubmitResult, TransactionStatus, + CallArgs, DeployErc20TokenArgs, PausePrecompilesCallArgs, SetOwnerArgs, + SetUpgradeDelayBlocksArgs, SubmitArgs, SubmitResult, TransactionStatus, }; use aurora_engine_sdk::env::{self, Env}; use aurora_engine_transactions::legacy::{LegacyEthSignedTransaction, TransactionLegacy}; @@ -57,7 +57,7 @@ impl StandaloneRunner { maybe_result: Ok(None), }; self.cumulative_diff.append(outcome.diff.clone()); - test_utils::standalone::storage::commit(storage, &outcome); + storage::commit(storage, &outcome); } pub fn mint_account( @@ -192,9 +192,9 @@ impl StandaloneRunner { promise_results: &[PromiseResult], ) -> Result { let mut env = self.env.clone(); - env.block_height = ctx.block_index; + env.block_height = ctx.block_height; env.attached_deposit = ctx.attached_deposit; - env.block_timestamp = aurora_engine_sdk::env::Timestamp::new(ctx.block_timestamp); + env.block_timestamp = env::Timestamp::new(ctx.block_timestamp); env.predecessor_account_id = ctx.predecessor_account_id.as_ref().parse().unwrap(); env.current_account_id = ctx.current_account_id.as_ref().parse().unwrap(); env.signer_account_id = ctx.signer_account_id.as_ref().parse().unwrap(); @@ -305,6 +305,25 @@ impl StandaloneRunner { self.cumulative_diff.append(outcome.diff.clone()); storage::commit(storage, &outcome); + Ok(SubmitResult::new( + TransactionStatus::Succeed(Vec::new()), + 0, + Vec::new(), + )) + } else if method_name == test_utils::SET_UPGRADE_DELAY_BLOCKS { + let input = &ctx.input; + let call_args = SetUpgradeDelayBlocksArgs::try_from_slice(input) + .expect("Unable to parse input as SetUpgradeDelayBlocksArgs"); + + let transaction_hash = aurora_engine_sdk::keccak(&ctx.input); + let mut tx_msg = + Self::template_tx_msg(storage, &env, 0, transaction_hash, promise_results); + tx_msg.transaction = TransactionKind::SetUpgradeDelayBlocks(call_args); + + let outcome = sync::execute_transaction_message(storage, tx_msg).unwrap(); + self.cumulative_diff.append(outcome.diff.clone()); + storage::commit(storage, &outcome); + Ok(SubmitResult::new( TransactionStatus::Succeed(Vec::new()), 0, @@ -403,7 +422,7 @@ impl StandaloneRunner { let outcome = sync::execute_transaction_message(storage, tx_msg).unwrap(); cumulative_diff.append(outcome.diff.clone()); - test_utils::standalone::storage::commit(storage, &outcome); + storage::commit(storage, &outcome); unwrap_result(outcome) } diff --git a/engine-tests/src/tests/contract_call.rs b/engine-tests/src/tests/contract_call.rs index 5ecb025d0..b4d5f4d43 100644 --- a/engine-tests/src/tests/contract_call.rs +++ b/engine-tests/src/tests/contract_call.rs @@ -25,7 +25,9 @@ fn setup_test() -> (AuroraRunner, Signer, Address, Tester) { ) .into(); - runner.mint(token, tester.contract.address, 1_000_000_000, ORIGIN); + runner + .mint(token, tester.contract.address, 1_000_000_000, ORIGIN) + .unwrap(); (runner, signer, token, tester) } diff --git a/engine-tests/src/tests/eip1559.rs b/engine-tests/src/tests/eip1559.rs index b1c1840ef..8c468a468 100644 --- a/engine-tests/src/tests/eip1559.rs +++ b/engine-tests/src/tests/eip1559.rs @@ -78,11 +78,10 @@ fn test_eip_1559_example() { let signed_tx = test_utils::sign_eip_1559_transaction(transaction, &signer.secret_key); let sender = "relay.aurora"; - let (maybe_outcome, maybe_err) = runner.call(test_utils::SUBMIT, sender, encode_tx(&signed_tx)); - assert!(maybe_err.is_none()); - let result = - SubmitResult::try_from_slice(&maybe_outcome.unwrap().return_data.as_value().unwrap()) - .unwrap(); + let outcome = runner + .call(test_utils::SUBMIT, sender, encode_tx(&signed_tx)) + .unwrap(); + let result = SubmitResult::try_from_slice(&outcome.return_data.as_value().unwrap()).unwrap(); assert_eq!(result.gas_used, 0xb8d2); // Check post state: diff --git a/engine-tests/src/tests/erc20.rs b/engine-tests/src/tests/erc20.rs index e7fe344a7..966414050 100644 --- a/engine-tests/src/tests/erc20.rs +++ b/engine-tests/src/tests/erc20.rs @@ -5,6 +5,7 @@ use crate::test_utils::{ erc20::{ERC20Constructor, ERC20}, Signer, }; +use aurora_engine::engine::EngineErrorKind; use aurora_engine::parameters::TransactionStatus; use aurora_engine_sdk as sdk; use bstr::ByteSlice; @@ -61,10 +62,10 @@ fn erc20_mint_out_of_gas() { .intrinsic_gas(&evm::Config::istanbul()) .unwrap(); mint_tx.gas_limit = (intrinsic_gas - 1).into(); - let outcome = runner.submit_transaction(&source_account.secret_key, mint_tx.clone()); - let error = outcome.unwrap_err(); - let error_message = format!("{error:?}"); - assert!(error_message.contains("ERR_INTRINSIC_GAS")); + let error = runner + .submit_transaction(&source_account.secret_key, mint_tx.clone()) + .unwrap_err(); + assert_eq!(error.kind, EngineErrorKind::IntrinsicGasNotMet); // not enough gas to complete transaction mint_tx.gas_limit = U256::from(GAS_LIMIT); @@ -102,9 +103,10 @@ fn profile_erc20_get_balance() { assert!(outcome.is_ok()); let balance_tx = contract.balance_of(source_address, U256::zero()); - let (result, profile) = - runner.profiled_view_call(&test_utils::as_view_call(balance_tx, source_address)); - assert!(result.is_ok()); + let (status, profile) = runner + .profiled_view_call(&test_utils::as_view_call(balance_tx, source_address)) + .unwrap(); + assert!(status.is_ok()); // call costs less than 2 Tgas test_utils::assert_gas_bound(profile.all_gas(), 2); @@ -215,10 +217,10 @@ fn deploy_erc_20_out_of_gas() { .intrinsic_gas(&evm::Config::istanbul()) .unwrap(); deploy_transaction.gas_limit = (intrinsic_gas - 1).into(); - let outcome = runner.submit_transaction(&source_account, deploy_transaction.clone()); - let error = outcome.unwrap_err(); - let error_message = format!("{error:?}"); - assert!(error_message.contains("ERR_INTRINSIC_GAS")); + let error = runner + .submit_transaction(&source_account, deploy_transaction.clone()) + .unwrap_err(); + assert_eq!(error.kind, EngineErrorKind::IntrinsicGasNotMet); // not enough gas to complete transaction deploy_transaction.gas_limit = U256::from(intrinsic_gas + 1); diff --git a/engine-tests/src/tests/erc20_connector.rs b/engine-tests/src/tests/erc20_connector.rs index 74cbcac11..a09f6d6aa 100644 --- a/engine-tests/src/tests/erc20_connector.rs +++ b/engine-tests/src/tests/erc20_connector.rs @@ -1,43 +1,19 @@ use crate::prelude::{Address, Balance, Wei, WeiU256, U256}; use crate::test_utils::{self, create_eth_transaction, AuroraRunner, ORIGIN}; -use aurora_engine::parameters::{CallArgs, FunctionCallArgsV2, SubmitResult}; +use aurora_engine::engine::EngineError; +use aurora_engine::parameters::{CallArgs, FunctionCallArgsV2}; use aurora_engine_transactions::legacy::LegacyEthSignedTransaction; +use aurora_engine_types::parameters::engine::{SubmitResult, TransactionStatus}; use borsh::{BorshDeserialize, BorshSerialize}; use ethabi::Token; use libsecp256k1::SecretKey; use near_vm_logic::VMOutcome; -use near_vm_runner::VMError; use serde_json::json; use sha3::Digest; const INITIAL_BALANCE: Wei = Wei::new_u64(1000); const INITIAL_NONCE: u64 = 0; -pub struct CallResult { - outcome: Option, - error: Option, -} - -impl CallResult { - fn check_ok(&self) { - assert!(self.error.is_none()); - } - - fn value(&self) -> Vec { - self.outcome - .as_ref() - .unwrap() - .return_data - .clone() - .as_value() - .unwrap() - } - - fn submit_result(&self) -> SubmitResult { - SubmitResult::try_from_slice(self.value().as_slice()).unwrap() - } -} - fn keccak256(input: &[u8]) -> Vec { sha3::Keccak256::digest(input).to_vec() } @@ -73,9 +49,8 @@ impl AuroraRunner { method_name: &str, caller_account_id: &str, input: Vec, - ) -> CallResult { - let (outcome, error) = self.call(method_name, caller_account_id, input); - CallResult { outcome, error } + ) -> Result { + self.call(method_name, caller_account_id, input) } pub fn make_call_with_signer( @@ -84,13 +59,16 @@ impl AuroraRunner { caller_account_id: &str, signer_account_id: &str, input: Vec, - ) -> CallResult { - let (outcome, error) = - self.call_with_signer(method_name, caller_account_id, signer_account_id, input); - CallResult { outcome, error } + ) -> Result { + self.call_with_signer(method_name, caller_account_id, signer_account_id, input) } - pub fn evm_call(&mut self, contract: Address, input: Vec, origin: &str) -> CallResult { + pub fn evm_call( + &mut self, + contract: Address, + input: Vec, + origin: &str, + ) -> Result { self.make_call( "call", origin, @@ -104,20 +82,24 @@ impl AuroraRunner { ) } - pub fn evm_submit(&mut self, input: &LegacyEthSignedTransaction, origin: &str) -> CallResult { + pub fn evm_submit( + &mut self, + input: &LegacyEthSignedTransaction, + origin: &str, + ) -> Result { self.make_call("submit", origin, rlp::encode(input).to_vec()) } pub fn deploy_erc20_token(&mut self, nep141: &str) -> Address { - let result = self.make_call("deploy_erc20_token", ORIGIN, nep141.try_to_vec().unwrap()); - - result.check_ok(); + let result = self + .make_call("deploy_erc20_token", ORIGIN, nep141.try_to_vec().unwrap()) + .unwrap(); - let raw_address: [u8; 20] = Vec::::try_from_slice(result.value().as_slice()) + Vec::try_from_slice(&result.return_data.as_value().unwrap()) .unwrap() .try_into() - .unwrap(); - Address::try_from_slice(&raw_address).unwrap() + .map(Address::from_array) + .unwrap() } pub fn create_account(&mut self) -> EthereumAddress { @@ -133,10 +115,14 @@ impl AuroraRunner { pub fn balance_of(&mut self, token: Address, target: Address, origin: &str) -> U256 { let input = build_input("balanceOf(address)", &[Token::Address(target.raw())]); - let result = self.evm_call(token, input, origin); - result.check_ok(); - let output = test_utils::unwrap_success(result.submit_result()); - U256::from_big_endian(output.as_slice()) + let result = self.evm_call(token, input, origin).unwrap(); + let output = result.return_data.as_value().unwrap(); + let result = SubmitResult::try_from_slice(&output).unwrap(); + + match result.status { + TransactionStatus::Succeed(bytes) => U256::from_big_endian(&bytes), + other => panic!("Wrong EVM transaction status: {other:?}"), + } } pub fn mint( @@ -145,7 +131,7 @@ impl AuroraRunner { target: Address, amount: u64, origin: &str, - ) -> CallResult { + ) -> Result { let input = build_input( "mint(address,uint256)", &[ @@ -153,17 +139,14 @@ impl AuroraRunner { Token::Uint(U256::from(amount)), ], ); - let result = self.evm_call(token, input, origin); - result.check_ok(); - result + + self.evm_call(token, input, origin) } #[allow(dead_code)] - pub fn admin(&mut self, token: Address, origin: &str) -> CallResult { + pub fn admin(&mut self, token: Address, origin: &str) -> Result { let input = build_input("admin()", &[]); - let result = self.evm_call(token, input, origin); - result.check_ok(); - result + self.evm_call(token, input, origin) } pub fn transfer_erc20( @@ -173,7 +156,7 @@ impl AuroraRunner { receiver: Address, amount: u64, origin: &str, - ) -> CallResult { + ) -> Result { // transfer(address recipient, uint256 amount) let input = build_input( "transfer(address,uint256)", @@ -182,12 +165,8 @@ impl AuroraRunner { Token::Uint(U256::from(amount)), ], ); - let input = create_eth_transaction(Some(token), Wei::zero(), input, None, &sender); - - let result = self.evm_submit(&input, origin); // create_eth_transaction() - result.check_ok(); - result + self.evm_submit(&input, origin) // create_eth_transaction() } pub fn ft_on_transfer( @@ -210,15 +189,15 @@ impl AuroraRunner { .to_string() .into_bytes(), ); - res.check_ok(); - String::from_utf8(res.value()).unwrap() + assert!(res.is_ok()); + String::from_utf8(res.unwrap().return_data.as_value().unwrap()).unwrap() } pub fn register_relayer( &mut self, relayer_account_id: &str, relayer_address: Address, - ) -> CallResult { + ) -> Result { self.make_call( "register_relayer", relayer_account_id, @@ -254,7 +233,7 @@ fn test_mint_not_admin() { let balance = runner.balance_of(token, address, ORIGIN); assert_eq!(balance, U256::from(0)); let amount = 10; - runner.mint(token, address, amount, "not_admin"); + runner.mint(token, address, amount, "not_admin").unwrap(); let balance = runner.balance_of(token, address, ORIGIN); assert_eq!(balance, U256::from(0)); } @@ -311,7 +290,7 @@ fn test_relayer_charge_fee() { assert_eq!(recipient_balance, INITIAL_BALANCE); let relayer = create_ethereum_address(); - runner.register_relayer(alice, relayer); + runner.register_relayer(alice, relayer).unwrap(); let relayer_balance = runner.get_balance(relayer); assert_eq!(relayer_balance, Wei::zero()); @@ -360,14 +339,16 @@ fn test_transfer_erc20_token() { U256::zero() ); - runner.mint(token, peer0.address, to_mint, ORIGIN); + runner.mint(token, peer0.address, to_mint, ORIGIN).unwrap(); assert_eq!( runner.balance_of(token, peer0.address, ORIGIN), U256::from(to_mint) ); - runner.transfer_erc20(token, peer0.secret_key, peer1.address, to_transfer, ORIGIN); + runner + .transfer_erc20(token, peer0.secret_key, peer1.address, to_transfer, ORIGIN) + .unwrap(); assert_eq!( runner.balance_of(token, peer0.address, ORIGIN), U256::from(to_mint - to_transfer) @@ -683,7 +664,7 @@ pub mod sim_tests { let constructor = TesterConstructor::load(); let deploy_data = constructor.deploy(0, Address::zero()).data; let submit_result = match aurora.call("deploy_code", &deploy_data).status() { - near_primitives::transaction::ExecutionStatus::SuccessValue(bytes) => { + near_sdk_sim::transaction::ExecutionStatus::SuccessValue(bytes) => { SubmitResult::try_from_slice(&bytes).unwrap() } other => panic!("Unexpected status {other:?}"), @@ -858,7 +839,7 @@ pub mod sim_tests { }); let result = aurora.call("call", &call_args.try_to_vec().unwrap()); let submit_result = match result.status() { - near_primitives::transaction::ExecutionStatus::SuccessValue(bytes) => { + near_sdk_sim::transaction::ExecutionStatus::SuccessValue(bytes) => { SubmitResult::try_from_slice(&bytes).unwrap() } other => panic!("Unexpected status {other:?}"), diff --git a/engine-tests/src/tests/eth_connector.rs b/engine-tests/src/tests/eth_connector.rs index f6283423a..99bb29693 100644 --- a/engine-tests/src/tests/eth_connector.rs +++ b/engine-tests/src/tests/eth_connector.rs @@ -7,13 +7,12 @@ use aurora_engine::connector::{ }; use aurora_engine::fungible_token::FungibleTokenMetadata; use aurora_engine::parameters::{ - InitCallArgs, NewCallArgs, RegisterRelayerCallArgs, WithdrawResult, + InitCallArgs, LegacyNewCallArgs, RegisterRelayerCallArgs, WithdrawResult, }; use aurora_engine_types::types::{Fee, NEP141Wei}; use borsh::{BorshDeserialize, BorshSerialize}; use byte_slice_cast::AsByteSlice; use ethabi::ethereum_types::U256; -use near_sdk::test_utils::accounts; use near_sdk_sim::transaction::ExecutionStatus; use near_sdk_sim::{to_yocto, ExecutionResult, UserAccount, DEFAULT_GAS, STORAGE_AMOUNT}; use serde_json::json; @@ -68,10 +67,10 @@ fn init_contract( .call( contract_name.parse().unwrap(), "new", - &NewCallArgs { + &LegacyNewCallArgs { chain_id: [0u8; 32], owner_id: str_to_account_id(master_account.account_id.clone().as_str()), - bridge_prover_id: str_to_account_id(accounts(0).as_str()), + bridge_prover_id: str_to_account_id("bridge.prover.near"), upgrade_delay_blocks: 1, } .try_to_vec() diff --git a/engine-tests/src/tests/ghsa_3p69_m8gg_fwmf.rs b/engine-tests/src/tests/ghsa_3p69_m8gg_fwmf.rs index 604057253..fe730edb9 100644 --- a/engine-tests/src/tests/ghsa_3p69_m8gg_fwmf.rs +++ b/engine-tests/src/tests/ghsa_3p69_m8gg_fwmf.rs @@ -41,11 +41,10 @@ fn test_exploit_fix() { let sender = test_utils::address_from_secret_key(&signer.secret_key); let view_call_args = test_utils::as_view_call(tx, sender); let input = view_call_args.try_to_vec().unwrap(); + let error = runner.one_shot().call("view", "viewer", input).unwrap_err(); - let (_outcome, maybe_error) = runner.one_shot().call("view", "viewer", input); - let error_message = format!("{maybe_error:?}"); assert!( - error_message.contains("ERR_ILLEGAL_RETURN"), - "{error_message}", + error.kind.as_bytes().starts_with(b"ERR_ILLEGAL_RETURN"), + "{error:?}" ); } diff --git a/engine-tests/src/tests/modexp.rs b/engine-tests/src/tests/modexp.rs index 77b2accaf..6453a8000 100644 --- a/engine-tests/src/tests/modexp.rs +++ b/engine-tests/src/tests/modexp.rs @@ -1,10 +1,147 @@ +use aurora_engine::engine::EngineError; +use near_primitives_core::contract::ContractCode; +use rand::{Rng, SeedableRng}; + use super::sanity::initialize_transfer; use crate::prelude::Wei; use crate::prelude::{Address, U256}; -use crate::test_utils::{self, AuroraRunner, Signer}; +use crate::test_utils::{self, standalone::StandaloneRunner, AuroraRunner, Signer}; const MODEXP_ADDRESS: Address = aurora_engine_precompiles::make_address(0, 5); +#[test] +fn bench_modexp() { + let mut context = ModExpBenchContext::default(); + + // Example with even modulus and very large exponent + let input = BenchInput { + base: vec![224, 6, 0, 0, 169, 33, 33, 33, 33, 33, 33, 33, 255, 0, 0, 33], + exp: vec![35; 216], + modulus: vec![ + 130, 130, 130, 130, 130, 130, 0, 255, 255, 40, 255, 43, 33, 130, 130, 0, + ], + num_iters: Some(1_000), + }; + let result = context.bench(&input); + assert_eq!( + result.least(), + Implementation::Aurora, + "Aurora not least:\n{result:?}" + ); + + // Example with odd modulus and very small exponent + let input = BenchInput { + base: vec![ + 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], + exp: vec![3], + // Modulus is a large, odd number in this test + modulus: { + let mut tmp = vec![0; 748]; + let mut rng = rand::rngs::StdRng::seed_from_u64(314159); + rng.fill(tmp.as_mut_slice()); + *tmp.last_mut().unwrap() = 0x87; + tmp + }, + num_iters: Some(1_000), + }; + let result = context.bench(&input); + assert_eq!( + result.least(), + Implementation::Aurora, + "Aurora not least:\n{result:?}" + ); + + let input = BenchInput { + base: vec![ + 0x36, 0xAB, 0xD4, 0x52, 0x4E, 0x89, 0xA3, 0x4C, 0x89, 0xC4, 0x20, 0x94, 0x25, 0x47, + 0xE1, 0x2C, 0x7B, 0xE1, + ], + exp: vec![0x01, 0x00, 0x00, 0x00, 0x00, 0x05, 0x17, 0xEA, 0x78], + modulus: vec![ + 0x02, 0xF0, 0x75, 0x8C, 0x6A, 0x04, 0x20, 0x09, 0x55, 0xB6, 0x49, 0xC3, 0x57, 0x22, + 0xB8, 0x00, 0x00, 0x00, 0x00, + ], + num_iters: Some(1_000), + }; + let result = context.bench(&input); + assert_eq!( + result.least(), + Implementation::Aurora, + "Aurora not least:\n{result:?}" + ); + + // Typical example with U256-sized inputs. + let input = BenchInput::random(32); + let result = context.bench(&input); + assert_eq!( + result.least(), + Implementation::Aurora, + "Aurora not least:\n{result:?}" + ); +} + +// This test is marked as ignored because it should only be run with `--release` +// specified (it requires the standalone engine to be compiled with an optimized build). +// This test can be run with `cargo make --profile mainnet bench-modexp` +#[ignore] +#[test] +fn bench_modexp_standalone() { + const GAS_LIMIT: u64 = 30_000_000; + let mut standalone = StandaloneRunner::default(); + let mut signer = Signer::random(); + + standalone.init_evm(); + + let deploy_contract = |standalone: &mut StandaloneRunner, signer: &mut Signer, path| { + let contract_code = std::fs::read_to_string(path).unwrap(); + let deploy_tx = test_utils::create_deploy_transaction( + hex::decode(contract_code.trim()).unwrap(), + signer.use_nonce().into(), + ); + let deploy_result = standalone + .submit_transaction(&signer.secret_key, deploy_tx) + .unwrap(); + Address::try_from_slice(&test_utils::unwrap_success(deploy_result)).unwrap() + }; + + let do_bench = |standalone: &mut StandaloneRunner, signer: &mut Signer, path| { + let contract_address = deploy_contract(standalone, signer, path); + + let bench_tx = aurora_engine_transactions::legacy::TransactionLegacy { + nonce: signer.use_nonce().into(), + gas_price: U256::zero(), + gas_limit: GAS_LIMIT.into(), + to: Some(contract_address), + value: Wei::zero(), + data: Vec::new(), + }; + + let start = std::time::Instant::now(); + standalone + .submit_transaction(&signer.secret_key, bench_tx) + .unwrap(); + let duration = start.elapsed().as_millis(); + + assert!(duration < 1000, "{path} failed to run in under 1 second"); + }; + + // These contracts run the modexp precompile in an infinite loop using strategically selecting + // input that can take a long time to run with some modexp implementations. It should be + // possible to burn 30M EVM gas (the GAS_LIMIT for this transactions) within 1 second. + // This test checks this is case for these specially chosen modexp inputs. + do_bench( + &mut standalone, + &mut signer, + "../etc/tests/modexp-bench/res/evm_contract_1.hex", + ); + do_bench( + &mut standalone, + &mut signer, + "../etc/tests/modexp-bench/res/evm_contract_2.hex", + ); +} + #[test] fn test_modexp_oom() { let (mut runner, mut signer, _) = initialize_transfer(); @@ -53,3 +190,140 @@ fn check_wasm_modexp( test_utils::unwrap_success_slice(&wasm_result), ); } + +/// Input to the modexp call (base, exp, modulus in big-endian bytes). +#[derive(Debug)] +struct BenchInput { + base: Vec, + exp: Vec, + modulus: Vec, + num_iters: Option, +} + +impl BenchInput { + /// Generate a random input where the base, exponent and modulus are all the same number of bytes. + fn random(size: usize) -> Self { + let mut rng = rand::rngs::StdRng::seed_from_u64(314159); + let mut make_bytes = || { + let mut buf = vec![0u8; size]; + rng.fill(buf.as_mut_slice()); + buf + }; + + Self { + base: make_bytes(), + exp: make_bytes(), + modulus: make_bytes(), + num_iters: None, + } + } + + fn to_json(&self) -> String { + format!( + r#"{{ + "base": "{}", + "exp": "{}", + "modulus": "{}", + "n_iters": {} + }}"#, + hex::encode(&self.base), + hex::encode(&self.exp), + hex::encode(&self.modulus), + self.num_iters + .map_or_else(|| "null".into(), |n| n.to_string()), + ) + } +} + +#[derive(Debug)] +struct BenchResult { + /// Amount of Near gas used by Aurora's modexp implementation + aurora: u64, + /// Amount of Near gas used by ibig crate modexp implementation + ibig: u64, + /// Amount of Near gas used by num crate modexp implementation + num: Result, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum Implementation { + Aurora, + IBig, + Num, +} + +impl BenchResult { + fn least(&self) -> Implementation { + let num = self.num.as_ref().copied().unwrap_or(u64::MAX); + + if self.aurora <= self.ibig && self.aurora <= num { + Implementation::Aurora + } else if self.ibig <= self.aurora && self.ibig <= num { + Implementation::IBig + } else { + Implementation::Num + } + } +} + +struct ModExpBenchContext { + inner: test_utils::AuroraRunner, +} + +impl ModExpBenchContext { + fn bench(&mut self, input: &BenchInput) -> BenchResult { + let input = input.to_json().into_bytes(); + let parse_output = |bytes: &[u8]| -> Vec { + let n = bytes.len(); + let parsed = hex::decode(&bytes[1..(n - 1)]).unwrap(); + // remove leading zeros, if any + let mut tmp = parsed.as_slice(); + while !tmp.is_empty() && tmp[0] == 0 { + tmp = &tmp[1..]; + } + tmp.to_vec() + }; + + let outcome = self.inner.call("modexp", "aurora", input.clone()).unwrap(); + let aurora = outcome.burnt_gas; + let aurora_result = parse_output(&outcome.return_data.as_value().unwrap()); + + let outcome = self + .inner + .call("modexp_ibig", "aurora", input.clone()) + .unwrap(); + let ibig = outcome.burnt_gas; + let ibig_result = parse_output(&outcome.return_data.as_value().unwrap()); + assert_eq!( + aurora_result, ibig_result, + "Aurora and ibig responses differed!" + ); + + let maybe_outcome = self.inner.call("modexp_num", "aurora", input); + let num = maybe_outcome.map(|outcome| outcome.burnt_gas); + + BenchResult { aurora, ibig, num } + } +} + +impl Default for ModExpBenchContext { + fn default() -> Self { + let mut inner = test_utils::AuroraRunner::default(); + + let bench_contract_bytes = { + let base_path = std::path::Path::new("../etc") + .join("tests") + .join("modexp-bench"); + let output_path = + base_path.join("target/wasm32-unknown-unknown/release/modexp_bench.wasm"); + test_utils::rust::compile(base_path); + std::fs::read(output_path).unwrap() + }; + + inner.wasm_config.limit_config.max_gas_burnt = u64::MAX; + + inner.code = ContractCode::new(bench_contract_bytes, None); + + Self { inner } + } +} diff --git a/engine-tests/src/tests/one_inch.rs b/engine-tests/src/tests/one_inch.rs index 123cc33e2..6ae4a294c 100644 --- a/engine-tests/src/tests/one_inch.rs +++ b/engine-tests/src/tests/one_inch.rs @@ -58,7 +58,7 @@ fn test_1inch_liquidity_protocol() { }, ); assert!(result.gas_used >= 302_000); // more than 302k EVM gas used - assert_gas_bound(profile.all_gas(), 23); + assert_gas_bound(profile.all_gas(), 22); // Same here helper.runner.context.block_timestamp += 10_000_000 * 1_000_000_000; @@ -133,13 +133,13 @@ fn deploy_1_inch_limit_order_contract( data: constructor.code, }; let tx = test_utils::sign_transaction(deploy_tx, Some(runner.chain_id), &signer.secret_key); - - let (outcome, error) = runner.call( + let outcome = runner.call( test_utils::SUBMIT, "any_account.near", rlp::encode(&tx).to_vec(), ); - assert!(error.is_none()); + + assert!(outcome.is_ok()); outcome.unwrap() } diff --git a/engine-tests/src/tests/pausable_precompiles.rs b/engine-tests/src/tests/pausable_precompiles.rs index 7e6351120..6ebff130f 100644 --- a/engine-tests/src/tests/pausable_precompiles.rs +++ b/engine-tests/src/tests/pausable_precompiles.rs @@ -3,11 +3,10 @@ use crate::test_utils::exit_precompile::{Tester, TesterConstructor}; use crate::test_utils::{ self, AuroraRunner, Signer, ORIGIN, PAUSED_PRECOMPILES, PAUSE_PRECOMPILES, RESUME_PRECOMPILES, }; +use aurora_engine::engine::EngineErrorKind; use aurora_engine::parameters::{PausePrecompilesCallArgs, TransactionStatus}; use aurora_engine_types::types::Wei; use borsh::BorshSerialize; -use near_vm_errors::{FunctionCallError, HostError}; -use near_vm_runner::VMError; const EXIT_TO_ETHEREUM_FLAG: u32 = 0b10; const CALLED_ACCOUNT_ID: &str = "aurora"; @@ -24,18 +23,10 @@ fn test_paused_precompile_is_shown_when_viewing() { call_args.serialize(&mut input).unwrap(); let _res = runner.call(PAUSE_PRECOMPILES, CALLED_ACCOUNT_ID, input.clone()); - let (outcome, error) = runner.call(PAUSED_PRECOMPILES, CALLED_ACCOUNT_ID, Vec::new()); - - assert!(error.is_none(), "{error:?}"); - - let output: Vec = outcome - .as_ref() - .unwrap() - .return_data - .clone() - .as_value() + let result = runner + .call(PAUSED_PRECOMPILES, CALLED_ACCOUNT_ID, Vec::new()) .unwrap(); - + let output = result.return_data.as_value().unwrap(); let actual_paused_precompiles = u32::from_le_bytes(output.as_slice().try_into().unwrap()); let expected_paused_precompiles = EXIT_TO_ETHEREUM_FLAG; @@ -55,21 +46,14 @@ fn test_executing_paused_precompile_throws_error() { let _res = runner.call(PAUSE_PRECOMPILES, CALLED_ACCOUNT_ID, input.clone()); let is_to_near = false; - let result = tester.withdraw(&mut runner, &mut signer, is_to_near); - - assert!(result.is_err(), "{result:?}"); - - let error = result.unwrap_err(); - match &error { - VMError::FunctionCallError(fn_error) => match fn_error { - FunctionCallError::HostError(err) => match err { - HostError::GuestPanic { panic_msg } => assert_eq!(panic_msg, "ERR_PAUSED"), - other => panic!("Unexpected host error {other:?}"), - }, - other => panic!("Unexpected function call error {other:?}"), - }, - other => panic!("Unexpected VM error {other:?}"), - }; + let error = tester + .withdraw(&mut runner, &mut signer, is_to_near) + .unwrap_err(); + + assert!(matches!( + error.kind, + EngineErrorKind::EvmFatal(evm::ExitFatal::Other(e)) if e == "ERR_PAUSED" + )); } #[test] @@ -107,23 +91,19 @@ fn test_resuming_precompile_does_not_throw_error() { let mut input: Vec = Vec::new(); call_args.serialize(&mut input).unwrap(); - let (_, error) = runner.call(RESUME_PRECOMPILES, CALLED_ACCOUNT_ID, input); + let result = runner.call(RESUME_PRECOMPILES, CALLED_ACCOUNT_ID, input); - assert!(error.is_none(), "{error:?}"); + assert!(result.is_ok(), "{result:?}"); } #[test] fn test_pausing_precompile_does_not_throw_error() { let mut runner = test_utils::deploy_evm(); - let call_args = PausePrecompilesCallArgs { paused_mask: 0b1 }; + let input = call_args.try_to_vec().unwrap(); + let result = runner.call(PAUSE_PRECOMPILES, CALLED_ACCOUNT_ID, input); - let mut input: Vec = Vec::new(); - call_args.serialize(&mut input).unwrap(); - - let (_, error) = runner.call(PAUSE_PRECOMPILES, CALLED_ACCOUNT_ID, input); - - assert!(error.is_none(), "{error:?}"); + assert!(result.is_ok(), "{result:?}"); } fn setup_test() -> (AuroraRunner, Signer, Address, Tester) { @@ -149,7 +129,9 @@ fn setup_test() -> (AuroraRunner, Signer, Address, Tester) { ) .into(); - runner.mint(token, tester.contract.address, 1_000_000_000, ORIGIN); + runner + .mint(token, tester.contract.address, 1_000_000_000, ORIGIN) + .unwrap(); (runner, signer, token, tester) } diff --git a/engine-tests/src/tests/promise_results_precompile.rs b/engine-tests/src/tests/promise_results_precompile.rs index 967aed2fa..3d28de702 100644 --- a/engine-tests/src/tests/promise_results_precompile.rs +++ b/engine-tests/src/tests/promise_results_precompile.rs @@ -55,7 +55,7 @@ fn test_promise_result_gas_cost() { standalone.init_evm(); runner.standalone_runner = Some(standalone); let mut signer = test_utils::Signer::random(); - runner.context.block_index = aurora_engine::engine::ZERO_ADDRESS_FIX_HEIGHT + 1; + runner.context.block_height = aurora_engine::engine::ZERO_ADDRESS_FIX_HEIGHT + 1; // Baseline transaction that does essentially nothing. let (_, baseline) = runner diff --git a/engine-tests/src/tests/repro.rs b/engine-tests/src/tests/repro.rs index 42c327181..f39479122 100644 --- a/engine-tests/src/tests/repro.rs +++ b/engine-tests/src/tests/repro.rs @@ -23,11 +23,11 @@ fn repro_GdASJ3KESs() { // in the transaction. This pruned snapshot contains precisely those keys, and no others. repro_common(&ReproContext { snapshot_path: "src/tests/res/aurora_state_GdASJ3KESs.json", - block_index: 83_596_945, + block_height: 83_596_945, block_timestamp: 1_645_717_564_644_206_730, input_path: "src/tests/res/input_GdASJ3KESs.hex", evm_gas_used: 706_713, - near_gas_used: 122, + near_gas_used: 121, }); } @@ -48,11 +48,11 @@ fn repro_8ru7VEA() { // in the transaction. This pruned snapshot contains precisely those keys, and no others. repro_common(&ReproContext { snapshot_path: "src/tests/res/aurora_state_8ru7VEA.json", - block_index: 62_625_815, + block_height: 62_625_815, block_timestamp: 1_648_829_935_343_349_589, input_path: "src/tests/res/input_8ru7VEA.hex", evm_gas_used: 1_732_181, - near_gas_used: 223, + near_gas_used: 220, }); } @@ -68,11 +68,11 @@ fn repro_8ru7VEA() { fn repro_FRcorNv() { repro_common(&ReproContext { snapshot_path: "src/tests/res/aurora_state_FRcorNv.json", - block_index: 64_328_524, + block_height: 64_328_524, block_timestamp: 1_650_960_438_774_745_116, input_path: "src/tests/res/input_FRcorNv.hex", evm_gas_used: 1_239_721, - near_gas_used: 181, + near_gas_used: 179, }); } @@ -85,11 +85,11 @@ fn repro_FRcorNv() { fn repro_5bEgfRQ() { repro_common(&ReproContext { snapshot_path: "src/tests/res/aurora_state_5bEgfRQ.json", - block_index: 64_417_403, + block_height: 64_417_403, block_timestamp: 1_651_073_772_931_594_646, input_path: "src/tests/res/input_5bEgfRQ.hex", evm_gas_used: 6_414_105, - near_gas_used: 657, + near_gas_used: 654, }); } @@ -103,11 +103,11 @@ fn repro_5bEgfRQ() { fn repro_D98vwmi() { repro_common(&ReproContext { snapshot_path: "src/tests/res/aurora_state_D98vwmi.json", - block_index: 64_945_381, + block_height: 64_945_381, block_timestamp: 1_651_753_443_421_003_245, input_path: "src/tests/res/input_D98vwmi.hex", evm_gas_used: 1_035_348, - near_gas_used: 182, + near_gas_used: 180, }); } @@ -122,18 +122,18 @@ fn repro_D98vwmi() { fn repro_Emufid2() { repro_common(&ReproContext { snapshot_path: "src/tests/res/aurora_state_Emufid2.json", - block_index: 99_197_180, + block_height: 99_197_180, block_timestamp: 1_662_118_048_636_713_538, input_path: "src/tests/res/input_Emufid2.hex", evm_gas_used: 1_156_364, - near_gas_used: 306, + near_gas_used: 296, }); } fn repro_common(context: &ReproContext) { let ReproContext { snapshot_path, - block_index, + block_height, block_timestamp, input_path, evm_gas_used, @@ -146,18 +146,19 @@ fn repro_common(context: &ReproContext) { runner.wasm_config.limit_config.max_gas_burnt = 3_000_000_000_000_000; runner.context.storage_usage = 1_000_000_000; runner.consume_json_snapshot(snapshot.clone()); - runner.context.block_index = *block_index; + runner.context.block_height = *block_height; runner.context.block_timestamp = *block_timestamp; let tx_hex = std::fs::read_to_string(input_path).unwrap(); let tx_bytes = hex::decode(tx_hex.trim()).unwrap(); - let (outcome, error) = runner.call("submit", "relay.aurora", tx_bytes); - let outcome = outcome.unwrap(); + // Make a random call that touches the Engine state to force the lazy migration + runner + .call("get_chain_id", "relay.aurora", Vec::new()) + .unwrap(); + // Run benchmark post-migration + let outcome = runner.call("submit", "relay.aurora", tx_bytes).unwrap(); let profile = ExecutionProfile::new(&outcome); - if let Some(error) = error { - panic!("{error:?}"); - } let submit_result = SubmitResult::try_from_slice(&outcome.return_data.as_value().unwrap()).unwrap(); @@ -183,7 +184,7 @@ fn repro_common(context: &ReproContext) { struct ReproContext<'a> { snapshot_path: &'a str, - block_index: u64, + block_height: u64, block_timestamp: u64, input_path: &'a str, evm_gas_used: u64, diff --git a/engine-tests/src/tests/sanity.rs b/engine-tests/src/tests/sanity.rs index 6f8328c82..4834f9813 100644 --- a/engine-tests/src/tests/sanity.rs +++ b/engine-tests/src/tests/sanity.rs @@ -2,11 +2,18 @@ use crate::prelude::{Address, U256}; use crate::prelude::{Wei, ERC20_MINT_SELECTOR}; use crate::test_utils::{self, str_to_account_id}; use crate::tests::state_migration; +use aurora_engine::engine::{EngineErrorKind, GasPaymentError, ZERO_ADDRESS_FIX_HEIGHT}; use aurora_engine::fungible_token::FungibleTokenMetadata; -use aurora_engine::parameters::{SetOwnerArgs, SubmitResult, TransactionStatus}; +use aurora_engine::parameters::{ + SetOwnerArgs, SetUpgradeDelayBlocksArgs, SubmitResult, TransactionStatus, +}; use aurora_engine_sdk as sdk; -use borsh::BorshSerialize; +use aurora_engine_types::H160; +use borsh::{BorshDeserialize, BorshSerialize}; +use evm::ExitFatal; use libsecp256k1::SecretKey; +use near_sdk_sim::errors::TxExecutionError; +use near_sdk_sim::transaction::ExecutionStatus; use rand::RngCore; use std::path::{Path, PathBuf}; @@ -43,8 +50,8 @@ fn test_total_supply_accounting() { }; let get_total_supply = |runner: &mut test_utils::AuroraRunner| -> Wei { - let (outcome, _) = runner.call("ft_total_eth_supply_on_aurora", "aurora", Vec::new()); - let amount: u128 = String::from_utf8(outcome.unwrap().return_data.as_value().unwrap()) + let result = runner.call("ft_total_eth_supply_on_aurora", "aurora", Vec::new()); + let amount: u128 = String::from_utf8(result.unwrap().return_data.as_value().unwrap()) .unwrap() .replace('"', "") .parse() @@ -109,7 +116,7 @@ fn test_transaction_to_zero_address() { context.input = tx_bytes; // Prior to the fix the zero address is interpreted as None, causing a contract deployment. // It also incorrectly derives the sender address, so does not increment the right nonce. - context.block_index = ZERO_ADDRESS_FIX_HEIGHT - 1; + context.block_height = ZERO_ADDRESS_FIX_HEIGHT - 1; let result = runner .submit_raw(test_utils::SUBMIT, &context, &[]) .unwrap(); @@ -118,7 +125,7 @@ fn test_transaction_to_zero_address() { assert_eq!(runner.get_nonce(&address), U256::zero()); // After the fix this transaction is simply a transfer of 0 ETH to the zero address - context.block_index = ZERO_ADDRESS_FIX_HEIGHT; + context.block_height = ZERO_ADDRESS_FIX_HEIGHT; let result = runner .submit_raw(test_utils::SUBMIT, &context, &[]) .unwrap(); @@ -133,21 +140,19 @@ fn test_state_format() { // change the binary format of the `EngineState` then we will know // about it. This is important because changing the state format will // break the contract unless we do a state migration. - let args = aurora_engine::parameters::NewCallArgs { + let args = aurora_engine::parameters::NewCallArgsV2 { chain_id: aurora_engine_types::types::u256_to_arr(&666.into()), owner_id: "boss".parse().unwrap(), - bridge_prover_id: "prover_mcprovy_face".parse().unwrap(), upgrade_delay_blocks: 3, }; let state: aurora_engine::state::EngineState = args.into(); let expected_hex: String = [ - "000000000000000000000000000000000000000000000000000000000000029a", + "01000000000000000000000000000000000000000000000000000000000000029a", "04000000626f7373", - "1300000070726f7665725f6d6370726f76795f66616365", "0300000000000000", ] .concat(); - assert_eq!(hex::encode(state.try_to_vec().unwrap()), expected_hex); + assert_eq!(hex::encode(state.borsh_serialize().unwrap()), expected_hex); } fn generate_code(len: usize) -> Vec { @@ -355,7 +360,7 @@ fn test_solidity_pure_bench() { let code = near_primitives_core::contract::ContractCode::new(contract_bytes, None); let mut context = runner.context.clone(); context.input = loop_limit.to_le_bytes().to_vec(); - let (outcome, error) = match near_vm_runner::run( + let outcome = near_vm_runner::run( &code, "cpu_ram_soak_test", &mut runner.ext, @@ -365,15 +370,10 @@ fn test_solidity_pure_bench() { &[], runner.current_protocol_version, Some(&runner.cache), - ) { - near_vm_runner::VMResult::Aborted(outcome, error) => (Some(outcome), Some(error)), - near_vm_runner::VMResult::Ok(outcome) => (Some(outcome), None), - }; - if let Some(e) = error { - panic!("{e:?}"); - } - let outcome = outcome.unwrap(); + ) + .unwrap(); let profile = test_utils::ExecutionProfile::new(&outcome); + // Check the contract actually did the work. assert_eq!(&outcome.logs, &[format!("Done {loop_limit} iterations!")]); assert!(profile.all_gas() < 1_000_000_000_000); // Less than 1 Tgas used! @@ -688,14 +688,13 @@ fn test_eth_transfer_incorrect_nonce() { test_utils::validate_address_balance_and_nonce(&runner, dest_address, Wei::zero(), 0.into()); // attempt transfer - let err = runner + let error = runner .submit_with_signer(&mut source_account, |nonce| { // creating transaction with incorrect nonce test_utils::transfer(dest_address, TRANSFER_AMOUNT, nonce + 1) }) .unwrap_err(); - let error_message = format!("{err:?}"); - assert!(error_message.contains("ERR_INCORRECT_NONCE")); + assert_eq!(error.kind, EngineErrorKind::IncorrectNonce); // validate post-state (which is the same as pre-state in this case) test_utils::validate_address_balance_and_nonce( @@ -727,11 +726,10 @@ fn test_eth_transfer_not_enough_gas() { test_utils::validate_address_balance_and_nonce(&runner, dest_address, Wei::zero(), 0.into()); // attempt transfer - let err = runner + let error = runner .submit_with_signer(&mut source_account, transaction) .unwrap_err(); - let error_message = format!("{err:?}"); - assert!(error_message.contains("ERR_INTRINSIC_GAS")); + assert_eq!(error.kind, EngineErrorKind::IntrinsicGasNotMet); // validate post-state (which is the same as pre-state in this case) test_utils::validate_address_balance_and_nonce( @@ -798,8 +796,6 @@ fn test_transfer_charging_gas_success() { #[test] fn test_eth_transfer_charging_gas_not_enough_balance() { - use near_vm_errors::{FunctionCallError, HostError, VMError}; - let (mut runner, mut source_account, dest_address) = initialize_transfer(); let source_address = test_utils::address_from_secret_key(&source_account.secret_key); let transaction = |nonce| { @@ -824,10 +820,10 @@ fn test_eth_transfer_charging_gas_not_enough_balance() { let error = runner .submit_with_signer(&mut source_account, transaction) .unwrap_err(); - assert!(matches!(error, VMError::FunctionCallError( - FunctionCallError::HostError( - HostError::GuestPanic { panic_msg })) if panic_msg == "ERR_OUT_OF_FUND" - )); + assert_eq!( + error.kind, + EngineErrorKind::GasPayment(GasPaymentError::OutOfFund) + ); // validate post-state let relayer = sdk::types::near_account_to_evm_address( @@ -859,15 +855,12 @@ pub fn initialize_transfer() -> (test_utils::AuroraRunner, test_utils::Signer, A (runner, signer, dest_address) } -use aurora_engine::engine::ZERO_ADDRESS_FIX_HEIGHT; -use aurora_engine_types::H160; -use sha3::Digest; - #[test] fn check_selector() { // Selector to call mint function in ERC 20 contract // // keccak("mint(address,uint256)".as_bytes())[..4]; + use sha3::Digest; let mut hasher = sha3::Keccak256::default(); hasher.update(b"mint(address,uint256)"); assert_eq!(hasher.finalize()[..4].to_vec(), ERC20_MINT_SELECTOR); @@ -892,17 +885,14 @@ fn test_block_hash() { #[test] fn test_block_hash_api() { let mut runner = test_utils::deploy_evm(); - let block_height: u64 = 10; - let (maybe_outcome, maybe_error) = runner.call( - "get_block_hash", - "any.near", - block_height.try_to_vec().unwrap(), - ); - if let Some(error) = maybe_error { - panic!("Call failed: {error:?}"); - } - let outcome = maybe_outcome.unwrap(); + let outcome = runner + .call( + "get_block_hash", + "any.near", + block_height.try_to_vec().unwrap(), + ) + .unwrap(); let block_hash = outcome.return_data.as_value().unwrap(); assert_eq!( @@ -939,11 +929,8 @@ fn test_block_hash_contract() { #[test] fn test_ft_metadata() { let mut runner = test_utils::deploy_evm(); - let account_id: String = runner.context.signer_account_id.clone().into(); - let (maybe_outcome, maybe_error) = runner.call("ft_metadata", &account_id, Vec::new()); - assert!(maybe_error.is_none()); - let outcome = maybe_outcome.unwrap(); + let outcome = runner.call("ft_metadata", &account_id, Vec::new()).unwrap(); let metadata = serde_json::from_slice::(&outcome.return_data.as_value().unwrap()) .unwrap(); @@ -974,7 +961,7 @@ fn test_eth_transfer_insufficient_balance_sim() { ); let call_result = aurora.call("submit", rlp::encode(&signed_tx).as_ref()); let result = match call_result.status() { - near_primitives::transaction::ExecutionStatus::SuccessValue(bytes) => { + ExecutionStatus::SuccessValue(bytes) => { use borsh::BorshDeserialize; SubmitResult::try_from_slice(&bytes).unwrap() } @@ -996,8 +983,6 @@ fn test_eth_transfer_insufficient_balance_sim() { // Same as `test_eth_transfer_charging_gas_not_enough_balance` but run through `near-sdk-sim`. #[test] fn test_eth_transfer_charging_gas_not_enough_balance_sim() { - use near_primitives::{errors::TxExecutionError, transaction::ExecutionStatus}; - let (aurora, mut signer, address) = initialize_evm_sim(); // Run transaction which will fail (not enough balance to cover gas) @@ -1012,9 +997,8 @@ fn test_eth_transfer_charging_gas_not_enough_balance_sim() { ); let call_result = aurora.call("submit", rlp::encode(&signed_tx).as_ref()); let outcome = call_result.outcome(); - assert!(matches!( - &outcome.status, - ExecutionStatus::Failure( + + assert!(matches!(&outcome.status, ExecutionStatus::Failure( TxExecutionError::ActionError(e)) if e.to_string().contains("ERR_OUT_OF_FUND") )); @@ -1081,25 +1065,24 @@ fn test_set_owner() { new_owner: str_to_account_id("new_owner.near"), }; - let (outcome, error) = runner.call( + let result = runner.call( "set_owner", &aurora_account_id, set_owner_args.try_to_vec().unwrap(), ); // setting owner from the owner with same owner id should succeed - assert!(outcome.is_some() && error.is_none()); + assert!(result.is_ok()); // get owner to see if the owner_id property has changed - let (outcome, error) = runner.call("get_owner", &aurora_account_id, vec![]); - - // check if the query goes through the standalone runner - assert!(outcome.is_some() && error.is_none()); + let outcome = runner + .call("get_owner", &aurora_account_id, vec![]) + .unwrap(); // check if the owner_id property has changed to new_owner.near assert_eq!( b"new_owner.near", - outcome.unwrap().return_data.as_value().unwrap().as_slice() + outcome.return_data.as_value().unwrap().as_slice() ); } @@ -1113,20 +1096,52 @@ fn test_set_owner_fail_on_same_owner() { new_owner: str_to_account_id(&aurora_account_id), }; - let (outcome, error) = runner.call( - "set_owner", - &aurora_account_id, - set_owner_args.try_to_vec().unwrap(), - ); - - // setting owner from the owner with same owner id should fail - assert!(outcome.is_some() && error.is_some()); + let error = runner + .call( + "set_owner", + &aurora_account_id, + set_owner_args.try_to_vec().unwrap(), + ) + .unwrap_err(); // check error equality assert_eq!( - error.unwrap().to_string(), - "Smart contract panicked: ERR_SAME_OWNER" + error.kind, + EngineErrorKind::EvmFatal(ExitFatal::Other("ERR_SAME_OWNER".into())) + ); +} + +#[test] +fn test_set_upgrade_delay_blocks() { + let mut runner = test_utils::deploy_evm(); + let aurora_account_id = runner.aurora_account_id.clone(); + + // set upgrade_delay_blocks args + let set_upgrade_delay_blocks = SetUpgradeDelayBlocksArgs { + upgrade_delay_blocks: 2, + }; + + let result = runner.call( + "set_upgrade_delay_blocks", + &aurora_account_id, + set_upgrade_delay_blocks.try_to_vec().unwrap(), ); + + // should succeed + assert!(result.is_ok()); + + // get upgrade_delay_blocks to see if the upgrade_delay_blocks property has changed + let result = runner.call("get_upgrade_delay_blocks", &aurora_account_id, vec![]); + + // check if the query goes through the standalone runner + assert!(result.is_ok()); + + // check if the upgrade_delay_blocks property has changed to 2 + let result = SetUpgradeDelayBlocksArgs::try_from_slice( + result.unwrap().return_data.as_value().unwrap().as_slice(), + ) + .unwrap(); + assert_eq!(result.upgrade_delay_blocks, 2); } fn initialize_evm_sim() -> (state_migration::AuroraAccount, test_utils::Signer, Address) { @@ -1159,7 +1174,7 @@ fn query_address_sim( ) -> U256 { let x = aurora.call(method, address.as_bytes()); match &x.outcome().status { - near_sdk_sim::transaction::ExecutionStatus::SuccessValue(b) => U256::from_big_endian(b), + ExecutionStatus::SuccessValue(b) => U256::from_big_endian(b), other => panic!("Unexpected outcome: {other:?}"), } } diff --git a/engine-tests/src/tests/standalone/json_snapshot.rs b/engine-tests/src/tests/standalone/json_snapshot.rs index 2eadaef01..95abee687 100644 --- a/engine-tests/src/tests/standalone/json_snapshot.rs +++ b/engine-tests/src/tests/standalone/json_snapshot.rs @@ -1,4 +1,5 @@ use crate::test_utils::{self, standalone}; +use aurora_engine_types::storage::{self, KeyPrefix}; use aurora_engine_types::types::{Address, Wei}; use aurora_engine_types::{H160, U256}; use engine_standalone_storage::json_snapshot; @@ -92,13 +93,16 @@ fn test_produce_snapshot() { .get_snapshot(runner.env.block_height) .unwrap(); + let state_key = storage::bytes_to_key(KeyPrefix::Config, aurora_engine::state::STATE_KEY); // New snapshot should still contain all keys from initial snapshot for entry in snapshot.result.values { let key = aurora_engine_sdk::base64::decode(entry.key).unwrap(); // skip the eth-connector keys; they were changed by minting the new account - if key[0..3] == [7, 6, 1] { + // also skip the state since it was automatically migrated from the old format + if (key[0..3] == [7, 6, 1]) || (key == state_key) { continue; } + println!("{}", hex::encode(&key)); let value = aurora_engine_sdk::base64::decode(entry.value).unwrap(); assert_eq!(computed_snapshot.get(&key).unwrap(), &value); } diff --git a/engine-tests/src/tests/standalone/sanity.rs b/engine-tests/src/tests/standalone/sanity.rs index 88fdb2a12..57a4b0d9a 100644 --- a/engine-tests/src/tests/standalone/sanity.rs +++ b/engine-tests/src/tests/standalone/sanity.rs @@ -18,7 +18,6 @@ fn test_deploy_code() { let state = state::EngineState { chain_id, owner_id: owner_id.clone(), - bridge_prover_id: "mr_the_prover".parse().unwrap(), upgrade_delay_blocks: 0, }; let origin = Address::new(H160([0u8; 20])); diff --git a/engine-tests/src/tests/standard_precompiles.rs b/engine-tests/src/tests/standard_precompiles.rs index 9d16dfc3c..94454ba63 100644 --- a/engine-tests/src/tests/standard_precompiles.rs +++ b/engine-tests/src/tests/standard_precompiles.rs @@ -54,7 +54,7 @@ fn profile_identity() { #[test] fn profile_modexp() { let profile = precompile_execution_profile("test_modexp"); - test_utils::assert_gas_bound(profile.all_gas(), 8); + test_utils::assert_gas_bound(profile.all_gas(), 7); } #[test] diff --git a/engine-tests/src/tests/state_migration.rs b/engine-tests/src/tests/state_migration.rs index c1cc0ee5d..ca0a95e74 100644 --- a/engine-tests/src/tests/state_migration.rs +++ b/engine-tests/src/tests/state_migration.rs @@ -1,7 +1,7 @@ use crate::prelude::U256; use crate::test_utils::{self, str_to_account_id, AuroraRunner}; use aurora_engine::fungible_token::FungibleTokenMetadata; -use aurora_engine::parameters::{InitCallArgs, NewCallArgs}; +use aurora_engine::parameters::{InitCallArgs, NewCallArgs, NewCallArgsV2}; use borsh::BorshSerialize; use near_sdk_sim::{ExecutionResult, UserAccount}; use std::fs; @@ -25,6 +25,23 @@ fn test_state_migration() { assert_eq!(some_numbers, [3, 1, 4, 1, 5, 9, 2]); } +#[test] +fn test_repeated_calls_to_deploy_upgrade_should_fail() { + let aurora = deploy_evm(); + + // First upgrade should succeed + let upgraded_contract_bytes = contract_bytes(); + aurora + .call("stage_upgrade", &upgraded_contract_bytes) + .assert_success(); + aurora.call("deploy_upgrade", &[]).assert_success(); + + // Second upgrade should fail + aurora.call("stage_upgrade", &upgraded_contract_bytes); + let result = aurora.call("deploy_upgrade", &[]); + assert!(!result.is_ok()); +} + pub fn deploy_evm() -> AuroraAccount { let aurora_runner = AuroraRunner::default(); let main_account = near_sdk_sim::init_simulator(None); @@ -39,12 +56,11 @@ pub fn deploy_evm() -> AuroraAccount { 5 * near_sdk_sim::STORAGE_AMOUNT, ); let prover_account = str_to_account_id("prover.near"); - let new_args = NewCallArgs { + let new_args = NewCallArgs::V2(NewCallArgsV2 { chain_id: crate::prelude::u256_to_arr(&U256::from(aurora_runner.chain_id)), owner_id: str_to_account_id(main_account.account_id.as_str()), - bridge_prover_id: prover_account.clone(), upgrade_delay_blocks: 1, - }; + }); main_account .call( contract_account.account_id.clone(), diff --git a/engine-tests/src/tests/uniswap.rs b/engine-tests/src/tests/uniswap.rs index c0d9ebc1d..4c28b7403 100644 --- a/engine-tests/src/tests/uniswap.rs +++ b/engine-tests/src/tests/uniswap.rs @@ -38,7 +38,7 @@ fn test_uniswap_input_multihop() { let (_amount_out, _evm_gas, profile) = context.exact_input(&tokens, INPUT_AMOUNT.into()); - assert_eq!(113, profile.all_gas() / 1_000_000_000_000); + assert_eq!(112, profile.all_gas() / 1_000_000_000_000); } #[test] @@ -152,8 +152,8 @@ impl UniswapTestContext { } pub fn create_tokens(&mut self, n: usize, mint_amount: U256) -> Vec { - let names = ('a'..='z').into_iter().map(|c| format!("token_{c}")); - let symbols = ('A'..='Z').into_iter().map(|c| format!("{c}{c}{c}")); + let names = ('a'..='z').map(|c| format!("token_{c}")); + let symbols = ('A'..='Z').map(|c| format!("{c}{c}{c}")); let mut result: Vec = names .zip(symbols) .take(n) diff --git a/engine-tests/src/tests/xcc.rs b/engine-tests/src/tests/xcc.rs index 18b2d866e..858fe73db 100644 --- a/engine-tests/src/tests/xcc.rs +++ b/engine-tests/src/tests/xcc.rs @@ -31,7 +31,7 @@ fn test_xcc_eth_gas_cost() { let _res = runner.call("factory_update", ORIGIN, xcc_wasm_bytes); let mut signer = test_utils::Signer::random(); let mut baseline_signer = test_utils::Signer::random(); - runner.context.block_index = aurora_engine::engine::ZERO_ADDRESS_FIX_HEIGHT + 1; + runner.context.block_height = aurora_engine::engine::ZERO_ADDRESS_FIX_HEIGHT + 1; // Need to use for engine's deployment! let wnear_erc20 = deploy_erc20(&mut runner, &mut signer); approve_erc20( @@ -233,7 +233,7 @@ fn test_xcc_external_fund() { .call("get_code", deployed_address.as_bytes()) .status() { - near_primitives::transaction::ExecutionStatus::SuccessValue(bytes) => bytes, + near_sdk_sim::transaction::ExecutionStatus::SuccessValue(bytes) => bytes, other => panic!("Unexpected status {other:?}"), }; @@ -635,7 +635,7 @@ fn submit_xcc_transaction( ); result.assert_success(); let submit_result = match result.status() { - near_primitives::transaction::ExecutionStatus::SuccessValue(bytes) => { + near_sdk_sim::transaction::ExecutionStatus::SuccessValue(bytes) => { aurora_engine::parameters::SubmitResult::try_from_slice(&bytes).unwrap() } other => panic!("Unexpected status {other:?}"), @@ -675,13 +675,13 @@ fn test_xcc_schedule_gas() { attached_gas: NearGas::new(100_000_000_000_000), }; - let (maybe_outcome, maybe_error) = router.call( - "schedule", - ORIGIN, - PromiseArgs::Create(promise).try_to_vec().unwrap(), - ); - assert!(maybe_error.is_none()); - let outcome = maybe_outcome.unwrap(); + let outcome = router + .call( + "schedule", + ORIGIN, + PromiseArgs::Create(promise).try_to_vec().unwrap(), + ) + .unwrap(); assert!( outcome.burnt_gas < costs::ROUTER_SCHEDULE.as_u64(), "{:?} not less than {:?}", @@ -719,11 +719,9 @@ fn test_xcc_exec_gas() { let x = create_promise_chain(&promise, callback_count); let args = PromiseArgs::Recursive(x); - let (maybe_outcome, maybe_error) = - router.call("execute", ORIGIN, args.try_to_vec().unwrap()); - assert!(maybe_error.is_none()); - let outcome = maybe_outcome.unwrap(); - + let outcome = router + .call("execute", ORIGIN, args.try_to_vec().unwrap()) + .unwrap(); let callback_count = args.promise_count() - 1; let router_exec_cost = costs::ROUTER_EXEC_BASE + NearGas::new(callback_count * costs::ROUTER_EXEC_PER_CALLBACK.as_u64()); @@ -785,10 +783,9 @@ fn deploy_router() -> AuroraRunner { router.context.predecessor_account_id = ORIGIN.parse().unwrap(); let init_args = r#"{"wnear_account": "wrap.near", "must_register": true}"#; - let (maybe_outcome, maybe_error) = - router.call("initialize", ORIGIN, init_args.as_bytes().to_vec()); - assert!(maybe_error.is_none()); - let outcome = maybe_outcome.unwrap(); + let outcome = router + .call("initialize", ORIGIN, init_args.as_bytes().to_vec()) + .unwrap(); assert!(outcome.used_gas < aurora_engine::xcc::INITIALIZE_GAS.as_u64()); router @@ -867,16 +864,16 @@ fn deploy_erc20(runner: &mut AuroraRunner, signer: &mut test_utils::Signer) -> E let args = aurora_engine::parameters::DeployErc20TokenArgs { nep141: "wrap.near".parse().unwrap(), }; - let (maybe_output, maybe_error) = runner.call( - "deploy_erc20_token", - &engine_account, - args.try_to_vec().unwrap(), - ); - assert!(maybe_error.is_none()); - let output = maybe_output.unwrap(); + let outcome = runner + .call( + "deploy_erc20_token", + &engine_account, + args.try_to_vec().unwrap(), + ) + .unwrap(); let address = { let bytes: Vec = - BorshDeserialize::try_from_slice(output.return_data.as_value().as_ref().unwrap()) + BorshDeserialize::try_from_slice(outcome.return_data.as_value().as_ref().unwrap()) .unwrap(); Address::try_from_slice(&bytes).unwrap() }; @@ -890,8 +887,8 @@ fn deploy_erc20(runner: &mut AuroraRunner, signer: &mut test_utils::Signer) -> E .mint(dest_address, WNEAR_AMOUNT.into(), U256::zero()) .data, }); - let (_, maybe_error) = runner.call("call", &engine_account, call_args.try_to_vec().unwrap()); - assert!(maybe_error.is_none()); + let result = runner.call("call", &engine_account, call_args.try_to_vec().unwrap()); + assert!(result.is_ok()); contract } diff --git a/engine-types/src/storage.rs b/engine-types/src/storage.rs index 3df7adf1d..e4c2a2606 100644 --- a/engine-types/src/storage.rs +++ b/engine-types/src/storage.rs @@ -94,7 +94,7 @@ impl From for KeyPrefix { 0x8 => Self::Nep141Erc20Map, 0x9 => Self::Erc20Nep141Map, 0xa => Self::CrossContractCall, - _ => unreachable!(), + _ => unreachable!("Unknown key prefix"), } } } diff --git a/engine/Cargo.toml b/engine/Cargo.toml index 45cc25d2f..2c63735b5 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aurora-engine" -version = "2.9.0" +version = "2.9.1" authors = ["Aurora Labs "] edition = "2021" description = "" @@ -35,7 +35,7 @@ wee_alloc = { version = "0.4.5", default-features = false } [dev-dependencies] aurora-engine-test-doubles = { path = "../engine-test-doubles" } -test-case = "2.1" +test-case = "3.1" digest = "0.10" [features] diff --git a/engine/src/engine.rs b/engine/src/engine.rs index 8cdf0ebf3..e1c85c10d 100644 --- a/engine/src/engine.rs +++ b/engine/src/engine.rs @@ -1023,7 +1023,7 @@ pub fn compute_block_hash(chain_id: [u8; 32], block_height: u64, account_id: &[u } #[must_use] -pub fn get_authorizer(io: &I) -> EngineAuthorizer { +pub fn get_authorizer(io: &I) -> EngineAuthorizer { // TODO: a temporary use the owner account only until the engine adapts std with near-plugins state::get_state(io) .map(|state| EngineAuthorizer::from_accounts(once(state.owner_id))) diff --git a/engine/src/lib.rs b/engine/src/lib.rs index b555c8939..b81a9b131 100644 --- a/engine/src/lib.rs +++ b/engine/src/lib.rs @@ -75,7 +75,7 @@ pub unsafe fn on_alloc_error(_: core::alloc::Layout) -> ! { #[cfg(feature = "contract")] mod contract { use borsh::{BorshDeserialize, BorshSerialize}; - use parameters::SetOwnerArgs; + use parameters::{SetOwnerArgs, SetUpgradeDelayBlocksArgs}; use crate::connector::{self, EthConnectorContract}; use crate::engine::{self, Engine}; @@ -122,11 +122,13 @@ mod contract { #[no_mangle] pub extern "C" fn new() { let mut io = Runtime; - if let Ok(state) = state::get_state(&io) { - require_owner_only(&state, &io.predecessor_account_id()); + + if state::get_state(&io).is_ok() { + sdk::panic_utf8(b"ERR_ALREADY_INITIALIZED"); } - let args: NewCallArgs = io.read_input_borsh().sdk_unwrap(); + let bytes = io.read_input().to_vec(); + let args = NewCallArgs::deserialize(&bytes).sdk_expect(errors::ERR_BORSH_DESERIALIZE); state::set_state(&mut io, &args.into()).sdk_unwrap(); } @@ -177,6 +179,23 @@ mod contract { io.return_output(&state::get_state(&io).sdk_unwrap().chain_id); } + #[no_mangle] + pub extern "C" fn get_upgrade_delay_blocks() { + let mut io = Runtime; + let state = state::get_state(&io).sdk_unwrap(); + io.return_output(&state.upgrade_delay_blocks.to_le_bytes()); + } + + #[no_mangle] + pub extern "C" fn set_upgrade_delay_blocks() { + let mut io = Runtime; + let mut state = state::get_state(&io).sdk_unwrap(); + require_owner_only(&state, &io.predecessor_account_id()); + let args: SetUpgradeDelayBlocksArgs = io.read_input_borsh().sdk_unwrap(); + state.upgrade_delay_blocks = args.upgrade_delay_blocks; + state::set_state(&mut io, &state).sdk_unwrap(); + } + #[no_mangle] pub extern "C" fn get_upgrade_index() { let mut io = Runtime; @@ -201,7 +220,7 @@ mod contract { /// Deploy staged upgrade. #[no_mangle] pub extern "C" fn deploy_upgrade() { - let io = Runtime; + let mut io = Runtime; let state = state::get_state(&io).sdk_unwrap(); require_owner_only(&state, &io.predecessor_account_id()); let index = internal_get_upgrade_index(); @@ -209,6 +228,7 @@ mod contract { sdk::panic_utf8(errors::ERR_NOT_ALLOWED_TOO_EARLY); } Runtime::self_deploy(&bytes_to_key(KeyPrefix::Config, CODE_KEY)); + io.remove_storage(&bytes_to_key(KeyPrefix::Config, CODE_STAGE_KEY)); } /// Called as part of the upgrade process (see `engine-sdk::self_deploy`). This function is meant diff --git a/engine/src/parameters.rs b/engine/src/parameters.rs index f13038199..e67480d7b 100644 --- a/engine/src/parameters.rs +++ b/engine/src/parameters.rs @@ -11,9 +11,25 @@ pub use aurora_engine_types::parameters::engine::{ use aurora_engine_types::types::{Fee, NEP141Wei, Yocto}; use serde::{Deserialize, Serialize}; -/// Borsh-encoded parameters for the `new` function. +/// Parameters for the `new` function. #[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] -pub struct NewCallArgs { +pub enum NewCallArgs { + V1(LegacyNewCallArgs), + V2(NewCallArgsV2), +} + +impl NewCallArgs { + pub fn deserialize(bytes: &[u8]) -> Result { + Self::try_from_slice(bytes).map_or_else( + |_| LegacyNewCallArgs::try_from_slice(bytes).map(Self::V1), + Ok, + ) + } +} + +/// Old Borsh-encoded parameters for the `new` function. +#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] +pub struct LegacyNewCallArgs { /// Chain id, according to the EIP-115 / ethereum-lists spec. pub chain_id: RawU256, /// Account which can upgrade this contract. @@ -26,12 +42,29 @@ pub struct NewCallArgs { pub upgrade_delay_blocks: u64, } +#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] +pub struct NewCallArgsV2 { + /// Chain id, according to the EIP-115 / ethereum-lists spec. + pub chain_id: RawU256, + /// Account which can upgrade this contract. + /// Use empty to disable updatability. + pub owner_id: AccountId, + /// How many blocks after staging upgrade can deploy it. + pub upgrade_delay_blocks: u64, +} + /// Borsh-encoded parameters for the `set_owner` function. #[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize, Serialize, Deserialize)] pub struct SetOwnerArgs { pub new_owner: AccountId, } +/// Borsh-encoded parameters for the `set_upgrade_delay_blocks` function. +#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize, Serialize, Deserialize)] +pub struct SetUpgradeDelayBlocksArgs { + pub upgrade_delay_blocks: u64, +} + /// Borsh-encoded (genesis) account balance used by the `begin_chain` function. #[cfg(feature = "evm_bully")] #[derive(BorshSerialize, BorshDeserialize)] diff --git a/engine/src/state.rs b/engine/src/state.rs index 166d4bf10..51f7ae108 100644 --- a/engine/src/state.rs +++ b/engine/src/state.rs @@ -1,50 +1,150 @@ -use crate::parameters::NewCallArgs; +use crate::parameters::{LegacyNewCallArgs, NewCallArgs, NewCallArgsV2}; use aurora_engine_sdk::io::{StorageIntermediate, IO}; use aurora_engine_types::account_id::AccountId; use aurora_engine_types::storage::{bytes_to_key, KeyPrefix}; +use aurora_engine_types::{Cow, Vec}; use borsh::{BorshDeserialize, BorshSerialize}; pub use error::EngineStateError; /// Key for storing the state of the engine. -const STATE_KEY: &[u8; 5] = b"STATE"; +pub const STATE_KEY: &[u8; 5] = b"STATE"; /// Engine internal state, mostly configuration. /// Should not contain anything large or enumerable. -#[derive(BorshSerialize, BorshDeserialize, Default, Clone, PartialEq, Eq, Debug)] +#[derive(Default, Clone, PartialEq, Eq, Debug)] pub struct EngineState { /// Chain id, according to the EIP-155 / ethereum-lists spec. pub chain_id: [u8; 32], /// Account which can upgrade this contract. /// Use empty to disable updatability. pub owner_id: AccountId, - /// Account of the bridge prover. - /// Use empty to not use base token as bridged asset. - pub bridge_prover_id: AccountId, /// How many blocks after staging upgrade can deploy it. pub upgrade_delay_blocks: u64, } -impl From for EngineState { - fn from(args: NewCallArgs) -> Self { +impl EngineState { + pub fn borsh_serialize(&self) -> Result, error::EngineStateError> { + let borshable: BorshableEngineState = self.into(); + borshable + .try_to_vec() + .map_err(|_| EngineStateError::SerializationFailed) + } + + /// Deserialization with lazy state migration. + pub fn try_from_slice( + bytes: &[u8], + io: &I, + ) -> Result { + let Ok(borshable) = BorshableEngineState::try_from_slice(bytes) else { + let legacy = BorshableEngineStateV1::try_from_slice(bytes) + .map_err(|_| EngineStateError::DeserializationFailed)?; + let result = legacy.into(); + + let mut io = *io; + set_state(&mut io, &result)?; + + return Ok(result); + }; + Ok(borshable.into()) + } +} + +#[derive(BorshSerialize, BorshDeserialize, Clone, PartialEq, Eq, Debug)] +pub enum BorshableEngineState<'a> { + V1(BorshableEngineStateV1<'a>), + V2(BorshableEngineStateV2<'a>), +} + +#[derive(BorshSerialize, BorshDeserialize, Default, Clone, PartialEq, Eq, Debug)] +pub struct BorshableEngineStateV1<'a> { + pub chain_id: [u8; 32], + pub owner_id: Cow<'a, AccountId>, + pub bridge_prover_id: Cow<'a, AccountId>, + pub upgrade_delay_blocks: u64, +} + +#[derive(BorshSerialize, BorshDeserialize, Default, Clone, PartialEq, Eq, Debug)] +pub struct BorshableEngineStateV2<'a> { + pub chain_id: [u8; 32], + pub owner_id: Cow<'a, AccountId>, + pub upgrade_delay_blocks: u64, +} + +impl<'a> From<&'a EngineState> for BorshableEngineState<'a> { + fn from(state: &'a EngineState) -> Self { + Self::V2(BorshableEngineStateV2 { + chain_id: state.chain_id, + owner_id: Cow::Borrowed(&state.owner_id), + upgrade_delay_blocks: state.upgrade_delay_blocks, + }) + } +} + +impl<'a> From> for EngineState { + fn from(state: BorshableEngineState<'a>) -> Self { + match state { + BorshableEngineState::V1(state) => state.into(), + BorshableEngineState::V2(state) => state.into(), + } + } +} + +impl<'a> From> for EngineState { + fn from(state: BorshableEngineStateV1<'a>) -> Self { + Self { + chain_id: state.chain_id, + owner_id: state.owner_id.into_owned(), + upgrade_delay_blocks: state.upgrade_delay_blocks, + } + } +} + +impl<'a> From> for EngineState { + fn from(state: BorshableEngineStateV2<'a>) -> Self { + Self { + chain_id: state.chain_id, + owner_id: state.owner_id.into_owned(), + upgrade_delay_blocks: state.upgrade_delay_blocks, + } + } +} + +impl From for EngineState { + fn from(args: LegacyNewCallArgs) -> Self { + Self { + chain_id: args.chain_id, + owner_id: args.owner_id, + upgrade_delay_blocks: args.upgrade_delay_blocks, + } + } +} + +impl From for EngineState { + fn from(args: NewCallArgsV2) -> Self { Self { chain_id: args.chain_id, owner_id: args.owner_id, - bridge_prover_id: args.bridge_prover_id, upgrade_delay_blocks: args.upgrade_delay_blocks, } } } +impl From for EngineState { + fn from(args: NewCallArgs) -> Self { + match args { + NewCallArgs::V1(args) => args.into(), + NewCallArgs::V2(args) => args.into(), + } + } +} + /// Gets the state from storage, if it exists otherwise it will error. -pub fn get_state(io: &I) -> Result { +pub fn get_state(io: &I) -> Result { io.read_storage(&bytes_to_key(KeyPrefix::Config, STATE_KEY)) .map_or_else( || Err(EngineStateError::NotFound), - |bytes| { - EngineState::try_from_slice(&bytes.to_vec()) - .map_err(|_| EngineStateError::DeserializationFailed) - }, + |bytes| EngineState::try_from_slice(&bytes.to_vec(), io), ) } @@ -52,9 +152,7 @@ pub fn get_state(io: &I) -> Result pub fn set_state(io: &mut I, state: &EngineState) -> Result<(), EngineStateError> { io.write_storage( &bytes_to_key(KeyPrefix::Config, STATE_KEY), - &state - .try_to_vec() - .map_err(|_| error::EngineStateError::SerializationFailed)?, + &state.borsh_serialize()?, ); Ok(()) diff --git a/engine/src/xcc.rs b/engine/src/xcc.rs index 8bc30ec59..ebeb1e16b 100644 --- a/engine/src/xcc.rs +++ b/engine/src/xcc.rs @@ -207,7 +207,7 @@ pub fn handle_precompile_promise( let wnear_address = get_wnear_address(io); let wnear_account = crate::engine::nep141_erc20_map(*io) .lookup_right(&crate::engine::ERC20Address(wnear_address)) - .unwrap(); + .expect("wnear account not found"); let init_args = format!( r#"{{"wnear_account": "{}", "must_register": {}}}"#, wnear_account.0.as_ref(), diff --git a/etc/tests/modexp-bench/Cargo.toml b/etc/tests/modexp-bench/Cargo.toml new file mode 100644 index 000000000..d37a60ae1 --- /dev/null +++ b/etc/tests/modexp-bench/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "modexp_bench" +version = "1.0.0" +authors = ["Aurora "] +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[profile.release] +codegen-units = 1 +opt-level = 3 +lto = true +debug = false +panic = "abort" + +[dependencies] +aurora-engine-modexp = { path = "../../../engine-modexp", default-features = false, features = ["bench", "std"] } +hex = { version = "0.4", default-features = false, features = ["alloc"] } +near-sdk = "4.1" diff --git a/etc/tests/modexp-bench/res/evm_contract_1.hex b/etc/tests/modexp-bench/res/evm_contract_1.hex new file mode 100644 index 000000000..0963d88d7 --- /dev/null +++ b/etc/tests/modexp-bench/res/evm_contract_1.hex @@ -0,0 +1 @@ +601a60005260016020526102ec6040527f4000000000000000000000000000000000000000000000000000030cd3f37c8d6060527fbafc2c4599da86baf4eb7780886673ee1a35cf28872a133fe9028f42e4566d9c6080527feed5e5629b5370d851dfb35b647b9ec8ae25a6c16295fda482a3560e50a2ad4460a0527f29afdb199e534b8d8291421f3a335c2e9b39c717dc121a6b1c63af71751a505a60c0527f52300fef1fa6b8276de9c1b7b0ed27264f78d0e0fcffe1e96d5498977798ff2960e0527f4b406ad85d321683a61fed9a5b1f3a281f6444533bb9f94bd7a0067f9cdb2b3f610100527f580c17e27a9abfd7bccab166a840bdf87a1fb1361576d18caccc6924b35cb892610120527f9c63d3f03c8219d0a703051bc8b8fa9561abfbc732f30e9e5d32e2d0bbc68bf1610140527f9e39f54f04002135fc7b437a09edf2e9a4ab16c5c9f6d8b594f4c0762593cdd4610160527f0d85d9ebab399da75398f45ec4e664e7734e88d100787c4475d15750c921fac8610180527fde3c9ca2d3832de8428a82468b5051e5fdadb7ca9fa3a8f836c81f4b5d88a75c6101a0527ff15b7c505e49b2b12b4ed46b77ae0c6c77ecbf3e7d7387a5416721a8f1c1bec16101c0527f27210566c88024350fac653fc761f82b223b9ae9cec747081c7e17c72aeae5716101e0527fc079c179628830ba77e27b8a83cda014b351b089f1c1dad5f03e38ecb05ffd58610200527f7d9b666e2970e74b0c27045a35df6951de359432421684d7990749f0f681f57c610220527f12ba3d91311f237a34768ff6c151e73b37144336ea2df6abf2d47ac7974342b0610240527f585b6ecbe369110913405c89e415336f3e42cf39d7f0a7a2571b23d49965ff2f610260527fc1ae996c36fd92502c0775d19ec9f0f8d03958e2de9c68ecd525fb5e49e31066610280527f700b719712d4adb52d9153a5c63b8abc4f8f119cdb2faaa74f32a9d5e1fd56366102a0527f7766b68b12829a9a4c14f96d1e13e21307bf5d1547ddd42b008d91446864fc6b6102c0527fb1134c8ce98306531e566afd354d3be634d7be4d15aee3a288aa8e43a5ebdf446102e0527f0f9e5e8d6ce23b070f193c6f159d25e0cf423dfcfd661b3d0b82a10c78b2dbc0610300527f5d71f53cf3ee21f8e30f7fec6d9ddbca1b698e131d1c37d3ac074c3b2ceea72e610320527f17c39cb378a576eb30f389bd8edf4b8ca86d08362594022d096e6390a2b0bd8a610340527f0452c0544ca12300000000000000000000000000000000000000000000000000610360525b60006000610367600060055af4506103a856 diff --git a/etc/tests/modexp-bench/res/evm_contract_2.hex b/etc/tests/modexp-bench/res/evm_contract_2.hex new file mode 100644 index 000000000..fb2b5a200 --- /dev/null +++ b/etc/tests/modexp-bench/res/evm_contract_2.hex @@ -0,0 +1 @@ +601060005260d860205260106040527fe0060000a921212121212121ff0000212b212121ffff1f1f1f1f1f1f1f1f1f1f6060527f1f1f1f1f1f1f1f1f1f1f1f1f00feffff212121212121ffffffff1fe1e0e0e01e6080527f1f1f169f1f1f1f490afcefffffffffffffffff8282828282828282828282828260a0527f828282828282828200ffff28ff2b212121ffff1f1f1f1f1f1f1f1f1f1f1f1f1f60c0527f1f1f1f1f1fffffffffff0afceffffff7ffffffffff7c8282828282a18282828260e0527f8282828282828282828200ffff28ff2b212121ffff1f1f1f1f1f1fd11f1f1f1f610100527f1f1f1f1f1f1f1fffffffffffffffff21212121212121fb2121212121ffff1f1f610120527f1f1f1f1f1f1fffaf82828282828200ffff28ff2b218282000000000000000000610140525b60006000610158600060055af45061013256 diff --git a/etc/tests/modexp-bench/src/lib.rs b/etc/tests/modexp-bench/src/lib.rs new file mode 100644 index 000000000..bdd3cdbc0 --- /dev/null +++ b/etc/tests/modexp-bench/src/lib.rs @@ -0,0 +1,79 @@ +use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +use near_sdk::{env, near_bindgen}; + +#[near_bindgen] +#[derive(BorshDeserialize, BorshSerialize, Default)] +pub struct Modexp; + +#[near_bindgen] +impl Modexp { + pub fn modexp( + &self, + base: String, + exp: String, + modulus: String, + n_iters: Option, + ) -> String { + bench_modexp(base, exp, modulus, aurora_engine_modexp::modexp, n_iters) + } + + pub fn modexp_ibig( + &self, + base: String, + exp: String, + modulus: String, + n_iters: Option, + ) -> String { + bench_modexp( + base, + exp, + modulus, + aurora_engine_modexp::modexp_ibig, + n_iters, + ) + } + + pub fn modexp_num( + &self, + base: String, + exp: String, + modulus: String, + n_iters: Option, + ) -> String { + bench_modexp( + base, + exp, + modulus, + aurora_engine_modexp::modexp_num, + n_iters, + ) + } +} + +fn bench_modexp( + base: String, + exp: String, + modulus: String, + function: fn(&[u8], &[u8], &[u8]) -> Vec, + n_iters: Option, +) -> String { + let (base_bytes, exp_bytes, mod_bytes) = parse_input(base, exp, modulus); + let output = function(&base_bytes, &exp_bytes, &mod_bytes); + if let Some(n_iters) = n_iters { + for _ in 1..n_iters { + function(&base_bytes, &exp_bytes, &mod_bytes); + } + } + hex::encode(output) +} + +fn parse_input(base: String, exp: String, modulus: String) -> (Vec, Vec, Vec) { + let base_bytes = hex::decode(base).unwrap_or_else(hex_failure); + let exp_bytes = hex::decode(exp).unwrap_or_else(hex_failure); + let mod_bytes = hex::decode(modulus).unwrap_or_else(hex_failure); + (base_bytes, exp_bytes, mod_bytes) +} + +fn hex_failure(_e: E) -> T { + env::panic_str("Invalid hex input"); +} diff --git a/etc/tests/state-migration-test/src/lib.rs b/etc/tests/state-migration-test/src/lib.rs index 08b82b09e..f9e5a2775 100644 --- a/etc/tests/state-migration-test/src/lib.rs +++ b/etc/tests/state-migration-test/src/lib.rs @@ -4,14 +4,14 @@ extern crate alloc; use alloc::vec::Vec; use aurora_engine::state; +use aurora_engine_sdk::io::{StorageIntermediate, IO}; use aurora_engine_sdk::near_runtime::Runtime; -use aurora_engine_sdk::io::{IO, StorageIntermediate}; use aurora_engine_types::storage; use borsh::{BorshDeserialize, BorshSerialize}; #[derive(BorshDeserialize, BorshSerialize)] -struct NewFancyState { - old_state: state::EngineState, +struct NewFancyState<'a> { + old_state: state::BorshableEngineState<'a>, some_other_numbers: [u32; 7], } @@ -23,8 +23,9 @@ pub extern "C" fn state_migration() { Err(e) => aurora_engine_sdk::panic_utf8(e.as_ref()), }; + let state_ref = &old_state; let new_state = NewFancyState { - old_state, + old_state: state_ref.into(), some_other_numbers: [3, 1, 4, 1, 5, 9, 2], }; @@ -34,7 +35,8 @@ pub extern "C" fn state_migration() { #[no_mangle] pub extern "C" fn some_new_fancy_function() { let mut io = Runtime; - let state = io.read_storage(&state_key()) + let state = io + .read_storage(&state_key()) .and_then(|bytes| NewFancyState::try_from_slice(&bytes.to_vec()).ok()) .unwrap(); diff --git a/rust-toolchain b/rust-toolchain index e1a2ebf0f..23462d93c 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2022-09-29" +channel = "nightly-2023-03-13" targets = ["wasm32-unknown-unknown"]