diff --git a/Cargo.lock b/Cargo.lock index a68c3b47f81c5..4b8737237060e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,9 +257,9 @@ dependencies = [ [[package]] name = "async-io" -version = "1.1.10" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54bc4c1c7292475efb2253227dbcfad8fe1ca4c02bc62c510cc2f3da5c4704e" +checksum = "9315f8f07556761c3e48fec2e6b276004acf426e6dc068b2c2251854d65ee0fd" dependencies = [ "concurrent-queue", "fastrand", @@ -319,15 +319,15 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-tls" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d85a97c4a0ecce878efd3f945f119c78a646d8975340bca0398f9bb05c30cc52" +checksum = "2f23d769dbf1838d5df5156e7b1ad404f4c463d1ac2c6aeb6cd943630f8a8400" dependencies = [ "futures-core", "futures-io", - "rustls", + "rustls 0.19.0", "webpki", - "webpki-roots 0.20.0", + "webpki-roots", ] [[package]] @@ -1521,9 +1521,9 @@ checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "evm" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0da85b407262b8caaffec7c5cb04c255538afdc1245de482d6216580d1f5e2" +checksum = "52494176f51e37ac07f10f0368a162391a3c368d6c859b69d4ebc52cfc090952" dependencies = [ "ethereum", "evm-core", @@ -1539,9 +1539,9 @@ dependencies = [ [[package]] name = "evm-core" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "decb1397cbc7c7e3c3fee6564eed1f294612a0365c66c90ab92726d19d253a6e" +checksum = "cad7ff84008aa24272cf3e9f7a71054271ede93613665cd9fdfa65447ae6e017" dependencies = [ "parity-scale-codec", "primitive-types", @@ -1550,9 +1550,9 @@ dependencies = [ [[package]] name = "evm-gasometer" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da079283764366124ee955f0bd049e691c3d00895e88c79d9c3b744ff4cd6595" +checksum = "8aed6fc83d542d58a63b7827bd9e4808e1e2a9324b503c255f9e2acccfa0bef9" dependencies = [ "evm-core", "evm-runtime", @@ -1561,9 +1561,9 @@ dependencies = [ [[package]] name = "evm-runtime" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95524d03dfcd11ca540fa3481d76dcc891db1abf704c2bec7a67fc51cdf95e67" +checksum = "507a6d0c3377f34335a264b387e13dc56c7946c34073e0c1250b923018bdf3fa" dependencies = [ "evm-core", "primitive-types", @@ -1635,7 +1635,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "derive_more 0.99.11", "ethereum", @@ -1658,7 +1658,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "ethereum", "ethereum-types", @@ -1694,7 +1694,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "ethereum-types", "jsonrpc-core 15.1.0", @@ -1788,7 +1788,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "parity-scale-codec", "sp-core", @@ -1799,9 +1799,10 @@ dependencies = [ [[package]] name = "fp-evm" version = "0.8.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "evm", + "impl-trait-for-tuples", "parity-scale-codec", "serde", "sp-core", @@ -1811,7 +1812,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "ethereum", "ethereum-types", @@ -2574,7 +2575,7 @@ dependencies = [ "futures-util", "hyper 0.13.9", "log", - "rustls", + "rustls 0.18.1", "rustls-native-certs", "tokio 0.2.22", "tokio-rustls", @@ -3098,9 +3099,9 @@ checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" [[package]] name = "libc" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] name = "libloading" @@ -3497,9 +3498,9 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.26.0" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5736e2fccdcea6e728bbaf903bddc113be223313ce2c756ad9fe43b5a2b0f06" +checksum = "522a877ce42ededf1f5dd011dbc40ea116f1776818f09dacb3d7a206f3ad6305" dependencies = [ "async-tls", "either", @@ -3507,12 +3508,12 @@ dependencies = [ "libp2p-core", "log", "quicksink", - "rustls", + "rustls 0.19.0", "rw-stream-sink", "soketto", "url 2.1.1", "webpki", - "webpki-roots 0.21.0", + "webpki-roots", ] [[package]] @@ -4089,8 +4090,8 @@ dependencies = [ "approx", "generic-array 0.13.2", "matrixmultiply", - "num-complex", - "num-rational", + "num-complex 0.2.4", + "num-rational 0.2.4", "num-traits 0.2.14", "rand 0.7.3", "rand_distr", @@ -4177,6 +4178,20 @@ dependencies = [ "version_check", ] +[[package]] +name = "num" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f" +dependencies = [ + "num-bigint 0.3.1", + "num-complex 0.3.1", + "num-integer", + "num-iter", + "num-rational 0.3.2", + "num-traits 0.2.14", +] + [[package]] name = "num-bigint" version = "0.2.6" @@ -4188,6 +4203,17 @@ dependencies = [ "num-traits 0.2.14", ] +[[package]] +name = "num-bigint" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e9a41747ae4633fce5adffb4d2e81ffc5e89593cb19917f8fb2cc5ff76507bf" +dependencies = [ + "autocfg 1.0.1", + "num-integer", + "num-traits 0.2.14", +] + [[package]] name = "num-complex" version = "0.2.4" @@ -4198,6 +4224,15 @@ dependencies = [ "num-traits 0.2.14", ] +[[package]] +name = "num-complex" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" +dependencies = [ + "num-traits 0.2.14", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -4208,6 +4243,17 @@ dependencies = [ "num-traits 0.2.14", ] +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg 1.0.1", + "num-integer", + "num-traits 0.2.14", +] + [[package]] name = "num-rational" version = "0.2.4" @@ -4215,7 +4261,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ "autocfg 1.0.1", - "num-bigint", + "num-bigint 0.2.6", + "num-integer", + "num-traits 0.2.14", +] + +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg 1.0.1", + "num-bigint 0.3.1", "num-integer", "num-traits 0.2.14", ] @@ -4444,7 +4502,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "ethereum", "ethereum-types", @@ -4481,7 +4539,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "2.0.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "evm", "evm-gasometer", @@ -4489,12 +4547,10 @@ dependencies = [ "fp-evm", "frame-support", "frame-system", - "impl-trait-for-tuples", "pallet-balances", "pallet-timestamp", "parity-scale-codec", "primitive-types", - "ripemd160", "rlp", "serde", "sha3 0.8.2", @@ -4504,6 +4560,44 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-evm-precompile-dispatch" +version = "2.0.0" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" +dependencies = [ + "evm", + "fp-evm", + "frame-support", + "pallet-evm", + "parity-scale-codec", + "sp-core", + "sp-io", +] + +[[package]] +name = "pallet-evm-precompile-modexp" +version = "2.0.0" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" +dependencies = [ + "evm", + "fp-evm", + "num", + "sp-core", + "sp-io", +] + +[[package]] +name = "pallet-evm-precompile-simple" +version = "2.0.0" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" +dependencies = [ + "evm", + "fp-evm", + "ripemd160", + "sp-core", + "sp-io", +] + [[package]] name = "pallet-grandpa" version = "2.0.0" @@ -6206,6 +6300,9 @@ version = "0.1.0" dependencies = [ "log", "pallet-evm", + "pallet-evm-precompile-dispatch", + "pallet-evm-precompile-modexp", + "pallet-evm-precompile-simple", "rustc-hex", "sp-core", "sp-std", @@ -6961,6 +7058,19 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustls" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b" +dependencies = [ + "base64 0.13.0", + "log", + "ring", + "sct", + "webpki", +] + [[package]] name = "rustls-native-certs" version = "0.4.0" @@ -6968,7 +7078,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "629d439a7672da82dd955498445e496ee2096fe2117b9f796558a43fdb9e59b8" dependencies = [ "openssl-probe", - "rustls", + "rustls 0.18.1", "schannel", "security-framework", ] @@ -7257,8 +7367,8 @@ dependencies = [ "futures-timer 3.0.2", "log", "merlin", - "num-bigint", - "num-rational", + "num-bigint 0.2.6", + "num-rational 0.2.4", "num-traits 0.2.14", "parity-scale-codec", "parking_lot 0.10.2", @@ -8309,7 +8419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb931b1367faadea6b1ab1c306a860ec17aaa5fa39f367d0c744e69d971a1fb2" dependencies = [ "approx", - "num-complex", + "num-complex 0.2.4", "num-traits 0.2.14", "paste", ] @@ -8399,13 +8509,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.3.15" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" +checksum = "97e0e9fd577458a4f61fb91fcb559ea2afecc54c934119421f9f5d3d5b1a1057" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "redox_syscall", "winapi 0.3.9", ] @@ -9695,7 +9804,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" dependencies = [ "futures-core", - "rustls", + "rustls 0.18.1", "tokio 0.2.22", "webpki", ] @@ -9970,7 +10079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" dependencies = [ "cfg-if 0.1.10", - "rand 0.7.3", + "rand 0.3.23", "static_assertions", ] @@ -10288,7 +10397,7 @@ checksum = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" dependencies = [ "libc", "memory_units", - "num-rational", + "num-rational 0.2.4", "num-traits 0.2.14", "parity-wasm 0.41.0", "wasmi-validation", @@ -10508,15 +10617,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "webpki-roots" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f" -dependencies = [ - "webpki", -] - [[package]] name = "webpki-roots" version = "0.21.0" @@ -10699,9 +10799,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f33972566adbd2d3588b0491eb94b98b43695c4ef897903470ede4f3f5a28a" +checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" dependencies = [ "zeroize_derive", ] diff --git a/node/standalone/Cargo.lock b/node/standalone/Cargo.lock index f430ffdf3b43a..96e41037281a8 100644 --- a/node/standalone/Cargo.lock +++ b/node/standalone/Cargo.lock @@ -243,9 +243,9 @@ dependencies = [ [[package]] name = "async-io" -version = "1.1.10" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54bc4c1c7292475efb2253227dbcfad8fe1ca4c02bc62c510cc2f3da5c4704e" +checksum = "9315f8f07556761c3e48fec2e6b276004acf426e6dc068b2c2251854d65ee0fd" dependencies = [ "concurrent-queue", "fastrand", @@ -305,15 +305,15 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" [[package]] name = "async-tls" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d85a97c4a0ecce878efd3f945f119c78a646d8975340bca0398f9bb05c30cc52" +checksum = "2f23d769dbf1838d5df5156e7b1ad404f4c463d1ac2c6aeb6cd943630f8a8400" dependencies = [ "futures-core", "futures-io", - "rustls", + "rustls 0.19.0", "webpki", - "webpki-roots 0.20.0", + "webpki-roots", ] [[package]] @@ -333,7 +333,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3410529e8288c463bedb5930f82833bc0c90e5d2fe639a56582a4d09220b281" dependencies = [ - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -353,12 +353,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "autocfg" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" - [[package]] name = "autocfg" version = "1.0.1" @@ -791,7 +785,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" dependencies = [ - "autocfg 1.0.1", + "autocfg", "cfg-if 0.1.10", "crossbeam-utils 0.7.2", "lazy_static", @@ -817,7 +811,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "autocfg 1.0.1", + "autocfg", "cfg-if 0.1.10", "lazy_static", ] @@ -828,7 +822,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" dependencies = [ - "autocfg 1.0.1", + "autocfg", "cfg-if 1.0.0", "const_fn", "lazy_static", @@ -1176,9 +1170,9 @@ checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" [[package]] name = "evm" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0da85b407262b8caaffec7c5cb04c255538afdc1245de482d6216580d1f5e2" +checksum = "52494176f51e37ac07f10f0368a162391a3c368d6c859b69d4ebc52cfc090952" dependencies = [ "ethereum", "evm-core", @@ -1194,9 +1188,9 @@ dependencies = [ [[package]] name = "evm-core" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "decb1397cbc7c7e3c3fee6564eed1f294612a0365c66c90ab92726d19d253a6e" +checksum = "cad7ff84008aa24272cf3e9f7a71054271ede93613665cd9fdfa65447ae6e017" dependencies = [ "parity-scale-codec", "primitive-types", @@ -1205,9 +1199,9 @@ dependencies = [ [[package]] name = "evm-gasometer" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da079283764366124ee955f0bd049e691c3d00895e88c79d9c3b744ff4cd6595" +checksum = "8aed6fc83d542d58a63b7827bd9e4808e1e2a9324b503c255f9e2acccfa0bef9" dependencies = [ "evm-core", "evm-runtime", @@ -1216,9 +1210,9 @@ dependencies = [ [[package]] name = "evm-runtime" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95524d03dfcd11ca540fa3481d76dcc891db1abf704c2bec7a67fc51cdf95e67" +checksum = "507a6d0c3377f34335a264b387e13dc56c7946c34073e0c1250b923018bdf3fa" dependencies = [ "evm-core", "primitive-types", @@ -1274,7 +1268,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "derive_more", "ethereum", @@ -1297,7 +1291,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "ethereum", "ethereum-types", @@ -1333,7 +1327,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "ethereum-types", "jsonrpc-core 15.1.0", @@ -1417,7 +1411,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "parity-scale-codec", "sp-core", @@ -1428,9 +1422,10 @@ dependencies = [ [[package]] name = "fp-evm" version = "0.8.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "evm", + "impl-trait-for-tuples", "parity-scale-codec", "serde", "sp-core", @@ -1440,7 +1435,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "ethereum", "ethereum-types", @@ -1947,7 +1942,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25" dependencies = [ "ahash 0.3.8", - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -2156,7 +2151,7 @@ dependencies = [ "futures-util", "hyper 0.13.9", "log", - "rustls", + "rustls 0.18.1", "rustls-native-certs", "tokio 0.2.22", "tokio-rustls", @@ -2250,7 +2245,7 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ - "autocfg 1.0.1", + "autocfg", "hashbrown 0.9.1", ] @@ -2599,9 +2594,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.80" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] name = "libloading" @@ -2998,9 +2993,9 @@ dependencies = [ [[package]] name = "libp2p-websocket" -version = "0.26.0" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5736e2fccdcea6e728bbaf903bddc113be223313ce2c756ad9fe43b5a2b0f06" +checksum = "522a877ce42ededf1f5dd011dbc40ea116f1776818f09dacb3d7a206f3ad6305" dependencies = [ "async-tls", "either", @@ -3008,12 +3003,12 @@ dependencies = [ "libp2p-core", "log", "quicksink", - "rustls", + "rustls 0.19.0", "rw-stream-sink", "soketto", "url 2.1.1", "webpki", - "webpki-roots 0.21.0", + "webpki-roots", ] [[package]] @@ -3206,7 +3201,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" dependencies = [ - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -3274,7 +3269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" dependencies = [ "adler", - "autocfg 1.0.1", + "autocfg", ] [[package]] @@ -3536,8 +3531,8 @@ dependencies = [ "approx", "generic-array 0.13.2", "matrixmultiply", - "num-complex", - "num-rational", + "num-complex 0.2.4", + "num-rational 0.2.4", "num-traits 0.2.14", "rand 0.7.3", "rand_distr", @@ -3611,13 +3606,38 @@ dependencies = [ "version_check", ] +[[package]] +name = "num" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f" +dependencies = [ + "num-bigint 0.3.1", + "num-complex 0.3.1", + "num-integer", + "num-iter", + "num-rational 0.3.2", + "num-traits 0.2.14", +] + [[package]] name = "num-bigint" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ - "autocfg 1.0.1", + "autocfg", + "num-integer", + "num-traits 0.2.14", +] + +[[package]] +name = "num-bigint" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e9a41747ae4633fce5adffb4d2e81ffc5e89593cb19917f8fb2cc5ff76507bf" +dependencies = [ + "autocfg", "num-integer", "num-traits 0.2.14", ] @@ -3628,7 +3648,16 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" dependencies = [ - "autocfg 1.0.1", + "autocfg", + "num-traits 0.2.14", +] + +[[package]] +name = "num-complex" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" +dependencies = [ "num-traits 0.2.14", ] @@ -3638,7 +3667,18 @@ version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" dependencies = [ - "autocfg 1.0.1", + "autocfg", + "num-traits 0.2.14", +] + +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg", + "num-integer", "num-traits 0.2.14", ] @@ -3648,8 +3688,20 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" dependencies = [ - "autocfg 1.0.1", - "num-bigint", + "autocfg", + "num-bigint 0.2.6", + "num-integer", + "num-traits 0.2.14", +] + +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg", + "num-bigint 0.3.1", "num-integer", "num-traits 0.2.14", ] @@ -3669,7 +3721,7 @@ version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ - "autocfg 1.0.1", + "autocfg", "libm", ] @@ -3776,7 +3828,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "0.1.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "ethereum", "ethereum-types", @@ -3813,7 +3865,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "2.0.0" -source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#c8d3a83e371d9e171bec1a9eee79dfe07a56d18d" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" dependencies = [ "evm", "evm-gasometer", @@ -3821,12 +3873,10 @@ dependencies = [ "fp-evm", "frame-support", "frame-system", - "impl-trait-for-tuples", "pallet-balances", "pallet-timestamp", "parity-scale-codec", "primitive-types", - "ripemd160", "rlp", "serde", "sha3 0.8.2", @@ -3836,6 +3886,44 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-evm-precompile-dispatch" +version = "2.0.0" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" +dependencies = [ + "evm", + "fp-evm", + "frame-support", + "pallet-evm", + "parity-scale-codec", + "sp-core", + "sp-io", +] + +[[package]] +name = "pallet-evm-precompile-modexp" +version = "2.0.0" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" +dependencies = [ + "evm", + "fp-evm", + "num", + "sp-core", + "sp-io", +] + +[[package]] +name = "pallet-evm-precompile-simple" +version = "2.0.0" +source = "git+https://github.com/purestake/frontier?branch=v0.4-hotfixes#6e8512c8d7e72ad927901b7a30eda4a4e76ce1d5" +dependencies = [ + "evm", + "fp-evm", + "ripemd160", + "sp-core", + "sp-io", +] + [[package]] name = "pallet-grandpa" version = "2.0.0" @@ -4492,6 +4580,9 @@ version = "0.1.0" dependencies = [ "log", "pallet-evm", + "pallet-evm-precompile-dispatch", + "pallet-evm-precompile-modexp", + "pallet-evm-precompile-simple", "rustc-hex", "sp-core", "sp-std", @@ -4702,25 +4793,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.7", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg 0.1.2", - "rand_xorshift", - "winapi 0.3.9", -] - [[package]] name = "rand" version = "0.7.3" @@ -4729,20 +4801,10 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom", "libc", - "rand_chacha 0.2.2", + "rand_chacha", "rand_core 0.5.1", - "rand_hc 0.2.0", - "rand_pcg 0.2.1", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.3.1", + "rand_hc", + "rand_pcg", ] [[package]] @@ -4788,15 +4850,6 @@ dependencies = [ "rand 0.7.3", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -4806,50 +4859,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi 0.3.9", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi 0.0.3", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi 0.3.9", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.7", - "rand_core 0.4.2", -] - [[package]] name = "rand_pcg" version = "0.2.1" @@ -4859,15 +4868,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rawpointer" version = "0.2.1" @@ -5087,6 +5087,19 @@ dependencies = [ "webpki", ] +[[package]] +name = "rustls" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b" +dependencies = [ + "base64 0.13.0", + "log", + "ring", + "sct", + "webpki", +] + [[package]] name = "rustls-native-certs" version = "0.4.0" @@ -5094,7 +5107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "629d439a7672da82dd955498445e496ee2096fe2117b9f796558a43fdb9e59b8" dependencies = [ "openssl-probe", - "rustls", + "rustls 0.18.1", "schannel", "security-framework", ] @@ -5386,8 +5399,8 @@ dependencies = [ "futures-timer 3.0.2", "log", "merlin", - "num-bigint", - "num-rational", + "num-bigint 0.2.6", + "num-rational 0.2.4", "num-traits 0.2.14", "parity-scale-codec", "parking_lot 0.10.2", @@ -6325,7 +6338,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb931b1367faadea6b1ab1c306a860ec17aaa5fa39f367d0c744e69d971a1fb2" dependencies = [ "approx", - "num-complex", + "num-complex 0.2.4", "num-traits 0.2.14", "paste", ] @@ -6415,13 +6428,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.3.15" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" +checksum = "97e0e9fd577458a4f61fb91fcb559ea2afecc54c934119421f9f5d3d5b1a1057" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "libc", - "redox_syscall", "winapi 0.3.9", ] @@ -7552,7 +7564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" dependencies = [ "futures-core", - "rustls", + "rustls 0.18.1", "tokio 0.2.22", "webpki", ] @@ -7812,7 +7824,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04f8ab788026715fa63b31960869617cba39117e520eb415b0139543e325ab59" dependencies = [ "cfg-if 0.1.10", - "rand 0.6.5", + "rand 0.7.3", "static_assertions", ] @@ -8121,7 +8133,7 @@ checksum = "bf617d864d25af3587aa745529f7aaa541066c876d57e050c0d0c85c61c92aff" dependencies = [ "libc", "memory_units", - "num-rational", + "num-rational 0.2.4", "num-traits 0.2.14", "parity-wasm 0.41.0", "wasmi-validation", @@ -8156,15 +8168,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "webpki-roots" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f20dea7535251981a9670857150d571846545088359b28e4951d350bdaf179f" -dependencies = [ - "webpki", -] - [[package]] name = "webpki-roots" version = "0.21.0" @@ -8272,9 +8275,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f33972566adbd2d3588b0491eb94b98b43695c4ef897903470ede4f3f5a28a" +checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" dependencies = [ "zeroize_derive", ] diff --git a/runtime/precompiles/Cargo.toml b/runtime/precompiles/Cargo.toml index 8d4ed773db42b..acf07dc7437cf 100644 --- a/runtime/precompiles/Cargo.toml +++ b/runtime/precompiles/Cargo.toml @@ -11,10 +11,18 @@ rustc-hex = { version = "2.0.1", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" } pallet-evm = { git = "https://github.com/purestake/frontier", default-features = false, branch = "v0.4-hotfixes" } +# pallet-evm-precompile-bn128 = { git = "https://github.com/purestake/frontier", default-features = false, branch = "v0.4-hotfixes" } +pallet-evm-precompile-dispatch = { git = "https://github.com/purestake/frontier", default-features = false, branch = "v0.4-hotfixes" } +pallet-evm-precompile-modexp = { git = "https://github.com/purestake/frontier", default-features = false, branch = "v0.4-hotfixes" } +pallet-evm-precompile-simple = { git = "https://github.com/purestake/frontier", default-features = false, branch = "v0.4-hotfixes" } [features] default = [ "std" ] std = [ "sp-std/std", "sp-core/std", + # "pallet-evm-precompile-bn128/std", + "pallet-evm-precompile-dispatch/std", + "pallet-evm-precompile-modexp/std", + "pallet-evm-precompile-simple/std", ] diff --git a/runtime/precompiles/src/lib.rs b/runtime/precompiles/src/lib.rs index 42cbc29a92f9d..ad2c13a630320 100644 --- a/runtime/precompiles/src/lib.rs +++ b/runtime/precompiles/src/lib.rs @@ -17,38 +17,24 @@ #![cfg_attr(not(feature = "std"), no_std)] use sp_std::prelude::*; -use sp_core::H160; -use pallet_evm::{Precompile, Precompiles}; - -pub struct ExperimentalMoonbeamPrecompiles; - -/// Linear gas cost -fn ensure_linear_cost( - target_gas: Option, - len: usize, - base: usize, - word: usize -) -> Result { - let cost = base.checked_add( - word.checked_mul(len.saturating_add(31) / 32).ok_or(pallet_evm::ExitError::OutOfGas)? - ).ok_or(pallet_evm::ExitError::OutOfGas)?; - if let Some(target_gas) = target_gas { - if cost > target_gas { - return Err(pallet_evm::ExitError::OutOfGas) - } - } - Ok(cost) -} - -// prepends "deadbeef" to any data provided +use pallet_evm::LinearCostPrecompile; +use pallet_evm_precompile_simple::{ECRecover, Sha256, Ripemd160, Identity}; +// use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing}; +use pallet_evm_precompile_modexp::Modexp; +use pallet_evm_precompile_dispatch::Dispatch; + +/// An example of implementing a simple precompile. +/// prepends "deadbeef" to any data provided struct DeadbeefPrecompiled; -impl Precompile for DeadbeefPrecompiled { +impl LinearCostPrecompile for DeadbeefPrecompiled { + const BASE: usize = 15; + const WORD: usize = 3; + fn execute( input: &[u8], - target_gas: Option - ) -> core::result::Result<(pallet_evm::ExitSucceed, Vec, usize), pallet_evm::ExitError> { - let cost = ensure_linear_cost(target_gas, input.len(), 15, 3)?; + _: usize, + ) -> core::result::Result<(pallet_evm::ExitSucceed, Vec), pallet_evm::ExitError> { log::info!("Calling deadbeef precompiled contract"); @@ -58,53 +44,28 @@ impl Precompile for DeadbeefPrecompiled { ))?; result_vec.extend(input.to_vec()); - Ok((pallet_evm::ExitSucceed::Returned, result_vec, cost)) - } -} - -type PrecompiledCallable = fn(&[u8], Option) - -> core::result::Result<(pallet_evm::ExitSucceed, Vec, usize), pallet_evm::ExitError>; - -fn get_precompiled_func_from_address(address: &H160) -> Option { - use core::str::FromStr; - - // Note that addresses from_str should not start with 0x, just the hex value - let addr_deadbeef = H160::from_str("0000000000000000000000000000000000001000") - .expect("Invalid address at precompiles generation"); - - if *address == addr_deadbeef { - return Some(DeadbeefPrecompiled::execute); - } - - None -} - -impl Precompiles for ExperimentalMoonbeamPrecompiles { - fn execute( - address: H160, - input: &[u8], - target_gas: Option - ) -> Option< - core::result::Result< - (pallet_evm::ExitSucceed, Vec, usize), - pallet_evm::ExitError, - > - > { - match get_precompiled_func_from_address(&address) { - Some(func) => return Some(func(input, target_gas)), - _ => {}, - }; - - None + Ok((pallet_evm::ExitSucceed::Returned, result_vec)) } } -pub type MoonbeamPrecompiles = +/// The PrecompileSet installed in the Moonbeam runtime. +/// We include the nine Istanbul precompiles +/// (https://github.com/ethereum/go-ethereum/blob/3c46f557/core/vm/contracts.go#L69) +/// as well as a special precompile for dispatching Substrate extrinsics +/// +/// TODO I had trouble getting the BN precompiles to compile. +/// Also, Why are the BN precompiles in geth called bn256*, but in Frontier they are called Bn128* +pub type MoonbeamPrecompiles = ( - pallet_evm::precompiles::ECRecover, - pallet_evm::precompiles::Sha256, - pallet_evm::precompiles::Ripemd160, - pallet_evm::precompiles::Identity, + ECRecover, + Sha256, + Ripemd160, + Identity, + Modexp, + // Bn128Add, + // Bn128Mul, + // Bn128Pairing, + Dispatch, ); diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 863e7bbe410b9..91a6778e4dac3 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -246,14 +246,14 @@ impl pallet_ethereum_chain_id::Config for Runtime {} impl pallet_evm::Config for Runtime { type FeeCalculator = (); - type GasToWeight = (); + type GasWeightMapping = (); type CallOrigin = EnsureAddressSame; type WithdrawOrigin = EnsureAddressNever; type AddressMapping = IdentityAddressMapping; type Currency = Balances; type Event = Event; type Runner = pallet_evm::runner::stack::Runner; - type Precompiles = precompiles::MoonbeamPrecompiles; + type Precompiles = precompiles::MoonbeamPrecompiles; type ChainId = EthereumChainId; } diff --git a/tests/tests/test-block.ts b/tests/tests/test-block.ts index 391fb0b976c0d..97eb8b8ef79ac 100644 --- a/tests/tests/test-block.ts +++ b/tests/tests/test-block.ts @@ -21,7 +21,7 @@ describeWithMoonbeam("Moonbeam RPC (Block)", `simple-specs.json`, (context) => { author: "0x0000000000000000000000000000000000000000", difficulty: "0", extraData: "0x", - gasLimit: 0, + gasLimit: 4294967295, gasUsed: 0, logsBloom: `0x${"0".repeat(512)}`, number: 0, @@ -67,7 +67,7 @@ describeWithMoonbeam("Moonbeam RPC (Block)", `simple-specs.json`, (context) => { author: "0x0000000000000000000000000000000000000000", difficulty: "0", extraData: "0x", - gasLimit: 0, + gasLimit: 4294967295, gasUsed: 0, //hash: "0x14fe6f7c93597f79b901f8b5d7a84277a90915b8d355959b587e18de34f1dc17", logsBloom: `0x${"0".repeat(512)}`, diff --git a/tests/tests/test-precompiles.ts b/tests/tests/test-precompiles.ts index f1d4b22809593..2e875c3f2b6d1 100644 --- a/tests/tests/test-precompiles.ts +++ b/tests/tests/test-precompiles.ts @@ -22,6 +22,59 @@ describeWithMoonbeam("Moonbeam (Precompiles)", `simple-specs.json`, (context) => "573d6000803e3d6000fd5b5050506040515160601b6bffffffffffffffffffffffff19161461010257600080fd5b" + "603f806101106000396000f3fe6080604052600080fdfea26469706673582212202febccafbee65a134279d3397f" + "ecfc56a3d2125987802a91add0260c7efa94d264736f6c634300060c0033"; + + /* + * pragma solidity ^0.7.0; + * + * contract ModularCheck { + * + * // Verify simple modular exponentiation + * constructor() { + * require(modExp(3, 5, 7) == 5); + * require(modExp(5, 7, 11) == 3); + * } + * + * // Wrapper function to use the precompile. + * // Taken from https://ethereum.stackexchange.com/a/71590/9963 + * function modExp(uint256 _b, uint256 _e, uint256 _m) public returns (uint256 result) { + * assembly { + * // Free memory pointer + * let pointer := mload(0x40) + * + * // Define length of base, exponent and modulus. 0x20 == 32 bytes + * mstore(pointer, 0x20) + * mstore(add(pointer, 0x20), 0x20) + * mstore(add(pointer, 0x40), 0x20) + * + * // Define variables base, exponent and modulus + * mstore(add(pointer, 0x60), _b) + * mstore(add(pointer, 0x80), _e) + + * mstore(add(pointer, 0xa0), _m) + * // Store the result + * let value := mload(0xc0) + * + * // Call the precompiled contract 0x05 = bigModExp + * if iszero(call(not(0), 0x05, 0, pointer, 0xc0, value, 0x20)) { + * revert(0, 0) + * } + * + * result := mload(value) + * } + * } + * } + */ + const MODEXP_CONTRACT_BYTECODE = + "608060405234801561001057600080fd5b50600561002760036005600761005660201b60201c565b146100315760" + + "0080fd5b600361004760056007600b61005660201b60201c565b1461005157600080fd5b6100a5565b6000604051" + + "60208152602080820152602060408201528460608201528360808201528260a082015260c05160208160c0846000" + + "6005600019f161009857600080fd5b8051925050509392505050565b610104806100b46000396000f3fe60806040" + + "52348015600f57600080fd5b506004361060285760003560e01c80633148f14f14602d575b600080fd5b606a6004" + + "8036036060811015604157600080fd5b810190808035906020019092919080359060200190929190803590602001" + + "909291905050506080565b6040518082815260200191505060405180910390f35b60006040516020815260208082" + + "0152602060408201528460608201528360808201528260a082015260c05160208160c08460006005600019f160c1" + + "57600080fd5b805192505050939250505056fea26469706673582212204d7e7dcd400a3b0d5772d63f43f37a9855" + + "d556cdcdf0f7991cb39169ce7871ce64736f6c63430007000033"; const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b"; const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342"; @@ -62,4 +115,26 @@ describeWithMoonbeam("Moonbeam (Precompiles)", `simple-specs.json`, (context) => "87802a91add0260c7efa94d264736f6c634300060c0033" ); }); + + it("ModExp is valid inside a contract", async function () { + // See also the ModExp unit tests at + // github.com/paritytech/frontier/blob/378221a4/frame/evm/precompile/modexp/src/lib.rs#L101 + this.timeout(15000); + const { rawTransaction, transactionHash } = await context.web3.eth.accounts.signTransaction( + { + from: GENESIS_ACCOUNT, + data: MODEXP_CONTRACT_BYTECODE, + value: "0x00", + gasPrice: "0x01", + gas: "0x100000", + }, + GENESIS_ACCOUNT_PRIVATE_KEY + ); + await customRequest(context.web3, "eth_sendRawTransaction", [rawTransaction]); + await createAndFinalizeBlock(context.polkadotApi); + + // The contract should deploy successfully and the receipt should show success. + let receipt = await customRequest(context.web3, "eth_getTransactionReceipt", [transactionHash]); + expect(receipt.result.status).equals("0x1"); + }); });