From 96890df5e854750ab4a61cd2a236a1104d4a1970 Mon Sep 17 00:00:00 2001 From: Gregory Hill Date: Thu, 20 Jul 2023 16:32:12 +0000 Subject: [PATCH] feat: add frontier evm Signed-off-by: Gregory Hill --- Cargo.lock | 1424 ++++++++++++++--- parachain/Cargo.toml | 9 + parachain/runtime/common/Cargo.toml | 33 +- parachain/runtime/common/src/evm/mod.rs | 71 + .../runtime/common/src/evm/precompiles.rs | 45 + parachain/runtime/common/src/lib.rs | 2 + parachain/runtime/interlay/Cargo.toml | 30 +- parachain/runtime/interlay/src/evm.rs | 90 ++ parachain/runtime/interlay/src/lib.rs | 278 +++- parachain/runtime/kintsugi/Cargo.toml | 28 +- parachain/runtime/kintsugi/src/evm.rs | 90 ++ parachain/runtime/kintsugi/src/lib.rs | 280 +++- parachain/src/chain_spec/interlay.rs | 7 + parachain/src/chain_spec/kintsugi.rs | 7 + parachain/src/cli.rs | 5 +- parachain/src/command.rs | 8 +- parachain/src/eth.rs | 262 +++ parachain/src/lib.rs | 2 + parachain/src/main.rs | 1 + parachain/src/service.rs | 227 ++- rpc/Cargo.toml | 14 + rpc/src/eth.rs | 198 +++ rpc/src/lib.rs | 58 +- 23 files changed, 2866 insertions(+), 303 deletions(-) create mode 100644 parachain/runtime/common/src/evm/mod.rs create mode 100644 parachain/runtime/common/src/evm/precompiles.rs create mode 100644 parachain/runtime/interlay/src/evm.rs create mode 100644 parachain/runtime/kintsugi/src/evm.rs create mode 100644 parachain/src/eth.rs create mode 100644 rpc/src/eth.rs diff --git a/Cargo.lock b/Cargo.lock index 6f7b7bdfe5..c35b95fa9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,9 +23,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" dependencies = [ "gimli 0.27.3", ] @@ -188,6 +188,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9" + [[package]] name = "always-assert" version = "0.1.3" @@ -444,7 +450,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.20", + "rustix 0.37.23", "slab", "socket2 0.4.9", "waker-fn", @@ -467,18 +473,18 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -491,7 +497,16 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", ] [[package]] @@ -511,6 +526,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "auto_impl" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "autocfg" version = "0.1.8" @@ -528,16 +555,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" dependencies = [ - "addr2line 0.19.0", + "addr2line 0.20.0", "cc", "cfg-if", "libc", - "miniz_oxide 0.6.2", - "object 0.30.4", + "miniz_oxide", + "object 0.31.1", "rustc-demangle", ] @@ -597,7 +624,7 @@ name = "binary-merkle-tree" version = "4.0.0-dev" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "hash-db", + "hash-db 0.16.0", "log", ] @@ -616,7 +643,7 @@ version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", @@ -676,6 +703,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + [[package]] name = "bitvec" version = "1.0.1" @@ -817,9 +850,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" +checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", "serde", @@ -1116,9 +1149,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.9" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba77a07e4489fb41bd90e8d4201c3eb246b3c2c9ea2ba0bddd6c1d1df87db7d" +checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" dependencies = [ "clap_builder", "clap_derive", @@ -1127,13 +1160,12 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.9" +version = "4.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9b4a88bb4bc35d3d6f65a21b0f0bafe9c894fa00978de242c555ec28bea1c0" +checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex", "strsim", ] @@ -1147,7 +1179,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -1182,7 +1214,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1274,9 +1306,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "6340df57935414636969091153f35f68d9f00bbc8fb4a9c6054706c213e6c6bc" [[package]] name = "constant_time_eq" @@ -1336,9 +1368,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -1874,7 +1906,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -2173,9 +2205,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.97" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88abab2f5abbe4c56e8f1fb431b784d710b709888f35755a160e62e33fe38e8" +checksum = "e928d50d5858b744d1ea920b790641129c347a770d1530c3a85b77705a5ee031" dependencies = [ "cc", "cxxbridge-flags", @@ -2185,9 +2217,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.97" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0c11acd0e63bae27dcd2afced407063312771212b7a823b4fd72d633be30fb" +checksum = "8332ba63f8a8040ca479de693150129067304a3496674477fff6d0c372cc34ae" dependencies = [ "cc", "codespan-reporting", @@ -2195,24 +2227,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] name = "cxxbridge-flags" -version = "1.0.97" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3816ed957c008ccd4728485511e3d9aaf7db419aa321e3d2c5a2f3411e36c8" +checksum = "5966a5a87b6e9bb342f5fab7170a93c77096efe199872afffc4b477cfeb86957" [[package]] name = "cxxbridge-macro" -version = "1.0.97" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26acccf6f445af85ea056362561a24ef56cdc15fcc685f03aec50b9c702cb6d" +checksum = "81b2dab6991c7ab1572fea8cb049db819b1aeea1e2dac74c0869f244d9f21a7c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -2312,9 +2344,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" +checksum = "0c7ed52955ce76b1554f509074bb357d3fb8ac9b51288a65a3fd480d1dfba946" dependencies = [ "const-oid", "zeroize", @@ -2621,9 +2653,15 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + [[package]] name = "downcast" version = "0.11.0" @@ -2638,9 +2676,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" +checksum = "519b83cd10f5f6e969625a409f735182bea5558cd8b64c655806ceaae36f1999" [[package]] name = "dyn-clonable" @@ -2687,7 +2725,7 @@ version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" dependencies = [ - "der 0.7.6", + "der 0.7.7", "digest 0.10.7", "elliptic-curve 0.13.5", "rfc6979 0.4.0", @@ -2737,6 +2775,9 @@ name = "either" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +dependencies = [ + "serde", +] [[package]] name = "elliptic-curve" @@ -2814,18 +2855,18 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] name = "enumn" -version = "0.1.8" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" +checksum = "c9838a970f5de399d3070ae1739e131986b2f5dcc223c7423ca0927e3a878522" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -2931,12 +2972,115 @@ dependencies = [ "sp-api", ] +[[package]] +name = "ethbloom" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" +dependencies = [ + "crunchy", + "fixed-hash 0.8.0", + "impl-codec", + "impl-rlp", + "impl-serde 0.4.0", + "scale-info", + "tiny-keccak", +] + +[[package]] +name = "ethereum" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a89fb87a9e103f71b903b80b670200b54cc67a07578f070681f1fffb7396fb7" +dependencies = [ + "bytes", + "ethereum-types", + "hash-db 0.15.2", + "hash256-std-hasher", + "parity-scale-codec", + "rlp", + "scale-info", + "serde", + "sha3", + "triehash", +] + +[[package]] +name = "ethereum-types" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" +dependencies = [ + "ethbloom", + "fixed-hash 0.8.0", + "impl-codec", + "impl-rlp", + "impl-serde 0.4.0", + "primitive-types", + "scale-info", + "uint", +] + [[package]] name = "event-listener" version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "evm" +version = "0.39.1" +source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +dependencies = [ + "auto_impl", + "environmental", + "ethereum", + "evm-core", + "evm-gasometer", + "evm-runtime", + "log", + "parity-scale-codec", + "primitive-types", + "rlp", + "scale-info", + "serde", + "sha3", +] + +[[package]] +name = "evm-core" +version = "0.39.0" +source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +dependencies = [ + "parity-scale-codec", + "primitive-types", + "scale-info", + "serde", +] + +[[package]] +name = "evm-gasometer" +version = "0.39.0" +source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +dependencies = [ + "environmental", + "evm-core", + "evm-runtime", + "primitive-types", +] + +[[package]] +name = "evm-runtime" +version = "0.39.0" +source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +dependencies = [ + "auto_impl", + "environmental", + "evm-core", + "primitive-types", + "sha3", +] + [[package]] name = "exit-future" version = "0.2.0" @@ -2993,7 +3137,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -3066,6 +3210,156 @@ dependencies = [ "thiserror", ] +[[package]] +name = "fc-consensus" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "async-trait", + "fp-consensus", + "fp-rpc", + "sc-consensus", + "sp-api", + "sp-block-builder", + "sp-consensus", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "fc-db" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "async-trait", + "ethereum", + "fc-storage", + "fp-consensus", + "fp-rpc", + "fp-storage", + "futures", + "kvdb-rocksdb", + "log", + "parity-db", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-client-db", + "smallvec", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-database 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42)", + "sp-runtime", + "sp-storage", + "sqlx", + "tokio", +] + +[[package]] +name = "fc-mapping-sync" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "fc-db", + "fc-storage", + "fp-consensus", + "fp-rpc", + "futures", + "futures-timer", + "log", + "parking_lot 0.12.1", + "sc-client-api", + "sc-utils", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "tokio", +] + +[[package]] +name = "fc-rpc" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "ethereum", + "ethereum-types", + "evm", + "fc-db", + "fc-mapping-sync", + "fc-rpc-core", + "fc-storage", + "fp-ethereum", + "fp-evm", + "fp-rpc", + "fp-storage", + "futures", + "hex", + "jsonrpsee", + "libsecp256k1 0.7.1", + "log", + "lru 0.8.1", + "pallet-evm", + "parity-scale-codec", + "prometheus", + "rand 0.8.5", + "rlp", + "sc-client-api", + "sc-network", + "sc-network-common", + "sc-network-sync", + "sc-rpc", + "sc-service", + "sc-transaction-pool", + "sc-transaction-pool-api", + "sc-utils", + "serde", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-storage", + "substrate-prometheus-endpoint", + "tokio", +] + +[[package]] +name = "fc-rpc-core" +version = "1.1.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "ethereum", + "ethereum-types", + "jsonrpsee", + "rustc-hex", + "serde", + "serde_json", +] + +[[package]] +name = "fc-storage" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "ethereum", + "ethereum-types", + "fp-rpc", + "fp-storage", + "parity-scale-codec", + "sc-client-api", + "sp-api", + "sp-blockchain", + "sp-io", + "sp-runtime", + "sp-storage", +] + [[package]] name = "fdlimit" version = "0.2.1" @@ -3203,7 +3497,7 @@ checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -3215,12 +3509,39 @@ dependencies = [ "num-traits", ] +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "futures-core", + "futures-sink", + "pin-project", + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "fork-tree" version = "3.0.0" @@ -3238,6 +3559,104 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fp-account" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "hex", + "impl-serde 0.4.0", + "libsecp256k1 0.7.1", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", +] + +[[package]] +name = "fp-consensus" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "ethereum", + "parity-scale-codec", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "fp-ethereum" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "ethereum", + "ethereum-types", + "fp-evm", + "frame-support", + "num_enum", + "parity-scale-codec", + "sp-std", +] + +[[package]] +name = "fp-evm" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "evm", + "frame-support", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "fp-rpc" +version = "3.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "ethereum", + "ethereum-types", + "fp-evm", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-std", +] + +[[package]] +name = "fp-self-contained" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "frame-support", + "parity-scale-codec", + "scale-info", + "serde", + "sp-runtime", +] + +[[package]] +name = "fp-storage" +version = "2.0.0" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "parity-scale-codec", + "serde", +] + [[package]] name = "fragile" version = "2.0.0" @@ -3303,7 +3722,7 @@ dependencies = [ "sp-api", "sp-blockchain", "sp-core", - "sp-database", + "sp-database 4.0.0-dev (git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42)", "sp-externalities", "sp-inherents", "sp-keystore", @@ -3324,7 +3743,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -3398,7 +3817,7 @@ name = "frame-support" version = "4.0.0-dev" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "bitflags", + "bitflags 1.3.2", "environmental", "frame-metadata", "frame-support-procedural", @@ -3439,7 +3858,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -3451,7 +3870,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -3461,7 +3880,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -3536,11 +3955,11 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" +checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.37.20", + "rustix 0.38.3", "windows-sys 0.48.0", ] @@ -3599,6 +4018,17 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot 0.12.1", +] + [[package]] name = "futures-io" version = "0.3.28" @@ -3616,7 +4046,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "waker-fn", ] @@ -3628,7 +4058,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -3673,7 +4103,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "pin-utils", "slab", ] @@ -3850,6 +4280,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "hash-db" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d23bd4e7b5eda0d0f3a307e8b381fdc8ba9000f26fbe912250c0a4cc3956364a" + [[package]] name = "hash-db" version = "0.16.0" @@ -3888,36 +4324,43 @@ name = "hashbrown" version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +dependencies = [ + "ahash 0.8.3", + "allocator-api2", +] [[package]] -name = "heck" -version = "0.4.1" +name = "hashlink" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "312f66718a2d7789ffef4f4b7b213138ed9f1eb3aa1d0d82fc99f88fb3ffd26f" +dependencies = [ + "hashbrown 0.14.0", +] [[package]] -name = "hermit-abi" -version = "0.1.19" +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" dependencies = [ - "libc", + "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.2.6" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -4035,7 +4478,7 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", ] [[package]] @@ -4078,7 +4521,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "socket2 0.4.9", "tokio", "tower-service", @@ -4190,6 +4633,15 @@ dependencies = [ "parity-scale-codec", ] +[[package]] +name = "impl-rlp" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" +dependencies = [ + "rlp", +] + [[package]] name = "impl-serde" version = "0.3.2" @@ -4290,6 +4742,7 @@ dependencies = [ name = "interbtc-parachain" version = "1.2.0" dependencies = [ + "async-trait", "bitcoin", "btc-relay-rpc-runtime-api", "clap", @@ -4311,6 +4764,12 @@ dependencies = [ "dex-general-rpc-runtime-api", "dex-stable-rpc-runtime-api", "escrow-rpc-runtime-api", + "fc-consensus", + "fc-db", + "fc-mapping-sync", + "fc-rpc", + "fc-rpc-core", + "fp-rpc", "frame-benchmarking", "frame-benchmarking-cli", "frame-support", @@ -4403,6 +4862,12 @@ dependencies = [ "dex-general-rpc", "dex-stable-rpc", "escrow-rpc", + "fc-db", + "fc-mapping-sync", + "fc-rpc", + "fc-rpc-core", + "fc-storage", + "fp-rpc", "futures", "interbtc-primitives", "issue-rpc", @@ -4413,15 +4878,20 @@ dependencies = [ "redeem-rpc", "replace-rpc", "reward-rpc", + "sc-client-api", "sc-consensus-manual-seal", + "sc-network", + "sc-network-sync", "sc-rpc", "sc-rpc-api", + "sc-transaction-pool", "sc-transaction-pool-api", "sp-api", "sp-arithmetic", "sp-block-builder", "sp-blockchain", "sp-core", + "sp-runtime", "substrate-frame-rpc-system", "vault-registry", "vault-registry-rpc", @@ -4475,6 +4945,8 @@ dependencies = [ "escrow-rpc-runtime-api", "farming", "fee", + "fp-rpc", + "fp-self-contained", "frame-benchmarking", "frame-executive", "frame-support", @@ -4504,7 +4976,12 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", + "pallet-base-fee", "pallet-collective", + "pallet-ethereum", + "pallet-evm", + "pallet-evm-chain-id", + "pallet-evm-precompile-dispatch", "pallet-identity", "pallet-membership", "pallet-multisig", @@ -4566,7 +5043,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys 0.48.0", ] @@ -4597,13 +5074,12 @@ checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix 0.37.20", + "hermit-abi 0.3.2", + "rustix 0.38.3", "windows-sys 0.48.0", ] @@ -4674,9 +5150,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" [[package]] name = "jobserver" @@ -4891,6 +5367,8 @@ dependencies = [ "escrow-rpc-runtime-api", "farming", "fee", + "fp-rpc", + "fp-self-contained", "frame-benchmarking", "frame-executive", "frame-support", @@ -4921,7 +5399,12 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", + "pallet-base-fee", "pallet-collective", + "pallet-ethereum", + "pallet-evm", + "pallet-evm-chain-id", + "pallet-evm-precompile-dispatch", "pallet-identity", "pallet-membership", "pallet-multisig", @@ -5726,6 +6209,17 @@ dependencies = [ "libsecp256k1-core 0.3.0", ] +[[package]] +name = "libsqlite3-sys" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "libz-sys" version = "1.1.9" @@ -5739,9 +6233,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" dependencies = [ "cc", ] @@ -5763,9 +6257,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" +checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" dependencies = [ "nalgebra", ] @@ -5782,6 +6276,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" + [[package]] name = "loans" version = "1.9.3" @@ -5929,7 +6429,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -5969,7 +6469,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.20", + "rustix 0.37.23", ] [[package]] @@ -6005,7 +6505,7 @@ version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" dependencies = [ - "hash-db", + "hash-db 0.16.0", ] [[package]] @@ -6043,15 +6543,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -6330,6 +6821,24 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "netlink-packet-core" version = "0.4.2" @@ -6349,7 +6858,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "netlink-packet-core", @@ -6402,7 +6911,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.6.5", @@ -6461,6 +6970,20 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "num" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -6501,6 +7024,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg 1.1.0", + "num-integer", + "num-traits", +] + [[package]] name = "num-rational" version = "0.4.1" @@ -6525,14 +7059,35 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.2", "libc", ] +[[package]] +name = "num_enum" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.23", +] + [[package]] name = "number_prefix" version = "0.4.0" @@ -6553,9 +7108,9 @@ dependencies = [ [[package]] name = "object" -version = "0.30.4" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" dependencies = [ "memchr", ] @@ -6596,12 +7151,50 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl" +version = "0.10.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.23", +] + [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-sys" +version = "0.9.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "oracle" version = "1.2.0" @@ -6996,11 +7589,25 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", - "log", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-base-fee" +version = "1.0.0" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "fp-evm", + "frame-support", + "frame-system", "parity-scale-codec", "scale-info", + "sp-core", "sp-runtime", - "sp-std", ] [[package]] @@ -7189,6 +7796,103 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-ethereum" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "ethereum", + "ethereum-types", + "evm", + "fp-consensus", + "fp-ethereum", + "fp-evm", + "fp-rpc", + "fp-storage", + "frame-support", + "frame-system", + "pallet-evm", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-evm" +version = "6.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "environmental", + "evm", + "fp-account", + "fp-evm", + "frame-benchmarking", + "frame-support", + "frame-system", + "hex", + "hex-literal 0.4.1", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "rlp", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-evm-chain-id" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "pallet-evm-precompile-dispatch" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "fp-evm", + "frame-support", + "pallet-evm", +] + +[[package]] +name = "pallet-evm-precompile-modexp" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "fp-evm", + "num", +] + +[[package]] +name = "pallet-evm-precompile-sha3fips" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "fp-evm", + "tiny-keccak", +] + +[[package]] +name = "pallet-evm-precompile-simple" +version = "2.0.0-dev" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +dependencies = [ + "fp-evm", + "ripemd", + "sp-io", +] + [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" @@ -7621,7 +8325,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -7993,9 +8697,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" +checksum = "0dab3ac198341b2f0fec6e7f8a6eeed07a41201d98a124260611598c142e76df" dependencies = [ "blake2", "crc32fast", @@ -8013,9 +8717,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.1" +version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" +checksum = "756d439303e94fae44f288ba881ad29670c65b0c4b0e05674ca81061bb65f2c5" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -8028,9 +8732,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.1" +version = "3.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6937b5e67bfba3351b87b040d48352a2fcb6ad72f81855412ce97b45c8f110" +checksum = "9d884d78fcf214d70b1e239fcd1c6e5e95aa3be1881918da2e488cc946c7a476" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8101,14 +8805,14 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] name = "paste" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" [[package]] name = "pbkdf2" @@ -8188,7 +8892,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -8214,22 +8918,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -8240,9 +8944,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" [[package]] name = "pin-utils" @@ -8266,7 +8970,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.6", + "der 0.7.7", "spki 0.7.2", ] @@ -9279,7 +9983,7 @@ name = "polkadot-runtime-parachains" version = "0.9.42" source = "git+https://github.com/paritytech//polkadot?branch=release-v0.9.42#6f991987c0b4cbbd7d4badc9ef08d83da5fefbfd" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bitvec", "derive_more", "frame-benchmarking", @@ -9466,12 +10170,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg 1.1.0", - "bitflags", + "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "windows-sys 0.48.0", ] @@ -9582,6 +10286,7 @@ checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ "fixed-hash 0.8.0", "impl-codec", + "impl-rlp", "impl-serde 0.4.0", "scale-info", "uint", @@ -9651,7 +10356,7 @@ checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -9707,7 +10412,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e35c06b98bf36aba164cc17cb25f7e232f5c4aeea73baa14b8a9f0d92dbfa65" dependencies = [ "bit-set", - "bitflags", + "bitflags 1.3.2", "byteorder", "lazy_static", "num-traits", @@ -9842,9 +10547,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" dependencies = [ "proc-macro2", ] @@ -10173,7 +10878,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -10182,7 +10887,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -10211,22 +10916,22 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" +checksum = "1641819477c319ef452a075ac34a4be92eb9ba09f6841f62d594d50fdcf0bf6b" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" +checksum = "68bf53dad9b6086826722cdc99140793afd9f62faa14a1ad07eb4f955e7a7216" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -10243,13 +10948,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.4" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "89089e897c013b3deb627116ae56a6955a72b8bed395c9526af31c9fe528b484" dependencies = [ "aho-corasick 1.0.2", "memchr", - "regex-syntax 0.7.2", + "regex-automata 0.3.0", + "regex-syntax 0.7.3", ] [[package]] @@ -10261,6 +10967,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa250384981ea14565685dea16a9ccc4d1c541a13f82b9c168572264d1df8c56" +dependencies = [ + "aho-corasick 1.0.2", + "memchr", + "regex-syntax 0.7.3", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -10269,9 +10986,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846" [[package]] name = "region" @@ -10279,7 +10996,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "mach", "winapi", @@ -10430,6 +11147,37 @@ dependencies = [ "winapi", ] +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "rlp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" +dependencies = [ + "bytes", + "rlp-derive", + "rustc-hex", +] + +[[package]] +name = "rlp-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "rocksdb" version = "0.20.1" @@ -10629,11 +11377,20 @@ dependencies = [ "orml-xcm-support", "orml-xtokens", "pallet-aura", + "pallet-base-fee", + "pallet-ethereum", + "pallet-evm", + "pallet-evm-chain-id", + "pallet-evm-precompile-modexp", + "pallet-evm-precompile-sha3fips", + "pallet-evm-precompile-simple", "pallet-sudo", + "parachain-info", "redeem", "replace", "reward", "security", + "sp-core", "sp-runtime", "sp-std", "staking", @@ -10682,11 +11439,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.14" +version = "0.36.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" +checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -10696,11 +11453,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.20" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -10708,6 +11465,19 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustix" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac5ffa1efe7548069688cd7028f32591853cd7b5b756d41bcffd2353e4fc75b4" +dependencies = [ + "bitflags 2.3.3", + "errno", + "libc", + "linux-raw-sys 0.4.3", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.19.1" @@ -10756,9 +11526,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" [[package]] name = "rusty-fork" @@ -10785,9 +11555,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" [[package]] name = "safe_arch" @@ -10911,7 +11681,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -10971,7 +11741,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-core", - "sp-database", + "sp-database 4.0.0-dev (git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42)", "sp-externalities", "sp-keystore", "sp-runtime", @@ -10985,7 +11755,7 @@ name = "sc-client-db" version = "0.10.0-dev" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "hash-db", + "hash-db 0.16.0", "kvdb", "kvdb-memorydb", "kvdb-rocksdb", @@ -11000,7 +11770,7 @@ dependencies = [ "sp-arithmetic", "sp-blockchain", "sp-core", - "sp-database", + "sp-database 4.0.0-dev (git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-state-machine", "sp-trie", @@ -11362,7 +12132,7 @@ dependencies = [ "libc", "log", "once_cell", - "rustix 0.36.14", + "rustix 0.36.15", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -11473,7 +12243,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "array-bytes 4.2.0", "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "futures", "futures-timer", @@ -11921,7 +12691,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -12045,9 +12815,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad560913365790f17cbf12479491169f01b9d46d29cfc7422bf8c64bdc61b731" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" dependencies = [ "bitvec", "cfg-if", @@ -12059,9 +12829,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19df9bd9ace6cc2fe19387c96ce677e823e07d017ceed253e7bb3d1d1bd9c73b" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -12071,11 +12841,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -12172,7 +12942,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" dependencies = [ "base16ct 0.2.0", - "der 0.7.6", + "der 0.7.7", "generic-array 0.14.7", "pkcs8 0.10.2", "subtle", @@ -12247,7 +13017,7 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -12290,29 +13060,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "d01b7404f9d441d3ad40e6a636a7782c377d2abdbe4fa2440e2edcc2f4f10db8" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "5dd83d6dde2b6b2d466e14d9d1acce8816dedee94f735eac6395808b3483c6d6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] name = "serde_json" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" dependencies = [ "itoa", "ryu", @@ -12499,9 +13269,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "snap" @@ -12568,7 +13338,7 @@ name = "sp-api" version = "4.0.0-dev" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "hash-db", + "hash-db 0.16.0", "log", "parity-scale-codec", "scale-info", @@ -12594,7 +13364,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -12661,7 +13431,7 @@ dependencies = [ "parking_lot 0.12.1", "sp-api", "sp-consensus", - "sp-database", + "sp-database 4.0.0-dev (git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42)", "sp-runtime", "sp-state-machine", "thiserror", @@ -12776,14 +13546,14 @@ version = "7.0.0" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "array-bytes 4.2.0", - "bitflags", + "bitflags 1.3.2", "blake2", "bounded-collections", "bs58", "dyn-clonable", "ed25519-zebra", "futures", - "hash-db", + "hash-db 0.16.0", "hash256-std-hasher", "impl-serde 0.4.0", "lazy_static", @@ -12836,7 +13606,7 @@ dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -12848,6 +13618,15 @@ dependencies = [ "parking_lot 0.12.1", ] +[[package]] +name = "sp-database" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +dependencies = [ + "kvdb", + "parking_lot 0.12.1", +] + [[package]] name = "sp-debug-derive" version = "5.0.0" @@ -12855,7 +13634,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -13066,7 +13845,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -13101,7 +13880,7 @@ name = "sp-state-machine" version = "0.13.0" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "hash-db", + "hash-db 0.16.0", "log", "parity-scale-codec", "parking_lot 0.12.1", @@ -13192,7 +13971,7 @@ version = "7.0.0" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "ahash 0.8.3", - "hash-db", + "hash-db 0.16.0", "hashbrown 0.13.2", "lazy_static", "memory-db", @@ -13234,7 +14013,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -13278,6 +14057,15 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13287b4da9d1207a4f4929ac390916d64eacfe236a487e9a9f5b3be392be5162" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + [[package]] name = "spinners" version = "4.1.0" @@ -13306,14 +14094,135 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.6", + "der 0.7.7", +] + +[[package]] +name = "sqlformat" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c12bc9199d1db8234678b7051747c07f517cdcf019262d1847b94ec8b1aee3e" +dependencies = [ + "itertools", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ef53c86d2066e04f0ac6b1364f16d13d82388e2d07f11a5c71782345555761" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a22fd81e9c1ad53c562edb869ff042b215d4eadefefc4784bacfbfd19835945" +dependencies = [ + "ahash 0.8.3", + "atoi", + "byteorder", + "bytes", + "crc", + "crossbeam-queue", + "dotenvy", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap 2.0.0", + "log", + "memchr", + "native-tls", + "once_cell", + "paste", + "percent-encoding", + "serde", + "sha2 0.10.7", + "smallvec", + "sqlformat", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00bb7c096a202b8164c175614cbfb79fe0e1e0a3d50e0374526183ef2974e4a2" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d644623ab9699014e5b3cb61a040d16caa50fd477008f63f1399ae35498a58" +dependencies = [ + "dotenvy", + "either", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2 0.10.7", + "sqlx-core", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59fba60afa64718104b71eec6984f8779d4caffff3b30cde91a75843c7efc126" +dependencies = [ + "atoi", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "tracing", + "url", ] [[package]] name = "ss58-registry" -version = "1.40.0" +version = "1.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" +checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" dependencies = [ "Inflector", "num-format", @@ -13378,7 +14287,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg_aliases", "libc", "parking_lot 0.11.2", @@ -13556,7 +14465,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.5", + "toml 0.7.6", "walkdir", "wasm-opt", ] @@ -13610,9 +14519,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.22" +version = "2.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" +checksum = "59fb7d6d8281a51045d62b8eb3a7d1ce347b76f312af50cd3dc0af39c87c1737" dependencies = [ "proc-macro2", "quote", @@ -13637,7 +14546,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -13674,7 +14583,7 @@ dependencies = [ "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.20", + "rustix 0.37.23", "windows-sys 0.48.0", ] @@ -13695,22 +14604,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "c16a64ba9387ef3fdae4f9c1a7f07a0997fce91985c0336f1ddc1822b3b37802" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "d14928354b01c4d6a4f0e549069adef399a284e7995c7ccca94e8a07a5346c59" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -13829,6 +14738,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -13856,9 +14774,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.0" +version = "1.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374442f06ee49c3a28a8fc9f01a2596fed7559c6b99b31279c3261778e77d84f" +checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" dependencies = [ "autocfg 1.1.0", "backtrace", @@ -13867,7 +14785,7 @@ dependencies = [ "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "signal-hook-registry", "socket2 0.4.9", "tokio-macros", @@ -13882,7 +14800,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -13903,7 +14821,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tokio", "tokio-util", ] @@ -13918,7 +14836,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tokio", "tracing", ] @@ -13934,9 +14852,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebafdf5ad1220cb59e7d17cf4d2c72015297b75b19a10472f99b89225089240" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -13955,9 +14873,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.11" +version = "0.19.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" +checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" dependencies = [ "indexmap 2.0.0", "serde", @@ -13983,14 +14901,14 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tower-layer", "tower-service", ] @@ -14015,7 +14933,7 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.10", "tracing-attributes", "tracing-core", ] @@ -14028,7 +14946,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -14071,7 +14989,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -14144,7 +15062,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" dependencies = [ - "hash-db", + "hash-db 0.16.0", "hashbrown 0.13.2", "log", "rustc-hex", @@ -14157,7 +15075,17 @@ version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" dependencies = [ - "hash-db", + "hash-db 0.16.0", +] + +[[package]] +name = "triehash" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1631b201eb031b563d2e85ca18ec8092508e262a3196ce9bd10a67ec87b9f5c" +dependencies = [ + "hash-db 0.15.2", + "rlp", ] [[package]] @@ -14282,7 +15210,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.6.5", "static_assertions", ] @@ -14342,9 +15270,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" [[package]] name = "unicode-normalization" @@ -14355,6 +15283,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + [[package]] name = "unicode-width" version = "0.1.10" @@ -14367,6 +15301,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "universal-hash" version = "0.4.1" @@ -14607,7 +15547,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", "wasm-bindgen-shared", ] @@ -14641,7 +15581,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -14810,7 +15750,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.14", + "rustix 0.36.15", "serde", "sha2 0.10.7", "toml 0.5.11", @@ -14890,7 +15830,7 @@ checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" dependencies = [ "object 0.29.0", "once_cell", - "rustix 0.36.14", + "rustix 0.36.15", ] [[package]] @@ -14921,7 +15861,7 @@ dependencies = [ "memoffset 0.6.5", "paste", "rand 0.8.5", - "rustix 0.36.14", + "rustix 0.36.15", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -15174,7 +16114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "cc", "ipnet", @@ -15371,7 +16311,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -15404,7 +16344,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.1", ] [[package]] @@ -15424,9 +16364,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", @@ -15553,9 +16493,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" +checksum = "a9482fe6ceabdf32f3966bfdd350ba69256a97c30253dc616fe0005af24f164e" dependencies = [ "memchr", ] @@ -15729,7 +16669,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] @@ -15789,7 +16729,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.23", ] [[package]] diff --git a/parachain/Cargo.toml b/parachain/Cargo.toml index 86180393d8..1a3b828e93 100644 --- a/parachain/Cargo.toml +++ b/parachain/Cargo.toml @@ -15,6 +15,7 @@ name = "interbtc-parachain" substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } [dependencies] +async-trait = "0.1" clap = { version = "4.0.9", features = [ "derive" ] } log = "0.4.8" codec = { package = "parity-scale-codec", version = "3.1.5" } @@ -112,6 +113,14 @@ polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "relea polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.31" } polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.31" } +# Frontier dependencies +fc-consensus = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fc-db = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fc-mapping-sync = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", features = ["sql"] } +fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fc-rpc-core = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } + [features] default = [] diff --git a/parachain/runtime/common/Cargo.toml b/parachain/runtime/common/Cargo.toml index 73045bf708..c3c4122d27 100644 --- a/parachain/runtime/common/Cargo.toml +++ b/parachain/runtime/common/Cargo.toml @@ -12,6 +12,7 @@ targets = ['x86_64-unknown-linux-gnu'] # Substrate dependencies sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.31", default-features = false } @@ -20,6 +21,9 @@ frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = pallet-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } +# Cumulus dependencies +parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.31", default-features = false } + # Parachain dependencies btc-relay = { path = "../../../crates/btc-relay", default-features = false } currency = { path = "../../../crates/currency", default-features = false } @@ -48,12 +52,20 @@ primitives = { package = "interbtc-primitives", path = "../../../primitives", de orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "3fcd3cf9e63fe80fd9671912833a900ba09d1cc0", default-features = false } orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "3fcd3cf9e63fe80fd9671912833a900ba09d1cc0", default-features = false } orml-vesting = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "3fcd3cf9e63fe80fd9671912833a900ba09d1cc0", default-features = false } +orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "3fcd3cf9e63fe80fd9671912833a900ba09d1cc0", default-features = false } orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "3fcd3cf9e63fe80fd9671912833a900ba09d1cc0", default-features = false } orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "3fcd3cf9e63fe80fd9671912833a900ba09d1cc0", default-features = false } orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "3fcd3cf9e63fe80fd9671912833a900ba09d1cc0", default-features = false } -orml-asset-registry= { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "3fcd3cf9e63fe80fd9671912833a900ba09d1cc0", default-features = false } +# Frontier dependencies +pallet-base-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-ethereum = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm-precompile-modexp = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm-precompile-sha3fips = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm-precompile-simple = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } # TODO: enable weak dependency activation when available # https://github.com/rust-lang/cargo/issues/8832 @@ -64,12 +76,15 @@ default = ["std"] std = [ "sp-std/std", "sp-runtime/std", + "sp-core/std", "frame-support/std", "frame-system/std", "frame-benchmarking?/std", "xcm/std", "xcm-executor/std", + "parachain-info/std", + "btc-relay/std", "currency/std", "security/std", @@ -101,12 +116,21 @@ std = [ "orml-xtokens/std", "orml-xcm-support/std", "orml-unknown-tokens/std", + + "pallet-base-fee/std", + "pallet-ethereum/std", + "pallet-evm/std", + "pallet-evm-chain-id/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-sha3fips/std", + "pallet-evm-precompile-simple/std", ] dev-interlay = [] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "currency/try-runtime", + "parachain-info/try-runtime", "orml-tokens/try-runtime", "supply/try-runtime", "orml-vesting/try-runtime", @@ -130,7 +154,12 @@ try-runtime = [ "loans/try-runtime", "democracy/try-runtime", "orml-xtokens/try-runtime", - "orml-unknown-tokens/try-runtime" + "orml-unknown-tokens/try-runtime", + + "pallet-base-fee/try-runtime", + "pallet-ethereum/try-runtime", + "pallet-evm/try-runtime", + "pallet-evm-chain-id/try-runtime", ] runtime-benchmarks = [ "frame-benchmarking", diff --git a/parachain/runtime/common/src/evm/mod.rs b/parachain/runtime/common/src/evm/mod.rs new file mode 100644 index 0000000000..92787363c5 --- /dev/null +++ b/parachain/runtime/common/src/evm/mod.rs @@ -0,0 +1,71 @@ +use frame_support::{ + traits::OnRuntimeUpgrade, + weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}, +}; +use pallet_ethereum::{Transaction, TransactionAction}; +use sp_core::Get; +use sp_runtime::Permill; +use sp_std::marker::PhantomData; + +pub mod precompiles; + +/// Current approximation of the gas/s consumption (Moonbeam) +pub const GAS_PER_SECOND: u64 = 40_000_000; +/// Approximate ratio of the amount of Weight per Gas (Moonbeam) +pub const WEIGHT_PER_GAS: u64 = WEIGHT_REF_TIME_PER_SECOND / GAS_PER_SECOND; + +/// Sets the ideal block fullness to 50%. +/// If the block weight is between: +/// - 0-50% the gas fee will decrease +/// - 50-100% the gas fee will increase +pub struct BaseFeeThreshold; +impl pallet_base_fee::BaseFeeThreshold for BaseFeeThreshold { + fn lower() -> Permill { + Permill::zero() + } + fn ideal() -> Permill { + Permill::from_parts(500_000) + } + fn upper() -> Permill { + Permill::from_parts(1_000_000) + } +} + +/// Get the "action" (call or create) of an Ethereum transaction +pub trait GetTransactionAction { + fn action(&self) -> TransactionAction; +} + +impl GetTransactionAction for Transaction { + fn action(&self) -> TransactionAction { + match self { + Transaction::Legacy(transaction) => transaction.action, + Transaction::EIP2930(transaction) => transaction.action, + Transaction::EIP1559(transaction) => transaction.action, + } + } +} + +/// Set the EVM chain ID based on the parachain ID +pub struct SetEvmChainId(PhantomData); +impl OnRuntimeUpgrade for SetEvmChainId +where + T: frame_system::Config + parachain_info::Config + pallet_evm_chain_id::Config, +{ + fn on_runtime_upgrade() -> Weight { + let para_id: u32 = parachain_info::Pallet::::parachain_id().into(); + let evm_id: u64 = para_id.into(); + pallet_evm_chain_id::ChainId::::put(evm_id); + ::DbWeight::get().reads_writes(1, 1) + } + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result, &'static str> { + Ok(Default::default()) + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade(_: sp_std::vec::Vec) -> Result<(), &'static str> { + Ok(()) + } +} diff --git a/parachain/runtime/common/src/evm/precompiles.rs b/parachain/runtime/common/src/evm/precompiles.rs new file mode 100644 index 0000000000..03c58c5f17 --- /dev/null +++ b/parachain/runtime/common/src/evm/precompiles.rs @@ -0,0 +1,45 @@ +use pallet_evm::{IsPrecompileResult, Precompile, PrecompileHandle, PrecompileResult, PrecompileSet}; +use sp_core::H160; +use sp_std::marker::PhantomData; + +use pallet_evm_precompile_modexp::Modexp; +use pallet_evm_precompile_simple::{ECRecover, Identity, Ripemd160, Sha256}; + +pub struct InterBtcPrecompiles(PhantomData); + +impl InterBtcPrecompiles { + pub fn new() -> Self { + Self(Default::default()) + } + pub fn used_addresses() -> [H160; 5] { + [hash(1), hash(2), hash(3), hash(4), hash(5)] + } +} + +impl PrecompileSet for InterBtcPrecompiles +where + R: pallet_evm::Config, +{ + fn execute(&self, handle: &mut impl PrecompileHandle) -> Option { + match handle.code_address() { + // Ethereum precompiles: + a if a == hash(1) => Some(ECRecover::execute(handle)), + a if a == hash(2) => Some(Sha256::execute(handle)), + a if a == hash(3) => Some(Ripemd160::execute(handle)), + a if a == hash(4) => Some(Identity::execute(handle)), + a if a == hash(5) => Some(Modexp::execute(handle)), + _ => None, + } + } + + fn is_precompile(&self, address: H160, _gas: u64) -> IsPrecompileResult { + IsPrecompileResult::Answer { + is_precompile: Self::used_addresses().contains(&address), + extra_cost: 0, + } + } +} + +fn hash(a: u64) -> H160 { + H160::from_low_u64_be(a) +} diff --git a/parachain/runtime/common/src/lib.rs b/parachain/runtime/common/src/lib.rs index 62476048cc..aa77b4981c 100644 --- a/parachain/runtime/common/src/lib.rs +++ b/parachain/runtime/common/src/lib.rs @@ -13,6 +13,8 @@ use sp_std::prelude::*; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; +pub mod evm; + // The relay chain is limited to 12s to include parachain blocks. pub const MILLISECS_PER_BLOCK: u64 = 12000; pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); diff --git a/parachain/runtime/interlay/Cargo.toml b/parachain/runtime/interlay/Cargo.toml index e1ae1ed24f..5766020176 100644 --- a/parachain/runtime/interlay/Cargo.toml +++ b/parachain/runtime/interlay/Cargo.toml @@ -125,11 +125,20 @@ dex-stable-rpc-runtime-api = { path = "../../../crates/dex-stable/rpc/runtime-ap orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-vesting = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } +orml-asset-registry= { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } -orml-asset-registry= { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } + +# Frontier dependencies +fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +fp-self-contained = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-base-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-ethereum = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm-precompile-dispatch = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } [dev-dependencies] hex = '0.4.2' @@ -251,11 +260,19 @@ std = [ "orml-tokens/std", "orml-traits/std", "orml-vesting/std", + "orml-asset-registry/std", "orml-xtokens/std", "orml-xcm-support/std", "orml-unknown-tokens/std", - "orml-asset-registry/std", + + "fp-rpc/std", + "fp-self-contained/std", + "pallet-base-fee/std", + "pallet-ethereum/std", + "pallet-evm/std", + "pallet-evm-chain-id/std", + "pallet-evm-precompile-dispatch/std", ] runtime-benchmarks = [ "frame-benchmarking", @@ -303,6 +320,9 @@ runtime-benchmarks = [ "runtime-common/runtime-benchmarks", "primitives/runtime-benchmarks", + + "pallet-ethereum/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", ] disable-runtime-api = [] try-runtime = [ @@ -366,5 +386,11 @@ try-runtime = [ "orml-xtokens/try-runtime", "orml-unknown-tokens/try-runtime", "multi-transaction-payment/try-runtime", + + "fp-self-contained/try-runtime", + "pallet-base-fee/try-runtime", + "pallet-ethereum/try-runtime", + "pallet-evm/try-runtime", + "pallet-evm-chain-id/try-runtime", ] vesting-any = [] \ No newline at end of file diff --git a/parachain/runtime/interlay/src/evm.rs b/parachain/runtime/interlay/src/evm.rs new file mode 100644 index 0000000000..e4f7605d1e --- /dev/null +++ b/parachain/runtime/interlay/src/evm.rs @@ -0,0 +1,90 @@ +use crate::{ + AccountId, Aura, BaseFee, EVMChainId, NativeCurrency, Runtime, RuntimeEvent, Timestamp, MAXIMUM_BLOCK_WEIGHT, + NORMAL_DISPATCH_RATIO, +}; +use frame_support::{ + parameter_types, + traits::{ConstU32, FindAuthor}, + weights::Weight, + ConsensusEngineId, +}; +use pallet_ethereum::PostLogContent; +use pallet_evm::{EnsureAddressRoot, EnsureAddressTruncated, FixedGasWeightMapping, HashedAddressMapping}; +use sp_core::{crypto::ByteArray, H160, U256}; +use sp_runtime::{traits::BlakeTwo256, Permill}; +use sp_std::marker::PhantomData; + +pub use runtime_common::evm::{ + precompiles::InterBtcPrecompiles, BaseFeeThreshold, GetTransactionAction, SetEvmChainId, WEIGHT_PER_GAS, +}; + +parameter_types! { + pub DefaultBaseFeePerGas: U256 = U256::from(1_000_000_000); + pub DefaultElasticity: Permill = Permill::from_parts(125_000); +} + +impl pallet_base_fee::Config for Runtime { + type DefaultBaseFeePerGas = DefaultBaseFeePerGas; + type DefaultElasticity = DefaultElasticity; + type RuntimeEvent = RuntimeEvent; + type Threshold = BaseFeeThreshold; +} + +parameter_types! { + pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; +} + +impl pallet_ethereum::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type StateRoot = pallet_ethereum::IntermediateStateRoot; + type PostLogContent = PostBlockAndTxnHashes; + type ExtraDataLength = ConstU32<30>; +} + +pub struct FindAuthorTruncated(PhantomData); +impl> FindAuthor for FindAuthorTruncated { + fn find_author<'a, I>(digests: I) -> Option + where + I: 'a + IntoIterator, + { + if let Some(author_index) = F::find_author(digests) { + let authority_id = Aura::authorities()[author_index as usize].clone(); + return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24])); + } + None + } +} + +parameter_types! { + pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); + pub PrecompilesValue: InterBtcPrecompiles = InterBtcPrecompiles::<_>::new(); + pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0); + /// The amount of gas per pov, taken from Moonbeam: + /// ceil(MAXIMUM_BLOCK_WEIGHT.ref_time() / MAXIMUM_BLOCK_WEIGHT.proof_size() / WEIGHT_PER_GAS) + pub const GasLimitPovSizeRatio: u64 = 4; +} + +impl pallet_evm::Config for Runtime { + type AddressMapping = HashedAddressMapping; + type BlockGasLimit = BlockGasLimit; + type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; + type CallOrigin = EnsureAddressRoot; + type WithdrawOrigin = EnsureAddressTruncated; + type ChainId = EVMChainId; + type Currency = NativeCurrency; + type FeeCalculator = BaseFee; + type FindAuthor = FindAuthorTruncated; + type GasWeightMapping = FixedGasWeightMapping; + type OnChargeTransaction = (); + type OnCreate = (); + type PrecompilesType = InterBtcPrecompiles; + type PrecompilesValue = PrecompilesValue; + type Runner = pallet_evm::runner::stack::Runner; + type RuntimeEvent = RuntimeEvent; + type WeightPerGas = WeightPerGas; + type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type Timestamp = Timestamp; + type WeightInfo = pallet_evm::weights::SubstrateWeight; +} + +impl pallet_evm_chain_id::Config for Runtime {} diff --git a/parachain/runtime/interlay/src/lib.rs b/parachain/runtime/interlay/src/lib.rs index 1702616773..21fde63aab 100644 --- a/parachain/runtime/interlay/src/lib.rs +++ b/parachain/runtime/interlay/src/lib.rs @@ -43,6 +43,18 @@ use sp_version::NativeVersion; use sp_version::RuntimeVersion; use weights::{block_weights::BlockExecutionWeight, extrinsic_weights::ExtrinsicBaseWeight}; +// Frontier imports +use codec::{Decode, Encode}; +use fp_rpc::TransactionStatus; +use frame_support::traits::OnFinalize; +use pallet_ethereum::{Transaction as EthereumTransaction, TransactionAction}; +use pallet_evm::{Account as EVMAccount, FeeCalculator, Runner}; +use sp_core::{H160, U256}; +use sp_runtime::{ + traits::{DispatchInfoOf, Dispatchable, PostDispatchInfoOf, UniqueSaturatedInto}, + transaction_validity::{InvalidTransaction, TransactionValidityError}, +}; + // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, @@ -84,6 +96,7 @@ pub mod weights; pub mod xcm_config; mod dex; +mod evm; type VaultId = primitives::VaultId; @@ -189,6 +202,9 @@ impl Contains for BaseCallFilter { // governance are still able to call these (sudo is explicitly white-listed, while // governance bypasses this call filter). false + } else if let RuntimeCall::EVM(_) = call { + // disable non-root EVM access + false } else { // normal operation: allow all calls that are not explicitly paused TxPause::contains(call) @@ -1265,6 +1281,11 @@ construct_runtime! { DexGeneral: dex_general::{Pallet, Call, Storage, Event} = 101, DexStable: dex_stable::{Pallet, Call, Storage, Event} = 102, DexSwapRouter: dex_swap_router::{Pallet, Call, Event} = 103, + + BaseFee: pallet_base_fee::{Pallet, Call, Storage, Event, Config} = 110, + Ethereum: pallet_ethereum::{Pallet, Call, Storage, Event, Config, Origin} = 111, + EVM: pallet_evm::{Pallet, Call, Storage, Event, Config} = 112, + EVMChainId: pallet_evm_chain_id::{Pallet, Storage, Config} = 113, } } @@ -1289,9 +1310,9 @@ pub type SignedExtra = ( pallet_transaction_payment::ChargeTransactionPayment, ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = fp_self_contained::UncheckedExtrinsic; /// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; +pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -1304,9 +1325,88 @@ pub type Executive = frame_executive::Executive< orml_unknown_tokens::Migration, dex::SetLoansExchangeRates, issue::migration::v1::Migration, + evm::SetEvmChainId, ), >; +impl fp_self_contained::SelfContainedCall for RuntimeCall { + type SignedInfo = H160; + + fn is_self_contained(&self) -> bool { + match self { + RuntimeCall::Ethereum(call) => call.is_self_contained(), + _ => false, + } + } + + fn check_self_contained(&self) -> Option> { + match self { + RuntimeCall::Ethereum(call) => match call { + pallet_ethereum::Call::transact { transaction } + if evm::GetTransactionAction::action(transaction) == TransactionAction::Create => + { + Some(Err(TransactionValidityError::Invalid(InvalidTransaction::Call))) + } + _ => call.check_self_contained(), + }, + _ => None, + } + } + + fn validate_self_contained( + &self, + info: &Self::SignedInfo, + dispatch_info: &DispatchInfoOf, + len: usize, + ) -> Option { + match self { + RuntimeCall::Ethereum(call) => call.validate_self_contained(info, dispatch_info, len), + _ => None, + } + } + + fn pre_dispatch_self_contained( + &self, + info: &Self::SignedInfo, + dispatch_info: &DispatchInfoOf, + len: usize, + ) -> Option> { + match self { + RuntimeCall::Ethereum(call) => call.pre_dispatch_self_contained(info, dispatch_info, len), + _ => None, + } + } + + fn apply_self_contained( + self, + info: Self::SignedInfo, + ) -> Option>> { + match self { + call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch( + RuntimeOrigin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)), + )), + _ => None, + } + } +} + +pub struct TransactionConverter; + +impl fp_rpc::ConvertTransaction for TransactionConverter { + fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic { + UncheckedExtrinsic::new_unsigned(pallet_ethereum::Call::::transact { transaction }.into()) + } +} + +impl fp_rpc::ConvertTransaction for TransactionConverter { + fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> sp_runtime::OpaqueExtrinsic { + let extrinsic = + UncheckedExtrinsic::new_unsigned(pallet_ethereum::Call::::transact { transaction }.into()); + let encoded = extrinsic.encode(); + sp_runtime::OpaqueExtrinsic::decode(&mut &encoded[..]).expect("Encoded extrinsic is always valid") + } +} + #[cfg(feature = "runtime-benchmarks")] #[macro_use] extern crate frame_benchmarking; @@ -1888,6 +1988,180 @@ impl_runtime_apis! { Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed") } } + + impl fp_rpc::EthereumRuntimeRPCApi for Runtime { + fn chain_id() -> u64 { + ::ChainId::get() + } + + fn account_basic(address: H160) -> EVMAccount { + let (account, _) = pallet_evm::Pallet::::account_basic(&address); + account + } + + fn gas_price() -> U256 { + let (gas_price, _) = ::FeeCalculator::min_gas_price(); + gas_price + } + + fn account_code_at(address: H160) -> Vec { + pallet_evm::AccountCodes::::get(address) + } + + fn author() -> H160 { + >::find_author() + } + + fn storage_at(address: H160, index: U256) -> H256 { + let mut tmp = [0u8; 32]; + index.to_big_endian(&mut tmp); + pallet_evm::AccountStorages::::get(address, H256::from_slice(&tmp[..])) + } + + fn call( + from: H160, + to: H160, + data: Vec, + value: U256, + gas_limit: U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, + estimate: bool, + access_list: Option)>>, + ) -> Result { + let config = if estimate { + let mut config = ::config().clone(); + config.estimate = true; + Some(config) + } else { + None + }; + + let is_transactional = false; + let validate = true; + let evm_config = config.as_ref().unwrap_or(::config()); + ::Runner::call( + from, + to, + data, + value, + gas_limit.unique_saturated_into(), + max_fee_per_gas, + max_priority_fee_per_gas, + nonce, + access_list.unwrap_or_default(), + is_transactional, + validate, + // TODO we probably want to support external cost recording in non-transactional calls + None, + None, + evm_config, + ).map_err(|err| err.error.into()) + } + + fn create( + from: H160, + data: Vec, + value: U256, + gas_limit: U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, + estimate: bool, + access_list: Option)>>, + ) -> Result { + let config = if estimate { + let mut config = ::config().clone(); + config.estimate = true; + Some(config) + } else { + None + }; + + let is_transactional = false; + let validate = true; + let evm_config = config.as_ref().unwrap_or(::config()); + ::Runner::create( + from, + data, + value, + gas_limit.unique_saturated_into(), + max_fee_per_gas, + max_priority_fee_per_gas, + nonce, + access_list.unwrap_or_default(), + is_transactional, + validate, + // TODO we probably want to support external cost recording in non-transactional calls + None, + None, + evm_config, + ).map_err(|err| err.error.into()) + } + + fn current_transaction_statuses() -> Option> { + pallet_ethereum::CurrentTransactionStatuses::::get() + } + + fn current_block() -> Option { + pallet_ethereum::CurrentBlock::::get() + } + + fn current_receipts() -> Option> { + pallet_ethereum::CurrentReceipts::::get() + } + + fn current_all() -> ( + Option, + Option>, + Option> + ) { + ( + pallet_ethereum::CurrentBlock::::get(), + pallet_ethereum::CurrentReceipts::::get(), + pallet_ethereum::CurrentTransactionStatuses::::get() + ) + } + + fn extrinsic_filter( + xts: Vec<::Extrinsic>, + ) -> Vec { + xts.into_iter().filter_map(|xt| match xt.0.function { + RuntimeCall::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction), + _ => None + }).collect::>() + } + + fn elasticity() -> Option { + Some(pallet_base_fee::Elasticity::::get()) + } + + fn gas_limit_multiplier_support() {} + + fn pending_block( + xts: Vec<::Extrinsic>, + ) -> (Option, Option>) { + for ext in xts.into_iter() { + let _ = Executive::apply_extrinsic(ext); + } + + Ethereum::on_finalize(System::block_number() + 1); + + ( + pallet_ethereum::CurrentBlock::::get(), + pallet_ethereum::CurrentTransactionStatuses::::get() + ) + } + } + + impl fp_rpc::ConvertTransactionRuntimeApi for Runtime { + fn convert_transaction(transaction: EthereumTransaction) -> ::Extrinsic { + UncheckedExtrinsic::new_unsigned( + pallet_ethereum::Call::::transact { transaction }.into(), + ) + } + } } struct CheckInherents; diff --git a/parachain/runtime/kintsugi/Cargo.toml b/parachain/runtime/kintsugi/Cargo.toml index 8836064a91..6207ebe045 100644 --- a/parachain/runtime/kintsugi/Cargo.toml +++ b/parachain/runtime/kintsugi/Cargo.toml @@ -126,11 +126,20 @@ dex-stable-rpc-runtime-api = { path = "../../../crates/dex-stable/rpc/runtime-ap orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-vesting = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } +orml-asset-registry = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } -orml-asset-registry= { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false } + +# Frontier dependencies +fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +fp-self-contained = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-base-fee = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-ethereum = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm-chain-id = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } +pallet-evm-precompile-dispatch = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42", default-features = false } [dev-dependencies] hex = '0.4.2' @@ -263,6 +272,14 @@ std = [ "orml-xtokens/std", "orml-xcm-support/std", "orml-unknown-tokens/std", + + "fp-rpc/std", + "fp-self-contained/std", + "pallet-base-fee/std", + "pallet-ethereum/std", + "pallet-evm/std", + "pallet-evm-chain-id/std", + "pallet-evm-precompile-dispatch/std", ] runtime-benchmarks = [ "frame-benchmarking", @@ -310,6 +327,9 @@ runtime-benchmarks = [ "runtime-common/runtime-benchmarks", "primitives/runtime-benchmarks", + + "pallet-ethereum/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", ] disable-runtime-api = [] try-runtime = [ @@ -371,5 +391,11 @@ try-runtime = [ "orml-xtokens/try-runtime", "orml-unknown-tokens/try-runtime", "multi-transaction-payment/try-runtime", + + "fp-self-contained/try-runtime", + "pallet-base-fee/try-runtime", + "pallet-ethereum/try-runtime", + "pallet-evm/try-runtime", + "pallet-evm-chain-id/try-runtime", ] vesting-any = [] \ No newline at end of file diff --git a/parachain/runtime/kintsugi/src/evm.rs b/parachain/runtime/kintsugi/src/evm.rs new file mode 100644 index 0000000000..e4f7605d1e --- /dev/null +++ b/parachain/runtime/kintsugi/src/evm.rs @@ -0,0 +1,90 @@ +use crate::{ + AccountId, Aura, BaseFee, EVMChainId, NativeCurrency, Runtime, RuntimeEvent, Timestamp, MAXIMUM_BLOCK_WEIGHT, + NORMAL_DISPATCH_RATIO, +}; +use frame_support::{ + parameter_types, + traits::{ConstU32, FindAuthor}, + weights::Weight, + ConsensusEngineId, +}; +use pallet_ethereum::PostLogContent; +use pallet_evm::{EnsureAddressRoot, EnsureAddressTruncated, FixedGasWeightMapping, HashedAddressMapping}; +use sp_core::{crypto::ByteArray, H160, U256}; +use sp_runtime::{traits::BlakeTwo256, Permill}; +use sp_std::marker::PhantomData; + +pub use runtime_common::evm::{ + precompiles::InterBtcPrecompiles, BaseFeeThreshold, GetTransactionAction, SetEvmChainId, WEIGHT_PER_GAS, +}; + +parameter_types! { + pub DefaultBaseFeePerGas: U256 = U256::from(1_000_000_000); + pub DefaultElasticity: Permill = Permill::from_parts(125_000); +} + +impl pallet_base_fee::Config for Runtime { + type DefaultBaseFeePerGas = DefaultBaseFeePerGas; + type DefaultElasticity = DefaultElasticity; + type RuntimeEvent = RuntimeEvent; + type Threshold = BaseFeeThreshold; +} + +parameter_types! { + pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; +} + +impl pallet_ethereum::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type StateRoot = pallet_ethereum::IntermediateStateRoot; + type PostLogContent = PostBlockAndTxnHashes; + type ExtraDataLength = ConstU32<30>; +} + +pub struct FindAuthorTruncated(PhantomData); +impl> FindAuthor for FindAuthorTruncated { + fn find_author<'a, I>(digests: I) -> Option + where + I: 'a + IntoIterator, + { + if let Some(author_index) = F::find_author(digests) { + let authority_id = Aura::authorities()[author_index as usize].clone(); + return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24])); + } + None + } +} + +parameter_types! { + pub BlockGasLimit: U256 = U256::from(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT.ref_time() / WEIGHT_PER_GAS); + pub PrecompilesValue: InterBtcPrecompiles = InterBtcPrecompiles::<_>::new(); + pub WeightPerGas: Weight = Weight::from_parts(WEIGHT_PER_GAS, 0); + /// The amount of gas per pov, taken from Moonbeam: + /// ceil(MAXIMUM_BLOCK_WEIGHT.ref_time() / MAXIMUM_BLOCK_WEIGHT.proof_size() / WEIGHT_PER_GAS) + pub const GasLimitPovSizeRatio: u64 = 4; +} + +impl pallet_evm::Config for Runtime { + type AddressMapping = HashedAddressMapping; + type BlockGasLimit = BlockGasLimit; + type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; + type CallOrigin = EnsureAddressRoot; + type WithdrawOrigin = EnsureAddressTruncated; + type ChainId = EVMChainId; + type Currency = NativeCurrency; + type FeeCalculator = BaseFee; + type FindAuthor = FindAuthorTruncated; + type GasWeightMapping = FixedGasWeightMapping; + type OnChargeTransaction = (); + type OnCreate = (); + type PrecompilesType = InterBtcPrecompiles; + type PrecompilesValue = PrecompilesValue; + type Runner = pallet_evm::runner::stack::Runner; + type RuntimeEvent = RuntimeEvent; + type WeightPerGas = WeightPerGas; + type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type Timestamp = Timestamp; + type WeightInfo = pallet_evm::weights::SubstrateWeight; +} + +impl pallet_evm_chain_id::Config for Runtime {} diff --git a/parachain/runtime/kintsugi/src/lib.rs b/parachain/runtime/kintsugi/src/lib.rs index 3251487c2d..2517a2f2bc 100644 --- a/parachain/runtime/kintsugi/src/lib.rs +++ b/parachain/runtime/kintsugi/src/lib.rs @@ -43,6 +43,18 @@ use sp_version::NativeVersion; use sp_version::RuntimeVersion; use weights::{block_weights::BlockExecutionWeight, extrinsic_weights::ExtrinsicBaseWeight}; +// Frontier imports +use codec::{Decode, Encode}; +use fp_rpc::TransactionStatus; +use frame_support::traits::OnFinalize; +use pallet_ethereum::{Transaction as EthereumTransaction, TransactionAction}; +use pallet_evm::{Account as EVMAccount, FeeCalculator, Runner}; +use sp_core::{H160, U256}; +use sp_runtime::{ + traits::{DispatchInfoOf, Dispatchable, PostDispatchInfoOf, UniqueSaturatedInto}, + transaction_validity::{InvalidTransaction, TransactionValidityError}, +}; + // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, @@ -83,6 +95,7 @@ pub mod constants; pub mod xcm_config; mod dex; +mod evm; type VaultId = primitives::VaultId; @@ -187,6 +200,9 @@ impl Contains for BaseCallFilter { // governance are still able to call these (sudo is explicitly white-listed, while // governance bypasses this call filter). false + } else if let RuntimeCall::EVM(_) = call { + // disable non-root EVM access + false } else { // normal operation: allow all calls that are not explicitly paused TxPause::contains(call) @@ -1265,6 +1281,11 @@ construct_runtime! { DexGeneral: dex_general::{Pallet, Call, Storage, Event} = 101, DexStable: dex_stable::{Pallet, Call, Storage, Event} = 102, DexSwapRouter: dex_swap_router::{Pallet, Call, Event} = 103, + + BaseFee: pallet_base_fee::{Pallet, Call, Storage, Event, Config} = 110, + Ethereum: pallet_ethereum::{Pallet, Call, Storage, Event, Config, Origin} = 111, + EVM: pallet_evm::{Pallet, Call, Storage, Event, Config} = 112, + EVMChainId: pallet_evm_chain_id::{Pallet, Storage, Config} = 113, } } @@ -1289,9 +1310,9 @@ pub type SignedExtra = ( pallet_transaction_payment::ChargeTransactionPayment, ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = fp_self_contained::UncheckedExtrinsic; /// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; +pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -1303,9 +1324,90 @@ pub type Executive = frame_executive::Executive< orml_asset_registry::Migration, orml_unknown_tokens::Migration, issue::migration::v1::Migration, + evm::SetEvmChainId, ), >; +impl fp_self_contained::SelfContainedCall for RuntimeCall { + type SignedInfo = H160; + + fn is_self_contained(&self) -> bool { + match self { + RuntimeCall::Ethereum(call) => call.is_self_contained(), + _ => false, + } + } + + fn check_self_contained(&self) -> Option> { + match self { + RuntimeCall::Ethereum(call) => match call { + pallet_ethereum::Call::transact { transaction } + if evm::GetTransactionAction::action(transaction) == TransactionAction::Create => + { + Some(Err(TransactionValidityError::Invalid(InvalidTransaction::Call))) + } + _ => call.check_self_contained(), + }, + _ => None, + } + } + + fn validate_self_contained( + &self, + info: &Self::SignedInfo, + dispatch_info: &DispatchInfoOf, + len: usize, + ) -> Option { + match self { + RuntimeCall::Ethereum(call) => call.validate_self_contained(info, dispatch_info, len), + _ => None, + } + } + + fn pre_dispatch_self_contained( + &self, + info: &Self::SignedInfo, + dispatch_info: &DispatchInfoOf, + len: usize, + ) -> Option> { + match self { + RuntimeCall::Ethereum(call) => call.pre_dispatch_self_contained(info, dispatch_info, len), + _ => None, + } + } + + fn apply_self_contained( + self, + info: Self::SignedInfo, + ) -> Option>> { + match self { + call @ RuntimeCall::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch( + RuntimeOrigin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)), + )), + _ => None, + } + } +} + +// TODO: remove clone +#[derive(Clone)] +pub struct TransactionConverter; + +impl fp_rpc::ConvertTransaction for TransactionConverter { + fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic { + UncheckedExtrinsic::new_unsigned(pallet_ethereum::Call::::transact { transaction }.into()) + } +} + +impl fp_rpc::ConvertTransaction for TransactionConverter { + fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> sp_runtime::OpaqueExtrinsic { + let extrinsic = + UncheckedExtrinsic::new_unsigned(pallet_ethereum::Call::::transact { transaction }.into()); + let encoded = extrinsic.encode(); + sp_runtime::OpaqueExtrinsic::decode(&mut &encoded[..]).expect("Encoded extrinsic is always valid") + } +} + #[cfg(feature = "runtime-benchmarks")] #[macro_use] extern crate frame_benchmarking; @@ -1887,6 +1989,180 @@ impl_runtime_apis! { Executive::try_execute_block(block, state_root_check, signature_check, select).expect("execute-block failed") } } + + impl fp_rpc::EthereumRuntimeRPCApi for Runtime { + fn chain_id() -> u64 { + ::ChainId::get() + } + + fn account_basic(address: H160) -> EVMAccount { + let (account, _) = pallet_evm::Pallet::::account_basic(&address); + account + } + + fn gas_price() -> U256 { + let (gas_price, _) = ::FeeCalculator::min_gas_price(); + gas_price + } + + fn account_code_at(address: H160) -> Vec { + pallet_evm::AccountCodes::::get(address) + } + + fn author() -> H160 { + >::find_author() + } + + fn storage_at(address: H160, index: U256) -> H256 { + let mut tmp = [0u8; 32]; + index.to_big_endian(&mut tmp); + pallet_evm::AccountStorages::::get(address, H256::from_slice(&tmp[..])) + } + + fn call( + from: H160, + to: H160, + data: Vec, + value: U256, + gas_limit: U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, + estimate: bool, + access_list: Option)>>, + ) -> Result { + let config = if estimate { + let mut config = ::config().clone(); + config.estimate = true; + Some(config) + } else { + None + }; + + let is_transactional = false; + let validate = true; + let evm_config = config.as_ref().unwrap_or(::config()); + ::Runner::call( + from, + to, + data, + value, + gas_limit.unique_saturated_into(), + max_fee_per_gas, + max_priority_fee_per_gas, + nonce, + access_list.unwrap_or_default(), + is_transactional, + validate, + // TODO we probably want to support external cost recording in non-transactional calls + None, + None, + evm_config, + ).map_err(|err| err.error.into()) + } + + fn create( + from: H160, + data: Vec, + value: U256, + gas_limit: U256, + max_fee_per_gas: Option, + max_priority_fee_per_gas: Option, + nonce: Option, + estimate: bool, + access_list: Option)>>, + ) -> Result { + let config = if estimate { + let mut config = ::config().clone(); + config.estimate = true; + Some(config) + } else { + None + }; + + let is_transactional = false; + let validate = true; + let evm_config = config.as_ref().unwrap_or(::config()); + ::Runner::create( + from, + data, + value, + gas_limit.unique_saturated_into(), + max_fee_per_gas, + max_priority_fee_per_gas, + nonce, + access_list.unwrap_or_default(), + is_transactional, + validate, + // TODO we probably want to support external cost recording in non-transactional calls + None, + None, + evm_config, + ).map_err(|err| err.error.into()) + } + + fn current_transaction_statuses() -> Option> { + pallet_ethereum::CurrentTransactionStatuses::::get() + } + + fn current_block() -> Option { + pallet_ethereum::CurrentBlock::::get() + } + + fn current_receipts() -> Option> { + pallet_ethereum::CurrentReceipts::::get() + } + + fn current_all() -> ( + Option, + Option>, + Option> + ) { + ( + pallet_ethereum::CurrentBlock::::get(), + pallet_ethereum::CurrentReceipts::::get(), + pallet_ethereum::CurrentTransactionStatuses::::get() + ) + } + + fn extrinsic_filter( + xts: Vec<::Extrinsic>, + ) -> Vec { + xts.into_iter().filter_map(|xt| match xt.0.function { + RuntimeCall::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction), + _ => None + }).collect::>() + } + + fn elasticity() -> Option { + Some(pallet_base_fee::Elasticity::::get()) + } + + fn gas_limit_multiplier_support() {} + + fn pending_block( + xts: Vec<::Extrinsic>, + ) -> (Option, Option>) { + for ext in xts.into_iter() { + let _ = Executive::apply_extrinsic(ext); + } + + Ethereum::on_finalize(System::block_number() + 1); + + ( + pallet_ethereum::CurrentBlock::::get(), + pallet_ethereum::CurrentTransactionStatuses::::get() + ) + } + } + + impl fp_rpc::ConvertTransactionRuntimeApi for Runtime { + fn convert_transaction(transaction: EthereumTransaction) -> ::Extrinsic { + UncheckedExtrinsic::new_unsigned( + pallet_ethereum::Call::::transact { transaction }.into(), + ) + } + } } struct CheckInherents; diff --git a/parachain/src/chain_spec/interlay.rs b/parachain/src/chain_spec/interlay.rs index 132131b034..20afbb4615 100644 --- a/parachain/src/chain_spec/interlay.rs +++ b/parachain/src/chain_spec/interlay.rs @@ -133,6 +133,7 @@ pub fn interlay_genesis( id: ParaId, bitcoin_confirmations: u32, ) -> interlay_runtime::GenesisConfig { + let chain_id: u32 = id.into(); interlay_runtime::GenesisConfig { system: interlay_runtime::SystemConfig { code: interlay_runtime::WASM_BINARY @@ -242,5 +243,11 @@ pub fn interlay_genesis( max_exchange_rate: Rate::from_inner(loans::DEFAULT_MAX_EXCHANGE_RATE), min_exchange_rate: Rate::from_inner(loans::DEFAULT_MIN_EXCHANGE_RATE), }, + base_fee: Default::default(), + ethereum: Default::default(), + evm: Default::default(), + evm_chain_id: kintsugi_runtime::EVMChainIdConfig { + chain_id: chain_id.into(), + }, } } diff --git a/parachain/src/chain_spec/kintsugi.rs b/parachain/src/chain_spec/kintsugi.rs index c98820e118..e18fccac70 100644 --- a/parachain/src/chain_spec/kintsugi.rs +++ b/parachain/src/chain_spec/kintsugi.rs @@ -137,6 +137,7 @@ pub fn kintsugi_genesis( id: ParaId, bitcoin_confirmations: u32, ) -> kintsugi_runtime::GenesisConfig { + let chain_id: u32 = id.into(); kintsugi_runtime::GenesisConfig { system: kintsugi_runtime::SystemConfig { code: kintsugi_runtime::WASM_BINARY @@ -270,5 +271,11 @@ pub fn kintsugi_genesis( max_exchange_rate: Rate::from_inner(loans::DEFAULT_MAX_EXCHANGE_RATE), min_exchange_rate: Rate::from_inner(loans::DEFAULT_MIN_EXCHANGE_RATE), }, + base_fee: Default::default(), + ethereum: Default::default(), + evm: Default::default(), + evm_chain_id: kintsugi_runtime::EVMChainIdConfig { + chain_id: chain_id.into(), + }, } } diff --git a/parachain/src/cli.rs b/parachain/src/cli.rs index 349ab59f13..f6aaad6011 100644 --- a/parachain/src/cli.rs +++ b/parachain/src/cli.rs @@ -1,7 +1,7 @@ use clap::Parser; use std::path::PathBuf; -use crate::chain_spec; +use crate::{chain_spec, eth::EthConfiguration}; /// Sub-commands supported by the collator. #[derive(Debug, Parser)] @@ -87,6 +87,9 @@ pub struct Cli { #[clap(flatten)] pub run: cumulus_client_cli::RunCmd, + #[clap(flatten)] + pub eth: EthConfiguration, + /// Relaychain arguments #[clap(raw = true)] pub relaychain_args: Vec, diff --git a/parachain/src/command.rs b/parachain/src/command.rs index 9bbb21f0e7..750de33051 100644 --- a/parachain/src/command.rs +++ b/parachain/src/command.rs @@ -455,7 +455,7 @@ pub fn run() -> Result<()> { runner .run_node_until_exit(|config| async move { if cli.instant_seal { - start_instant(config).await + start_instant(cli, config).await } else { start_node(cli, config).await } @@ -465,10 +465,10 @@ pub fn run() -> Result<()> { } } -async fn start_instant(config: Configuration) -> sc_service::error::Result { +async fn start_instant(cli: Cli, config: Configuration) -> sc_service::error::Result { with_runtime_or_err!(config.chain_spec, { { - crate::service::start_instant::(config) + crate::service::start_instant::(config, cli.eth) .await .map(|r| r.0) .map_err(Into::into) @@ -505,7 +505,7 @@ async fn start_node(cli: Cli, config: Configuration) -> sc_service::error::Resul with_runtime_or_err!(config.chain_spec, { { - crate::service::start_node::(config, polkadot_config, collator_options, id) + crate::service::start_node::(config, polkadot_config, cli.eth, collator_options, id) .await .map(|r| r.0) .map_err(Into::into) diff --git a/parachain/src/eth.rs b/parachain/src/eth.rs new file mode 100644 index 0000000000..1baf6b67dc --- /dev/null +++ b/parachain/src/eth.rs @@ -0,0 +1,262 @@ +use cumulus_client_consensus_common::ParachainBlockImportMarker; +pub use fc_consensus::FrontierBlockImport; +use fc_rpc::{EthTask, OverrideHandle}; +pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; +use fp_rpc::EthereumRuntimeRPCApi; +use futures::{future, prelude::*}; +use sc_client_api::{BlockchainEvents, StateBackendFor}; +use sc_consensus::{BlockCheckParams, BlockImport as BlockImportT, BlockImportParams, ImportResult}; +use sc_executor::NativeExecutionDispatch; +use sc_network_sync::SyncingService; +use sc_service::{error::Error as ServiceError, BasePath, Configuration, TaskManager}; +use sp_api::{ConstructRuntimeApi, ProvideRuntimeApi}; +use sp_block_builder::BlockBuilder as BlockBuilderApi; +use sp_consensus::Error as ConsensusError; +use sp_runtime::traits::{BlakeTwo256, Block as BlockT}; +use std::{ + collections::BTreeMap, + path::PathBuf, + sync::{Arc, Mutex}, + time::Duration, +}; + +use crate::service::{FullBackend, FullClient}; +use primitives::Block; + +/// Frontier DB backend type. +pub type FrontierBackend = fc_db::Backend; + +pub fn db_config_dir(config: &Configuration) -> PathBuf { + let application = &config.impl_name; + config + .base_path + .as_ref() + .map(|base_path| base_path.config_dir(config.chain_spec.id())) + .unwrap_or_else(|| BasePath::from_project("", "", application).config_dir(config.chain_spec.id())) +} + +pub fn open_frontier_backend(client: Arc, config: &Configuration) -> Result +where + C: sc_client_api::HeaderBackend, +{ + Ok(FrontierBackend::KeyValue(fc_db::kv::Backend::open( + Arc::clone(&client), + &config.database, + &db_config_dir(config), + )?)) +} + +/// Available frontier backend types. +#[derive(Debug, Copy, Clone, Default, clap::ValueEnum)] +pub enum BackendType { + /// Either RocksDb or ParityDb as per inherited from the global backend settings. + #[default] + KeyValue, + /// Sql database with custom log indexing. + Sql, +} + +/// The ethereum-compatibility configuration used to run a node. +#[derive(Clone, Debug, clap::Parser)] +pub struct EthConfiguration { + /// Maximum number of logs in a query. + #[arg(long, default_value = "10000")] + pub max_past_logs: u32, + + /// Maximum fee history cache size. + #[arg(long, default_value = "2048")] + pub fee_history_limit: u64, + + #[arg(long)] + pub enable_dev_signer: bool, + + /// The dynamic-fee pallet target gas price set by block author + #[arg(long, default_value = "1")] + pub target_gas_price: u64, + + /// Maximum allowed gas limit will be `block.gas_limit * execute_gas_limit_multiplier` + /// when using eth_call/eth_estimateGas. + #[arg(long, default_value = "10")] + pub execute_gas_limit_multiplier: u64, + + /// Size in bytes of the LRU cache for block data. + #[arg(long, default_value = "50")] + pub eth_log_block_cache: usize, + + /// Size in bytes of the LRU cache for transactions statuses data. + #[arg(long, default_value = "50")] + pub eth_statuses_cache: usize, + + /// Sets the frontier backend type (KeyValue or Sql) + #[arg(long, value_enum, ignore_case = true, default_value_t = BackendType::default())] + pub frontier_backend_type: BackendType, + + // Sets the SQL backend's pool size. + #[arg(long, default_value = "100")] + pub frontier_sql_backend_pool_size: u32, + + /// Sets the SQL backend's query timeout in number of VM ops. + #[arg(long, default_value = "10000000")] + pub frontier_sql_backend_num_ops_timeout: u32, + + /// Sets the SQL backend's auxiliary thread limit. + #[arg(long, default_value = "4")] + pub frontier_sql_backend_thread_count: u32, + + /// Sets the SQL backend's query timeout in number of VM ops. + /// Default value is 200MB. + #[arg(long, default_value = "209715200")] + pub frontier_sql_backend_cache_size: u64, +} + +pub struct FrontierPartialComponents { + pub filter_pool: Option, + pub fee_history_cache: FeeHistoryCache, + pub fee_history_cache_limit: FeeHistoryCacheLimit, +} + +pub fn new_frontier_partial(config: &EthConfiguration) -> Result { + Ok(FrontierPartialComponents { + filter_pool: Some(Arc::new(Mutex::new(BTreeMap::new()))), + fee_history_cache: Arc::new(Mutex::new(BTreeMap::new())), + fee_history_cache_limit: config.fee_history_limit, + }) +} + +/// A set of APIs that ethereum-compatible runtimes must implement. +pub trait EthCompatRuntimeApiCollection: + sp_api::ApiExt + fp_rpc::ConvertTransactionRuntimeApi + fp_rpc::EthereumRuntimeRPCApi +where + >::StateBackend: sp_api::StateBackend, +{ +} + +impl EthCompatRuntimeApiCollection for Api +where + Api: sp_api::ApiExt + fp_rpc::ConvertTransactionRuntimeApi + fp_rpc::EthereumRuntimeRPCApi, + >::StateBackend: sp_api::StateBackend, +{ +} + +pub async fn spawn_frontier_tasks( + task_manager: &TaskManager, + client: Arc>, + backend: Arc, + frontier_backend: FrontierBackend, + filter_pool: Option, + overrides: Arc>, + fee_history_cache: FeeHistoryCache, + fee_history_cache_limit: FeeHistoryCacheLimit, + sync: Arc>, + pubsub_notification_sinks: Arc< + fc_mapping_sync::EthereumBlockNotificationSinks>, + >, +) where + RuntimeApi: ConstructRuntimeApi>, + RuntimeApi: Send + Sync + 'static, + RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection>, + Executor: NativeExecutionDispatch + 'static, +{ + // Spawn main mapping sync worker background task. + match frontier_backend { + fc_db::Backend::KeyValue(b) => { + task_manager.spawn_essential_handle().spawn( + "frontier-mapping-sync-worker", + Some("frontier"), + fc_mapping_sync::kv::MappingSyncWorker::new( + client.import_notification_stream(), + Duration::new(6, 0), + client.clone(), + backend, + overrides.clone(), + Arc::new(b), + 3, + 0, + fc_mapping_sync::SyncStrategy::Normal, + sync, + pubsub_notification_sinks, + ) + .for_each(|()| future::ready(())), + ); + } + fc_db::Backend::Sql(b) => { + task_manager.spawn_essential_handle().spawn_blocking( + "frontier-mapping-sync-worker", + Some("frontier"), + fc_mapping_sync::sql::SyncWorker::run( + client.clone(), + backend, + Arc::new(b), + client.import_notification_stream(), + fc_mapping_sync::sql::SyncWorkerConfig { + read_notification_timeout: Duration::from_secs(10), + check_indexed_blocks_interval: Duration::from_secs(60), + }, + fc_mapping_sync::SyncStrategy::Parachain, + sync, + pubsub_notification_sinks, + ), + ); + } + } + + // Spawn Frontier EthFilterApi maintenance task. + if let Some(filter_pool) = filter_pool { + // Each filter is allowed to stay in the pool for 100 blocks. + const FILTER_RETAIN_THRESHOLD: u64 = 100; + task_manager.spawn_essential_handle().spawn( + "frontier-filter-pool", + Some("frontier"), + EthTask::filter_pool_task(client.clone(), filter_pool, FILTER_RETAIN_THRESHOLD), + ); + } + + // Spawn Frontier FeeHistory cache maintenance task. + task_manager.spawn_essential_handle().spawn( + "frontier-fee-history", + Some("frontier"), + EthTask::fee_history_task(client, overrides, fee_history_cache, fee_history_cache_limit), + ); +} + +#[derive(Clone)] +pub struct BlockImport, C>(FrontierBlockImport); + +impl BlockImport +where + B: BlockT, + I: BlockImportT>, + I::Error: Into, + C: ProvideRuntimeApi, + C::Api: BlockBuilderApi + EthereumRuntimeRPCApi, +{ + pub fn new(inner: I, client: Arc) -> Self { + Self(FrontierBlockImport::new(inner, client)) + } +} + +#[async_trait::async_trait] +impl BlockImportT for BlockImport +where + B: BlockT, + I: BlockImportT> + Send + Sync, + I::Error: Into, + C: ProvideRuntimeApi + Send + Sync, + C::Api: BlockBuilderApi + EthereumRuntimeRPCApi, +{ + type Error = ConsensusError; + type Transaction = sp_api::TransactionFor; + + async fn check_block(&mut self, block: BlockCheckParams) -> Result { + self.0.check_block(block).await + } + + async fn import_block( + &mut self, + block: BlockImportParams, + ) -> Result { + self.0.import_block(block).await + } +} + +impl, C> ParachainBlockImportMarker for BlockImport {} diff --git a/parachain/src/lib.rs b/parachain/src/lib.rs index 38e43372ca..5a048e9d6d 100644 --- a/parachain/src/lib.rs +++ b/parachain/src/lib.rs @@ -1,2 +1,4 @@ pub mod chain_spec; pub mod service; + +mod eth; diff --git a/parachain/src/main.rs b/parachain/src/main.rs index df8e9fffe1..b5e880fa4b 100644 --- a/parachain/src/main.rs +++ b/parachain/src/main.rs @@ -5,6 +5,7 @@ mod chain_spec; #[macro_use] mod cli; mod command; +mod eth; mod service; #[cfg(feature = "runtime-benchmarks")] diff --git a/parachain/src/service.rs b/parachain/src/service.rs index 37426d8e21..341b8cb9e9 100644 --- a/parachain/src/service.rs +++ b/parachain/src/service.rs @@ -13,7 +13,7 @@ use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node; use futures::StreamExt; use polkadot_service::CollatorPair; use primitives::*; -use sc_client_api::HeaderBackend; +use sc_client_api::{HeaderBackend, StateBackendFor}; use sc_consensus::{ImportQueue, LongestChain}; use sc_executor::NativeElseWasmExecutor; use sc_network::NetworkBlock; @@ -30,6 +30,12 @@ use sp_runtime::traits::BlakeTwo256; use std::{sync::Arc, time::Duration}; use substrate_prometheus_endpoint::Registry; +// Frontier imports +use crate::eth::{ + new_frontier_partial, open_frontier_backend, spawn_frontier_tasks, BlockImport as EthBlockImport, + EthCompatRuntimeApiCollection, EthConfiguration, FrontierBackend, FrontierPartialComponents, +}; + macro_rules! new_runtime_executor { ($name:ident,$runtime:ident) => { pub struct $name; @@ -54,13 +60,33 @@ new_runtime_executor!(InterlayRuntimeExecutor, interlay_runtime); // Native kintsugi executor instance. new_runtime_executor!(KintsugiRuntimeExecutor, kintsugi_runtime); -pub trait RuntimeApiCollection: - sp_transaction_pool::runtime_api::TaggedTransactionQueue +/// A set of APIs that every runtime must implement. +pub trait BaseRuntimeApiCollection: + sp_api::ApiExt + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt, Block>> - + sp_offchain::OffchainWorkerApi + sp_block_builder::BlockBuilder + + sp_offchain::OffchainWorkerApi + + sp_session::SessionKeys + + sp_transaction_pool::runtime_api::TaggedTransactionQueue +where + >::StateBackend: sp_api::StateBackend, +{ +} + +impl BaseRuntimeApiCollection for Api +where + Api: sp_api::ApiExt + + sp_api::Metadata + + sp_block_builder::BlockBuilder + + sp_offchain::OffchainWorkerApi + + sp_session::SessionKeys + + sp_transaction_pool::runtime_api::TaggedTransactionQueue, + >::StateBackend: sp_api::StateBackend, +{ +} +pub trait RuntimeApiCollection: + BaseRuntimeApiCollection + + EthCompatRuntimeApiCollection + substrate_frame_rpc_system::AccountNonceApi + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + cumulus_primitives_core::CollectCollationInfo @@ -107,12 +133,8 @@ where impl RuntimeApiCollection for Api where - Api: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt, Block>> - + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder + Api: BaseRuntimeApiCollection + + EthCompatRuntimeApiCollection + substrate_frame_rpc_system::AccountNonceApi + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi + cumulus_primitives_core::CollectCollationInfo @@ -156,10 +178,10 @@ where { } -type FullBackend = TFullBackend; +pub(crate) type FullBackend = TFullBackend; -type FullClient = - sc_service::TFullClient>; +pub(crate) type FullClient = + TFullClient>; type MaybeFullSelectChain = Option>; @@ -198,18 +220,19 @@ pub fn new_partial( instant_seal: bool, ) -> Result< PartialComponents< - TFullClient>, - TFullBackend, + FullClient, + FullBackend, MaybeFullSelectChain, - sc_consensus::DefaultImportQueue>>, - sc_transaction_pool::FullPool>>, - (Option, Option), + sc_consensus::DefaultImportQueue>, + sc_transaction_pool::FullPool>, + (Option, Option, FrontierBackend), >, sc_service::Error, > where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, - RuntimeApi::RuntimeApi: RuntimeApiCollection>, + RuntimeApi::RuntimeApi: BaseRuntimeApiCollection>, + RuntimeApi::RuntimeApi: EthCompatRuntimeApiCollection>, RuntimeApi::RuntimeApi: sp_consensus_aura::AuraApi, Executor: sc_executor::NativeExecutionDispatch + 'static, { @@ -261,10 +284,12 @@ where None }; + let frontier_backend = open_frontier_backend(client.clone(), config)?; + let import_queue = if instant_seal { - // instance sealing + // instant sealing sc_consensus_manual_seal::import_queue( - Box::new(client.clone()), + Box::new(EthBlockImport::new(client.clone(), client.clone())), &task_manager.spawn_essential_handle(), registry, ) @@ -273,7 +298,10 @@ where cumulus_client_consensus_aura::import_queue::( cumulus_client_consensus_aura::ImportQueueParams { - block_import: ParachainBlockImport::new(client.clone(), backend.clone()), + block_import: EthBlockImport::new( + ParachainBlockImport::new(client.clone(), backend.clone()), + client.clone(), + ), client: client.clone(), create_inherent_data_providers: move |_parent: sp_core::H256, _| async move { let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); @@ -300,7 +328,7 @@ where task_manager, transaction_pool, select_chain, - other: (telemetry, telemetry_worker_handle), + other: (telemetry, telemetry_worker_handle, frontier_backend), }; Ok(params) @@ -333,6 +361,7 @@ async fn build_relay_chain_interface( async fn start_node_impl( parachain_config: Configuration, polkadot_config: Configuration, + eth_config: EthConfiguration, collator_options: CollatorOptions, id: ParaId, build_consensus: BIC, @@ -344,7 +373,7 @@ where Executor: sc_executor::NativeExecutionDispatch + 'static, BIC: FnOnce( Arc>, - ParachainBlockImport, + EthBlockImport, FullClient>, Option<&Registry>, Option, &TaskManager, @@ -355,10 +384,16 @@ where bool, ) -> Result>, sc_service::Error>, { - let parachain_config = prepare_node_config(parachain_config); + let mut parachain_config = prepare_node_config(parachain_config); let params = new_partial(¶chain_config, false)?; - let (mut telemetry, telemetry_worker_handle) = params.other; + let (mut telemetry, telemetry_worker_handle, frontier_backend) = params.other; + + let FrontierPartialComponents { + filter_pool, + fee_history_cache, + fee_history_cache_limit, + } = new_frontier_partial(ð_config)?; let client = params.client.clone(); let backend = params.backend.clone(); @@ -392,19 +427,57 @@ where warp_sync_params: None, })?; + let pubsub_notification_sinks: fc_mapping_sync::EthereumBlockNotificationSinks< + fc_mapping_sync::EthereumBlockNotification, + > = Default::default(); + let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks); + let overrides = interbtc_rpc::overrides_handle(client.clone()); + parachain_config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider)); + let eth_rpc_params = interbtc_rpc::EthDeps { + client: client.clone(), + pool: transaction_pool.clone(), + graph: transaction_pool.pool().clone(), + converter: Some(kintsugi_runtime::TransactionConverter), // TODO: fix this + is_authority: parachain_config.role.is_authority(), + enable_dev_signer: eth_config.enable_dev_signer, + network: network.clone(), + sync: sync_service.clone(), + frontier_backend: match frontier_backend.clone() { + fc_db::Backend::KeyValue(b) => Arc::new(b), + fc_db::Backend::Sql(b) => Arc::new(b), + }, + overrides: overrides.clone(), + block_data_cache: Arc::new(fc_rpc::EthBlockDataCacheTask::new( + task_manager.spawn_handle(), + overrides.clone(), + eth_config.eth_log_block_cache, + eth_config.eth_statuses_cache, + prometheus_registry.clone(), + )), + filter_pool: filter_pool.clone(), + max_past_logs: eth_config.max_past_logs, + fee_history_cache: fee_history_cache.clone(), + fee_history_cache_limit, + execute_gas_limit_multiplier: eth_config.execute_gas_limit_multiplier, + forced_parent_hashes: None, + }; + let rpc_builder = { let client = client.clone(); let transaction_pool = transaction_pool.clone(); + let pubsub_notification_sinks = pubsub_notification_sinks.clone(); - move |deny_unsafe, _| { + move |deny_unsafe, subscription_task_executor| { let deps = interbtc_rpc::FullDeps { client: client.clone(), pool: transaction_pool.clone(), deny_unsafe, command_sink: None, + eth: eth_rpc_params.clone(), }; - interbtc_rpc::create_full(deps).map_err(Into::into) + interbtc_rpc::create_full(deps, subscription_task_executor, pubsub_notification_sinks.clone()) + .map_err(Into::into) } }; @@ -432,6 +505,20 @@ where sync_service: sync_service.clone(), })?; + spawn_frontier_tasks( + &task_manager, + client.clone(), + backend.clone(), + frontier_backend, + filter_pool, + overrides, + fee_history_cache, + fee_history_cache_limit, + sync_service.clone(), + pubsub_notification_sinks, + ) + .await; + let announce_block = { let sync_service = sync_service.clone(); Arc::new(move |hash, data| sync_service.announce_block(hash, data)) @@ -446,7 +533,10 @@ where if validator { let parachain_consensus = build_consensus( client.clone(), - ParachainBlockImport::new(client.clone(), backend.clone()), + EthBlockImport::new( + ParachainBlockImport::new(client.clone(), backend.clone()), + client.clone(), + ), prometheus_registry.as_ref(), telemetry.as_ref().map(|t| t.handle()), &task_manager, @@ -501,6 +591,7 @@ where pub async fn start_node( parachain_config: Configuration, polkadot_config: Configuration, + eth_config: EthConfiguration, collator_options: CollatorOptions, id: ParaId, ) -> sc_service::error::Result<(TaskManager, Arc>)> @@ -513,6 +604,7 @@ where start_node_impl( parachain_config, polkadot_config, + eth_config, collator_options, id, |client, @@ -589,7 +681,8 @@ where } pub async fn start_instant( - config: Configuration, + mut config: Configuration, + eth_config: EthConfiguration, ) -> sc_service::error::Result<(TaskManager, RpcHandlers)> where RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, @@ -605,9 +698,15 @@ where keystore_container, select_chain: maybe_select_chain, transaction_pool, - other: (mut telemetry, _), + other: (mut telemetry, _telemetry_worker_handle, frontier_backend), } = new_partial::(&config, true)?; + let FrontierPartialComponents { + filter_pool, + fee_history_cache, + fee_history_cache_limit, + } = new_frontier_partial(ð_config)?; + let (network, system_rpc_tx, tx_handler_controller, network_starter, sync_service) = sc_service::build_network(sc_service::BuildNetworkParams { config: &config, @@ -654,7 +753,7 @@ where let client_for_cidp = client.clone(); let authorship_future = sc_consensus_manual_seal::run_manual_seal(sc_consensus_manual_seal::ManualSealParams { - block_import: client.clone(), + block_import: EthBlockImport::new(client.clone(), client.clone()), env: proposer_factory, client: client.clone(), pool: transaction_pool.clone(), @@ -693,19 +792,57 @@ where None }; + let pubsub_notification_sinks: fc_mapping_sync::EthereumBlockNotificationSinks< + fc_mapping_sync::EthereumBlockNotification, + > = Default::default(); + let pubsub_notification_sinks = Arc::new(pubsub_notification_sinks); + let overrides = interbtc_rpc::overrides_handle(client.clone()); + config.rpc_id_provider = Some(Box::new(fc_rpc::EthereumSubIdProvider)); + let eth_rpc_params = interbtc_rpc::EthDeps { + client: client.clone(), + pool: transaction_pool.clone(), + graph: transaction_pool.pool().clone(), + converter: Some(kintsugi_runtime::TransactionConverter), // TODO: fix this + is_authority: config.role.is_authority(), + enable_dev_signer: eth_config.enable_dev_signer, + network: network.clone(), + sync: sync_service.clone(), + frontier_backend: match frontier_backend.clone() { + fc_db::Backend::KeyValue(b) => Arc::new(b), + fc_db::Backend::Sql(b) => Arc::new(b), + }, + overrides: overrides.clone(), + block_data_cache: Arc::new(fc_rpc::EthBlockDataCacheTask::new( + task_manager.spawn_handle(), + overrides.clone(), + eth_config.eth_log_block_cache, + eth_config.eth_statuses_cache, + prometheus_registry.clone(), + )), + filter_pool: filter_pool.clone(), + max_past_logs: eth_config.max_past_logs, + fee_history_cache: fee_history_cache.clone(), + fee_history_cache_limit, + execute_gas_limit_multiplier: eth_config.execute_gas_limit_multiplier, + forced_parent_hashes: None, + }; + let rpc_builder = { let client = client.clone(); let transaction_pool = transaction_pool.clone(); + let pubsub_notification_sinks = pubsub_notification_sinks.clone(); - move |deny_unsafe, _| { + move |deny_unsafe, subscription_task_executor| { let deps = interbtc_rpc::FullDeps { client: client.clone(), pool: transaction_pool.clone(), deny_unsafe, command_sink: command_sink.clone(), + eth: eth_rpc_params.clone(), }; - interbtc_rpc::create_full(deps).map_err(Into::into) + interbtc_rpc::create_full(deps, subscription_task_executor, pubsub_notification_sinks.clone()) + .map_err(Into::into) } }; @@ -716,14 +853,28 @@ where task_manager: &mut task_manager, config, keystore: keystore_container.keystore(), - backend, + backend: backend.clone(), network, system_rpc_tx, tx_handler_controller, telemetry: telemetry.as_mut(), - sync_service, + sync_service: sync_service.clone(), })?; + spawn_frontier_tasks( + &task_manager, + client.clone(), + backend, + frontier_backend, + filter_pool, + overrides, + fee_history_cache, + fee_history_cache_limit, + sync_service.clone(), + pubsub_notification_sinks, + ) + .await; + network_starter.start_network(); Ok((task_manager, rpc_handlers)) diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 85aa0213e9..f09ee2ea4d 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -37,3 +37,17 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "pol pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } substrate-frame-rpc-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } + +# Ethereum +sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-network-sync = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sc-transaction-pool = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } +sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } + +fc-db = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fc-mapping-sync = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fc-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fc-rpc-core = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fc-storage = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } +fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.42" } \ No newline at end of file diff --git a/rpc/src/eth.rs b/rpc/src/eth.rs new file mode 100644 index 0000000000..5e264624eb --- /dev/null +++ b/rpc/src/eth.rs @@ -0,0 +1,198 @@ +pub use fc_rpc::{EthBlockDataCacheTask, EthConfig, OverrideHandle, StorageOverride, TxPool}; +pub use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool}; +pub use fc_storage::overrides_handle; +use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi}; +use jsonrpsee::RpcModule; +use sc_client_api::{ + backend::{Backend, StorageProvider}, + client::BlockchainEvents, +}; +use sc_network::NetworkService; +use sc_network_sync::SyncingService; +use sc_rpc::SubscriptionTaskExecutor; +use sc_transaction_pool::{ChainApi, Pool}; +use sc_transaction_pool_api::TransactionPool; +use sp_api::{CallApiAt, ProvideRuntimeApi}; +use sp_block_builder::BlockBuilder as BlockBuilderApi; +use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; +use sp_core::H256; +use sp_runtime::traits::Block as BlockT; +use std::{collections::BTreeMap, sync::Arc}; + +/// Extra dependencies for Ethereum compatibility. +pub struct EthDeps { + /// The client instance to use. + pub client: Arc, + /// Transaction pool instance. + pub pool: Arc

, + /// Graph pool instance. + pub graph: Arc>, + /// Ethereum transaction converter. + pub converter: Option, + /// The Node authority flag + pub is_authority: bool, + /// Whether to enable dev signer + pub enable_dev_signer: bool, + /// Network service + pub network: Arc>, + /// Chain syncing service + pub sync: Arc>, + /// Frontier Backend. + pub frontier_backend: Arc + Send + Sync>, + /// Ethereum data access overrides. + pub overrides: Arc>, + /// Cache for Ethereum block data. + pub block_data_cache: Arc>, + /// EthFilterApi pool. + pub filter_pool: Option, + /// Maximum number of logs in a query. + pub max_past_logs: u32, + /// Fee history cache. + pub fee_history_cache: FeeHistoryCache, + /// Maximum fee history cache size. + pub fee_history_cache_limit: FeeHistoryCacheLimit, + /// Maximum allowed gas limit will be ` block.gas_limit * execute_gas_limit_multiplier` when + /// using eth_call/eth_estimateGas. + pub execute_gas_limit_multiplier: u64, + /// Mandated parent hashes for a given block hash. + pub forced_parent_hashes: Option>, +} + +impl Clone for EthDeps { + fn clone(&self) -> Self { + Self { + client: self.client.clone(), + pool: self.pool.clone(), + graph: self.graph.clone(), + converter: self.converter.clone(), + is_authority: self.is_authority, + enable_dev_signer: self.enable_dev_signer, + network: self.network.clone(), + sync: self.sync.clone(), + frontier_backend: self.frontier_backend.clone(), + overrides: self.overrides.clone(), + block_data_cache: self.block_data_cache.clone(), + filter_pool: self.filter_pool.clone(), + max_past_logs: self.max_past_logs, + fee_history_cache: self.fee_history_cache.clone(), + fee_history_cache_limit: self.fee_history_cache_limit, + execute_gas_limit_multiplier: self.execute_gas_limit_multiplier, + forced_parent_hashes: self.forced_parent_hashes.clone(), + } + } +} + +/// Instantiate Ethereum-compatible RPC extensions. +pub fn create_eth>( + mut io: RpcModule<()>, + deps: EthDeps, + subscription_task_executor: SubscriptionTaskExecutor, + pubsub_notification_sinks: Arc< + fc_mapping_sync::EthereumBlockNotificationSinks>, + >, +) -> Result, Box> +where + B: BlockT, + C: CallApiAt + ProvideRuntimeApi, + C::Api: BlockBuilderApi + ConvertTransactionRuntimeApi + EthereumRuntimeRPCApi, + C: BlockchainEvents + 'static, + C: HeaderBackend + HeaderMetadata + StorageProvider, + BE: Backend + 'static, + P: TransactionPool + 'static, + A: ChainApi + 'static, + CT: ConvertTransaction<::Extrinsic> + Send + Sync + 'static, +{ + use fc_rpc::{ + Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub, EthPubSubApiServer, EthSigner, Net, + NetApiServer, TxPoolApiServer, Web3, Web3ApiServer, + }; + + let EthDeps { + client, + pool, + graph, + converter, + is_authority, + enable_dev_signer, + network, + sync, + frontier_backend, + overrides, + block_data_cache, + filter_pool, + max_past_logs, + fee_history_cache, + fee_history_cache_limit, + execute_gas_limit_multiplier, + forced_parent_hashes, + } = deps; + + let mut signers = Vec::new(); + if enable_dev_signer { + signers.push(Box::new(EthDevSigner::new()) as Box); + } + + io.merge( + Eth::new( + client.clone(), + pool.clone(), + graph.clone(), + converter, + sync.clone(), + signers, + overrides.clone(), + frontier_backend.clone(), + is_authority, + block_data_cache.clone(), + fee_history_cache, + fee_history_cache_limit, + execute_gas_limit_multiplier, + forced_parent_hashes, + ) + .replace_config::() + .into_rpc(), + )?; + + let tx_pool = TxPool::new(client.clone(), graph); + if let Some(filter_pool) = filter_pool { + io.merge( + EthFilter::new( + client.clone(), + frontier_backend, + tx_pool.clone(), + filter_pool, + 500_usize, // max stored filters + max_past_logs, + block_data_cache, + ) + .into_rpc(), + )?; + } + + io.merge( + EthPubSub::new( + pool, + client.clone(), + sync, + subscription_task_executor, + overrides, + pubsub_notification_sinks, + ) + .into_rpc(), + )?; + + io.merge( + Net::new( + client.clone(), + network, + // Whether to format the `peer_count` response as Hex (default) or not. + true, + ) + .into_rpc(), + )?; + + io.merge(Web3::new(client).into_rpc())?; + io.merge(tx_pool.into_rpc())?; + + Ok(io) +} diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 5f365a6862..764a7f69e8 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -3,8 +3,6 @@ //! used by Substrate nodes. This file extends those RPC definitions with //! capabilities that are specific to this project's runtime configuration. -#![warn(missing_docs)] - use primitives::{ issue::IssueRequest, redeem::RedeemRequest, replace::ReplaceRequest, AccountId, Balance, Block, BlockNumber, CurrencyId, H256Le, Hash, Nonce, StablePoolId, VaultId, @@ -19,13 +17,21 @@ use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata}; use sp_core::H256; use std::sync::Arc; -pub use jsonrpsee; +// Frontier imports +use sc_client_api::{backend::Backend, client::BlockchainEvents, StorageProvider}; +use sc_rpc::SubscriptionTaskExecutor; +use sc_transaction_pool::ChainApi; +use sp_api::CallApiAt; +use sp_runtime::traits::Block as BlockT; + +pub mod eth; +pub use self::eth::{create_eth, overrides_handle, EthDeps}; /// A type representing all RPC extensions. pub type RpcExtension = jsonrpsee::RpcModule<()>; /// Full client dependencies. -pub struct FullDeps { +pub struct FullDeps { /// The client instance to use. pub client: Arc, /// Transaction pool instance. @@ -34,14 +40,37 @@ pub struct FullDeps { pub deny_unsafe: DenyUnsafe, /// Manual seal command sink pub command_sink: Option>>, + /// Ethereum-compatibility specific dependencies. + pub eth: EthDeps, +} + +pub struct DefaultEthConfig(std::marker::PhantomData<(C, BE)>); + +impl fc_rpc::EthConfig for DefaultEthConfig +where + C: sc_client_api::StorageProvider + Sync + Send + 'static, + BE: Backend + 'static, +{ + type EstimateGasAdapter = (); + type RuntimeStorageOverride = fc_rpc::frontier_backend_client::SystemAccountId20StorageOverride; } /// Instantiate all full RPC extensions. -pub fn create_full(deps: FullDeps) -> Result> +pub fn create_full( + deps: FullDeps, + subscription_task_executor: SubscriptionTaskExecutor, + pubsub_notification_sinks: Arc< + fc_mapping_sync::EthereumBlockNotificationSinks>, + >, +) -> Result> where - C: ProvideRuntimeApi, - C: HeaderBackend + HeaderMetadata + 'static, + C: CallApiAt + ProvideRuntimeApi, + C: BlockchainEvents, + C: HeaderBackend + HeaderMetadata + StorageProvider, C: Send + Sync + 'static, + C::Api: BlockBuilder, + C::Api: fp_rpc::ConvertTransactionRuntimeApi, + C::Api: fp_rpc::EthereumRuntimeRPCApi, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: btc_relay_rpc::BtcRelayRuntimeApi, @@ -81,8 +110,10 @@ where C::Api: loans_rpc::LoansRuntimeApi, C::Api: dex_general_rpc::DexGeneralRuntimeApi, C::Api: dex_stable_rpc::DexStableRuntimeApi, - C::Api: BlockBuilder, - P: TransactionPool + 'static, + P: TransactionPool + 'static, + BE: Backend + 'static, + A: ChainApi + 'static, + CT: fp_rpc::ConvertTransaction<::Extrinsic> + Send + Sync + 'static, { use btc_relay_rpc::{BtcRelay, BtcRelayApiServer}; use dex_general_rpc::{DexGeneral, DexGeneralApiServer}; @@ -104,6 +135,7 @@ where pool, deny_unsafe, command_sink, + eth, } = deps; if let Some(command_sink) = command_sink { @@ -114,6 +146,14 @@ where )?; } + // Ethereum compatibility RPCs + let mut module = create_eth::<_, _, _, _, _, _, DefaultEthConfig>( + module, + eth, + subscription_task_executor, + pubsub_notification_sinks, + )?; + module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?;