diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9c2b0364d..2be24a71f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,7 +27,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --locked --verbose + args: --locked --verbose --features meta-call bully-build: name: Bully build runs-on: ubuntu-latest diff --git a/CHANGES.md b/CHANGES.md index 8798d8b86..89d5381ab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.4.1] - 2021-06-23 + ## [1.4.0] - 2021-06-18 ## [1.3.0] - 2021-06-17 @@ -15,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.0.0] - 2021-05-12 +[1.4.1]: https://github.com/aurora-is-near/aurora-engine/compare/1.4.0...1.4.1 [1.4.0]: https://github.com/aurora-is-near/aurora-engine/compare/1.3.0...1.4.0 [1.3.0]: https://github.com/aurora-is-near/aurora-engine/compare/1.2.0...1.3.0 [1.2.0]: https://github.com/aurora-is-near/aurora-engine/compare/1.1.0...1.2.0 diff --git a/Cargo.lock b/Cargo.lock index 86bcf7fe6..21e681d2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,15 +8,6 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -[[package]] -name = "addr2line" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" -dependencies = [ - "gimli 0.23.0", -] - [[package]] name = "addr2line" version = "0.15.1" @@ -132,12 +123,12 @@ dependencies = [ "lazy-static-include", "libsecp256k1", "logos", - "near-crypto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "near-primitives-core 0.1.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", + "near-crypto", + "near-primitives-core 0.4.0", "near-sdk", "near-sdk-sim", - "near-vm-logic 3.0.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "near-vm-runner 3.0.0", + "near-vm-logic 4.0.0-pre.1", + "near-vm-runner", "num", "primitive-types", "rand 0.7.3", @@ -163,7 +154,7 @@ version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" dependencies = [ - "addr2line 0.15.1", + "addr2line", "cc", "cfg-if 1.0.0", "libc", @@ -551,16 +542,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" -[[package]] -name = "cpp_demangle" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44919ecaf6f99e8e737bc239408931c9a01e9a6c74814fee8242dd2506b65390" -dependencies = [ - "cfg-if 1.0.0", - "glob", -] - [[package]] name = "cpufeatures" version = "0.1.1" @@ -588,15 +569,6 @@ dependencies = [ "cranelift-entity 0.68.0", ] -[[package]] -name = "cranelift-bforest" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841476ab6d3530136b5162b64a2c6969d68141843ad2fd59126e5ea84fd9b5fe" -dependencies = [ - "cranelift-entity 0.72.0", -] - [[package]] name = "cranelift-codegen" version = "0.67.0" @@ -636,26 +608,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cranelift-codegen" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5619cef8d19530298301f91e9a0390d369260799a3d8dd01e28fc88e53637a" -dependencies = [ - "byteorder", - "cranelift-bforest 0.72.0", - "cranelift-codegen-meta 0.72.0", - "cranelift-codegen-shared 0.72.0", - "cranelift-entity 0.72.0", - "gimli 0.23.0", - "log", - "regalloc 0.0.31", - "serde", - "smallvec", - "target-lexicon 0.11.2", - "thiserror", -] - [[package]] name = "cranelift-codegen-meta" version = "0.67.0" @@ -676,16 +628,6 @@ dependencies = [ "cranelift-entity 0.68.0", ] -[[package]] -name = "cranelift-codegen-meta" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a319709b8267939155924114ea83f2a5b5af65ece3ac6f703d4735f3c66bb0d" -dependencies = [ - "cranelift-codegen-shared 0.72.0", - "cranelift-entity 0.72.0", -] - [[package]] name = "cranelift-codegen-shared" version = "0.67.0" @@ -698,15 +640,6 @@ version = "0.68.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938" -[[package]] -name = "cranelift-codegen-shared" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15925b23cd3a448443f289d85a8f53f3cf7a80f0137aa53c8e3b01ae8aefaef7" -dependencies = [ - "serde", -] - [[package]] name = "cranelift-entity" version = "0.67.0" @@ -725,15 +658,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cranelift-entity" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "610cf464396c89af0f9f7c64b5aa90aa9e8812ac84084098f1565b40051bc415" -dependencies = [ - "serde", -] - [[package]] name = "cranelift-frontend" version = "0.67.0" @@ -758,18 +682,6 @@ dependencies = [ "target-lexicon 0.11.2", ] -[[package]] -name = "cranelift-frontend" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d20c8bd4a1c41ded051734f0e33ad1d843a0adc98b9bd975ee6657e2c70cdc9" -dependencies = [ - "cranelift-codegen 0.72.0", - "log", - "smallvec", - "target-lexicon 0.11.2", -] - [[package]] name = "cranelift-native" version = "0.67.0" @@ -781,16 +693,6 @@ dependencies = [ "target-lexicon 0.11.2", ] -[[package]] -name = "cranelift-native" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e100df41f34a5a15291b37bfe0fd7abd0427a2c84195cc69578b4137f9099" -dependencies = [ - "cranelift-codegen 0.72.0", - "target-lexicon 0.11.2", -] - [[package]] name = "cranelift-wasm" version = "0.67.0" @@ -806,23 +708,6 @@ dependencies = [ "wasmparser 0.59.0", ] -[[package]] -name = "cranelift-wasm" -version = "0.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4efd473b2917303957e0bfaea6ea9d08b8c93695bee015a611a2514ce5254abc" -dependencies = [ - "cranelift-codegen 0.72.0", - "cranelift-entity 0.72.0", - "cranelift-frontend 0.72.0", - "itertools 0.10.0", - "log", - "serde", - "smallvec", - "thiserror", - "wasmparser 0.76.0", -] - [[package]] name = "crc32fast" version = "1.2.1" @@ -1534,17 +1419,6 @@ dependencies = [ "stable_deref_trait", ] -[[package]] -name = "gimli" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" -dependencies = [ - "fallible-iterator", - "indexmap", - "stable_deref_trait", -] - [[package]] name = "gimli" version = "0.24.0" @@ -2055,30 +1929,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" -[[package]] -name = "near-crypto" -version = "0.1.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "arrayref", - "blake2 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "borsh", - "bs58", - "c2-chacha", - "curve25519-dalek", - "derive_more", - "ed25519-dalek", - "lazy_static", - "libc", - "parity-secp256k1", - "rand 0.7.3", - "rand_core 0.5.1", - "serde", - "serde_json", - "subtle 2.4.0", - "thiserror", -] - [[package]] name = "near-crypto" version = "0.1.0" @@ -2122,8 +1972,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bde79472f7cfc0675733b65f79f9e50c20bfbb9806298ab2872916869a45dccd" dependencies = [ "borsh", - "near-crypto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "near-primitives 0.1.0-pre.1", + "near-crypto", + "near-primitives", "rand 0.7.3", ] @@ -2143,9 +1993,9 @@ dependencies = [ "hex", "jemallocator", "lazy_static", - "near-crypto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-crypto", "near-primitives-core 0.4.0", - "near-rpc-error-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-rpc-error-macro", "near-vm-errors 4.0.0-pre.1", "num-rational 0.3.2", "primitive-types", @@ -2159,54 +2009,6 @@ dependencies = [ "validator", ] -[[package]] -name = "near-primitives" -version = "0.1.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "base64 0.13.0", - "borsh", - "bs58", - "byteorder", - "chrono", - "derive_more", - "easy-ext", - "hex", - "jemallocator", - "lazy_static", - "near-crypto 0.1.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "near-primitives-core 0.1.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "near-rpc-error-macro 0.1.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "near-vm-errors 3.0.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "num-rational 0.3.2", - "primitive-types", - "rand 0.7.3", - "reed-solomon-erasure", - "regex", - "serde", - "serde_json", - "sha2 0.9.5", - "smart-default", - "validator", -] - -[[package]] -name = "near-primitives-core" -version = "0.1.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "base64 0.11.0", - "borsh", - "bs58", - "derive_more", - "hex", - "lazy_static", - "num-rational 0.3.2", - "serde", - "serde_json", - "sha2 0.9.5", -] - [[package]] name = "near-primitives-core" version = "0.1.0" @@ -2243,17 +2045,6 @@ dependencies = [ "sha2 0.9.5", ] -[[package]] -name = "near-rpc-error-core" -version = "0.1.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "syn", -] - [[package]] name = "near-rpc-error-core" version = "0.1.0" @@ -2267,26 +2058,13 @@ dependencies = [ "syn", ] -[[package]] -name = "near-rpc-error-macro" -version = "0.1.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "near-rpc-error-core 0.1.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn", -] - [[package]] name = "near-rpc-error-macro" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6111d713e90c7c551dee937f4a06cb9ea2672243455a4454cc7566387ba2d9" dependencies = [ - "near-rpc-error-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-rpc-error-core", "proc-macro2", "quote", "serde", @@ -2306,14 +2084,14 @@ dependencies = [ "hex", "lazy_static", "log", - "near-crypto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-crypto", "near-metrics", - "near-primitives 0.1.0-pre.1", + "near-primitives", "near-runtime-utils 4.0.0-pre.1", "near-store", "near-vm-errors 4.0.0-pre.1", "near-vm-logic 4.0.0-pre.1", - "near-vm-runner 4.0.0-pre.1", + "near-vm-runner", "num-bigint 0.3.2", "num-rational 0.3.2", "num-traits", @@ -2322,15 +2100,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "near-runtime-utils" -version = "3.0.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "lazy_static", - "regex", -] - [[package]] name = "near-runtime-utils" version = "3.0.0" @@ -2359,9 +2128,9 @@ dependencies = [ "base64 0.13.0", "borsh", "bs58", - "near-primitives-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-primitives-core 0.1.0", "near-sdk-macros", - "near-vm-logic 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-vm-logic 3.0.0", "serde", "serde_json", "wee_alloc", @@ -2396,9 +2165,9 @@ source = "git+https://github.com/near/near-sdk-rs?rev=9d99077c6acfde68c06845f2a1 dependencies = [ "funty", "lazy-static-include", - "near-crypto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-crypto", "near-pool", - "near-primitives 0.1.0-pre.1", + "near-primitives", "near-runtime", "near-sdk", "near-store", @@ -2417,8 +2186,8 @@ dependencies = [ "derive_more", "elastic-array", "lazy_static", - "near-crypto 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "near-primitives 0.1.0-pre.1", + "near-crypto", + "near-primitives", "num_cpus", "rand 0.7.3", "rocksdb", @@ -2427,17 +2196,6 @@ dependencies = [ "strum", ] -[[package]] -name = "near-vm-errors" -version = "3.0.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "borsh", - "hex", - "near-rpc-error-macro 0.1.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "serde", -] - [[package]] name = "near-vm-errors" version = "3.0.0" @@ -2446,7 +2204,7 @@ checksum = "53a100dda565c5375ac061126167afc5c33cdba1f2e325cfae3ce08f4a5a432a" dependencies = [ "borsh", "hex", - "near-rpc-error-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-rpc-error-macro", "serde", ] @@ -2458,25 +2216,8 @@ checksum = "e281d8730ed8cb0e3e69fb689acee6b93cdb43824cd69a8ffd7e1bfcbd1177d7" dependencies = [ "borsh", "hex", - "near-rpc-error-macro 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde", -] - -[[package]] -name = "near-vm-logic" -version = "3.0.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "base64 0.13.0", - "borsh", - "bs58", - "byteorder", - "near-primitives-core 0.1.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "near-runtime-utils 3.0.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "near-vm-errors 3.0.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", + "near-rpc-error-macro", "serde", - "sha2 0.9.5", - "sha3 0.9.1", ] [[package]] @@ -2489,9 +2230,9 @@ dependencies = [ "borsh", "bs58", "byteorder", - "near-primitives-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "near-runtime-utils 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "near-vm-errors 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "near-primitives-core 0.1.0", + "near-runtime-utils 3.0.0", + "near-vm-errors 3.0.0", "serde", "sha2 0.9.5", "sha3 0.9.1", @@ -2515,33 +2256,6 @@ dependencies = [ "sha3 0.9.1", ] -[[package]] -name = "near-vm-runner" -version = "3.0.0" -source = "git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f#3744f07e13bf43a9522fb39fa8f6f128396d0e1f" -dependencies = [ - "anyhow", - "borsh", - "cached", - "near-primitives 0.1.0", - "near-vm-errors 3.0.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "near-vm-logic 3.0.0 (git+https://github.com/near/nearcore?rev=3744f07e13bf43a9522fb39fa8f6f128396d0e1f)", - "parity-wasm", - "pwasm-utils", - "serde", - "threadpool", - "tracing", - "wasmer", - "wasmer-compiler-cranelift", - "wasmer-compiler-singlepass", - "wasmer-engine-native", - "wasmer-runtime-core-near", - "wasmer-runtime-near", - "wasmer-types", - "wasmer-vm", - "wasmtime 0.25.0", -] - [[package]] name = "near-vm-runner" version = "4.0.0-pre.1" @@ -2552,7 +2266,7 @@ dependencies = [ "borsh", "cached", "log", - "near-primitives 0.1.0-pre.1", + "near-primitives", "near-vm-errors 4.0.0-pre.1", "near-vm-logic 4.0.0-pre.1", "parity-wasm", @@ -2563,7 +2277,7 @@ dependencies = [ "wasmer-runtime-core-near", "wasmer-runtime-near", "wasmer-types", - "wasmtime 0.20.0", + "wasmtime", ] [[package]] @@ -2720,16 +2434,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "object" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" -dependencies = [ - "crc32fast", - "indexmap", -] - [[package]] name = "object" version = "0.24.0" @@ -2881,12 +2585,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "paste" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -3039,15 +2737,6 @@ version = "2.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45604fc7a88158e7d514d8e22e14ac746081e7a70d7690074dd0029ee37458d6" -[[package]] -name = "psm" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3abf49e5417290756acfd26501536358560c4a5cc4a0934d390939acb3e7083a" -dependencies = [ - "cc", -] - [[package]] name = "pwasm-utils" version = "0.12.0" @@ -3234,7 +2923,6 @@ checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5" dependencies = [ "log", "rustc-hash", - "serde", "smallvec", ] @@ -3683,15 +3371,6 @@ dependencies = [ "syn", ] -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - [[package]] name = "time" version = "0.1.43" @@ -4255,12 +3934,6 @@ version = "0.65.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf" -[[package]] -name = "wasmparser" -version = "0.76.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755a9a4afe3f6cccbbe6d7e965eef44cf260b001f93e547eba84255c1d0187d8" - [[package]] name = "wasmtime" version = "0.20.0" @@ -4280,38 +3953,10 @@ dependencies = [ "smallvec", "target-lexicon 0.11.2", "wasmparser 0.59.0", - "wasmtime-environ 0.20.0", - "wasmtime-jit 0.20.0", - "wasmtime-profiling 0.20.0", - "wasmtime-runtime 0.20.0", - "winapi", -] - -[[package]] -name = "wasmtime" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26ea2ad49bb047e10ca292f55cd67040bef14b676d07e7b04ed65fd312d52ece" -dependencies = [ - "anyhow", - "backtrace", - "bincode", - "cfg-if 1.0.0", - "cpp_demangle", - "indexmap", - "libc", - "log", - "paste", - "region", - "rustc-demangle", - "serde", - "smallvec", - "target-lexicon 0.11.2", - "wasmparser 0.76.0", - "wasmtime-environ 0.25.0", - "wasmtime-jit 0.25.0", - "wasmtime-profiling 0.25.0", - "wasmtime-runtime 0.25.0", + "wasmtime-environ", + "wasmtime-jit", + "wasmtime-profiling", + "wasmtime-runtime", "winapi", ] @@ -4324,22 +3969,8 @@ dependencies = [ "cranelift-codegen 0.67.0", "cranelift-entity 0.67.0", "cranelift-frontend 0.67.0", - "cranelift-wasm 0.67.0", - "wasmtime-environ 0.20.0", -] - -[[package]] -name = "wasmtime-cranelift" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e769b80abbb89255926f69ba37085f7dd6608c980134838c3c89d7bf6e776bc" -dependencies = [ - "cranelift-codegen 0.72.0", - "cranelift-entity 0.72.0", - "cranelift-frontend 0.72.0", - "cranelift-wasm 0.72.0", - "wasmparser 0.76.0", - "wasmtime-environ 0.25.0", + "cranelift-wasm", + "wasmtime-environ", ] [[package]] @@ -4355,23 +3986,7 @@ dependencies = [ "target-lexicon 0.11.2", "thiserror", "wasmparser 0.59.0", - "wasmtime-environ 0.20.0", -] - -[[package]] -name = "wasmtime-debug" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38501788c936a4932b0ddf61135963a4b7d1f549f63a6908ae56a1c86d74fc7b" -dependencies = [ - "anyhow", - "gimli 0.23.0", - "more-asserts", - "object 0.23.0", - "target-lexicon 0.11.2", - "thiserror", - "wasmparser 0.76.0", - "wasmtime-environ 0.25.0", + "wasmtime-environ", ] [[package]] @@ -4384,7 +3999,7 @@ dependencies = [ "cfg-if 0.1.10", "cranelift-codegen 0.67.0", "cranelift-entity 0.67.0", - "cranelift-wasm 0.67.0", + "cranelift-wasm", "gimli 0.21.0", "indexmap", "log", @@ -4394,27 +4009,6 @@ dependencies = [ "wasmparser 0.59.0", ] -[[package]] -name = "wasmtime-environ" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fae793ea1387b2fede277d209bb27285366df58f0a3ae9d59e58a7941dce60fa" -dependencies = [ - "anyhow", - "cfg-if 1.0.0", - "cranelift-codegen 0.72.0", - "cranelift-entity 0.72.0", - "cranelift-wasm 0.72.0", - "gimli 0.23.0", - "indexmap", - "log", - "more-asserts", - "region", - "serde", - "thiserror", - "wasmparser 0.76.0", -] - [[package]] name = "wasmtime-jit" version = "0.20.0" @@ -4426,8 +4020,8 @@ dependencies = [ "cranelift-codegen 0.67.0", "cranelift-entity 0.67.0", "cranelift-frontend 0.67.0", - "cranelift-native 0.67.0", - "cranelift-wasm 0.67.0", + "cranelift-native", + "cranelift-wasm", "gimli 0.21.0", "log", "more-asserts", @@ -4437,44 +4031,12 @@ dependencies = [ "target-lexicon 0.11.2", "thiserror", "wasmparser 0.59.0", - "wasmtime-cranelift 0.20.0", - "wasmtime-debug 0.20.0", - "wasmtime-environ 0.20.0", - "wasmtime-obj 0.20.0", - "wasmtime-profiling 0.20.0", - "wasmtime-runtime 0.20.0", - "winapi", -] - -[[package]] -name = "wasmtime-jit" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3bd0fae8396473a68a1491559d61776127bb9bea75c9a6a6c038ae4a656eb2" -dependencies = [ - "addr2line 0.14.1", - "anyhow", - "cfg-if 1.0.0", - "cranelift-codegen 0.72.0", - "cranelift-entity 0.72.0", - "cranelift-frontend 0.72.0", - "cranelift-native 0.72.0", - "cranelift-wasm 0.72.0", - "gimli 0.23.0", - "log", - "more-asserts", - "object 0.23.0", - "region", - "serde", - "target-lexicon 0.11.2", - "thiserror", - "wasmparser 0.76.0", - "wasmtime-cranelift 0.25.0", - "wasmtime-debug 0.25.0", - "wasmtime-environ 0.25.0", - "wasmtime-obj 0.25.0", - "wasmtime-profiling 0.25.0", - "wasmtime-runtime 0.25.0", + "wasmtime-cranelift", + "wasmtime-debug", + "wasmtime-environ", + "wasmtime-obj", + "wasmtime-profiling", + "wasmtime-runtime", "winapi", ] @@ -4488,22 +4050,8 @@ dependencies = [ "more-asserts", "object 0.21.1", "target-lexicon 0.11.2", - "wasmtime-debug 0.20.0", - "wasmtime-environ 0.20.0", -] - -[[package]] -name = "wasmtime-obj" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a79fa098a3be8fabc50f5be60f8e47694d569afdc255de37850fc80295485012" -dependencies = [ - "anyhow", - "more-asserts", - "object 0.23.0", - "target-lexicon 0.11.2", - "wasmtime-debug 0.25.0", - "wasmtime-environ 0.25.0", + "wasmtime-debug", + "wasmtime-environ", ] [[package]] @@ -4518,24 +4066,8 @@ dependencies = [ "libc", "serde", "target-lexicon 0.11.2", - "wasmtime-environ 0.20.0", - "wasmtime-runtime 0.20.0", -] - -[[package]] -name = "wasmtime-profiling" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d81e2106efeef4c01917fd16956a91d39bb78c07cf97027abdba9ca98da3f258" -dependencies = [ - "anyhow", - "cfg-if 1.0.0", - "lazy_static", - "libc", - "serde", - "target-lexicon 0.11.2", - "wasmtime-environ 0.25.0", - "wasmtime-runtime 0.25.0", + "wasmtime-environ", + "wasmtime-runtime", ] [[package]] @@ -4555,31 +4087,7 @@ dependencies = [ "more-asserts", "region", "thiserror", - "wasmtime-environ 0.20.0", - "winapi", -] - -[[package]] -name = "wasmtime-runtime" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f747c656ca4680cad7846ae91c57d03f2dd4f4170da77a700df4e21f0d805378" -dependencies = [ - "anyhow", - "backtrace", - "cc", - "cfg-if 1.0.0", - "indexmap", - "lazy_static", - "libc", - "log", - "memoffset 0.6.3", - "more-asserts", - "psm", - "rand 0.7.3", - "region", - "thiserror", - "wasmtime-environ 0.25.0", + "wasmtime-environ", "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index 11cca8ea8..0d08a3839 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,9 +65,9 @@ hex = { version = "0.4.3", default-features = false } near-sdk = { git = "https://github.com/near/near-sdk-rs", rev = "9d99077c6acfde68c06845f2a1eb2b5ed7983401" } near-sdk-sim = { git = "https://github.com/near/near-sdk-rs", rev = "9d99077c6acfde68c06845f2a1eb2b5ed7983401" } near-crypto = "0.1.0" -near-vm-runner = { git = "https://github.com/near/nearcore", rev = "3744f07e13bf43a9522fb39fa8f6f128396d0e1f" } -near-primitives-core = { git = "https://github.com/near/nearcore", rev = "3744f07e13bf43a9522fb39fa8f6f128396d0e1f" } -near-vm-logic = { git = "https://github.com/near/nearcore", rev = "3744f07e13bf43a9522fb39fa8f6f128396d0e1f" } +near-vm-runner = "4.0.0-pre.1" +near-vm-logic = "4.0.0-pre.1" +near-primitives-core = "0.4.0" libsecp256k1 = "0.3.5" rand = "0.7.3" criterion = "0.3.4" @@ -78,11 +78,10 @@ base64 = "0.13.0" [features] default = ["sha2", "std"] std = ["borsh/std", "evm/std", "primitive-types/std", "rlp/std", "sha3/std", "ethabi/std", "logos/std", "bn/std"] -engine = [] -contract = ["engine"] +contract = [] evm_bully = [] log = [] -meta-call = ["contract"] +meta-call = [] integration-test = ["log"] mainnet = ["contract", "log"] testnet = ["contract", "log"] diff --git a/Makefile b/Makefile index 517d3058e..d8d9566cb 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ check-clippy: # test depends on release since `tests/test_upgrade.rs` includes `release.wasm` test: test-build - $(CARGO) test + $(CARGO) test --features meta-call format: $(CARGO) fmt diff --git a/etc/eth-contracts/contracts/EvmErc20.sol b/etc/eth-contracts/contracts/EvmErc20.sol index c9759c4e3..83059cc06 100644 --- a/etc/eth-contracts/contracts/EvmErc20.sol +++ b/etc/eth-contracts/contracts/EvmErc20.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: CC0-1.0 pragma solidity ^0.8.0; -import "@openzeppelin/contracts/utils/Context.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./AdminControlled.sol"; import "./IExit.sol"; @@ -13,7 +12,7 @@ import "./IExit.sol"; * Note they can later distribute these tokens as they wish using `transfer` and other * `ERC20` functions. */ -contract EvmErc20 is Context, ERC20, AdminControlled, IExit { +contract EvmErc20 is ERC20, AdminControlled, IExit { uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimal, address admin) ERC20(name, symbol) AdminControlled(admin, 0) { @@ -29,7 +28,7 @@ contract EvmErc20 is Context, ERC20, AdminControlled, IExit { } function withdrawToNear(bytes memory recipient, uint256 amount) external override { - _burn(msg.sender, amount); + _burn(_msgSender(), amount); bytes32 amount_b = bytes32(amount); bytes memory input = abi.encodePacked("\x01", amount_b, recipient); @@ -41,7 +40,7 @@ contract EvmErc20 is Context, ERC20, AdminControlled, IExit { } function withdrawToEthereum(address recipient, uint256 amount) external override { - _burn(msg.sender, amount); + _burn(_msgSender(), amount); bytes32 amount_b = bytes32(amount); bytes20 recipient_b = bytes20(recipient); diff --git a/etc/state-migration-test/Cargo.toml b/etc/state-migration-test/Cargo.toml index 7a2bc3122..de0f11f77 100644 --- a/etc/state-migration-test/Cargo.toml +++ b/etc/state-migration-test/Cargo.toml @@ -38,4 +38,4 @@ rpath = false [dependencies] borsh = { version = "0.8.2", default-features = false } -aurora-engine = { path = "../../", default-features = false, features = ["sha2", "engine"] } +aurora-engine = { path = "../../", default-features = false, features = ["sha2"] } diff --git a/src/connector.rs b/src/connector.rs index 7a247da0c..1d6ad6c36 100644 --- a/src/connector.rs +++ b/src/connector.rs @@ -562,7 +562,7 @@ impl EthConnectorContract { _ => self.mint_eth_on_aurora(message_data.recipient, args.amount), } self.save_ft_contract(); - sdk::return_output(0.to_string().as_bytes()); + sdk::return_output("\"0\"".as_bytes()); } /// Get accounts counter for statistics. diff --git a/src/deposit_event.rs b/src/deposit_event.rs index 0cfbf5887..39c80ecf6 100644 --- a/src/deposit_event.rs +++ b/src/deposit_event.rs @@ -46,7 +46,6 @@ impl DepositedEvent { } /// Parses raw Ethereum logs proof's entry data - #[cfg(feature = "engine")] pub fn from_log_entry_data(data: &[u8]) -> Self { let event = EthEvent::fetch_log_entry_data(DEPOSITED_EVENT, Self::event_params(), data); let sender = event.log.params[0].value.clone().into_address().unwrap().0; diff --git a/src/engine.rs b/src/engine.rs index edd172e52..30d415718 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -14,7 +14,7 @@ use crate::parameters::{ }; use crate::precompiles; -use crate::prelude::{Address, ToString, TryInto, Vec, H256, U256}; +use crate::prelude::{Address, TryInto, Vec, H256, U256}; use crate::sdk; use crate::state::AuroraStackState; use crate::storage::{address_to_key, bytes_to_key, storage_to_key, KeyPrefix, KeyPrefixU8}; @@ -500,7 +500,7 @@ impl Engine { /// IMPORTANT: This function should not panic, otherwise it won't /// be possible to return the tokens to the sender. pub fn receive_erc20_tokens(&mut self, args: &NEP141FtOnTransferArgs) { - let str_amount = args.amount.to_string(); + let str_amount = crate::prelude::format!("\"{}\"", args.amount); let output_on_fail = str_amount.as_bytes(); let token = sdk::predecessor_account_id(); @@ -576,8 +576,9 @@ impl Engine { output_on_fail ); + // TODO(marX) // Everything succeed so return "0" - sdk::return_output(b"0"); + sdk::return_output(b"\"0\""); } pub fn nep141_erc20_map() -> BijectionMap< diff --git a/src/fungible_token.rs b/src/fungible_token.rs index 4b18fd471..00ff7b5c0 100644 --- a/src/fungible_token.rs +++ b/src/fungible_token.rs @@ -2,19 +2,17 @@ use crate::prelude::format; use crate::types::*; use borsh::{BorshDeserialize, BorshSerialize}; -#[cfg(feature = "engine")] use { crate::connector, crate::engine, + crate::json::parse_json, crate::parameters::*, crate::prelude::{self, Ordering, String, ToString, TryInto, Vec, U256}, crate::sdk, crate::storage, }; -#[cfg(feature = "engine")] const GAS_FOR_RESOLVE_TRANSFER: Gas = 5_000_000_000_000; -#[cfg(feature = "engine")] const GAS_FOR_FT_ON_TRANSFER: Gas = 10_000_000_000_000; #[derive(Debug, Default, BorshDeserialize, BorshSerialize)] @@ -29,7 +27,6 @@ pub struct FungibleToken { pub account_storage_usage: StorageUsage, } -#[cfg(feature = "engine")] impl FungibleToken { pub fn new() -> Self { Self::default() @@ -245,12 +242,9 @@ impl FungibleToken { let unused_amount = match sdk::promise_result(0) { PromiseResult::NotReady => unreachable!(), PromiseResult::Successful(value) => { - if let Ok(unused_amount) = String::from_utf8(value) { - let unused_amount = if let Ok(v) = unused_amount.parse::() { - v - } else { - amount - }; + if let Some(unused_amount) = + parse_json(value.as_slice()).and_then(|x| (&x).try_into().ok()) + { if amount > unused_amount { unused_amount } else { @@ -382,7 +376,6 @@ impl FungibleToken { } else { let min_balance = self.storage_balance_bounds().min; if amount < min_balance { - #[cfg(feature = "log")] sdk::panic_utf8(b"ERR_ATTACHED_DEPOSIT_NOT_ENOUGH"); } diff --git a/src/json.rs b/src/json.rs index f6074f81b..d1bae1ca8 100644 --- a/src/json.rs +++ b/src/json.rs @@ -1,6 +1,5 @@ use super::prelude::*; -use alloc::collections::BTreeMap; use core::convert::From; use rjson::{Array, Null, Object, Value}; @@ -60,13 +59,7 @@ impl JsonValue { #[allow(dead_code)] pub fn u128(&self, key: &str) -> Result { match self { - JsonValue::Object(o) => match o.get(key).ok_or(JsonError::MissingValue)? { - JsonValue::String(n) => { - Ok(n.parse::().map_err(|_| JsonError::InvalidU128)?) - } - JsonValue::Number(_) => Err(JsonError::ExpectedStringGotNumber), - _ => Err(JsonError::InvalidU128), - }, + JsonValue::Object(o) => o.get(key).ok_or(JsonError::MissingValue)?.try_into(), _ => Err(JsonError::NotJsonType), } } @@ -177,6 +170,18 @@ impl From for JsonValue { } } +impl TryFrom<&JsonValue> for u128 { + type Error = JsonError; + + fn try_from(value: &JsonValue) -> Result { + match value { + JsonValue::String(n) => Ok(n.parse::().map_err(|_| JsonError::InvalidU128)?), + JsonValue::Number(_) => Err(JsonError::ExpectedStringGotNumber), + _ => Err(JsonError::InvalidU128), + } + } +} + impl core::fmt::Debug for JsonValue { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { match *self { diff --git a/src/lib.rs b/src/lib.rs index 8ae87177a..0aae10d4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,6 @@ extern crate core; use crate::parameters::PromiseCreateArgs; -#[cfg(feature = "engine")] mod map; #[cfg(feature = "meta-call")] pub mod meta_parsing; @@ -20,27 +19,20 @@ pub mod storage; pub mod transaction; pub mod types; -#[cfg(feature = "engine")] mod admin_controlled; -#[cfg(feature = "engine")] +#[cfg_attr(not(feature = "contract"), allow(dead_code))] mod connector; mod deposit_event; -#[cfg(feature = "engine")] pub mod engine; -#[cfg(any(feature = "engine", test))] mod fungible_token; -#[cfg(feature = "engine")] mod json; mod log_entry; mod precompiles; -#[cfg(feature = "engine")] mod prover; -#[cfg(feature = "engine")] pub mod sdk; #[cfg(test)] mod benches; -#[cfg(feature = "engine")] mod state; #[cfg(test)] mod test_utils; diff --git a/src/parameters.rs b/src/parameters.rs index f70ab06ea..69bd6e087 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -2,7 +2,6 @@ use borsh::{BorshDeserialize, BorshSerialize}; use crate::prelude::{String, Vec}; use crate::types::{AccountId, Balance, RawAddress, RawH256, RawU256}; -#[cfg(feature = "engine")] use crate::{ admin_controlled::PausedMask, json, @@ -142,7 +141,6 @@ pub struct NEP141FtOnTransferArgs { pub msg: String, } -#[cfg(feature = "engine")] impl TryFrom for NEP141FtOnTransferArgs { type Error = json::JsonError; @@ -155,7 +153,6 @@ impl TryFrom for NEP141FtOnTransferArgs { } } -#[cfg(feature = "engine")] impl TryFrom for String { type Error = json::ParseError; @@ -183,7 +180,6 @@ pub struct PromiseCreateArgs { pub attached_gas: u64, } /// Eth-connector deposit arguments -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct DepositCallArgs { /// Proof data @@ -193,7 +189,6 @@ pub struct DepositCallArgs { } /// Eth-connector isUsedProof arguments -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct IsUsedProofCallArgs { /// Proof data @@ -201,7 +196,6 @@ pub struct IsUsedProofCallArgs { } /// withdraw result for eth-connector -#[cfg(feature = "engine")] #[derive(BorshSerialize)] pub struct WithdrawResult { pub amount: Balance, @@ -210,7 +204,6 @@ pub struct WithdrawResult { } /// ft_resolve_transfer eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize)] pub struct FtResolveTransfer { pub receiver_id: AccountId, @@ -219,18 +212,15 @@ pub struct FtResolveTransfer { } /// Fungible token storage balance -#[cfg(feature = "engine")] #[derive(Default)] pub struct StorageBalance { pub total: Balance, pub available: Balance, } -#[cfg(feature = "engine")] impl StorageBalance { pub fn to_json_bytes(&self) -> Vec { - use alloc::format; - format!( + crate::prelude::format!( "{{\"total\": \"{}\", \"available\": \"{}\",}}", self.total.to_string(), self.available.to_string() @@ -241,7 +231,6 @@ impl StorageBalance { } /// resolve_transfer eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct ResolveTransferCallArgs { pub sender_id: AccountId, @@ -250,7 +239,6 @@ pub struct ResolveTransferCallArgs { } /// Finish deposit NEAR eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct FinishDepositCallArgs { pub new_owner_id: AccountId, @@ -262,7 +250,6 @@ pub struct FinishDepositCallArgs { } /// Deposit ETH args -#[cfg(feature = "engine")] #[derive(Default, BorshDeserialize, BorshSerialize, Clone)] pub struct DepositEthCallArgs { pub proof: Proof, @@ -270,7 +257,6 @@ pub struct DepositEthCallArgs { } /// Finish deposit NEAR eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct FinishDepositEthCallArgs { pub new_owner_id: EthAddress, @@ -291,7 +277,6 @@ pub struct InitCallArgs { pub type SetContractDataCallArgs = InitCallArgs; /// transfer eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct TransferCallCallArgs { pub receiver_id: AccountId, @@ -300,7 +285,6 @@ pub struct TransferCallCallArgs { pub msg: String, } -#[cfg(feature = "engine")] impl From for TransferCallCallArgs { fn from(v: json::JsonValue) -> Self { Self { @@ -313,13 +297,11 @@ impl From for TransferCallCallArgs { } /// storage_balance_of eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct StorageBalanceOfCallArgs { pub account_id: AccountId, } -#[cfg(feature = "engine")] impl From for StorageBalanceOfCallArgs { fn from(v: json::JsonValue) -> Self { Self { @@ -329,14 +311,12 @@ impl From for StorageBalanceOfCallArgs { } /// storage_deposit eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct StorageDepositCallArgs { pub account_id: Option, pub registration_only: Option, } -#[cfg(feature = "engine")] impl From for StorageDepositCallArgs { fn from(v: json::JsonValue) -> Self { Self { @@ -347,13 +327,11 @@ impl From for StorageDepositCallArgs { } /// storage_withdraw eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct StorageWithdrawCallArgs { pub amount: Option, } -#[cfg(feature = "engine")] impl From for StorageWithdrawCallArgs { fn from(v: json::JsonValue) -> Self { Self { @@ -363,7 +341,6 @@ impl From for StorageWithdrawCallArgs { } /// transfer args for json invocation -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct TransferCallArgs { pub receiver_id: AccountId, @@ -371,7 +348,6 @@ pub struct TransferCallArgs { pub memo: Option, } -#[cfg(feature = "engine")] impl From for TransferCallArgs { fn from(v: json::JsonValue) -> Self { Self { @@ -383,7 +359,6 @@ impl From for TransferCallArgs { } /// withdraw NEAR eth-connector call args -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct WithdrawCallArgs { pub recipient_address: EthAddress, @@ -391,19 +366,16 @@ pub struct WithdrawCallArgs { } /// balance_of args for json invocation -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct BalanceOfCallArgs { pub account_id: AccountId, } -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct BalanceOfEthCallArgs { pub address: EthAddress, } -#[cfg(feature = "engine")] impl From for BalanceOfCallArgs { fn from(v: json::JsonValue) -> Self { Self { @@ -412,24 +384,20 @@ impl From for BalanceOfCallArgs { } } -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct RegisterRelayerCallArgs { pub address: EthAddress, } -#[cfg(feature = "engine")] #[derive(BorshSerialize, BorshDeserialize)] pub struct PauseEthConnectorCallArgs { pub paused_mask: PausedMask, } -#[cfg(feature = "engine")] pub trait ExpectUtf8 { fn expect_utf8(self, message: &[u8]) -> T; } -#[cfg(feature = "engine")] impl ExpectUtf8 for Option { fn expect_utf8(self, message: &[u8]) -> T { match self { @@ -439,7 +407,6 @@ impl ExpectUtf8 for Option { } } -#[cfg(feature = "engine")] impl ExpectUtf8 for core::result::Result { fn expect_utf8(self, message: &[u8]) -> T { match self { @@ -449,7 +416,6 @@ impl ExpectUtf8 for core::result::Result { } } -#[cfg(feature = "engine")] impl From for ResolveTransferCallArgs { fn from(v: json::JsonValue) -> Self { Self { diff --git a/src/precompiles/blake2.rs b/src/precompiles/blake2.rs index 6511cc80d..f78b82fa2 100644 --- a/src/precompiles/blake2.rs +++ b/src/precompiles/blake2.rs @@ -18,7 +18,6 @@ mod consts { pub(super) struct Blake2F(PhantomData); impl Blake2F { - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 9); } diff --git a/src/precompiles/bn128.rs b/src/precompiles/bn128.rs index 3d352f127..73b46f57e 100644 --- a/src/precompiles/bn128.rs +++ b/src/precompiles/bn128.rs @@ -48,11 +48,8 @@ mod consts { pub(super) mod addresses { use crate::precompiles; - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub const ADD: [u8; 20] = precompiles::make_address(0, 6); - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub const MUL: [u8; 20] = precompiles::make_address(0, 7); - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub const PAIR: [u8; 20] = precompiles::make_address(0, 8); } diff --git a/src/precompiles/hash.rs b/src/precompiles/hash.rs index c0f437545..51ae03632 100644 --- a/src/precompiles/hash.rs +++ b/src/precompiles/hash.rs @@ -24,7 +24,6 @@ mod consts { pub struct SHA256(PhantomData); impl SHA256 { - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 2); } @@ -90,7 +89,6 @@ impl Precompile for SHA256 { pub struct RIPEMD160(PhantomData); impl RIPEMD160 { - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 3); } diff --git a/src/precompiles/identity.rs b/src/precompiles/identity.rs index 36515505b..4053fe652 100644 --- a/src/precompiles/identity.rs +++ b/src/precompiles/identity.rs @@ -21,7 +21,6 @@ mod consts { pub struct Identity(PhantomData); impl Identity { - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 4); } diff --git a/src/precompiles/mod.rs b/src/precompiles/mod.rs index 4660303aa..de50d069c 100644 --- a/src/precompiles/mod.rs +++ b/src/precompiles/mod.rs @@ -3,6 +3,7 @@ mod bn128; mod hash; mod identity; mod modexp; +#[cfg_attr(not(feature = "contract"), allow(dead_code))] mod native; mod secp256k1; use evm::{Context, ExitError}; @@ -10,7 +11,6 @@ use evm::{Context, ExitError}; pub(crate) use crate::precompiles::secp256k1::ecrecover; use crate::prelude::Vec; use crate::AuroraState; -#[cfg(feature = "engine")] use crate::{ precompiles::blake2::Blake2F, precompiles::bn128::{BN128Add, BN128Mul, BN128Pair}, @@ -66,7 +66,6 @@ impl From for evm::executor::PrecompileOutput { /// A precompile operation result. type PrecompileResult = Result; -#[cfg(feature = "engine")] type EvmPrecompileResult = Result; /// A precompiled function for use in the EVM. @@ -211,7 +210,6 @@ pub fn byzantium_precompiles( } /// Matches the address given to Istanbul precompiles. -#[cfg(feature = "engine")] #[allow(dead_code)] pub fn istanbul_precompiles( address: Address, @@ -323,7 +321,6 @@ pub fn berlin_precompiles( /// const fn for making an address by concatenating the bytes from two given numbers, /// Note that 32 + 128 = 160 = 20 bytes (the length of an address). This function is used /// as a convenience for specifying the addresses of the various precompiles. -#[cfg_attr(not(feature = "engine"), allow(dead_code))] const fn make_address(x: u32, y: u128) -> [u8; 20] { let x_bytes = x.to_be_bytes(); let y_bytes = y.to_be_bytes(); diff --git a/src/precompiles/modexp.rs b/src/precompiles/modexp.rs index 26410f054..c1be8dbc8 100644 --- a/src/precompiles/modexp.rs +++ b/src/precompiles/modexp.rs @@ -6,7 +6,6 @@ use crate::AuroraState; use evm::{Context, ExitError}; use num::{BigUint, Integer}; -#[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 5); pub(super) struct ModExp(PhantomData, PhantomData); diff --git a/src/precompiles/native.rs b/src/precompiles/native.rs index 9b3382eae..c03b12553 100644 --- a/src/precompiles/native.rs +++ b/src/precompiles/native.rs @@ -4,7 +4,7 @@ use crate::prelude::PhantomData; #[cfg(not(feature = "contract"))] use crate::prelude::Vec; use crate::AuroraState; -#[cfg(feature = "engine")] +#[cfg(feature = "contract")] use { crate::parameters::PromiseCreateArgs, crate::parameters::WithdrawCallArgs, @@ -16,7 +16,6 @@ use { use super::{Precompile, PrecompileResult}; -#[cfg_attr(not(feature = "engine"), allow(dead_code))] const ERR_TARGET_TOKEN_NOT_FOUND: &str = "Target token not found"; use crate::precompiles::PrecompileOutput; @@ -31,11 +30,9 @@ mod costs { pub(super) const EXIT_TO_ETHEREUM_GAS: Gas = 0; // TODO(#51): Determine the correct amount of gas - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const FT_TRANSFER_GAS: Gas = 100_000_000_000_000; // TODO(#51): Determine the correct amount of gas - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const WITHDRAWAL_GAS: Gas = 100_000_000_000_000; } @@ -46,7 +43,6 @@ impl ExitToNear { /// /// Address: `0xe9217bc70b7ed1f598ddd3199e80b093fa71124f` /// This address is computed as: `&keccak("exitToNear")[12..]` - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const ADDRESS: [u8; 20] = super::make_address(0xe9217bc7, 0x0b7ed1f598ddd3199e80b093fa71124f); } @@ -194,7 +190,6 @@ impl ExitToEthereum { /// /// Address: `0xb0bd02f6a392af548bdf1cfaee5dfa0eefcc8eab` /// This address is computed as: `&keccak("exitToEthereum")[12..]` - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const ADDRESS: [u8; 20] = super::make_address(0xb0bd02f6, 0xa392af548bdf1cfaee5dfa0eefcc8eab); } @@ -329,21 +324,19 @@ impl Precompile for ExitToEthereum { } } -#[cfg(all(feature = "contract", test))] +#[cfg(test)] mod tests { use super::{ExitToEthereum, ExitToNear}; use crate::types::near_account_to_evm_address; - use super::*; - #[test] fn test_precompile_id() { assert_eq!( - ExitToEthereum::ADDRESS, + ExitToEthereum::<()>::ADDRESS, near_account_to_evm_address("exitToEthereum".as_bytes()).0 ); assert_eq!( - ExitToNear::ADDRESS, + ExitToNear::<()>::ADDRESS, near_account_to_evm_address("exitToNear".as_bytes()).0 ); } diff --git a/src/precompiles/secp256k1.rs b/src/precompiles/secp256k1.rs index 15b764883..f82f545ae 100644 --- a/src/precompiles/secp256k1.rs +++ b/src/precompiles/secp256k1.rs @@ -44,7 +44,6 @@ pub fn ecrecover(hash: H256, signature: &[u8]) -> Result { pub(super) struct ECRecover(PhantomData); impl ECRecover { - #[cfg_attr(not(feature = "engine"), allow(dead_code))] pub(super) const ADDRESS: [u8; 20] = super::make_address(0, 1); } diff --git a/src/prelude.rs b/src/prelude.rs index d76444da4..fb55e90be 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -4,6 +4,7 @@ pub use alloc::{ borrow::{Cow, Cow::*}, boxed::Box, collections::BTreeMap as HashMap, + collections::BTreeMap, fmt, format, str, string::String, string::ToString, diff --git a/src/sdk.rs b/src/sdk.rs index 7c3b80168..8a78c3124 100644 --- a/src/sdk.rs +++ b/src/sdk.rs @@ -173,11 +173,13 @@ pub fn read_input() -> Vec { } } +#[cfg_attr(not(feature = "contract"), allow(dead_code))] pub(crate) fn read_input_borsh() -> Result { let bytes = read_input(); T::try_from_slice(&bytes).map_err(|_| ArgParseErr) } +#[cfg_attr(not(feature = "contract"), allow(dead_code))] pub(crate) fn read_input_arr20() -> Result<[u8; 20], IncorrectInputLength> { unsafe { exports::input(INPUT_REGISTER_ID); diff --git a/src/test_utils/exit_precompile.rs b/src/test_utils/exit_precompile.rs index 3892cefef..6149529d4 100644 --- a/src/test_utils/exit_precompile.rs +++ b/src/test_utils/exit_precompile.rs @@ -2,8 +2,6 @@ use crate::parameters::SubmitResult; use crate::prelude::{Address, U256}; use crate::test_utils::{solidity, AuroraRunner, Signer}; use crate::transaction::EthTransaction; -#[cfg(feature = "engine")] -use {crate::parameters::FunctionCallArgs, borsh::BorshSerialize, std::convert::TryInto}; pub(crate) struct TesterConstructor(pub solidity::ContractConstructor); diff --git a/src/test_utils/mod.rs b/src/test_utils/mod.rs index 9f6bf6708..89ff97224 100644 --- a/src/test_utils/mod.rs +++ b/src/test_utils/mod.rs @@ -103,7 +103,8 @@ impl<'a> OneShotAuroraRunner<'a> { ); near_vm_runner::run( - &self.base.code, + self.base.code.hash.as_ref().to_vec(), + &self.base.code.code.as_slice(), method_name, &mut self.ext, self.context.clone(), @@ -168,7 +169,8 @@ impl AuroraRunner { ); let (maybe_outcome, maybe_error) = near_vm_runner::run( - &self.code, + self.code.hash.as_ref().to_vec(), + &self.code.code.as_slice(), method_name, &mut self.ext, self.context.clone(), @@ -275,7 +277,8 @@ impl AuroraRunner { address.as_bytes().to_vec(), ); let (outcome, maybe_error) = near_vm_runner::run( - &self.code, + self.code.hash.as_ref().to_vec(), + &self.code.code.as_slice(), method_name, &mut self.ext.clone(), context, diff --git a/src/tests/contract_call.rs b/src/tests/contract_call.rs index 02e8da91f..531da120f 100644 --- a/src/tests/contract_call.rs +++ b/src/tests/contract_call.rs @@ -2,15 +2,6 @@ use crate::test_utils::{origin, AuroraRunner, Signer}; use crate::test_utils; use crate::test_utils::exit_precompile::{Tester, TesterConstructor}; -#[cfg(feature = "engine")] -use { - crate::prelude::U256, - crate::test_utils::solidity, - crate::transaction::EthTransaction, - ethabi::Address, - near_crypto::SecretKey, - std::path::{Path, PathBuf}, -}; fn setup_test() -> (AuroraRunner, Signer, [u8; 20], Tester) { let mut runner = AuroraRunner::new(); diff --git a/src/tests/erc20_connector.rs b/src/tests/erc20_connector.rs index fbd89857e..4bb6106e0 100644 --- a/src/tests/erc20_connector.rs +++ b/src/tests/erc20_connector.rs @@ -272,7 +272,7 @@ fn test_ft_on_transfer() { let res = runner.ft_on_transfer(nep141, alice.clone(), alice, amount, hex::encode(recipient)); // Transaction should succeed so return amount is 0 - assert_eq!(res, "0"); + assert_eq!(res, "\"0\""); let balance = runner.balance_of(token, recipient, origin()); assert_eq!(balance, U256::from(amount)); @@ -290,7 +290,7 @@ fn test_ft_on_transfer_fail() { let res = runner.ft_on_transfer(nep141, alice.clone(), alice, amount, hex::encode(recipient)); // Transaction should fail so it must return everything - assert_eq!(res, amount.to_string()); + assert_eq!(res, format!("\"{}\"", amount.to_string())); } #[test] diff --git a/tests/test_meta_parsing.rs b/src/tests/meta_parsing.rs similarity index 86% rename from tests/test_meta_parsing.rs rename to src/tests/meta_parsing.rs index 19f315ca8..0af48d49e 100644 --- a/tests/test_meta_parsing.rs +++ b/src/tests/meta_parsing.rs @@ -1,20 +1,13 @@ -#[cfg(feature = "meta-call")] use { - aurora_engine::meta_parsing::{near_erc712_domain, parse_meta_call, prepare_meta_call_args}, - aurora_engine::parameters::MetaCallArgs, - aurora_engine::prelude::U256, - aurora_engine::types::{u256_to_arr, InternalMetaCallArgs, Wei}, + crate::meta_parsing::{near_erc712_domain, parse_meta_call, prepare_meta_call_args}, + crate::parameters::MetaCallArgs, + crate::prelude::{Address, U256}, + crate::types::{keccak, u256_to_arr, InternalMetaCallArgs, Wei}, borsh::BorshSerialize, - near_crypto::{InMemorySigner, KeyType, Signature, Signer}, + near_crypto::{InMemorySigner, KeyType, PublicKey, Signature, Signer}, }; -use near_crypto::PublicKey; - -use aurora_engine::prelude::Address; -use aurora_engine::types::keccak; - -#[cfg(feature = "meta-call")] -pub fn encode_meta_call_function_args( +fn encode_meta_call_function_args( signer: &dyn Signer, chain_id: u64, nonce: U256, @@ -67,7 +60,7 @@ pub fn encode_meta_call_function_args( } } -pub fn public_key_to_address(public_key: PublicKey) -> Address { +fn public_key_to_address(public_key: PublicKey) -> Address { match public_key { PublicKey::ED25519(_) => panic!("Wrong PublicKey"), PublicKey::SECP256K1(pubkey) => { @@ -80,7 +73,7 @@ pub fn public_key_to_address(public_key: PublicKey) -> Address { } } -#[cfg(all(feature = "meta-call", test))] +#[test] fn test_meta_parsing() { let chain_id = 1313161555; let signer = InMemorySigner::from_seed("doesnt", KeyType::SECP256K1, "a"); diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 3705e2c25..6d11fe463 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -1,6 +1,9 @@ mod contract_call; mod erc20; mod erc20_connector; +#[cfg(feature = "meta-call")] +mod meta_parsing; mod sanity; mod self_destruct_state; mod standard_precompiles; +mod state_migration; diff --git a/tests/test_state_migration.rs b/src/tests/state_migration.rs similarity index 72% rename from tests/test_state_migration.rs rename to src/tests/state_migration.rs index ecbdae253..1be240a31 100644 --- a/tests/test_state_migration.rs +++ b/src/tests/state_migration.rs @@ -1,19 +1,13 @@ -use aurora_engine::parameters::NewCallArgs; -use aurora_engine::prelude::U256; -use aurora_engine::types; +use crate::parameters::NewCallArgs; +use crate::prelude::U256; +use crate::test_utils::AuroraRunner; +use crate::types; use borsh::BorshSerialize; use near_sdk_sim::{ExecutionResult, UserAccount}; use std::fs; use std::path::Path; use std::process::Command; -// TODO: it would be nice to include this under src/tests but right now this is not possible. -// The issue is a linker error (arising from multiple dependencies on near-vm-logic I think). - -near_sdk_sim::lazy_static_include::lazy_static_include_bytes! { - EVM_WASM_BYTES => "release.wasm" -} - #[test] fn test_state_migration() { let aurora = deploy_evm(); @@ -33,15 +27,15 @@ fn test_state_migration() { } fn deploy_evm() -> AuroraAccount { - let aurora_config = AuroraConfig::default(); + let aurora_runner = AuroraRunner::default(); let main_account = near_sdk_sim::init_simulator(None); let contract_account = main_account.deploy( - &aurora_config.code, - aurora_config.account_id.clone(), + &aurora_runner.code.code, + aurora_runner.aurora_account_id.clone(), 5 * near_sdk_sim::STORAGE_AMOUNT, ); let new_args = NewCallArgs { - chain_id: types::u256_to_arr(&U256::from(aurora_config.chain_id)), + chain_id: types::u256_to_arr(&U256::from(aurora_runner.chain_id)), owner_id: main_account.account_id.clone(), bridge_prover_id: "prover.near".to_string(), upgrade_delay_blocks: 1, @@ -78,22 +72,6 @@ impl AuroraAccount { } } -struct AuroraConfig { - code: Vec, - chain_id: u64, - account_id: String, -} - -impl Default for AuroraConfig { - fn default() -> Self { - Self { - code: EVM_WASM_BYTES.to_vec(), - chain_id: 1313161556, // NEAR betanet - account_id: "aurora".to_string(), - } - } -} - fn contract_bytes() -> Vec { let base_path = Path::new("etc").join("state-migration-test"); let output_path = base_path diff --git a/src/types.rs b/src/types.rs index bf165650b..582afe8aa 100644 --- a/src/types.rs +++ b/src/types.rs @@ -12,10 +12,8 @@ use ethabi::{ParamType, Token}; #[cfg(not(feature = "contract"))] use sha3::{Digest, Keccak256}; -#[cfg(feature = "engine")] use crate::engine::EngineResult; use crate::log_entry::LogEntry; -#[cfg(feature = "engine")] use crate::sdk; #[cfg(not(feature = "contract"))] @@ -24,7 +22,7 @@ use ethabi::param_type::Writer; pub type AccountId = String; pub type Balance = u128; pub type RawAddress = [u8; 20]; -pub type RawU256 = [u8; 32]; // Little-endian large integer type. +pub type RawU256 = [u8; 32]; // Big-endian large integer type. pub type RawH256 = [u8; 32]; // Unformatted binary data of fixed length. pub type EthAddress = [u8; 20]; pub type Gas = u64; @@ -207,7 +205,6 @@ pub struct StorageBalanceBounds { } /// promise results structure -#[cfg(feature = "engine")] pub enum PromiseResult { NotReady, Successful(Vec), @@ -215,7 +212,6 @@ pub enum PromiseResult { } /// ft_resolve_transfer result of eth-connector -#[cfg(feature = "engine")] pub struct FtResolveTransferResult { pub amount: Balance, pub refund_amount: Balance, @@ -302,7 +298,6 @@ impl Stack { self.stack } } -#[cfg(feature = "engine")] pub fn str_from_slice(inp: &[u8]) -> &str { str::from_utf8(inp).unwrap() } @@ -332,12 +327,10 @@ impl ExpectUtf8 for core::result::Result { } } -#[cfg(feature = "engine")] pub trait SdkExpect { fn sdk_expect(self, msg: &str) -> T; } -#[cfg(feature = "engine")] impl SdkExpect for Option { fn sdk_expect(self, msg: &str) -> T { match self { @@ -347,7 +340,6 @@ impl SdkExpect for Option { } } -#[cfg(feature = "engine")] impl SdkExpect for core::result::Result { fn sdk_expect(self, msg: &str) -> T { match self { @@ -357,12 +349,10 @@ impl SdkExpect for core::result::Result { } } -#[cfg(feature = "engine")] pub trait SdkUnwrap { fn sdk_unwrap(self) -> T; } -#[cfg(feature = "engine")] impl SdkUnwrap for Option { fn sdk_unwrap(self) -> T { match self { @@ -372,7 +362,6 @@ impl SdkUnwrap for Option { } } -#[cfg(feature = "engine")] impl> SdkUnwrap for core::result::Result { fn sdk_unwrap(self) -> T { match self { @@ -382,12 +371,10 @@ impl> SdkUnwrap for core::result::Result { } } -#[cfg(feature = "engine")] pub(crate) trait SdkProcess { fn sdk_process(self); } -#[cfg(feature = "engine")] impl> SdkProcess for EngineResult { fn sdk_process(self) { match self { diff --git a/tests/test_upgrade.rs b/tests/test_upgrade.rs deleted file mode 100644 index 2bfff9e9d..000000000 --- a/tests/test_upgrade.rs +++ /dev/null @@ -1,55 +0,0 @@ -use near_sdk::borsh::BorshSerialize; -use near_sdk::test_utils::accounts; -use near_sdk_sim::{to_yocto, UserAccount, DEFAULT_GAS, STORAGE_AMOUNT}; - -use aurora_engine::parameters::NewCallArgs; - -near_sdk_sim::lazy_static_include::lazy_static_include_bytes! { - EVM_WASM_BYTES => "release.wasm" -} - -pub fn init() -> (UserAccount, UserAccount) { - let master_account = near_sdk_sim::init_simulator(None); - let contract_account = - master_account.deploy(*EVM_WASM_BYTES, accounts(0).to_string(), to_yocto("1000")); - contract_account - .call( - accounts(0).to_string(), - "new", - &NewCallArgs { - chain_id: [0u8; 32], - owner_id: master_account.account_id.clone(), - bridge_prover_id: accounts(0).to_string(), - upgrade_delay_blocks: 1, - } - .try_to_vec() - .unwrap(), - DEFAULT_GAS, - STORAGE_AMOUNT, - ) - .assert_success(); - (master_account, contract_account) -} - -#[test] -fn test_contract_upgrade() { - let (master_account, _contract_account) = init(); - master_account - .call( - accounts(0).to_string(), - "stage_upgrade", - &EVM_WASM_BYTES, - DEFAULT_GAS, - 0, - ) - .assert_success(); - master_account - .call( - accounts(0).to_string(), - "deploy_upgrade", - &[], - DEFAULT_GAS, - 0, - ) - .assert_success(); -}