From 92268df67749f62ee5046a1466495a69d6967f8c Mon Sep 17 00:00:00 2001 From: koushiro Date: Tue, 27 Jun 2023 11:40:39 +0800 Subject: [PATCH 01/46] update ACCOUNT_BASIC_PROOF_SIZE constant --- frame/evm/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/frame/evm/Cargo.toml b/frame/evm/Cargo.toml index 59544f3f8e..4697b22205 100644 --- a/frame/evm/Cargo.toml +++ b/frame/evm/Cargo.toml @@ -46,7 +46,6 @@ std = [ "environmental?/std", "evm/std", "evm/with-serde", - "hex?/std", "log/std", "rlp?/std", "scale-codec/std", From d4789685b9ffee2c4bf5dd4d6305dcb8ccde96a8 Mon Sep 17 00:00:00 2001 From: librelois Date: Mon, 3 Jul 2023 15:54:09 +0200 Subject: [PATCH 02/46] use moonbeam fork --- Cargo.lock | 1775 +++++++++++++++++++++++++++------------------------- Cargo.toml | 2 +- 2 files changed, 929 insertions(+), 848 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f6cf1c811a..7d06004a11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,16 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli", + "gimli 0.27.3", +] + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli 0.28.0", ] [[package]] @@ -33,7 +42,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -42,7 +51,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", ] @@ -53,7 +62,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -144,7 +153,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -156,20 +165,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.8", + "getrandom 0.2.10", "once_cell", "version_check", ] [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -190,30 +211,29 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] @@ -229,9 +249,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -239,9 +259,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.68" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "approx" @@ -293,7 +313,7 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.13.2", - "itertools", + "itertools 0.10.5", "num-traits", "zeroize", ] @@ -310,7 +330,7 @@ dependencies = [ "ark-std", "derivative", "digest 0.10.7", - "itertools", + "itertools 0.10.5", "num-bigint", "num-traits", "paste", @@ -325,7 +345,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -338,7 +358,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -374,7 +394,7 @@ checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -395,9 +415,9 @@ checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -424,7 +444,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.23", + "time", ] [[package]] @@ -440,7 +460,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.23", + "time", ] [[package]] @@ -451,7 +471,7 @@ checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", "synstructure", ] @@ -463,7 +483,7 @@ checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", "synstructure", ] @@ -475,7 +495,7 @@ checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -486,9 +506,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-channel" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener", @@ -509,44 +529,43 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.19", + "rustix 0.37.23", "slab", - "socket2", + "socket2 0.4.9", "waker-fn", ] [[package]] name = "async-lock" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ "event-listener", - "futures-lite", ] [[package]] name = "async-trait" -version = "0.1.63" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff18d764974428cf3a9328e23fc5c986f5fbed46e6cd4cdf42544df5d297ec1" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.33", ] [[package]] name = "asynchronous-codec" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" dependencies = [ "bytes", "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", ] [[package]] @@ -577,14 +596,14 @@ dependencies = [ [[package]] name = "auto_impl" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a8c1df849285fbacd587de7818cc7d13be6cd2cbcd47a04fb1801b0e2706e33" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -595,16 +614,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ - "addr2line", + "addr2line 0.21.0", "cc", "cfg-if", "libc", - "miniz_oxide 0.6.2", - "object", + "miniz_oxide", + "object 0.32.1", "rustc-demangle", ] @@ -634,15 +653,15 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" -version = "1.5.3" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beef" @@ -668,19 +687,19 @@ version = "0.65.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.6", + "prettyplease 0.2.15", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -689,6 +708,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "bitvec" version = "1.0.1" @@ -712,37 +737,37 @@ dependencies = [ [[package]] name = "blake2b_simd" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq 0.2.4", + "constant_time_eq", ] [[package]] name = "blake2s_simd" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db539cc2b5f6003621f1cd9ef92d7ded8ea5232c7de0f9faa2de251cd98730d4" +checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq 0.1.5", + "constant_time_eq", ] [[package]] name = "blake3" -version = "1.3.3" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" +checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" dependencies = [ "arrayref", "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq 0.2.4", + "constant_time_eq", ] [[package]] @@ -763,16 +788,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] name = "block-buffer" -version = "0.10.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -820,9 +845,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.1.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" +checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", "serde", @@ -839,9 +864,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "byte-slice-cast" @@ -857,9 +882,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" @@ -869,9 +894,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bzip2-sys" @@ -886,18 +911,18 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.2" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77df041dc383319cc661b428b6961a005db4d6808d5e12536931b1ca9556055" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" dependencies = [ "serde", ] @@ -910,7 +935,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.16", + "semver 1.0.18", "serde", "serde_json", "thiserror", @@ -918,11 +943,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.78" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -947,9 +973,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.2" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70d3ad08698a0568b0562f22710fe6bfc1f4a61a367c77d0398c562eadd453a" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" dependencies = [ "smallvec", ] @@ -993,17 +1019,16 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.23" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +checksum = "defd4e7873dbddba6c7c91e199c7fcb946abc4a6a4ac3195400bcfb01b5de877" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", - "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets 0.48.5", ] [[package]] @@ -1025,7 +1050,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -1034,7 +1059,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -1049,9 +1074,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.4.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -1060,45 +1085,43 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.8" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9394150f5b4273a1763355bd1c2ec54cc5a2593f790587bcd6b2c947cfa9211" +checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.8" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a78fbdd3cc2914ddf37ba444114bc7765bbdcb55ec9cbe6fa054f0137400717" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex", "strsim", ] [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "codespan-reporting" @@ -1129,18 +1152,18 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" dependencies = [ "crossbeam-utils", ] [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "const-random" @@ -1158,7 +1181,7 @@ version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.10", "once_cell", "proc-macro-hack", "tiny-keccak", @@ -1166,15 +1189,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - -[[package]] -name = "constant_time_eq" -version = "0.2.4" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ad85c1f65dc7b37604eb0e89748faf0b9653065f2a8ef69f96a687ec1e9279" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "core-foundation" @@ -1188,9 +1205,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "core2" @@ -1212,9 +1229,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -1240,7 +1257,7 @@ dependencies = [ "cranelift-codegen-shared", "cranelift-entity", "cranelift-isle", - "gimli", + "gimli 0.27.3", "hashbrown 0.13.2", "log", "regalloc2", @@ -1310,7 +1327,7 @@ dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools", + "itertools 0.10.5", "log", "smallvec", "wasmparser", @@ -1319,9 +1336,9 @@ dependencies = [ [[package]] name = "crc" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" dependencies = [ "crc-catalog", ] @@ -1343,9 +1360,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1353,9 +1370,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -1364,14 +1381,14 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.13" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset 0.7.1", + "memoffset 0.9.0", "scopeguard", ] @@ -1387,9 +1404,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.14" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] @@ -1406,7 +1423,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -1414,11 +1431,11 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -1430,7 +1447,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "typenum", ] @@ -1441,7 +1458,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -1451,7 +1468,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -1501,23 +1518,37 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-rc.1" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" +checksum = "622178105f911d937a42cdb140730ba4a3ed2becd8ae6ce39c7d28b5d75d4588" dependencies = [ "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", "fiat-crypto", - "packed_simd_2", "platforms", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.33", +] + [[package]] name = "cxx" -version = "1.0.87" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b61a7545f753a88bcbe0a70de1fcc0221e10bfc752f576754fa91e663db1622e" +checksum = "bbe98ba1789d56fb3db3bee5e032774d4f421b685de7ba703643584ba24effbe" dependencies = [ "cc", "cxxbridge-flags", @@ -1527,9 +1558,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.87" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f464457d494b5ed6905c63b0c4704842aba319084a0a3561cdc1359536b53200" +checksum = "c4ce20f6b8433da4841b1dadfb9468709868022d829d5ca1f2ffbda928455ea3" dependencies = [ "cc", "codespan-reporting", @@ -1537,24 +1568,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 1.0.107", + "syn 2.0.33", ] [[package]] name = "cxxbridge-flags" -version = "1.0.87" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43c7119ce3a3701ed81aca8410b9acf6fc399d2629d057b87e2efa4e63a3aaea" +checksum = "20888d9e1d2298e2ff473cee30efe7d5036e437857ab68bbfea84c74dba91da2" [[package]] name = "cxxbridge-macro" -version = "1.0.87" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e07508b90551e610910fa648a1878991d367064997a596135b86df30daf07e" +checksum = "2fa16a70dd58129e4dfffdff535fb1bce66673f7bbeec4a5a1765a504e1ccd84" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.33", ] [[package]] @@ -1578,7 +1609,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1589,7 +1620,7 @@ checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1600,9 +1631,9 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "data-encoding-macro" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" +checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -1610,12 +1641,12 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" +checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" dependencies = [ "data-encoding", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1631,9 +1662,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.5" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e58dffcdcc8ee7b22f0c1f71a69243d7c2d9ad87b5a14361f2424a1565c219" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", "zeroize", @@ -1667,6 +1698,12 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" + [[package]] name = "derivative" version = "2.2.0" @@ -1675,7 +1712,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1686,7 +1723,7 @@ checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1707,7 +1744,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1717,7 +1754,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" dependencies = [ "derive_builder_core", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1728,7 +1765,7 @@ checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -1752,7 +1789,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -1761,7 +1798,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.3", + "block-buffer 0.10.4", "const-oid", "crypto-common", "subtle", @@ -1816,7 +1853,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -1833,9 +1870,9 @@ checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" [[package]] name = "dtoa" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00704156a7de8df8da0911424e30c2049957b0a714542a44e05fe693dd85313" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dyn-clonable" @@ -1855,14 +1892,14 @@ checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] name = "dyn-clone" -version = "1.0.10" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b0705efd4599c15a38151f4721f7bc388306f61084d3bfd50bd07fbca5cb60" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "ecdsa" @@ -1878,13 +1915,13 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.16.7" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ - "der 0.7.5", + "der 0.7.8", "digest 0.10.7", - "elliptic-curve 0.13.4", + "elliptic-curve 0.13.5", "rfc6979 0.4.0", "signature 2.1.0", "spki 0.7.2", @@ -1899,6 +1936,16 @@ dependencies = [ "signature 1.6.4", ] +[[package]] +name = "ed25519" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +dependencies = [ + "pkcs8 0.10.2", + "signature 2.1.0", +] + [[package]] name = "ed25519-dalek" version = "1.0.1" @@ -1906,13 +1953,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek 3.2.0", - "ed25519", + "ed25519 1.5.3", "rand 0.7.3", - "serde", "sha2 0.9.9", "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +dependencies = [ + "curve25519-dalek 4.1.0", + "ed25519 2.2.2", + "rand_core 0.6.4", + "serde", + "sha2 0.10.7", + "zeroize", +] + [[package]] name = "ed25519-zebra" version = "3.1.0" @@ -1947,7 +2007,7 @@ dependencies = [ "der 0.6.1", "digest 0.10.7", "ff 0.12.1", - "generic-array 0.14.6", + "generic-array 0.14.7", "group 0.12.1", "hkdf", "pem-rfc7468", @@ -1960,19 +2020,19 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.4" +version = "0.13.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75c71eaa367f2e5d556414a8eea812bc62985c879748d6403edabd9cb03f16e7" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" dependencies = [ "base16ct 0.2.0", - "crypto-bigint 0.5.2", + "crypto-bigint 0.5.3", "digest 0.10.7", "ff 0.13.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "group 0.13.0", "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1 0.7.1", + "sec1 0.7.3", "subtle", "zeroize", ] @@ -1986,7 +2046,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -2016,9 +2076,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -2163,7 +2223,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -2180,13 +2240,19 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" [[package]] name = "fastrand" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + [[package]] name = "fc-cli" version = "1.0.0-dev" @@ -2413,9 +2479,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.20" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" +checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" [[package]] name = "file-per-thread-logger" @@ -2429,13 +2495,13 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "windows-sys 0.48.0", ] @@ -2475,13 +2541,13 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -2502,7 +2568,7 @@ dependencies = [ "futures-core", "futures-sink", "pin-project", - "spin 0.9.7", + "spin 0.9.8", ] [[package]] @@ -2536,9 +2602,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -2689,7 +2755,7 @@ dependencies = [ "frame-system", "gethostname", "handlebars", - "itertools", + "itertools 0.10.5", "lazy_static", "linked-hash-map", "log", @@ -2756,7 +2822,7 @@ name = "frame-support" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "bitflags", + "bitflags 1.3.2", "environmental", "frame-metadata", "frame-support-procedural", @@ -2795,12 +2861,12 @@ dependencies = [ "derive-syn-parse", "expander", "frame-support-procedural-tools", - "itertools", + "itertools 0.10.5", "macro_magic", "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -2812,7 +2878,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -2822,7 +2888,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -3079,16 +3145,16 @@ checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-lite" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand", + "fastrand 1.9.0", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "waker-fn", ] @@ -3100,7 +3166,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -3110,8 +3176,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" dependencies = [ "futures-io", - "rustls 0.20.8", - "webpki 0.22.0", + "rustls 0.20.9", + "webpki 0.22.1", ] [[package]] @@ -3145,7 +3211,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "pin-utils", "slab", ] @@ -3170,9 +3236,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -3202,9 +3268,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "libc", @@ -3238,10 +3304,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" dependencies = [ "fallible-iterator", - "indexmap 1.9.2", + "indexmap 1.9.3", "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" + [[package]] name = "glob" version = "0.3.1" @@ -3250,9 +3322,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" dependencies = [ "aho-corasick", "bstr", @@ -3285,9 +3357,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -3295,7 +3367,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.2", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -3304,9 +3376,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.3.6" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "035ef95d03713f2c347a72547b7cd38cbc9af7cd51e6099fb62d586d4a6dee3a" +checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" dependencies = [ "log", "pest", @@ -3360,21 +3432,25 @@ 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 = "hashlink" -version = "0.8.1" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.12.3", + "hashbrown 0.14.0", ] [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" dependencies = [ "unicode-segmentation", ] @@ -3390,18 +3466,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -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" @@ -3460,10 +3527,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "hmac 0.8.1", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -3477,9 +3553,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" dependencies = [ "bytes", "fnv", @@ -3494,14 +3570,14 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", ] [[package]] name = "http-range-header" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" [[package]] name = "httparse" @@ -3511,9 +3587,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" @@ -3537,8 +3613,8 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.9", - "socket2", + "pin-project-lite 0.2.13", + "socket2 0.4.9", "tokio", "tower-service", "tracing", @@ -3555,7 +3631,7 @@ dependencies = [ "http", "hyper", "log", - "rustls 0.21.5", + "rustls 0.21.7", "rustls-native-certs", "tokio", "tokio-rustls", @@ -3563,26 +3639,25 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows 0.48.0", ] [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -3604,9 +3679,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -3638,7 +3713,7 @@ dependencies = [ "rtnetlink", "system-configuration", "tokio", - "windows", + "windows 0.34.0", ] [[package]] @@ -3676,14 +3751,14 @@ checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -3706,7 +3781,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -3748,11 +3823,11 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys 0.48.0", ] @@ -3765,31 +3840,30 @@ checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" [[package]] name = "ipconfig" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2", + "socket2 0.5.4", "widestring", - "winapi", + "windows-sys 0.48.0", "winreg", ] [[package]] name = "ipnet" -version = "2.7.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +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.19", + "hermit-abi 0.3.2", + "rustix 0.38.13", "windows-sys 0.48.0", ] @@ -3802,17 +3876,26 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" -version = "0.1.25" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" dependencies = [ "libc", ] @@ -3828,9 +3911,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" +checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" dependencies = [ "jsonrpsee-core", "jsonrpsee-proc-macros", @@ -3841,9 +3924,9 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" +checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", "arrayvec 0.7.4", @@ -3867,22 +3950,22 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa6da1e4199c10d7b1d0a6e5e8bd8e55f351163b6f4b3cbb044672a69bd4c1c" +checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" dependencies = [ "heck", "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] name = "jsonrpsee-server" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb69dad85df79527c019659a992498d03f8495390496da2f07e6c24c2b356fc" +checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" dependencies = [ "futures-channel", "futures-util", @@ -3902,9 +3985,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd522fe1ce3702fd94812965d7bb7a3364b1c9aba743944c5a00529aae80f8c" +checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" dependencies = [ "anyhow", "beef", @@ -3921,17 +4004,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa 0.16.7", - "elliptic-curve 0.13.4", + "ecdsa 0.16.8", + "elliptic-curve 0.13.5", "once_cell", "sha2 0.10.7", ] [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" dependencies = [ "cpufeatures", ] @@ -3986,9 +4069,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libloading" @@ -4000,12 +4083,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libm" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - [[package]] name = "libp2p" version = "0.51.3" @@ -4015,7 +4092,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.8", + "getrandom 0.2.10", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4130,12 +4207,12 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58", - "ed25519-dalek", + "ed25519-dalek 2.0.0", "log", "multiaddr", "multihash", @@ -4189,7 +4266,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "tokio", "trust-dns-proto", "void", @@ -4266,7 +4343,7 @@ dependencies = [ "parking_lot 0.12.1", "quinn-proto", "rand 0.8.5", - "rustls 0.20.8", + "rustls 0.20.9", "thiserror", "tokio", ] @@ -4316,7 +4393,7 @@ checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" dependencies = [ "heck", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -4331,7 +4408,7 @@ dependencies = [ "libc", "libp2p-core", "log", - "socket2", + "socket2 0.4.9", "tokio", ] @@ -4347,9 +4424,9 @@ dependencies = [ "libp2p-identity", "rcgen 0.10.0", "ring", - "rustls 0.20.8", + "rustls 0.20.9", "thiserror", - "webpki 0.22.0", + "webpki 0.22.1", "x509-parser 0.14.0", "yasna", ] @@ -4507,9 +4584,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.8" +version = "1.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" dependencies = [ "cc", "pkg-config", @@ -4518,9 +4595,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", ] @@ -4542,9 +4619,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" +checksum = "4de04dcecc58d366391f9920245b85ffa684558a5ef6e7736e754347c3aea9c2" dependencies = [ "nalgebra", ] @@ -4557,15 +4634,21 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.3.7" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -4573,9 +4656,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" @@ -4633,7 +4716,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -4647,7 +4730,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -4658,7 +4741,7 @@ checksum = "c12469fc165526520dff2807c2975310ab47cf7190a45b99b49a7dc8befab17b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -4669,7 +4752,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -4690,7 +4773,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]] @@ -4701,10 +4784,11 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" -version = "0.3.2" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" dependencies = [ + "autocfg", "rawpointer", ] @@ -4719,24 +4803,24 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memfd" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.36.13", + "rustix 0.37.23", ] [[package]] name = "memmap2" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" dependencies = [ "libc", ] @@ -4752,18 +4836,18 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" dependencies = [ "autocfg", ] [[package]] name = "memoffset" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] @@ -4795,15 +4879,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" @@ -4826,9 +4901,9 @@ dependencies = [ [[package]] name = "mockall" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e4a1c770583dac7ab5e2f6c139153b783a53a1bbee9729613f193e59828326" +checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" dependencies = [ "cfg-if", "downcast", @@ -4841,14 +4916,14 @@ dependencies = [ [[package]] name = "mockall_derive" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "832663583d5fa284ca8810bf7015e46c9fff9622d3cf34bd1eea5003fec06dd0" +checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -4908,7 +4983,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", "synstructure", ] @@ -4934,9 +5009,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6515c882ebfddccaa73ead7320ca28036c4bc84c9bcca3cc0cbba8efe89223a" +checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" dependencies = [ "approx", "matrixmultiply", @@ -4950,13 +5025,13 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -5005,7 +5080,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", @@ -5014,9 +5089,9 @@ dependencies = [ [[package]] name = "netlink-packet-utils" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25af9cf0dc55498b7bd94a1508af7a78706aa0ab715a73c5169273e03c84845e" +checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" dependencies = [ "anyhow", "byteorder", @@ -5041,9 +5116,9 @@ dependencies = [ [[package]] name = "netlink-sys" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "260e21fbb6f3d253a14df90eb0000a6066780a15dd901a7519ce02d77a94985b" +checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" dependencies = [ "bytes", "futures", @@ -5058,7 +5133,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", @@ -5088,9 +5163,9 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "num" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" dependencies = [ "num-bigint", "num-complex", @@ -5102,9 +5177,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -5113,9 +5188,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ "num-traits", ] @@ -5165,20 +5240,20 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] [[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", ] @@ -5200,7 +5275,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -5211,7 +5286,16 @@ checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "crc32fast", "hashbrown 0.13.2", - "indexmap 1.9.2", + "indexmap 1.9.3", + "memchr", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ "memchr", ] @@ -5253,11 +5337,11 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.48" +version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518915b97df115dd36109bfa429a48b8f737bd05508cf9588977b599648926d2" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ - "bitflags", + "bitflags 2.4.0", "cfg-if", "foreign-types", "libc", @@ -5268,13 +5352,13 @@ dependencies = [ [[package]] name = "openssl-macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.33", ] [[package]] @@ -5285,11 +5369,10 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.83" +version = "0.9.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666416d899cf077260dac8698d60a60b435a46d57e82acb1be3d0dad87284e5b" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ - "autocfg", "cc", "libc", "pkg-config", @@ -5318,16 +5401,6 @@ dependencies = [ "sha2 0.10.7", ] -[[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" -dependencies = [ - "cfg-if", - "libm", -] - [[package]] name = "pallet-aura" version = "4.0.0-dev" @@ -5542,7 +5615,7 @@ dependencies = [ name = "pallet-evm-precompile-curve25519" version = "1.0.0-dev" dependencies = [ - "curve25519-dalek 4.0.0-rc.1", + "curve25519-dalek 4.1.0", "fp-evm", ] @@ -5569,7 +5642,7 @@ dependencies = [ name = "pallet-evm-precompile-ed25519" version = "2.0.0-dev" dependencies = [ - "ed25519-dalek", + "ed25519-dalek 1.0.1", "fp-evm", ] @@ -5768,9 +5841,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.9" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dab3ac198341b2f0fec6e7f8a6eeed07a41201d98a124260611598c142e76df" +checksum = "ab512a34b3c2c5e465731cc7668edf79208bbe520be03484eeb05e63ed221735" dependencies = [ "blake2", "crc32fast", @@ -5788,9 +5861,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -5803,14 +5876,14 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -5827,9 +5900,9 @@ checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" [[package]] name = "parking_lot" @@ -5876,7 +5949,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -5887,9 +5960,9 @@ checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" [[package]] name = "paste" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbkdf2" @@ -5935,25 +6008,26 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.5.4" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab62d2fa33726dbe6321cc97ef96d8cde531e3eeaf858a058de53a8a6d40d8f" +checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" dependencies = [ + "memchr", "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.5.4" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf026e2d0581559db66d837fe5242320f525d85c76283c61f4d51a1238d65ea" +checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" dependencies = [ "pest", "pest_generator", @@ -5961,22 +6035,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.5.4" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b27bd18aa01d91c8ed2b61ea23406a676b42d82609c6e2581fba42f0c15f17f" +checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.33", ] [[package]] name = "pest_meta" -version = "2.5.4" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f02b677c1859756359fc9983c2e56a0237f18624a3789528804406b7e915e5d" +checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" dependencies = [ "once_cell", "pest", @@ -5985,32 +6059,32 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 1.9.2", + "indexmap 2.0.0", ] [[package]] name = "pin-project" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030ad2bc4db10a8944cb0d837f158bdfec4d4a4873ab701a95046770d11f8842" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -6021,9 +6095,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -6047,35 +6121,35 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.5", + "der 0.7.8", "spki 0.7.2", ] [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" -version = "3.0.2" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" +checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" [[package]] name = "polling" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be1c66a6add46bff50935c313dae30a5030cf8385c5206e8a95e9e9def974aa" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags", + "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "windows-sys 0.48.0", ] @@ -6128,7 +6202,7 @@ checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" dependencies = [ "difflib", "float-cmp", - "itertools", + "itertools 0.10.5", "normalize-line-endings", "predicates-core", "regex", @@ -6136,15 +6210,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" [[package]] name = "predicates-tree" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" dependencies = [ "predicates-core", "termtree", @@ -6152,22 +6226,22 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.1.23" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" dependencies = [ "proc-macro2", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] name = "prettyplease" -version = "0.2.6" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b69d39aab54d069e7f2fe8cb970493e7834601ca2d8c65fd7bbd183578080d1" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -6203,7 +6277,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", "version_check", ] @@ -6226,20 +6300,20 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro-warning" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70550716265d1ec349c41f70dd4f964b4fd88394efe4405f0c1da679c4799a07" +checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -6272,20 +6346,20 @@ dependencies = [ [[package]] name = "prometheus-client-derive-encode" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1" +checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.33", ] [[package]] name = "prost" -version = "0.11.6" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21dc42e00223fc37204bd4aa177e69420c604ca4a183209a8f9de30c6d934698" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", "prost-derive", @@ -6293,46 +6367,45 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.6" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f8ad728fb08fe212df3c05169e940fbb6d9d16a877ddde14644a983ba2012e" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" dependencies = [ "bytes", "heck", - "itertools", + "itertools 0.10.5", "lazy_static", "log", "multimap", "petgraph", - "prettyplease 0.1.23", + "prettyplease 0.1.25", "prost", "prost-types", "regex", - "syn 1.0.107", + "syn 1.0.109", "tempfile", "which", ] [[package]] name = "prost-derive" -version = "0.11.6" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda8c0881ea9f722eb9629376db3d0b903b462477c1aafcb0566610ac28ac5d" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", - "itertools", + "itertools 0.10.5", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] name = "prost-types" -version = "0.11.6" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e0526209433e96d83d750dd81a99118edbc55739e7e61a46764fd2ad537788" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "bytes", "prost", ] @@ -6394,19 +6467,19 @@ dependencies = [ "rand 0.8.5", "ring", "rustc-hash", - "rustls 0.20.8", + "rustls 0.20.9", "slab", "thiserror", "tinyvec", "tracing", - "webpki 0.22.0", + "webpki 0.22.1", ] [[package]] name = "quote" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -6476,7 +6549,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.10", ] [[package]] @@ -6505,9 +6578,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" dependencies = [ "either", "rayon-core", @@ -6515,9 +6588,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.10.2" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "356a0625f1954f730c0201cdab48611198dc6ce21f4acff55089b5a78e6e835b" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -6533,7 +6606,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.23", + "time", "x509-parser 0.13.2", "yasna", ] @@ -6546,7 +6619,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.23", + "time", "yasna", ] @@ -6556,7 +6629,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -6565,7 +6638,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -6574,29 +6647,29 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] [[package]] name = "ref-cast" -version = "1.0.14" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c78fb8c9293bcd48ef6fce7b4ca950ceaf21210de6e105a883ee280c0f7b9ed" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.14" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f9c0c92af03644e4806106281fe2e068ac5bc0ae74a707266d06ea27bccee5f" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.33", ] [[package]] @@ -6613,13 +6686,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-automata 0.3.8", + "regex-syntax 0.7.5", ] [[package]] @@ -6628,23 +6702,31 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.5", ] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] -name = "remove_dir_all" -version = "0.5.3" +name = "regex-syntax" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "resolv-conf" @@ -6720,7 +6802,7 @@ checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -6796,9 +6878,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -6818,7 +6900,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.16", + "semver 1.0.18", ] [[package]] @@ -6832,11 +6914,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.13" +version = "0.36.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a38f9520be93aba504e8ca974197f46158de5dcaa9fa04b57c57cd6a679d658" +checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -6846,15 +6928,28 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.19" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", - "linux-raw-sys 0.3.7", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.7", "windows-sys 0.48.0", ] @@ -6873,21 +6968,21 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.8" +version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", "ring", "sct 0.7.0", - "webpki 0.22.0", + "webpki 0.22.1", ] [[package]] name = "rustls" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79ea77c539259495ce8ca47f53e66ae0330a8819f67e23ac96ca02f50e7b7d36" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", @@ -6897,9 +6992,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -6909,18 +7004,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.0", + "base64 0.21.4", ] [[package]] name = "rustls-webpki" -version = "0.101.1" +version = "0.101.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e" +checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" dependencies = [ "ring", "untrusted", @@ -6928,9 +7023,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "rw-stream-sink" @@ -6945,15 +7040,15 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.12" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "safe_arch" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "794821e4ccb0d9f979512f9c1973480123f9bd62a90d74ab0f9426fcf8f4a529" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" dependencies = [ "bytemuck", ] @@ -7043,7 +7138,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -7382,7 +7477,7 @@ dependencies = [ "cfg-if", "libc", "log", - "rustix 0.36.13", + "rustix 0.36.15", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -7487,7 +7582,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "futures", "libp2p-identity", "parity-scale-codec", @@ -7873,7 +7968,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -7956,16 +8051,16 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[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]] @@ -7999,15 +8094,15 @@ dependencies = [ [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scratch" -version = "1.0.3" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sct" @@ -8049,7 +8144,7 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ "base16ct 0.1.1", "der 0.6.1", - "generic-array 0.14.6", + "generic-array 0.14.7", "pkcs8 0.9.0", "subtle", "zeroize", @@ -8057,13 +8152,13 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct 0.2.0", - "der 0.7.5", - "generic-array 0.14.6", + "der 0.7.8", + "generic-array 0.14.7", "pkcs8 0.10.2", "subtle", "zeroize", @@ -8098,11 +8193,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.8.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c4437699b6d34972de58652c68b98cb5b53a4199ab126db8e20ec8ded29a721" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -8111,9 +8206,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.8.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -8130,9 +8225,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" dependencies = [ "serde", ] @@ -8145,29 +8240,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.171" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] name = "serde_json" -version = "1.0.93" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -8176,9 +8271,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ "serde", ] @@ -8245,9 +8340,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ "digest 0.10.7", "keccak", @@ -8264,15 +8359,15 @@ dependencies = [ [[package]] name = "shlex" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] @@ -8299,9 +8394,9 @@ dependencies = [ [[package]] name = "simba" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" dependencies = [ "approx", "num-complex", @@ -8312,24 +8407,24 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "slice-group-by" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" @@ -8345,14 +8440,14 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" +checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" dependencies = [ "aes-gcm 0.9.4", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.1", + "curve25519-dalek 4.1.0", "rand_core 0.6.4", "ring", "rustc_version", @@ -8370,6 +8465,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -8419,7 +8524,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -8565,7 +8670,7 @@ version = "21.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ "array-bytes", - "bitflags", + "bitflags 1.3.2", "blake2", "bounded-collections", "bs58", @@ -8624,7 +8729,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "quote", "sp-core-hashing", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -8643,7 +8748,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -8677,8 +8782,8 @@ version = "23.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ "bytes", - "ed25519", - "ed25519-dalek", + "ed25519 1.5.3", + "ed25519-dalek 1.0.1", "libsecp256k1", "log", "parity-scale-codec", @@ -8725,7 +8830,7 @@ version = "4.1.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ "thiserror", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] @@ -8818,7 +8923,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -9003,7 +9108,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -9042,9 +9147,9 @@ checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] name = "spin" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0959fd6f767df20b231736396e4f602171e00d95205676286e79d4a4eb67bef" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ "lock_api", ] @@ -9066,16 +9171,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.5", + "der 0.7.8", ] [[package]] name = "sqlformat" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c12bc9199d1db8234678b7051747c07f517cdcf019262d1847b94ec8b1aee3e" +checksum = "6b7b278788e7be4d0d29c0f39497a0eef3fba6bbc8e70d8bf7fde46edeaa9e85" dependencies = [ - "itertools", + "itertools 0.11.0", "nom", "unicode_categories", ] @@ -9141,7 +9246,7 @@ dependencies = [ "quote", "sqlx-core", "sqlx-macros-core", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -9162,7 +9267,7 @@ dependencies = [ "sha2 0.10.7", "sqlx-core", "sqlx-sqlite", - "syn 1.0.107", + "syn 1.0.109", "tempfile", "tokio", "url", @@ -9192,9 +9297,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.38.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e40c020d72bc0a9c5660bb71e4a6fdef081493583062c474740a7d59f55f0e7b" +checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" dependencies = [ "Inflector", "num-format", @@ -9223,7 +9328,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", @@ -9242,7 +9347,7 @@ dependencies = [ "memchr", "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -9270,7 +9375,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 1.0.107", + "syn 1.0.109", ] [[package]] @@ -9451,7 +9556,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.3", + "toml 0.7.8", "walkdir", "wasm-opt", ] @@ -9473,9 +9578,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -9484,9 +9589,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.26" +version = "2.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" +checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" dependencies = [ "proc-macro2", "quote", @@ -9501,17 +9606,17 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 1.0.109", "unicode-xid", ] [[package]] name = "system-configuration" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75182f12f490e953596550b65ee31bda7c8e043d9386174b353bda50838c3fd" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -9534,22 +9639,21 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.5" +version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" +checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "tempfile" -version = "3.3.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", - "fastrand", - "libc", - "redox_syscall 0.2.16", - "remove_dir_all", - "winapi", + "fastrand 2.0.0", + "redox_syscall 0.3.5", + "rustix 0.38.13", + "windows-sys 0.48.0", ] [[package]] @@ -9563,28 +9667,28 @@ dependencies = [ [[package]] name = "termtree" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -9595,10 +9699,11 @@ checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" [[package]] name = "thread_local" -version = "1.1.4" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" dependencies = [ + "cfg-if", "once_cell", ] @@ -9613,9 +9718,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.3+5.3.0-patched" +version = "0.5.4+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" dependencies = [ "cc", "libc", @@ -9623,21 +9728,11 @@ dependencies = [ [[package]] name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "time" -version = "0.3.23" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ + "deranged", "itoa", "serde", "time-core", @@ -9652,9 +9747,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.10" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -9708,26 +9803,25 @@ dependencies = [ [[package]] name = "tinyvec_macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "signal-hook-registry", - "socket2", + "socket2 0.5.4", "tokio-macros", "windows-sys 0.48.0", ] @@ -9740,7 +9834,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", ] [[package]] @@ -9749,33 +9843,33 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.5", + "rustls 0.21.7", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tokio", "tokio-util", ] [[package]] name = "tokio-util" -version = "0.7.4" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tokio", "tracing", ] @@ -9791,9 +9885,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.3" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b403acf6f2bb0859c93c7f0d967cb4a75a7ac552100f9322faf64dc047669b21" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", @@ -9803,20 +9897,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.8" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 1.9.2", + "indexmap 2.0.0", "serde", "serde_spanned", "toml_datetime", @@ -9836,18 +9930,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1d42a9b3f3ec46ba828e8d376aec14592ea199f70a06a548587ecd1c4ab658" +checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags", + "bitflags 2.4.0", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tower-layer", "tower-service", ] @@ -9872,27 +9966,27 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.13", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", + "syn 2.0.33", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", "valuable", @@ -10002,7 +10096,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.9", "thiserror", "tinyvec", "tokio", @@ -10081,9 +10175,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -10099,15 +10193,15 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -10148,7 +10242,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -10164,9 +10258,9 @@ dependencies = [ [[package]] name = "unsigned-varint" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" dependencies = [ "asynchronous-codec", "bytes", @@ -10182,12 +10276,12 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.3.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", - "idna 0.3.0", + "idna 0.4.0", "percent-encoding", ] @@ -10203,7 +10297,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.10", ] [[package]] @@ -10247,22 +10341,20 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", - "winapi", "winapi-util", ] [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] @@ -10272,12 +10364,6 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -10305,7 +10391,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", "wasm-bindgen-shared", ] @@ -10339,7 +10425,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.33", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -10420,7 +10506,7 @@ version = "0.102.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" dependencies = [ - "indexmap 1.9.2", + "indexmap 1.9.3", "url", ] @@ -10433,10 +10519,10 @@ dependencies = [ "anyhow", "bincode", "cfg-if", - "indexmap 1.9.2", + "indexmap 1.9.3", "libc", "log", - "object", + "object 0.30.4", "once_cell", "paste", "psm", @@ -10468,12 +10554,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.21.0", + "base64 0.21.4", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.13", + "rustix 0.36.15", "serde", "sha2 0.10.7", "toml 0.5.11", @@ -10493,9 +10579,9 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli", + "gimli 0.27.3", "log", - "object", + "object 0.30.4", "target-lexicon", "thiserror", "wasmparser", @@ -10512,8 +10598,8 @@ dependencies = [ "anyhow", "cranelift-codegen", "cranelift-native", - "gimli", - "object", + "gimli 0.27.3", + "object 0.30.4", "target-lexicon", "wasmtime-environ", ] @@ -10526,10 +10612,10 @@ checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" dependencies = [ "anyhow", "cranelift-entity", - "gimli", - "indexmap 1.9.2", + "gimli 0.27.3", + "indexmap 1.9.3", "log", - "object", + "object 0.30.4", "serde", "target-lexicon", "thiserror", @@ -10543,14 +10629,14 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ - "addr2line", + "addr2line 0.19.0", "anyhow", "bincode", "cfg-if", "cpp_demangle", - "gimli", + "gimli 0.27.3", "log", - "object", + "object 0.30.4", "rustc-demangle", "serde", "target-lexicon", @@ -10567,9 +10653,9 @@ version = "8.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ - "object", + "object 0.30.4", "once_cell", - "rustix 0.36.13", + "rustix 0.36.15", ] [[package]] @@ -10592,7 +10678,7 @@ dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap 1.9.2", + "indexmap 1.9.3", "libc", "log", "mach", @@ -10600,7 +10686,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.13", + "rustix 0.36.15", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -10621,9 +10707,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.60" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -10641,9 +10727,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" dependencies = [ "ring", "untrusted", @@ -10655,7 +10741,7 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", + "webpki 0.22.1", ] [[package]] @@ -10684,7 +10770,7 @@ dependencies = [ "sha2 0.10.7", "stun", "thiserror", - "time 0.3.23", + "time", "tokio", "turn", "url", @@ -10716,9 +10802,9 @@ dependencies = [ [[package]] name = "webrtc-dtls" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" +checksum = "c4a00f4242f2db33307347bd5be53263c52a0331c96c14292118c9a6bb48d267" dependencies = [ "aes 0.6.0", "aes-gcm 0.10.2", @@ -10733,12 +10819,11 @@ dependencies = [ "hkdf", "hmac 0.12.1", "log", - "oid-registry 0.6.1", "p256", "p384", "rand 0.8.5", "rand_core 0.6.4", - "rcgen 0.9.3", + "rcgen 0.10.0", "ring", "rustls 0.19.1", "sec1 0.3.0", @@ -10751,7 +10836,7 @@ dependencies = [ "tokio", "webpki 0.21.4", "webrtc-util", - "x25519-dalek 2.0.0-pre.1", + "x25519-dalek 2.0.0", "x509-parser 0.13.2", ] @@ -10786,7 +10871,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2", + "socket2 0.4.9", "thiserror", "tokio", "webrtc-util", @@ -10853,7 +10938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "cc", "ipnet", @@ -10869,20 +10954,21 @@ dependencies = [ [[package]] name = "which" -version = "4.4.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ "either", - "libc", + "home", "once_cell", + "rustix 0.38.13", ] [[package]] name = "wide" -version = "0.7.8" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b689b6c49d6549434bf944e6b0f39238cf63693cb7a147e9d887507fffa3b223" +checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" dependencies = [ "bytemuck", "safe_arch", @@ -10890,9 +10976,9 @@ dependencies = [ [[package]] name = "widestring" -version = "0.5.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17882f045410753661207383517a6f62ec3dbeb6a4ed2acce01f0728238d1983" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" [[package]] name = "winapi" @@ -10939,18 +11025,12 @@ dependencies = [ ] [[package]] -name = "windows-sys" -version = "0.42.0" +name = "windows" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm 0.42.1", - "windows_x86_64_msvc 0.42.1", + "windows-targets 0.48.5", ] [[package]] @@ -10959,7 +11039,7 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets 0.42.1", + "windows-targets 0.42.2", ] [[package]] @@ -10968,50 +11048,50 @@ 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.5", ] [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm 0.42.1", - "windows_aarch64_msvc 0.42.1", - "windows_i686_gnu 0.42.1", - "windows_i686_msvc 0.42.1", - "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm 0.42.1", - "windows_x86_64_msvc 0.42.1", + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", ] [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -11021,15 +11101,15 @@ checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -11039,15 +11119,15 @@ checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -11057,15 +11137,15 @@ checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -11075,27 +11155,27 @@ checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -11105,32 +11185,33 @@ checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.4.6" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] @@ -11155,12 +11236,13 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "2.0.0-pre.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek 4.1.0", "rand_core 0.6.4", + "serde", "zeroize", ] @@ -11180,7 +11262,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.23", + "time", ] [[package]] @@ -11198,7 +11280,7 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.23", + "time", ] [[package]] @@ -11221,7 +11303,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.23", + "time", ] [[package]] @@ -11235,14 +11317,13 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 1.0.107", - "synstructure", + "syn 2.0.33", ] [[package]] @@ -11256,11 +11337,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.12.3+zstd.1.5.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" dependencies = [ - "zstd-safe 6.0.5+zstd.1.5.4", + "zstd-safe 6.0.6", ] [[package]] @@ -11275,9 +11356,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.5+zstd.1.5.4" +version = "6.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" dependencies = [ "libc", "zstd-sys", diff --git a/Cargo.toml b/Cargo.toml index b673d5f510..49136515c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ resolver = "2" [workspace.package] authors = ["Parity Technologies "] edition = "2021" -repository = "https://github.com/paritytech/frontier/" +repository = "https://github.com/moonbeam-foundation/frontier/" [workspace.dependencies] async-trait = "0.1" From d3799c97e6c34292ec3d385c49b87aa0a6a54ff2 Mon Sep 17 00:00:00 2001 From: librelois Date: Mon, 3 Jul 2023 16:44:34 +0200 Subject: [PATCH 03/46] use moonbeam evm fork --- Cargo.lock | 10 +++---- Cargo.toml | 2 +- frame/evm/src/runner/stack.rs | 55 ----------------------------------- 3 files changed, 6 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d06004a11..9cd69852f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2152,8 +2152,8 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "evm" -version = "0.39.1" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +version = "0.39.0" +source = "git+https://github.com/moonbeam-foundation/evm?branch=tgm-record-external-cost#53315e22da8494dbcb6b54a18e09775e956b7c73" dependencies = [ "auto_impl", "environmental", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +source = "git+https://github.com/moonbeam-foundation/evm?branch=tgm-record-external-cost#53315e22da8494dbcb6b54a18e09775e956b7c73" dependencies = [ "parity-scale-codec", "primitive-types", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +source = "git+https://github.com/moonbeam-foundation/evm?branch=tgm-record-external-cost#53315e22da8494dbcb6b54a18e09775e956b7c73" dependencies = [ "environmental", "evm-core", @@ -2195,7 +2195,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=b7b82c7e1fc57b7449d6dfa6826600de37cc1e65#b7b82c7e1fc57b7449d6dfa6826600de37cc1e65" +source = "git+https://github.com/moonbeam-foundation/evm?branch=tgm-record-external-cost#53315e22da8494dbcb6b54a18e09775e956b7c73" dependencies = [ "auto_impl", "environmental", diff --git a/Cargo.toml b/Cargo.toml index 49136515c6..4d49e460cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ clap = { version = "4.3", features = ["derive", "deprecated"] } environmental = { version = "1.1.4", default-features = false } ethereum = { version = "0.14.0", default-features = false } ethereum-types = { version = "0.14.1", default-features = false } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false } +evm = { git = "https://github.com/moonbeam-foundation/evm", branch = "tgm-record-external-cost", default-features = false } futures = "0.3.28" hex = { version = "0.4.3", default-features = false, features = ["alloc"] } hex-literal = "0.4.1" diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 7af212593a..fefecdd98e 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -952,61 +952,6 @@ where >::account_code_metadata(address).hash } - fn record_external_operation(&mut self, op: evm::ExternalOperation) -> Result<(), ExitError> { - let size_limit: u64 = self - .metadata() - .gasometer() - .config() - .create_contract_limit - .unwrap_or_default() as u64; - - let (weight_info, recorded) = self.info_mut(); - - if let Some(weight_info) = weight_info { - match op { - evm::ExternalOperation::AccountBasicRead => { - weight_info.try_record_proof_size_or_fail(ACCOUNT_BASIC_PROOF_SIZE)? - } - evm::ExternalOperation::AddressCodeRead(address) => { - let maybe_record = !recorded.account_codes.contains(&address); - // Skip if the address has been already recorded this block - if maybe_record { - // First we record account emptiness check. - // Transfers to EOAs with standard 21_000 gas limit are able to - // pay for this pov size. - weight_info.try_record_proof_size_or_fail(IS_EMPTY_CHECK_PROOF_SIZE)?; - - if >::decode_len(address).unwrap_or(0) == 0 { - return Ok(()); - } - // Try to record fixed sized `AccountCodesMetadata` read - // Tentatively 16 + 20 + 40 - weight_info - .try_record_proof_size_or_fail(ACCOUNT_CODES_METADATA_PROOF_SIZE)?; - if let Some(meta) = >::get(address) { - weight_info.try_record_proof_size_or_fail(meta.size)?; - } else { - // If it does not exist, try to record `create_contract_limit` first. - weight_info.try_record_proof_size_or_fail(size_limit)?; - let meta = Pallet::::account_code_metadata(address); - let actual_size = meta.size; - // Refund if applies - weight_info.refund_proof_size(size_limit.saturating_sub(actual_size)); - } - recorded.account_codes.push(address); - } - } - evm::ExternalOperation::IsEmpty => { - weight_info.try_record_proof_size_or_fail(IS_EMPTY_CHECK_PROOF_SIZE)? - } - evm::ExternalOperation::Write => { - weight_info.try_record_proof_size_or_fail(WRITE_PROOF_SIZE)? - } - }; - } - Ok(()) - } - fn record_external_dynamic_opcode_cost( &mut self, opcode: Opcode, From 7512b0f52b0a762aca1c1b64b4edfd3c7afd061e Mon Sep 17 00:00:00 2001 From: tgmichel Date: Wed, 1 Mar 2023 14:01:03 +0100 Subject: [PATCH 04/46] catch ethereum execution info --- Cargo.lock | 1 + frame/ethereum/Cargo.toml | 2 ++ frame/ethereum/src/catch_exec_info.rs | 32 +++++++++++++++++++++++++++ frame/ethereum/src/lib.rs | 5 +++++ 4 files changed, 40 insertions(+) create mode 100644 frame/ethereum/src/catch_exec_info.rs diff --git a/Cargo.lock b/Cargo.lock index 9cd69852f6..4f5b59965a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5506,6 +5506,7 @@ dependencies = [ name = "pallet-ethereum" version = "4.0.0-dev" dependencies = [ + "environmental", "ethereum", "ethereum-types", "evm", diff --git a/frame/ethereum/Cargo.toml b/frame/ethereum/Cargo.toml index 634be1081d..5ffe6bddbe 100644 --- a/frame/ethereum/Cargo.toml +++ b/frame/ethereum/Cargo.toml @@ -11,6 +11,7 @@ repository = { workspace = true } targets = ["x86_64-unknown-linux-gnu"] [dependencies] +environmental = { workspace = true } ethereum = { workspace = true, features = ["with-codec"] } ethereum-types = { workspace = true } evm = { workspace = true, features = ["with-codec"] } @@ -44,6 +45,7 @@ fp-self-contained = { workspace = true, features = ["default"] } [features] default = ["std"] std = [ + "environmental/std", "ethereum/std", "evm/std", "ethereum-types/std", diff --git a/frame/ethereum/src/catch_exec_info.rs b/frame/ethereum/src/catch_exec_info.rs new file mode 100644 index 0000000000..a1aa652459 --- /dev/null +++ b/frame/ethereum/src/catch_exec_info.rs @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: Apache-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2020-2022 Parity Technologies (UK) Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use fp_evm::CallOrCreateInfo; + +environmental::environmental!(GLOBAL: Option); + +// Allow to catch informations of an ethereum execution inside the provided closure. +pub fn catch_exec_info R>( + execution_info: &mut Option, + f: F, +) -> R { + GLOBAL::using(execution_info, f) +} + +pub(super) fn fill_exec_info(execution_info: &CallOrCreateInfo) { + GLOBAL::with(|exec_info| exec_info.replace(execution_info.clone())); +} diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index cf69889944..4c0193ac35 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -25,11 +25,14 @@ #![allow(clippy::comparison_chain, clippy::large_enum_variant)] #![warn(unused_crate_dependencies)] +mod catch_exec_info; #[cfg(all(feature = "std", test))] mod mock; #[cfg(all(feature = "std", test))] mod tests; +pub use catch_exec_info::catch_exec_info; + use ethereum_types::{Bloom, BloomInput, H160, H256, H64, U256}; use evm::ExitReason; use fp_consensus::{PostLog, PreLog, FRONTIER_ENGINE_ID}; @@ -564,6 +567,8 @@ impl Pallet { ) -> DispatchResultWithPostInfo { let (to, _, info) = Self::execute(source, &transaction, None)?; + catch_exec_info::fill_exec_info(&info); + let pending = Pending::::get(); let transaction_hash = transaction.hash(); let transaction_index = pending.len() as u32; From 55cf4dca42203ba6d7e73cbf9e0672143d2e6456 Mon Sep 17 00:00:00 2001 From: agus Date: Tue, 4 Jul 2023 14:02:26 -0300 Subject: [PATCH 05/46] make Pending storage public --- frame/ethereum/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 4c0193ac35..cf79836abc 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -320,7 +320,7 @@ pub mod pallet { /// Current building block's transactions and receipts. #[pallet::storage] - pub(super) type Pending = + pub type Pending = StorageValue<_, Vec<(Transaction, TransactionStatus, Receipt)>, ValueQuery>; /// The current Ethereum block. From 721b7b7c4d21c9b4736e26b824aed238b7049569 Mon Sep 17 00:00:00 2001 From: librelois Date: Mon, 14 Aug 2023 16:02:26 +0200 Subject: [PATCH 06/46] refactor evm recursion lock --- frame/evm/src/runner/stack.rs | 51 ++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index fefecdd98e..c5df8840be 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -54,7 +54,7 @@ use crate::{ }; #[cfg(feature = "forbid-evm-reentrancy")] -environmental::thread_local_impl!(static IN_EVM: environmental::RefCell = environmental::RefCell::new(false)); +environmental::environmental!(IN_EVM: bool); #[derive(Default)] pub struct Runner { @@ -93,14 +93,7 @@ where { let (base_fee, weight) = T::FeeCalculator::min_gas_price(); - #[cfg(feature = "forbid-evm-reentrancy")] - if IN_EVM.with(|in_evm| in_evm.replace(true)) { - return Err(RunnerError { - error: Error::::Reentrancy, - weight, - }); - } - + #[cfg(not(feature = "forbid-evm-reentrancy"))] let res = Self::execute_inner( source, value, @@ -117,10 +110,44 @@ where proof_size_base_cost, ); - // Set IN_EVM to false - // We should make sure that this line is executed whatever the execution path. #[cfg(feature = "forbid-evm-reentrancy")] - let _ = IN_EVM.with(|in_evm| in_evm.take()); + let res = IN_EVM::using_once(&mut false, || { + IN_EVM::with(|in_evm| { + if *in_evm { + return Err(RunnerError { + error: Error::::Reentrancy, + weight, + }); + } + *in_evm = true; + Ok(()) + }) + // This should always return `Some`, but let's play it safe. + .unwrap_or(Ok(()))?; + + // Ensure that we always release the lock whenever we finish processing + sp_core::defer! { + IN_EVM::with(|in_evm| { + *in_evm = false; + }); + } + + Self::execute_inner( + source, + value, + gas_limit, + max_fee_per_gas, + max_priority_fee_per_gas, + config, + precompiles, + is_transactional, + f, + base_fee, + weight, + weight_limit, + proof_size_base_cost, + ) + }); res } From 06d2703ca9418dd10ee6c03b219861662e458ffb Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Fri, 18 Aug 2023 14:46:01 +0200 Subject: [PATCH 07/46] fix benchmarking for different node templates (#179) --- frame/evm/src/benchmarking.rs | 10 ++--- frame/evm/src/weights.rs | 70 +++++++++++++++++++++++++++++++++ scripts/benchmark.sh | 3 +- template/node/src/chain_spec.rs | 7 ++-- 4 files changed, 81 insertions(+), 9 deletions(-) diff --git a/frame/evm/src/benchmarking.rs b/frame/evm/src/benchmarking.rs index bf65792f7f..8ee4280100 100644 --- a/frame/evm/src/benchmarking.rs +++ b/frame/evm/src/benchmarking.rs @@ -71,7 +71,7 @@ benchmarks! { let caller = "1000000000000000000000000000000000000001".parse::().unwrap(); - let mut nonce: u64 = 1; + let mut nonce: u64 = 0; let nonce_as_u256: U256 = nonce.into(); let value = U256::default(); @@ -83,8 +83,8 @@ benchmarks! { contract_bytecode, value, gas_limit_create, - Some(U256::from(1_000_000_000)), - Some(U256::from(1_000_000_000)), + Some(U256::from(1_000_000_000_000_000u128)), + Some(U256::from(1_000_000_000_000_000u128)), Some(nonce_as_u256), Vec::new(), is_transactional, @@ -120,8 +120,8 @@ benchmarks! { encoded_call, value, gas_limit_call, - Some(U256::from(1_000_000_000)), - Some(U256::from(1_000_000_000)), + Some(U256::from(1_000_000_000_000_000u128)), + Some(U256::from(1_000_000_000_000_000u128)), Some(nonce_as_u256), Vec::new(), is_transactional, diff --git a/frame/evm/src/weights.rs b/frame/evm/src/weights.rs index a0d0e1d95e..90eac7fe22 100644 --- a/frame/evm/src/weights.rs +++ b/frame/evm/src/weights.rs @@ -48,12 +48,47 @@ use core::marker::PhantomData; /// Weight functions needed for pallet_evm. pub trait WeightInfo { + fn runner_execute(x: u32, ) -> Weight; fn withdraw() -> Weight; } /// Weights for pallet_evm using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + /// Storage: BaseFee BaseFeePerGas (r:1 w:0) + /// Proof: BaseFee BaseFeePerGas (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) + /// Storage: EVMChainId ChainId (r:1 w:0) + /// Proof: EVMChainId ChainId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:2 w:0) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + /// Storage: System Number (r:1 w:0) + /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System ExecutionPhase (r:1 w:0) + /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: System EventCount (r:1 w:1) + /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Events (r:1 w:1) + /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Digest (r:1 w:0) + /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: EVM AccountStorages (r:1 w:0) + /// Proof Skipped: EVM AccountStorages (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances TotalIssuance (r:1 w:1) + /// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// The range of component `x` is `[1, 10000000]`. + fn runner_execute(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `913` + // Estimated: `6853` + // Minimum execution time: 20_400_192_000 picoseconds. + Weight::from_parts(20_767_272_339, 6853) + // Standard Error: 33 + .saturating_add(Weight::from_parts(42, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } fn withdraw() -> Weight { // Proof Size summary in bytes: // Measured: `0` @@ -61,10 +96,45 @@ impl WeightInfo for SubstrateWeight { // Minimum execution time: 2_000_000 picoseconds. Weight::from_parts(2_000_000, 0) } + } // For backwards compatibility and tests impl WeightInfo for () { + /// Storage: BaseFee BaseFeePerGas (r:1 w:0) + /// Proof: BaseFee BaseFeePerGas (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:1) + /// Proof: System Account (max_values: None, max_size: Some(116), added: 2591, mode: MaxEncodedLen) + /// Storage: EVMChainId ChainId (r:1 w:0) + /// Proof: EVMChainId ChainId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: EVM AccountCodes (r:2 w:0) + /// Proof Skipped: EVM AccountCodes (max_values: None, max_size: None, mode: Measured) + /// Storage: System Number (r:1 w:0) + /// Proof: System Number (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System ExecutionPhase (r:1 w:0) + /// Proof: System ExecutionPhase (max_values: Some(1), max_size: Some(5), added: 500, mode: MaxEncodedLen) + /// Storage: System EventCount (r:1 w:1) + /// Proof: System EventCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: System Events (r:1 w:1) + /// Proof Skipped: System Events (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: System Digest (r:1 w:0) + /// Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) + /// Storage: EVM AccountStorages (r:1 w:0) + /// Proof Skipped: EVM AccountStorages (max_values: None, max_size: None, mode: Measured) + /// Storage: Balances TotalIssuance (r:1 w:1) + /// Proof: Balances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// The range of component `x` is `[1, 10000000]`. + fn runner_execute(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `913` + // Estimated: `6853` + // Minimum execution time: 20_400_192_000 picoseconds. + Weight::from_parts(20_767_272_339, 6853) + // Standard Error: 33 + .saturating_add(Weight::from_parts(42, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(13_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } fn withdraw() -> Weight { // Proof Size summary in bytes: // Measured: `0` diff --git a/scripts/benchmark.sh b/scripts/benchmark.sh index 7d798d3db3..fda64512bb 100755 --- a/scripts/benchmark.sh +++ b/scripts/benchmark.sh @@ -33,8 +33,9 @@ function bench { --extrinsic="${2}" \ --execution=wasm \ --wasm-execution=compiled \ + --header=HEADER-APACHE2 \ --output=weights.rs \ - --template=./benchmarking/frame-weight-template.hbs + --template=./.maintain/frame-weight-template.hbs } if [[ $# -eq 1 && "${1}" == "--help" ]]; then diff --git a/template/node/src/chain_spec.rs b/template/node/src/chain_spec.rs index 316ac85667..ede9fce3f7 100644 --- a/template/node/src/chain_spec.rs +++ b/template/node/src/chain_spec.rs @@ -260,10 +260,11 @@ fn testnet_genesis( H160::from_str("1000000000000000000000000000000000000001") .expect("internal H160 is valid; qed"), fp_evm::GenesisAccount { - nonce: U256::from(1), - balance: U256::from(1_000_000_000_000_000_000_000_000u128), + nonce: Default::default(), + balance: U256::from_str("0xffffffffffffffffffffffffffffffff") + .expect("internal U256 is valid; qed"), storage: Default::default(), - code: vec![0x00], + code: Default::default(), }, ); map From 1c9f2483a2207b118e4235506fe35b9cc8591e40 Mon Sep 17 00:00:00 2001 From: librelois Date: Fri, 18 Aug 2023 17:55:24 +0200 Subject: [PATCH 08/46] create helper function max_transaction_encoded_size --- frame/ethereum/src/lib.rs | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index cf79836abc..9b933bd0ee 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -359,17 +359,14 @@ pub mod pallet { } impl Pallet { - /// The call wrapped in the extrinsic is part of the PoV, record this as a base cost for the size of the proof. - fn proof_size_base_cost(transaction: &Transaction) -> u64 { - transaction - .encode() - .len() - // pallet index - .saturating_add(1) - // call index - .saturating_add(1) as u64 - } - + /// The call wrapped in the extrinsic is part of the PoV, record this as a base cost for the size of the proof. + fn proof_size_base_cost(transaction: &Transaction) -> u64 { + transaction + .encoded_size() + // pallet index + call index + .saturating_add(2) as u64 + } + fn recover_signer(transaction: &Transaction) -> Option { let mut sig = [0u8; 65]; let mut msg = [0u8; 32]; @@ -861,6 +858,24 @@ impl Pallet { } } + /// Estimated maximal SCALE encoded size of an ethereum transaction + pub fn max_transaction_encoded_size(input: &[u8], access_list: &[(H160, Vec)]) -> u64 { + Self::proof_size_base_cost(&Transaction::EIP1559(ethereum::EIP1559Transaction{ + chain_id: 0, + nonce: Default::default(), + max_priority_fee_per_gas: Default::default(), + max_fee_per_gas: Default::default(), + gas_limit: Default::default(), + action: ethereum::TransactionAction::Call(Default::default()), + value: Default::default(), + input: input.to_vec(), + access_list: access_list.iter().map(|(address, storage_keys)| AccessListItem { address: *address, storage_keys: storage_keys.to_vec() }).collect(), + odd_y_parity: false, + r: Default::default(), + s: Default::default(), + })) + } + /// Validate an Ethereum transaction already in block /// /// This function must be called during the pre-dispatch phase From 550ec5a6406b435d9f717cbbf7a09a677f5cba2f Mon Sep 17 00:00:00 2001 From: tgmichel Date: Thu, 27 Jul 2023 03:58:10 +0200 Subject: [PATCH 09/46] Fix refund base fee (#1118) From 7f07e2601a340b52b20f9de81b1d8109cb8b6843 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 31 Jul 2023 22:17:50 +0300 Subject: [PATCH 10/46] A new trait for recording foreign metrics --- primitives/evm/src/lib.rs | 1 + primitives/evm/src/metric.rs | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 primitives/evm/src/metric.rs diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 4a4902ba27..138ae72536 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -20,6 +20,7 @@ mod precompile; mod validation; +mod metric; use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight}; use scale_codec::{Decode, Encode}; diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/metric.rs new file mode 100644 index 0000000000..e60e6d5252 --- /dev/null +++ b/primitives/evm/src/metric.rs @@ -0,0 +1,67 @@ +use evm::ExitError; +use sp_runtime::{ + traits::{CheckedAdd, Zero}, + Saturating, +}; + +/// A trait for metering different foreign metrics. +pub trait Metric { + fn try_consume(&self, cost: T) -> Result; + fn refund(&mut self, amount: T); + fn record(&mut self, cost: T) -> Result<(), ExitError>; +} + +pub struct BasicMetric { + limit: T, + usage: T, +} + +impl BasicMetric +where + T: Zero, +{ + pub fn new(limit: T) -> Self { + Self { + limit, + usage: Zero::zero(), + } + } +} + +impl Metric for BasicMetric +where + T: CheckedAdd + Saturating + PartialOrd + Copy, +{ + fn try_consume(&self, cost: T) -> Result { + let usage = self.usage.checked_add(&cost).ok_or(ExitError::OutOfGas)?; + if usage > self.limit { + return Err(ExitError::OutOfGas); + } + Ok(usage) + } + + fn refund(&mut self, amount: T) { + self.usage = self.usage.saturating_sub(amount); + } + + fn record(&mut self, cost: T) -> Result<(), ExitError> { + + Ok(()) + } +} + +pub struct StorageMetric(pub BasicMetric); + +impl Metric for StorageMetric { + fn try_consume(&self, cost: u64) -> Result { + self.0.try_consume(cost) + } + + fn refund(&mut self, amount: u64) { + self.0.refund(amount) + } + + fn record(&mut self, cost: u64) -> Result<(), ExitError> { + Ok(()) + } +} From a8d0f3ff38db7c0e6a0841f98a3e23d8dbf9b7cb Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Wed, 2 Aug 2023 13:41:57 +0300 Subject: [PATCH 11/46] Remove Metric trait --- primitives/evm/src/metric.rs | 44 +++++++++++++++++------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/metric.rs index e60e6d5252..3a3009404b 100644 --- a/primitives/evm/src/metric.rs +++ b/primitives/evm/src/metric.rs @@ -1,16 +1,9 @@ -use evm::ExitError; +use evm::{gasometer::GasCost, ExitError, Opcode}; use sp_runtime::{ traits::{CheckedAdd, Zero}, Saturating, }; -/// A trait for metering different foreign metrics. -pub trait Metric { - fn try_consume(&self, cost: T) -> Result; - fn refund(&mut self, amount: T); - fn record(&mut self, cost: T) -> Result<(), ExitError>; -} - pub struct BasicMetric { limit: T, usage: T, @@ -28,40 +21,45 @@ where } } -impl Metric for BasicMetric +impl BasicMetric where T: CheckedAdd + Saturating + PartialOrd + Copy, { - fn try_consume(&self, cost: T) -> Result { + fn try_consume(&mut self, cost: T) -> Result<(), ExitError> { let usage = self.usage.checked_add(&cost).ok_or(ExitError::OutOfGas)?; if usage > self.limit { return Err(ExitError::OutOfGas); } - Ok(usage) + self.usage = usage; + Ok(()) } fn refund(&mut self, amount: T) { self.usage = self.usage.saturating_sub(amount); } - fn record(&mut self, cost: T) -> Result<(), ExitError> { - - Ok(()) - } + fn record(&mut self, opcode: Opcode, gas_cost: GasCost) -> Result<(), ExitError> { + Ok(()) + } } -pub struct StorageMetric(pub BasicMetric); - -impl Metric for StorageMetric { - fn try_consume(&self, cost: u64) -> Result { - self.0.try_consume(cost) - } +pub struct StorageMetric(BasicMetric); +impl StorageMetric { fn refund(&mut self, amount: u64) { self.0.refund(amount) } - fn record(&mut self, cost: u64) -> Result<(), ExitError> { - Ok(()) + fn record_dynamic_opcode_cost( + &mut self, + _opcode: Opcode, + gas_cost: GasCost, + ) -> Result<(), ExitError> { + let cost = match gas_cost { + GasCost::Create => 0, + GasCost::Create2 { len } => len.try_into().map_err(|_| ExitError::OutOfGas)?, + _ => return Ok(()), + }; + self.0.try_consume(cost) } } From 1303f0c8ff44c7df55bfd7160c3561fd83b16753 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Wed, 2 Aug 2023 13:42:55 +0300 Subject: [PATCH 12/46] rename BasicMetric to Metric --- primitives/evm/src/metric.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/metric.rs index 3a3009404b..4a1a095a19 100644 --- a/primitives/evm/src/metric.rs +++ b/primitives/evm/src/metric.rs @@ -4,12 +4,12 @@ use sp_runtime::{ Saturating, }; -pub struct BasicMetric { +pub struct Metric { limit: T, usage: T, } -impl BasicMetric +impl Metric where T: Zero, { @@ -21,7 +21,7 @@ where } } -impl BasicMetric +impl Metric where T: CheckedAdd + Saturating + PartialOrd + Copy, { @@ -43,7 +43,7 @@ where } } -pub struct StorageMetric(BasicMetric); +pub struct StorageMetric(Metric); impl StorageMetric { fn refund(&mut self, amount: u64) { From 8e3fffaf605b0c008d233ddfe7b0363bdccce7a5 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Wed, 2 Aug 2023 14:13:34 +0300 Subject: [PATCH 13/46] add unit tests and a new MetricError enum --- primitives/evm/src/metric.rs | 101 +++++++++++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 11 deletions(-) diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/metric.rs index 4a1a095a19..838142abdd 100644 --- a/primitives/evm/src/metric.rs +++ b/primitives/evm/src/metric.rs @@ -1,9 +1,17 @@ -use evm::{gasometer::GasCost, ExitError, Opcode}; +use evm::{gasometer::GasCost, Opcode}; use sp_runtime::{ traits::{CheckedAdd, Zero}, Saturating, }; +#[derive(Debug, PartialEq)] +/// Metric error. +enum MetricError { + /// The metric usage exceeds the limit. + LimitExceeded, +} + +/// A struct that keeps track of metric usage and limit. pub struct Metric { limit: T, usage: T, @@ -13,6 +21,7 @@ impl Metric where T: Zero, { + /// Creates a new `Metric` instance with the given limit. pub fn new(limit: T) -> Self { Self { limit, @@ -25,41 +34,111 @@ impl Metric where T: CheckedAdd + Saturating + PartialOrd + Copy, { - fn try_consume(&mut self, cost: T) -> Result<(), ExitError> { - let usage = self.usage.checked_add(&cost).ok_or(ExitError::OutOfGas)?; + /// Records the cost of an operation and updates the usage. + /// + /// # Errors + /// + /// Returns `MetricError::LimitExceeded` if the metric usage exceeds the limit. + fn record_cost(&mut self, cost: T) -> Result<(), MetricError> { + let usage = self + .usage + .checked_add(&cost) + .ok_or(MetricError::LimitExceeded)?; if usage > self.limit { - return Err(ExitError::OutOfGas); + return Err(MetricError::LimitExceeded); } self.usage = usage; Ok(()) } + /// Refunds the given amount. fn refund(&mut self, amount: T) { self.usage = self.usage.saturating_sub(amount); } - - fn record(&mut self, opcode: Opcode, gas_cost: GasCost) -> Result<(), ExitError> { - Ok(()) - } } +/// A struct that keeps track of new storage usage and limit. pub struct StorageMetric(Metric); impl StorageMetric { + /// Creates a new `StorageMetric` instance with the given limit. + pub fn new(limit: u64) -> Self { + Self(Metric::new(limit)) + } + + /// Refunds the given amount of storage gas. fn refund(&mut self, amount: u64) { self.0.refund(amount) } + /// Records the dynamic opcode cost and updates the storage usage. + /// + /// # Errors + /// + /// Returns `MetricError::LimitExceeded` if the storage gas usage exceeds the storage gas limit. fn record_dynamic_opcode_cost( &mut self, _opcode: Opcode, gas_cost: GasCost, - ) -> Result<(), ExitError> { + ) -> Result<(), MetricError> { let cost = match gas_cost { GasCost::Create => 0, - GasCost::Create2 { len } => len.try_into().map_err(|_| ExitError::OutOfGas)?, + GasCost::Create2 { len } => len.try_into().map_err(|_| MetricError::LimitExceeded)?, _ => return Ok(()), }; - self.0.try_consume(cost) + self.0.record_cost(cost) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_init() { + let metric = Metric::::new(100); + assert_eq!(metric.limit, 100); + assert_eq!(metric.usage, 0); + } + + #[test] + fn test_try_consume() { + let mut metric = Metric::::new(100); + assert_eq!(metric.record_cost(10), Ok(())); + assert_eq!(metric.usage, 10); + assert_eq!(metric.record_cost(90), Ok(())); + assert_eq!(metric.usage, 100); + assert_eq!(metric.record_cost(1), Err(MetricError::LimitExceeded)); + assert_eq!(metric.usage, 100); + } + + #[test] + fn test_refund() { + let mut metric = Metric::::new(100); + assert_eq!(metric.record_cost(10), Ok(())); + assert_eq!(metric.usage, 10); + metric.refund(10); + assert_eq!(metric.usage, 0); + + // refund more than usage + metric.refund(10); + assert_eq!(metric.usage, 0); + } + + #[test] + fn test_storage_metric() { + let mut metric = StorageMetric::new(100); + assert_eq!(metric.0.usage, 0); + assert_eq!(metric.0.limit, 100); + assert_eq!(metric.0.record_cost(10), Ok(())); + assert_eq!(metric.0.usage, 10); + assert_eq!(metric.0.record_cost(90), Ok(())); + assert_eq!(metric.0.usage, 100); + assert_eq!(metric.0.record_cost(1), Err(MetricError::LimitExceeded)); + assert_eq!(metric.0.usage, 100); + metric.0.refund(10); + assert_eq!(metric.0.usage, 90); + metric.refund(10); + assert_eq!(metric.0.usage, 80); } } From 9143345b6a9dfa25e139a98909fab1f906d0137a Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Thu, 3 Aug 2023 09:20:17 +0300 Subject: [PATCH 14/46] Add ProofSizeMeter --- primitives/evm/src/metric.rs | 107 +++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 31 deletions(-) diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/metric.rs index 838142abdd..15f8b43e03 100644 --- a/primitives/evm/src/metric.rs +++ b/primitives/evm/src/metric.rs @@ -1,14 +1,21 @@ -use evm::{gasometer::GasCost, Opcode}; -use sp_runtime::{ - traits::{CheckedAdd, Zero}, - Saturating, -}; +use evm::{gasometer::GasCost, ExitError, Opcode}; +use sp_runtime::{traits::CheckedAdd, Saturating}; #[derive(Debug, PartialEq)] /// Metric error. -enum MetricError { +pub enum MetricError { /// The metric usage exceeds the limit. LimitExceeded, + /// Invalid Base Cost. + InvalidBaseCost, +} + +impl Into for MetricError { + fn into(self) -> ExitError { + match self { + MetricError::LimitExceeded | MetricError::InvalidBaseCost => ExitError::OutOfGas, + } + } } /// A struct that keeps track of metric usage and limit. @@ -19,21 +26,23 @@ pub struct Metric { impl Metric where - T: Zero, + T: CheckedAdd + Saturating + PartialOrd + Copy, { - /// Creates a new `Metric` instance with the given limit. - pub fn new(limit: T) -> Self { - Self { - limit, - usage: Zero::zero(), + /// Creates a new `Metric` instance with the given base cost and limit. + /// + /// # Errors + /// + /// Returns `MetricError::InvalidBaseCost` if the base cost is greater than the limit. + pub fn new(base_cost: T, limit: T) -> Result { + if base_cost > limit { + return Err(MetricError::InvalidBaseCost); } + Ok(Self { + limit, + usage: base_cost, + }) } -} -impl Metric -where - T: CheckedAdd + Saturating + PartialOrd + Copy, -{ /// Records the cost of an operation and updates the usage. /// /// # Errors @@ -44,6 +53,7 @@ where .usage .checked_add(&cost) .ok_or(MetricError::LimitExceeded)?; + if usage > self.limit { return Err(MetricError::LimitExceeded); } @@ -57,16 +67,35 @@ where } } -/// A struct that keeps track of new storage usage and limit. -pub struct StorageMetric(Metric); +/// A struct that keeps track of the size of the proof. +pub struct ProofSizeMeter(Metric); + +impl ProofSizeMeter { + /// Creates a new `ProofSizeMetric` instance with the given limit. + pub fn new(base_cost: u64, limit: u64) -> Result { + Ok(Self(Metric::new(base_cost, limit)?)) + } -impl StorageMetric { + /// Records the size of the proof and updates the usage. + /// + /// # Errors + /// + /// Returns `MetricError::LimitExceeded` if the proof size exceeds the limit. + fn record_proof_size(&mut self, size: u64) -> Result<(), MetricError> { + self.0.record_cost(size) + } +} + +/// A struct that keeps track of storage usage (newly created storage) and limit. +pub struct StorageMeter(Metric); + +impl StorageMeter { /// Creates a new `StorageMetric` instance with the given limit. - pub fn new(limit: u64) -> Self { - Self(Metric::new(limit)) + pub fn new(limit: u64) -> Result { + Ok(Self(Metric::new(0, limit)?)) } - /// Refunds the given amount of storage gas. + /// Refunds the given amount of storage. fn refund(&mut self, amount: u64) { self.0.refund(amount) } @@ -75,15 +104,25 @@ impl StorageMetric { /// /// # Errors /// - /// Returns `MetricError::LimitExceeded` if the storage gas usage exceeds the storage gas limit. + /// Returns `MetricError::LimitExceeded` if the storage usage exceeds the storage limit. fn record_dynamic_opcode_cost( &mut self, _opcode: Opcode, gas_cost: GasCost, ) -> Result<(), MetricError> { let cost = match gas_cost { - GasCost::Create => 0, - GasCost::Create2 { len } => len.try_into().map_err(|_| MetricError::LimitExceeded)?, + GasCost::Create => { + // TODO record cost for create + 0 + } + GasCost::Create2 { len } => { + // len in bytes ?? + len.try_into().map_err(|_| MetricError::LimitExceeded)? + } + GasCost::SStore { .. } => { + // TODO record cost for sstore + 0 + } _ => return Ok(()), }; self.0.record_cost(cost) @@ -96,25 +135,31 @@ mod tests { #[test] fn test_init() { - let metric = Metric::::new(100); + let metric = Metric::::new(0, 100).unwrap(); assert_eq!(metric.limit, 100); assert_eq!(metric.usage, 0); + + // base cost > limit + let metric = Metric::::new(100, 0).err(); + assert_eq!(metric, Some(MetricError::InvalidBaseCost)); } #[test] - fn test_try_consume() { - let mut metric = Metric::::new(100); + fn test_record_cost() { + let mut metric = Metric::::new(0, 100).unwrap(); assert_eq!(metric.record_cost(10), Ok(())); assert_eq!(metric.usage, 10); assert_eq!(metric.record_cost(90), Ok(())); assert_eq!(metric.usage, 100); + + // exceed limit assert_eq!(metric.record_cost(1), Err(MetricError::LimitExceeded)); assert_eq!(metric.usage, 100); } #[test] fn test_refund() { - let mut metric = Metric::::new(100); + let mut metric = Metric::::new(0, 100).unwrap(); assert_eq!(metric.record_cost(10), Ok(())); assert_eq!(metric.usage, 10); metric.refund(10); @@ -127,7 +172,7 @@ mod tests { #[test] fn test_storage_metric() { - let mut metric = StorageMetric::new(100); + let mut metric = StorageMeter::new(100).unwrap(); assert_eq!(metric.0.usage, 0); assert_eq!(metric.0.limit, 100); assert_eq!(metric.0.record_cost(10), Ok(())); From c473838746e0863ff9a6fe04c8e5880e983b7d91 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Thu, 3 Aug 2023 13:30:04 +0300 Subject: [PATCH 15/46] Add ProofSizeMeter to WeightInfo --- frame/ethereum/src/lib.rs | 4 +-- frame/evm/src/lib.rs | 12 ++++---- frame/evm/src/runner/stack.rs | 7 ++--- frame/evm/src/tests.rs | 25 ++++++----------- primitives/evm/src/lib.rs | 40 ++++++++++++++------------- primitives/evm/src/metric.rs | 52 +++++++++++++++++++++++++++-------- 6 files changed, 81 insertions(+), 59 deletions(-) diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 9b933bd0ee..38f66d0c58 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -695,8 +695,8 @@ impl Pallet { true, ); if let Some(weight_info) = weight_info { - if let Some(proof_size_usage) = weight_info.proof_size_usage { - *gas_to_weight.proof_size_mut() = proof_size_usage; + if let Some(proof_size_meter) = weight_info.proof_size_meter { + *gas_to_weight.proof_size_mut() = proof_size_meter.usage(); } } Some(gas_to_weight) diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index c7f72bc31a..78bbf8322c 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -268,8 +268,8 @@ pub mod pallet { true, ); if let Some(weight_info) = info.weight_info { - if let Some(proof_size_usage) = weight_info.proof_size_usage { - *gas_to_weight.proof_size_mut() = proof_size_usage; + if let Some(proof_size_meter) = weight_info.proof_size_meter { + *gas_to_weight.proof_size_mut() = proof_size_meter.usage(); } } Some(gas_to_weight) @@ -355,8 +355,8 @@ pub mod pallet { true, ); if let Some(weight_info) = info.weight_info { - if let Some(proof_size_usage) = weight_info.proof_size_usage { - *gas_to_weight.proof_size_mut() = proof_size_usage; + if let Some(proof_size_meter) = weight_info.proof_size_meter { + *gas_to_weight.proof_size_mut() = proof_size_meter.usage(); } } Some(gas_to_weight) @@ -443,8 +443,8 @@ pub mod pallet { true, ); if let Some(weight_info) = info.weight_info { - if let Some(proof_size_usage) = weight_info.proof_size_usage { - *gas_to_weight.proof_size_mut() = proof_size_usage; + if let Some(proof_size_meter) = weight_info.proof_size_meter { + *gas_to_weight.proof_size_mut() = proof_size_meter.usage(); } } Some(gas_to_weight) diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index c5df8840be..31171723ee 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -281,8 +281,7 @@ where Some(weight_info) => U256::from(sp_std::cmp::max( used_gas, weight_info - .proof_size_usage - .unwrap_or_default() + .proof_size_usage() .saturating_mul(T::GasLimitPovSizeRatio::get()), )), _ => used_gas.into(), @@ -1029,8 +1028,8 @@ where // Record proof_size // Return if proof size recording is disabled - let proof_size_limit = if let Some(proof_size_limit) = weight_info.proof_size_limit { - proof_size_limit + let proof_size_limit = if let Some(proof_size_meter) = weight_info.proof_size_meter { + proof_size_meter.limit() } else { return Ok(()); }; diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index 7efae3ca92..e086550f80 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -185,8 +185,7 @@ mod proof_size_test { let actual_proof_size = result .weight_info .expect("weight info") - .proof_size_usage - .expect("proof size usage"); + .proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -246,8 +245,7 @@ mod proof_size_test { let actual_proof_size = result .weight_info .expect("weight info") - .proof_size_usage - .expect("proof size usage"); + .proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -303,8 +301,7 @@ mod proof_size_test { let actual_proof_size = result .weight_info .expect("weight info") - .proof_size_usage - .expect("proof size usage"); + .proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -352,8 +349,7 @@ mod proof_size_test { let actual_proof_size = result .weight_info .expect("weight info") - .proof_size_usage - .expect("proof size usage"); + .proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -402,8 +398,7 @@ mod proof_size_test { let actual_proof_size = result .weight_info .expect("weight info") - .proof_size_usage - .expect("proof size usage"); + .proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -459,9 +454,7 @@ mod proof_size_test { let actual_proof_size = result .weight_info .expect("weight info") - .proof_size_usage - .expect("proof size usage"); - + .proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); } @@ -529,8 +522,7 @@ mod proof_size_test { let actual_proof_size = result .weight_info .expect("weight info") - .proof_size_usage - .expect("proof size usage"); + .proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -616,8 +608,7 @@ mod proof_size_test { let actual_proof_size = result .weight_info .expect("weight info") - .proof_size_usage - .expect("proof size usage"); + .proof_size_usage(); assert_eq!(used_gas.standard, U256::from(21_000)); assert_eq!(used_gas.effective, U256::from(actual_proof_size * ratio)); diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 138ae72536..9e2765ff77 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -18,11 +18,12 @@ #![cfg_attr(not(feature = "std"), no_std)] #![deny(unused_crate_dependencies)] +mod metric; mod precompile; mod validation; -mod metric; use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight}; +use metric::ProofSizeMeter; use scale_codec::{Decode, Encode}; use scale_info::TypeInfo; #[cfg(feature = "serde")] @@ -78,9 +79,8 @@ pub enum AccessedStorage { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct WeightInfo { pub ref_time_limit: Option, - pub proof_size_limit: Option, pub ref_time_usage: Option, - pub proof_size_usage: Option, + pub proof_size_meter: Option, } impl WeightInfo { @@ -95,16 +95,17 @@ impl WeightInfo { { Some(WeightInfo { ref_time_limit: Some(weight_limit.ref_time()), - proof_size_limit: Some(weight_limit.proof_size()), ref_time_usage: Some(0u64), - proof_size_usage: Some(proof_size_base_cost), + proof_size_meter: Some( + ProofSizeMeter::new(proof_size_base_cost, weight_limit.proof_size()) + .map_err(|_| "invalid proof size base cost")?, + ), }) } (Some(weight_limit), None) => Some(WeightInfo { ref_time_limit: Some(weight_limit.ref_time()), - proof_size_limit: None, ref_time_usage: Some(0u64), - proof_size_usage: None, + proof_size_meter: None, }), _ => return Err("must provide Some valid weight limit or None"), }) @@ -129,22 +130,23 @@ impl WeightInfo { Ok(()) } pub fn try_record_proof_size_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { - if let (Some(proof_size_usage), Some(proof_size_limit)) = - (self.proof_size_usage, self.proof_size_limit) - { - let proof_size_usage = self.try_consume(cost, proof_size_limit, proof_size_usage)?; - if proof_size_usage > proof_size_limit { - return Err(ExitError::OutOfGas); - } - self.proof_size_usage = Some(proof_size_usage); + if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { + proof_size_meter + .record_proof_size(cost) + .map_err(|_| ExitError::OutOfGas)?; } + Ok(()) } pub fn refund_proof_size(&mut self, amount: u64) { - if let Some(proof_size_usage) = self.proof_size_usage { - let proof_size_usage = proof_size_usage.saturating_sub(amount); - self.proof_size_usage = Some(proof_size_usage); - } + self.proof_size_meter.as_mut().map(|proof_size_meter| { + proof_size_meter.refund(amount); + }); + } + + pub fn proof_size_usage(&self) -> u64 { + self.proof_size_meter + .map_or(0, |proof_size_meter| proof_size_meter.usage()) } pub fn refund_ref_time(&mut self, amount: u64) { if let Some(ref_time_usage) = self.ref_time_usage { diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/metric.rs index 15f8b43e03..885e1df9b1 100644 --- a/primitives/evm/src/metric.rs +++ b/primitives/evm/src/metric.rs @@ -1,6 +1,13 @@ -use evm::{gasometer::GasCost, ExitError, Opcode}; +use evm::{gasometer::GasCost, Opcode}; +use scale_codec::{Decode, Encode}; +use scale_info::TypeInfo; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; +use sp_core::U256; use sp_runtime::{traits::CheckedAdd, Saturating}; +use crate::AccessedStorage; + #[derive(Debug, PartialEq)] /// Metric error. pub enum MetricError { @@ -10,14 +17,8 @@ pub enum MetricError { InvalidBaseCost, } -impl Into for MetricError { - fn into(self) -> ExitError { - match self { - MetricError::LimitExceeded | MetricError::InvalidBaseCost => ExitError::OutOfGas, - } - } -} - +#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] /// A struct that keeps track of metric usage and limit. pub struct Metric { limit: T, @@ -65,12 +66,26 @@ where fn refund(&mut self, amount: T) { self.usage = self.usage.saturating_sub(amount); } + + /// Returns the usage. + fn usage(&self) -> T { + self.usage + } } -/// A struct that keeps track of the size of the proof. +#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +/// A struct that keeps track of the proof size and limit. pub struct ProofSizeMeter(Metric); impl ProofSizeMeter { + /// `System::Account` 16(hash) + 20 (key) + 60 (AccountInfo::max_encoded_len) + pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 96; + /// `AccountCodesMetadata` read, temptatively 16 (hash) + 20 (key) + 40 (CodeMetadata). + pub const ACCOUNT_CODES_METADATA_PROOF_SIZE: u64 = 76; + /// Account basic proof size + 5 bytes max of `decode_len` call. + pub const IS_EMPTY_CHECK_PROOF_SIZE: u64 = 93; + /// Creates a new `ProofSizeMetric` instance with the given limit. pub fn new(base_cost: u64, limit: u64) -> Result { Ok(Self(Metric::new(base_cost, limit)?)) @@ -81,9 +96,24 @@ impl ProofSizeMeter { /// # Errors /// /// Returns `MetricError::LimitExceeded` if the proof size exceeds the limit. - fn record_proof_size(&mut self, size: u64) -> Result<(), MetricError> { + pub fn record_proof_size(&mut self, size: u64) -> Result<(), MetricError> { self.0.record_cost(size) } + + /// Refunds the given amount of proof size. + pub fn refund(&mut self, amount: u64) { + self.0.refund(amount) + } + + /// Returns the proof size usage. + pub fn usage(&self) -> u64 { + self.0.usage() + } + + /// Returns the proof size limit. + pub fn limit(&self) -> u64 { + self.0.limit + } } /// A struct that keeps track of storage usage (newly created storage) and limit. From 1be13dfe19fc10dff964d85e0cdaa354fa2d3c2a Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Thu, 3 Aug 2023 13:34:13 +0300 Subject: [PATCH 16/46] formatting --- frame/evm/src/tests.rs | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index e086550f80..6fb1ea6f58 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -182,10 +182,7 @@ mod proof_size_test { let nonce_increases = ACCOUNT_BASIC_PROOF_SIZE * 2; let expected_proof_size = write_cost + is_empty_check + nonce_increases; - let actual_proof_size = result - .weight_info - .expect("weight info") - .proof_size_usage(); + let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -242,10 +239,7 @@ mod proof_size_test { + reading_main_contract_len + is_empty_check + increase_nonce) as u64; - let actual_proof_size = result - .weight_info - .expect("weight info") - .proof_size_usage(); + let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -298,10 +292,7 @@ mod proof_size_test { + reading_main_contract_len + is_empty_check + increase_nonce) as u64; - let actual_proof_size = result - .weight_info - .expect("weight info") - .proof_size_usage(); + let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -346,10 +337,7 @@ mod proof_size_test { + IS_EMPTY_CHECK_PROOF_SIZE + (ACCOUNT_BASIC_PROOF_SIZE * 2); - let actual_proof_size = result - .weight_info - .expect("weight info") - .proof_size_usage(); + let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -395,10 +383,7 @@ mod proof_size_test { + IS_EMPTY_CHECK_PROOF_SIZE + (ACCOUNT_BASIC_PROOF_SIZE * 2); - let actual_proof_size = result - .weight_info - .expect("weight info") - .proof_size_usage(); + let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -451,10 +436,7 @@ mod proof_size_test { let expected_proof_size = overhead + (number_balance_reads * ACCOUNT_BASIC_PROOF_SIZE) as u64; - let actual_proof_size = result - .weight_info - .expect("weight info") - .proof_size_usage(); + let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); } @@ -519,10 +501,7 @@ mod proof_size_test { + reading_main_contract_len + is_empty_check + increase_nonce) as u64; - let actual_proof_size = result - .weight_info - .expect("weight info") - .proof_size_usage(); + let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -605,10 +584,7 @@ mod proof_size_test { let ratio = <::GasLimitPovSizeRatio as Get>::get(); let used_gas = result.used_gas; - let actual_proof_size = result - .weight_info - .expect("weight info") - .proof_size_usage(); + let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); assert_eq!(used_gas.standard, U256::from(21_000)); assert_eq!(used_gas.effective, U256::from(actual_proof_size * ratio)); From 07ba5f531a431330a725dfcfdd7efff81cb0a57b Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Thu, 3 Aug 2023 14:41:30 +0300 Subject: [PATCH 17/46] Add RefTimeMeter to WeightInfo --- primitives/evm/src/lib.rs | 47 ++++++++++++++++-------------------- primitives/evm/src/metric.rs | 26 +++++++++++++++++--- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 9e2765ff77..1f4a7722bb 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -23,7 +23,7 @@ mod precompile; mod validation; use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight}; -use metric::ProofSizeMeter; +use metric::{ProofSizeMeter, RefTimeMeter}; use scale_codec::{Decode, Encode}; use scale_info::TypeInfo; #[cfg(feature = "serde")] @@ -78,8 +78,7 @@ pub enum AccessedStorage { #[derive(Clone, Copy, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct WeightInfo { - pub ref_time_limit: Option, - pub ref_time_usage: Option, + pub ref_time_meter: Option, pub proof_size_meter: Option, } @@ -94,8 +93,10 @@ impl WeightInfo { if weight_limit.proof_size() >= proof_size_base_cost => { Some(WeightInfo { - ref_time_limit: Some(weight_limit.ref_time()), - ref_time_usage: Some(0u64), + ref_time_meter: Some( + RefTimeMeter::new(weight_limit.ref_time()) + .map_err(|_| "invalid ref time base cost")?, + ), proof_size_meter: Some( ProofSizeMeter::new(proof_size_base_cost, weight_limit.proof_size()) .map_err(|_| "invalid proof size base cost")?, @@ -103,30 +104,23 @@ impl WeightInfo { }) } (Some(weight_limit), None) => Some(WeightInfo { - ref_time_limit: Some(weight_limit.ref_time()), - ref_time_usage: Some(0u64), + ref_time_meter: Some( + RefTimeMeter::new(weight_limit.ref_time()) + .map_err(|_| "invalid ref time base cost")?, + ), proof_size_meter: None, }), _ => return Err("must provide Some valid weight limit or None"), }) } - fn try_consume(&self, cost: u64, limit: u64, usage: u64) -> Result { - let usage = usage.checked_add(cost).ok_or(ExitError::OutOfGas)?; - if usage > limit { - return Err(ExitError::OutOfGas); - } - Ok(usage) - } + pub fn try_record_ref_time_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { - if let (Some(ref_time_usage), Some(ref_time_limit)) = - (self.ref_time_usage, self.ref_time_limit) - { - let ref_time_usage = self.try_consume(cost, ref_time_limit, ref_time_usage)?; - if ref_time_usage > ref_time_limit { - return Err(ExitError::OutOfGas); - } - self.ref_time_usage = Some(ref_time_usage); + if let Some(ref_time_meter) = self.ref_time_meter.as_mut() { + ref_time_meter + .record_ref_time(cost) + .map_err(|_| ExitError::OutOfGas)?; } + Ok(()) } pub fn try_record_proof_size_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { @@ -138,6 +132,7 @@ impl WeightInfo { Ok(()) } + pub fn refund_proof_size(&mut self, amount: u64) { self.proof_size_meter.as_mut().map(|proof_size_meter| { proof_size_meter.refund(amount); @@ -148,11 +143,11 @@ impl WeightInfo { self.proof_size_meter .map_or(0, |proof_size_meter| proof_size_meter.usage()) } + pub fn refund_ref_time(&mut self, amount: u64) { - if let Some(ref_time_usage) = self.ref_time_usage { - let ref_time_usage = ref_time_usage.saturating_sub(amount); - self.ref_time_usage = Some(ref_time_usage); - } + self.ref_time_meter.as_mut().map(|ref_time_meter| { + ref_time_meter.refund(amount); + }); } } diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/metric.rs index 885e1df9b1..fd3c36ed15 100644 --- a/primitives/evm/src/metric.rs +++ b/primitives/evm/src/metric.rs @@ -3,11 +3,8 @@ use scale_codec::{Decode, Encode}; use scale_info::TypeInfo; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; -use sp_core::U256; use sp_runtime::{traits::CheckedAdd, Saturating}; -use crate::AccessedStorage; - #[derive(Debug, PartialEq)] /// Metric error. pub enum MetricError { @@ -73,9 +70,9 @@ where } } +/// A struct that keeps track of the proof size and limit. #[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -/// A struct that keeps track of the proof size and limit. pub struct ProofSizeMeter(Metric); impl ProofSizeMeter { @@ -116,6 +113,27 @@ impl ProofSizeMeter { } } +/// A struct that keeps track of the ref_time usage and limit. +#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub struct RefTimeMeter(Metric); + +impl RefTimeMeter { + /// Creates a new `RefTimeMetric` instance with the given limit. + pub fn new(limit: u64) -> Result { + Ok(Self(Metric::new(0, limit)?)) + } + + /// Records the ref_time and updates the usage. + pub fn record_ref_time(&mut self, ref_time: u64) -> Result<(), MetricError> { + self.0.record_cost(ref_time) + } + + /// Refunds the given amount of ref_time. + pub fn refund(&mut self, amount: u64) { + self.0.refund(amount) + } +} /// A struct that keeps track of storage usage (newly created storage) and limit. pub struct StorageMeter(Metric); From 7a8c09e2fdce8c7ac5641fb3f0c4eafc3ed1832f Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Fri, 4 Aug 2023 12:25:09 +0300 Subject: [PATCH 18/46] add storage meter to WeightInfo --- frame/evm/src/runner/stack.rs | 51 ++++++++++++++++++++++++++------ primitives/evm/src/lib.rs | 55 ++++++++++++++++------------------- primitives/evm/src/metric.rs | 20 ++++++++----- 3 files changed, 79 insertions(+), 47 deletions(-) diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 31171723ee..d2e2bb3137 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -180,13 +180,46 @@ where R: Default, { // Used to record the external costs in the evm through the StackState implementation - let maybe_weight_info = - WeightInfo::new_from_weight_limit(weight_limit, proof_size_base_cost).map_err( - |_| RunnerError { - error: Error::::Undefined, - weight, - }, - )?; + + let mut weight_info = WeightInfo::new(); + match weight_limit { + Some(weight_limit) => { + weight_info + .add_ref_time_meter(weight_limit.ref_time()) + .map_err(|_| RunnerError { + error: Error::::Undefined, + weight, + })?; + if let Some(proof_size_base_cost) = proof_size_base_cost { + weight_info + .add_proof_size_meter(proof_size_base_cost, weight_limit.proof_size()) + .map_err(|_| RunnerError { + error: Error::::Undefined, + weight, + })?; + } + } + None => (), + } + + // TODO Compute the limit of storage per tx + let storage_limit = 0; + weight_info.add_storage_meter(storage_limit).map_err(|_| RunnerError { + error: Error::::Undefined, + weight, + })?; + + let weight_info = if weight_info.ref_time_meter.is_none() + && weight_info.proof_size_meter.is_none() + && weight_info.storage_meter.is_none() + { + None + } + else { + Some(weight_info) + }; + + // The precompile check is only used for transactional invocations. However, here we always // execute the check, because the check has side effects. match precompiles.is_precompile(source, gas_limit) { @@ -201,7 +234,7 @@ where standard: gas_limit.into(), effective: gas_limit.into(), }, - weight_info: maybe_weight_info, + weight_info, logs: Default::default(), }) } @@ -270,7 +303,7 @@ where }; let metadata = StackSubstateMetadata::new(gas_limit, config); - let state = SubstrateStackState::new(&vicinity, metadata, maybe_weight_info); + let state = SubstrateStackState::new(&vicinity, metadata, weight_info); let mut executor = StackExecutor::new_with_precompiles(state, config, precompiles); let (reason, retv) = f(&mut executor); diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 1f4a7722bb..44a96bd6ec 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -23,7 +23,7 @@ mod precompile; mod validation; use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight}; -use metric::{ProofSizeMeter, RefTimeMeter}; +use metric::{ProofSizeMeter, RefTimeMeter, StorageMeter}; use scale_codec::{Decode, Encode}; use scale_info::TypeInfo; #[cfg(feature = "serde")] @@ -80,38 +80,33 @@ pub enum AccessedStorage { pub struct WeightInfo { pub ref_time_meter: Option, pub proof_size_meter: Option, + pub storage_meter: Option, } impl WeightInfo { - pub fn new_from_weight_limit( - weight_limit: Option, - proof_size_base_cost: Option, - ) -> Result, &'static str> { - Ok(match (weight_limit, proof_size_base_cost) { - (None, _) => None, - (Some(weight_limit), Some(proof_size_base_cost)) - if weight_limit.proof_size() >= proof_size_base_cost => - { - Some(WeightInfo { - ref_time_meter: Some( - RefTimeMeter::new(weight_limit.ref_time()) - .map_err(|_| "invalid ref time base cost")?, - ), - proof_size_meter: Some( - ProofSizeMeter::new(proof_size_base_cost, weight_limit.proof_size()) - .map_err(|_| "invalid proof size base cost")?, - ), - }) - } - (Some(weight_limit), None) => Some(WeightInfo { - ref_time_meter: Some( - RefTimeMeter::new(weight_limit.ref_time()) - .map_err(|_| "invalid ref time base cost")?, - ), - proof_size_meter: None, - }), - _ => return Err("must provide Some valid weight limit or None"), - }) + pub fn new() -> Self { + Self { + ref_time_meter: None, + proof_size_meter: None, + storage_meter: None, + } + } + + pub fn add_ref_time_meter(&mut self, limit: u64) -> Result<(), &'static str> { + self.ref_time_meter = Some(RefTimeMeter::new(limit).map_err(|_| "Invalid parameters")?); + Ok(()) + } + + pub fn add_proof_size_meter(&mut self, base_cost: u64, limit: u64) -> Result<(), &'static str> { + self.proof_size_meter = + Some(ProofSizeMeter::new(base_cost, limit).map_err(|_| "Invalid parameters")?); + Ok(()) + } + + pub fn add_storage_meter(&mut self, limit: u64) -> Result<(), &'static str> { + self.storage_meter = + Some(StorageMeter::new(limit).map_err(|_| "Invalid parameters")?); + Ok(()) } pub fn try_record_ref_time_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/metric.rs index fd3c36ed15..03c590f6e5 100644 --- a/primitives/evm/src/metric.rs +++ b/primitives/evm/src/metric.rs @@ -14,9 +14,9 @@ pub enum MetricError { InvalidBaseCost, } +/// A struct that keeps track of metric usage and limit. #[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -/// A struct that keeps track of metric usage and limit. pub struct Metric { limit: T, usage: T, @@ -76,13 +76,6 @@ where pub struct ProofSizeMeter(Metric); impl ProofSizeMeter { - /// `System::Account` 16(hash) + 20 (key) + 60 (AccountInfo::max_encoded_len) - pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 96; - /// `AccountCodesMetadata` read, temptatively 16 (hash) + 20 (key) + 40 (CodeMetadata). - pub const ACCOUNT_CODES_METADATA_PROOF_SIZE: u64 = 76; - /// Account basic proof size + 5 bytes max of `decode_len` call. - pub const IS_EMPTY_CHECK_PROOF_SIZE: u64 = 93; - /// Creates a new `ProofSizeMetric` instance with the given limit. pub fn new(base_cost: u64, limit: u64) -> Result { Ok(Self(Metric::new(base_cost, limit)?)) @@ -135,6 +128,8 @@ impl RefTimeMeter { } } /// A struct that keeps track of storage usage (newly created storage) and limit. +#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct StorageMeter(Metric); impl StorageMeter { @@ -175,6 +170,15 @@ impl StorageMeter { }; self.0.record_cost(cost) } + + fn record_external_operation(&mut self, operation: evm::ExternalOperation) { + match operation { + evm::ExternalOperation::Write => { + // Todo record cost for write + } + _ => {} + } + } } #[cfg(test)] From 1ab2dc3da4432944e074ad0f0a1e8e14d07ae276 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Fri, 4 Aug 2023 14:17:52 +0300 Subject: [PATCH 19/46] rename metric to resource --- primitives/evm/src/lib.rs | 4 +- primitives/evm/src/{metric.rs => resource.rs} | 130 +++++++++--------- 2 files changed, 67 insertions(+), 67 deletions(-) rename primitives/evm/src/{metric.rs => resource.rs} (52%) diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 44a96bd6ec..4265a3b328 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -18,12 +18,12 @@ #![cfg_attr(not(feature = "std"), no_std)] #![deny(unused_crate_dependencies)] -mod metric; +mod resource; mod precompile; mod validation; use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight}; -use metric::{ProofSizeMeter, RefTimeMeter, StorageMeter}; +use resource::{ProofSizeMeter, RefTimeMeter, StorageMeter}; use scale_codec::{Decode, Encode}; use scale_info::TypeInfo; #[cfg(feature = "serde")] diff --git a/primitives/evm/src/metric.rs b/primitives/evm/src/resource.rs similarity index 52% rename from primitives/evm/src/metric.rs rename to primitives/evm/src/resource.rs index 03c590f6e5..4d80f60b08 100644 --- a/primitives/evm/src/metric.rs +++ b/primitives/evm/src/resource.rs @@ -6,34 +6,34 @@ use serde::{Deserialize, Serialize}; use sp_runtime::{traits::CheckedAdd, Saturating}; #[derive(Debug, PartialEq)] -/// Metric error. -pub enum MetricError { - /// The metric usage exceeds the limit. +/// Resource error. +pub enum ResourceError { + /// The Resource usage exceeds the limit. LimitExceeded, /// Invalid Base Cost. InvalidBaseCost, } -/// A struct that keeps track of metric usage and limit. +/// A struct that keeps track of resource usage and limit. #[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct Metric { +pub struct Resource { limit: T, usage: T, } -impl Metric +impl Resource where T: CheckedAdd + Saturating + PartialOrd + Copy, { - /// Creates a new `Metric` instance with the given base cost and limit. + /// Creates a new `Resource` instance with the given base cost and limit. /// /// # Errors /// - /// Returns `MetricError::InvalidBaseCost` if the base cost is greater than the limit. - pub fn new(base_cost: T, limit: T) -> Result { + /// Returns `ResourceError::InvalidBaseCost` if the base cost is greater than the limit. + pub fn new(base_cost: T, limit: T) -> Result { if base_cost > limit { - return Err(MetricError::InvalidBaseCost); + return Err(ResourceError::InvalidBaseCost); } Ok(Self { limit, @@ -45,15 +45,15 @@ where /// /// # Errors /// - /// Returns `MetricError::LimitExceeded` if the metric usage exceeds the limit. - fn record_cost(&mut self, cost: T) -> Result<(), MetricError> { + /// Returns `ResourceError::LimitExceeded` if the Resource usage exceeds the limit. + fn record_cost(&mut self, cost: T) -> Result<(), ResourceError> { let usage = self .usage .checked_add(&cost) - .ok_or(MetricError::LimitExceeded)?; + .ok_or(ResourceError::LimitExceeded)?; if usage > self.limit { - return Err(MetricError::LimitExceeded); + return Err(ResourceError::LimitExceeded); } self.usage = usage; Ok(()) @@ -73,20 +73,20 @@ where /// A struct that keeps track of the proof size and limit. #[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct ProofSizeMeter(Metric); +pub struct ProofSizeMeter(Resource); impl ProofSizeMeter { - /// Creates a new `ProofSizeMetric` instance with the given limit. - pub fn new(base_cost: u64, limit: u64) -> Result { - Ok(Self(Metric::new(base_cost, limit)?)) + /// Creates a new `ProofSizeResource` instance with the given limit. + pub fn new(base_cost: u64, limit: u64) -> Result { + Ok(Self(Resource::new(base_cost, limit)?)) } /// Records the size of the proof and updates the usage. /// /// # Errors /// - /// Returns `MetricError::LimitExceeded` if the proof size exceeds the limit. - pub fn record_proof_size(&mut self, size: u64) -> Result<(), MetricError> { + /// Returns `ResourceError::LimitExceeded` if the proof size exceeds the limit. + pub fn record_proof_size(&mut self, size: u64) -> Result<(), ResourceError> { self.0.record_cost(size) } @@ -109,16 +109,16 @@ impl ProofSizeMeter { /// A struct that keeps track of the ref_time usage and limit. #[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct RefTimeMeter(Metric); +pub struct RefTimeMeter(Resource); impl RefTimeMeter { - /// Creates a new `RefTimeMetric` instance with the given limit. - pub fn new(limit: u64) -> Result { - Ok(Self(Metric::new(0, limit)?)) + /// Creates a new `RefTimeResource` instance with the given limit. + pub fn new(limit: u64) -> Result { + Ok(Self(Resource::new(0, limit)?)) } /// Records the ref_time and updates the usage. - pub fn record_ref_time(&mut self, ref_time: u64) -> Result<(), MetricError> { + pub fn record_ref_time(&mut self, ref_time: u64) -> Result<(), ResourceError> { self.0.record_cost(ref_time) } @@ -130,12 +130,12 @@ impl RefTimeMeter { /// A struct that keeps track of storage usage (newly created storage) and limit. #[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct StorageMeter(Metric); +pub struct StorageMeter(Resource); impl StorageMeter { - /// Creates a new `StorageMetric` instance with the given limit. - pub fn new(limit: u64) -> Result { - Ok(Self(Metric::new(0, limit)?)) + /// Creates a new `StorageResource` instance with the given limit. + pub fn new(limit: u64) -> Result { + Ok(Self(Resource::new(0, limit)?)) } /// Refunds the given amount of storage. @@ -147,12 +147,12 @@ impl StorageMeter { /// /// # Errors /// - /// Returns `MetricError::LimitExceeded` if the storage usage exceeds the storage limit. + /// Returns `ResourceError::LimitExceeded` if the storage usage exceeds the storage limit. fn record_dynamic_opcode_cost( &mut self, _opcode: Opcode, gas_cost: GasCost, - ) -> Result<(), MetricError> { + ) -> Result<(), ResourceError> { let cost = match gas_cost { GasCost::Create => { // TODO record cost for create @@ -160,7 +160,7 @@ impl StorageMeter { } GasCost::Create2 { len } => { // len in bytes ?? - len.try_into().map_err(|_| MetricError::LimitExceeded)? + len.try_into().map_err(|_| ResourceError::LimitExceeded)? } GasCost::SStore { .. } => { // TODO record cost for sstore @@ -187,55 +187,55 @@ mod tests { #[test] fn test_init() { - let metric = Metric::::new(0, 100).unwrap(); - assert_eq!(metric.limit, 100); - assert_eq!(metric.usage, 0); + let resource = Resource::::new(0, 100).unwrap(); + assert_eq!(resource.limit, 100); + assert_eq!(resource.usage, 0); // base cost > limit - let metric = Metric::::new(100, 0).err(); - assert_eq!(metric, Some(MetricError::InvalidBaseCost)); + let resource = Resource::::new(100, 0).err(); + assert_eq!(resource, Some(ResourceError::InvalidBaseCost)); } #[test] fn test_record_cost() { - let mut metric = Metric::::new(0, 100).unwrap(); - assert_eq!(metric.record_cost(10), Ok(())); - assert_eq!(metric.usage, 10); - assert_eq!(metric.record_cost(90), Ok(())); - assert_eq!(metric.usage, 100); + let mut resource = Resource::::new(0, 100).unwrap(); + assert_eq!(resource.record_cost(10), Ok(())); + assert_eq!(resource.usage, 10); + assert_eq!(resource.record_cost(90), Ok(())); + assert_eq!(resource.usage, 100); // exceed limit - assert_eq!(metric.record_cost(1), Err(MetricError::LimitExceeded)); - assert_eq!(metric.usage, 100); + assert_eq!(resource.record_cost(1), Err(ResourceError::LimitExceeded)); + assert_eq!(resource.usage, 100); } #[test] fn test_refund() { - let mut metric = Metric::::new(0, 100).unwrap(); - assert_eq!(metric.record_cost(10), Ok(())); - assert_eq!(metric.usage, 10); - metric.refund(10); - assert_eq!(metric.usage, 0); + let mut resource = Resource::::new(0, 100).unwrap(); + assert_eq!(resource.record_cost(10), Ok(())); + assert_eq!(resource.usage, 10); + resource.refund(10); + assert_eq!(resource.usage, 0); // refund more than usage - metric.refund(10); - assert_eq!(metric.usage, 0); + resource.refund(10); + assert_eq!(resource.usage, 0); } #[test] - fn test_storage_metric() { - let mut metric = StorageMeter::new(100).unwrap(); - assert_eq!(metric.0.usage, 0); - assert_eq!(metric.0.limit, 100); - assert_eq!(metric.0.record_cost(10), Ok(())); - assert_eq!(metric.0.usage, 10); - assert_eq!(metric.0.record_cost(90), Ok(())); - assert_eq!(metric.0.usage, 100); - assert_eq!(metric.0.record_cost(1), Err(MetricError::LimitExceeded)); - assert_eq!(metric.0.usage, 100); - metric.0.refund(10); - assert_eq!(metric.0.usage, 90); - metric.refund(10); - assert_eq!(metric.0.usage, 80); + fn test_storage_resource() { + let mut resource = StorageMeter::new(100).unwrap(); + assert_eq!(resource.0.usage, 0); + assert_eq!(resource.0.limit, 100); + assert_eq!(resource.0.record_cost(10), Ok(())); + assert_eq!(resource.0.usage, 10); + assert_eq!(resource.0.record_cost(90), Ok(())); + assert_eq!(resource.0.usage, 100); + assert_eq!(resource.0.record_cost(1), Err(ResourceError::LimitExceeded)); + assert_eq!(resource.0.usage, 100); + resource.0.refund(10); + assert_eq!(resource.0.usage, 90); + resource.refund(10); + assert_eq!(resource.0.usage, 80); } } From 6b41b63f6cab357cc679aa8755eaa8d0d6652c9d Mon Sep 17 00:00:00 2001 From: Andrea Giacobino Date: Mon, 28 Aug 2023 23:08:51 +0200 Subject: [PATCH 20/46] code refactor --- frame/ethereum/src/lib.rs | 4 +- frame/evm/src/lib.rs | 13 +- frame/evm/src/resource.rs | 628 +++++++++++++++++++++++++++++++++ frame/evm/src/runner/stack.rs | 274 +++----------- frame/evm/src/tests.rs | 62 +++- primitives/evm/src/lib.rs | 89 +---- primitives/evm/src/resource.rs | 241 ------------- 7 files changed, 741 insertions(+), 570 deletions(-) create mode 100644 frame/evm/src/resource.rs delete mode 100644 primitives/evm/src/resource.rs diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 38f66d0c58..9b933bd0ee 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -695,8 +695,8 @@ impl Pallet { true, ); if let Some(weight_info) = weight_info { - if let Some(proof_size_meter) = weight_info.proof_size_meter { - *gas_to_weight.proof_size_mut() = proof_size_meter.usage(); + if let Some(proof_size_usage) = weight_info.proof_size_usage { + *gas_to_weight.proof_size_mut() = proof_size_usage; } } Some(gas_to_weight) diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 78bbf8322c..d281f1b873 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -60,6 +60,7 @@ pub mod benchmarking; #[cfg(test)] mod mock; +pub mod resource; pub mod runner; #[cfg(test)] mod tests; @@ -268,8 +269,8 @@ pub mod pallet { true, ); if let Some(weight_info) = info.weight_info { - if let Some(proof_size_meter) = weight_info.proof_size_meter { - *gas_to_weight.proof_size_mut() = proof_size_meter.usage(); + if let Some(proof_size_usage) = weight_info.proof_size_usage { + *gas_to_weight.proof_size_mut() = proof_size_usage; } } Some(gas_to_weight) @@ -355,8 +356,8 @@ pub mod pallet { true, ); if let Some(weight_info) = info.weight_info { - if let Some(proof_size_meter) = weight_info.proof_size_meter { - *gas_to_weight.proof_size_mut() = proof_size_meter.usage(); + if let Some(proof_size_usage) = weight_info.proof_size_usage { + *gas_to_weight.proof_size_mut() = proof_size_usage; } } Some(gas_to_weight) @@ -443,8 +444,8 @@ pub mod pallet { true, ); if let Some(weight_info) = info.weight_info { - if let Some(proof_size_meter) = weight_info.proof_size_meter { - *gas_to_weight.proof_size_mut() = proof_size_meter.usage(); + if let Some(proof_size_usage) = weight_info.proof_size_usage { + *gas_to_weight.proof_size_mut() = proof_size_usage; } } Some(gas_to_weight) diff --git a/frame/evm/src/resource.rs b/frame/evm/src/resource.rs new file mode 100644 index 0000000000..db07f775df --- /dev/null +++ b/frame/evm/src/resource.rs @@ -0,0 +1,628 @@ +use crate::{AccountCodes, AccountCodesMetadata, Config, Pallet}; + +use core::marker::PhantomData; +use evm::{ + gasometer::{GasCost, StorageTarget}, + ExitError, Opcode, +}; +use fp_evm::WeightInfo; +use sp_core::{Get, H160, H256, U256}; +use sp_runtime::{traits::CheckedAdd, Saturating}; +use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; + +/// `System::Account` 16(hash) + 20 (key) + 60 (AccountInfo::max_encoded_len) +pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 96; +/// `AccountCodesMetadata` read, temptatively 16 (hash) + 20 (key) + 40 (CodeMetadata). +pub const ACCOUNT_CODES_METADATA_PROOF_SIZE: u64 = 76; +/// 16 (hash1) + 20 (key1) + 16 (hash2) + 32 (key2) + 32 (value) +pub const ACCOUNT_STORAGE_PROOF_SIZE: u64 = 116; +/// Fixed trie 32 byte hash. +pub const WRITE_PROOF_SIZE: u64 = 32; +/// Account basic proof size + 5 bytes max of `decode_len` call. +pub const IS_EMPTY_CHECK_PROOF_SIZE: u64 = 93; + +#[derive(Debug, PartialEq)] +/// Resource error. +pub enum ResourceError { + /// The Resource usage exceeds the limit. + LimitExceeded, + /// Invalid Base Cost. + InvalidBaseCost, + ///Used to indicate that the code should be unreachable. + Unreachable, +} + +/// A struct that keeps track of resource usage and limit. +pub struct Resource { + limit: T, + usage: T, +} + +impl Resource +where + T: CheckedAdd + Saturating + PartialOrd + Copy, +{ + /// Creates a new `Resource` instance with the given base cost and limit. + /// + /// # Errors + /// + /// Returns `ResourceError::InvalidBaseCost` if the base cost is greater than the limit. + pub fn new(base_cost: T, limit: T) -> Result { + if base_cost > limit { + return Err(ResourceError::InvalidBaseCost); + } + Ok(Self { + limit, + usage: base_cost, + }) + } + + /// Records the cost of an operation and updates the usage. + /// + /// # Errors + /// + /// Returns `ResourceError::LimitExceeded` if the Resource usage exceeds the limit. + fn record_cost(&mut self, cost: T) -> Result<(), ResourceError> { + let usage = self + .usage + .checked_add(&cost) + .ok_or(ResourceError::LimitExceeded)?; + + if usage > self.limit { + return Err(ResourceError::LimitExceeded); + } + self.usage = usage; + Ok(()) + } + + /// Refunds the given amount. + fn refund(&mut self, amount: T) { + self.usage = self.usage.saturating_sub(amount); + } + + /// Returns the usage. + fn usage(&self) -> T { + self.usage + } +} + +pub enum AccessedStorage { + AccountCodes(H160), + AccountStorages((H160, H256)), +} + +#[derive(Default, Clone, Eq, PartialEq)] +pub struct Recorded { + account_codes: Vec, + account_storages: BTreeMap<(H160, H256), bool>, +} + +/// A struct that keeps track of the proof size and limit. +pub struct ProofSizeMeter { + resource: Resource, + recorded: Recorded, + _marker: PhantomData, +} + +impl ProofSizeMeter { + /// Creates a new `ProofSizeResource` instance with the given limit. + pub fn new(base_cost: u64, limit: u64) -> Result { + Ok(Self { + resource: Resource::new(base_cost, limit)?, + recorded: Recorded::default(), + _marker: PhantomData, + }) + } + + /// Records the size of the proof and updates the usage. + /// + /// # Errors + /// + /// Returns `ResourceError::LimitExceeded` if the proof size exceeds the limit. + pub fn record_proof_size(&mut self, size: u64) -> Result<(), ResourceError> { + self.resource.record_cost(size) + } + + /// Refunds the given amount of proof size. + pub fn refund(&mut self, amount: u64) { + self.resource.refund(amount) + } + + /// Returns the proof size usage. + pub fn usage(&self) -> u64 { + self.resource.usage() + } + + /// Returns the proof size limit. + pub fn limit(&self) -> u64 { + self.resource.limit + } + + pub fn record_external_operation( + &mut self, + op: &evm::ExternalOperation, + contract_size_limit: u64, + ) -> Result<(), ResourceError> { + match op { + evm::ExternalOperation::AccountBasicRead => { + self.record_proof_size(ACCOUNT_BASIC_PROOF_SIZE)? + } + evm::ExternalOperation::AddressCodeRead(address) => { + let maybe_record = !self.recorded.account_codes.contains(&address); + // Skip if the address has been already recorded this block + if maybe_record { + // First we record account emptiness check. + // Transfers to EOAs with standard 21_000 gas limit are able to + // pay for this pov size. + self.record_proof_size(IS_EMPTY_CHECK_PROOF_SIZE)?; + + if >::decode_len(address).unwrap_or(0) == 0 { + return Ok(()); + } + // Try to record fixed sized `AccountCodesMetadata` read + // Tentatively 16 + 20 + 40 + self.record_proof_size(ACCOUNT_CODES_METADATA_PROOF_SIZE)?; + if let Some(meta) = >::get(address) { + self.record_proof_size(meta.size)?; + } else { + // If it does not exist, try to record `create_contract_limit` first. + self.record_proof_size(contract_size_limit)?; + let meta = Pallet::::account_code_metadata(*address); + let actual_size = meta.size; + // Refund if applies + self.refund(contract_size_limit.saturating_sub(actual_size)); + } + self.recorded.account_codes.push(*address); + } + } + evm::ExternalOperation::IsEmpty => self.record_proof_size(IS_EMPTY_CHECK_PROOF_SIZE)?, + evm::ExternalOperation::Write => self.record_proof_size(WRITE_PROOF_SIZE)?, + }; + Ok(()) + } + + pub fn record_external_dynamic_opcode_cost( + &mut self, + opcode: Opcode, + target: evm::gasometer::StorageTarget, + contract_size_limit: u64, + ) -> Result<(), ResourceError> { + // If account code or storage slot is in the overlay it is already accounted for and early exit + let mut accessed_storage: Option = match target { + StorageTarget::Address(address) => { + if self.recorded.account_codes.contains(&address) { + return Ok(()); + } else { + Some(AccessedStorage::AccountCodes(address)) + } + } + StorageTarget::Slot(address, index) => { + if self + .recorded + .account_storages + .contains_key(&(address, index)) + { + return Ok(()); + } else { + Some(AccessedStorage::AccountStorages((address, index))) + } + } + _ => None, + }; + + let mut maybe_record_and_refund = |with_empty_check: bool| -> Result<(), ResourceError> { + let address = if let Some(AccessedStorage::AccountCodes(address)) = accessed_storage { + address + } else { + // This must be unreachable, a valid target must be set. + // TODO decide how do we want to gracefully handle. + return Err(ResourceError::Unreachable); + }; + // First try to record fixed sized `AccountCodesMetadata` read + // Tentatively 20 + 8 + 32 + let mut base_cost = ACCOUNT_CODES_METADATA_PROOF_SIZE; + if with_empty_check { + base_cost = base_cost.saturating_add(IS_EMPTY_CHECK_PROOF_SIZE); + } + self.record_proof_size(base_cost)?; + if let Some(meta) = >::get(address) { + self.record_proof_size(meta.size)?; + } else { + // If it does not exist, try to record `create_contract_limit` first. + self.record_proof_size(contract_size_limit)?; + let meta = Pallet::::account_code_metadata(address); + let actual_size = meta.size; + // Refund if applies + self.refund(contract_size_limit.saturating_sub(actual_size)); + } + self.recorded.account_codes.push(address); + // Already recorded, return + Ok(()) + }; + + // Proof size is fixed length for writes (a 32-byte hash in a merkle trie), and + // the full key/value for reads. For read and writes over the same storage, the full value + // is included. + // For cold reads involving code (call, callcode, staticcall and delegatecall): + // - We depend on https://github.com/paritytech/frontier/pull/893 + // - Try to get the cached size or compute it on the fly + // - We record the actual size after caching, refunding the difference between it and the initially deducted + // contract size limit. + let opcode_proof_size = match opcode { + // Basic account fixed length + Opcode::BALANCE => { + accessed_storage = None; + U256::from(ACCOUNT_BASIC_PROOF_SIZE) + } + Opcode::EXTCODESIZE | Opcode::EXTCODECOPY | Opcode::EXTCODEHASH => { + return maybe_record_and_refund(false) + } + Opcode::CALLCODE | Opcode::CALL | Opcode::DELEGATECALL | Opcode::STATICCALL => { + return maybe_record_and_refund(true) + } + // (H160, H256) double map blake2 128 concat key size (68) + value 32 + Opcode::SLOAD => U256::from(ACCOUNT_STORAGE_PROOF_SIZE), + Opcode::SSTORE => { + let (address, index) = + if let Some(AccessedStorage::AccountStorages((address, index))) = + accessed_storage + { + (address, index) + } else { + // This must be unreachable, a valid target must be set. + // TODO decide how do we want to gracefully handle. + return Err(ResourceError::Unreachable); + }; + let mut cost = WRITE_PROOF_SIZE; + let maybe_record = !self + .recorded + .account_storages + .contains_key(&(address, index)); + // If the slot is yet to be accessed we charge for it, as the evm reads + // it prior to the opcode execution. + // Skip if the address and index has been already recorded this block. + if maybe_record { + cost = cost.saturating_add(ACCOUNT_STORAGE_PROOF_SIZE); + } + U256::from(cost) + } + // Fixed trie 32 byte hash + Opcode::CREATE | Opcode::CREATE2 => U256::from(WRITE_PROOF_SIZE), + // When calling SUICIDE a target account will receive the self destructing + // address's balance. We need to account for both: + // - Target basic account read + // - 5 bytes of `decode_len` + Opcode::SUICIDE => { + accessed_storage = None; + U256::from(IS_EMPTY_CHECK_PROOF_SIZE) + } + // Rest of dynamic opcodes that do not involve proof size recording, do nothing + _ => return Ok(()), + }; + + if opcode_proof_size > U256::from(u64::MAX) { + self.record_proof_size(self.limit())?; + return Err(ResourceError::LimitExceeded); + } + + // Cache the storage access + match accessed_storage { + Some(AccessedStorage::AccountStorages((address, index))) => { + self.recorded + .account_storages + .insert((address, index), true); + } + Some(AccessedStorage::AccountCodes(address)) => { + self.recorded.account_codes.push(address); + } + _ => {} + } + + // Record cost + self.record_proof_size(opcode_proof_size.low_u64())?; + Ok(()) + } + + pub fn record_external_static_opcode_cost( + &mut self, + _opcode: Opcode, + _gas_cost: GasCost, + ) -> Result<(), ResourceError> { + Ok(()) + } +} + +/// A struct that keeps track of the ref_time usage and limit. +pub struct RefTimeMeter(Resource); + +impl RefTimeMeter { + /// Creates a new `RefTimeResource` instance with the given limit. + pub fn new(limit: u64) -> Result { + Ok(Self(Resource::new(0, limit)?)) + } + + /// Records the ref_time and updates the usage. + pub fn record_ref_time(&mut self, ref_time: u64) -> Result<(), ResourceError> { + self.0.record_cost(ref_time) + } + + /// Returns the ref time usage. + pub fn usage(&self) -> u64 { + self.0.usage() + } + + /// Returns the ref time limit. + pub fn limit(&self) -> u64 { + self.0.limit + } + + /// Refunds the given amount of ref_time. + pub fn refund(&mut self, amount: u64) { + self.0.refund(amount) + } +} + +/// A struct that keeps track of storage usage (newly created storage) and limit. +pub struct StorageMeter(Resource); + +impl StorageMeter { + /// Creates a new `StorageResource` instance with the given limit. + pub fn new(limit: u64) -> Result { + Ok(Self(Resource::new(0, limit)?)) + } + + /// Refunds the given amount of storage. + fn _refund(&mut self, amount: u64) { + self.0.refund(amount) + } + + /// Returns the storage usage. + pub fn usage(&self) -> u64 { + self.0.usage() + } + + /// Records the dynamic opcode cost and updates the storage usage. + /// + /// # Errors + /// + /// Returns `ResourceError::LimitExceeded` if the storage usage exceeds the storage limit. + fn _record_dynamic_opcode_cost( + &mut self, + _opcode: Opcode, + gas_cost: GasCost, + ) -> Result<(), ResourceError> { + let cost = match gas_cost { + GasCost::Create => { + // TODO record cost for create + 0 + } + GasCost::Create2 { len } => { + // len in bytes ?? + len.try_into().map_err(|_| ResourceError::LimitExceeded)? + } + GasCost::SStore { .. } => { + // TODO record cost for sstore + 0 + } + _ => return Ok(()), + }; + self.0.record_cost(cost) + } + + fn record_external_operation( + &mut self, + operation: &evm::ExternalOperation, + _contract_size_limit: u64, + ) { + match operation { + evm::ExternalOperation::Write => { + // Todo record cost for write + } + _ => {} + } + } +} + +pub struct ResourceInfo { + pub ref_time_meter: Option, + pub proof_size_meter: Option>, + pub storage_meter: Option, +} + +impl ResourceInfo { + pub fn new() -> Self { + Self { + ref_time_meter: None, + proof_size_meter: None, + storage_meter: None, + } + } + + pub fn add_ref_time_meter(&mut self, limit: u64) -> Result<(), &'static str> { + self.ref_time_meter = Some(RefTimeMeter::new(limit).map_err(|_| "Invalid parameters")?); + Ok(()) + } + + pub fn add_proof_size_meter(&mut self, base_cost: u64, limit: u64) -> Result<(), &'static str> { + self.proof_size_meter = + Some(ProofSizeMeter::new(base_cost, limit).map_err(|_| "Invalid parameters")?); + Ok(()) + } + + pub fn add_storage_meter(&mut self, limit: u64) -> Result<(), &'static str> { + self.storage_meter = Some(StorageMeter::new(limit).map_err(|_| "Invalid parameters")?); + Ok(()) + } + + pub fn try_record_ref_time_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { + if let Some(ref_time_meter) = self.ref_time_meter.as_mut() { + ref_time_meter + .record_ref_time(cost) + .map_err(|_| ExitError::OutOfGas)?; + } + + Ok(()) + } + + pub fn try_record_proof_size_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { + if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { + proof_size_meter + .record_proof_size(cost) + .map_err(|_| ExitError::OutOfGas)?; + } + + Ok(()) + } + + pub fn refund_proof_size(&mut self, amount: u64) { + self.proof_size_meter.as_mut().map(|proof_size_meter| { + proof_size_meter.refund(amount); + }); + } + + pub fn refund_ref_time(&mut self, amount: u64) { + self.ref_time_meter.as_mut().map(|ref_time_meter| { + ref_time_meter.refund(amount); + }); + } + + /// Returns WeightInfo for the resource. + pub fn weight_info(&self) -> WeightInfo { + macro_rules! usage_and_limit { + ($x:expr) => { + ( + $x.as_ref().map(|x| x.usage()), + $x.as_ref().map(|x| x.limit()), + ) + }; + } + + let (proof_size_usage, proof_size_limit) = usage_and_limit!(self.proof_size_meter); + let (ref_time_usage, ref_time_limit) = usage_and_limit!(self.ref_time_meter); + + WeightInfo { + proof_size_usage, + proof_size_limit, + ref_time_usage, + ref_time_limit, + } + } + + pub fn record_external_operation( + &mut self, + operation: evm::ExternalOperation, + contract_size_limit: u64, + ) -> Result<(), ResourceError> { + if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { + proof_size_meter.record_external_operation(&operation, contract_size_limit)?; + } + + if let Some(storage_meter) = self.storage_meter.as_mut() { + storage_meter.record_external_operation(&operation, contract_size_limit) + } + + Ok(()) + } + + pub fn record_external_dynamic_opcode_cost( + &mut self, + opcode: Opcode, + target: evm::gasometer::StorageTarget, + contract_size_limit: u64, + ) -> Result<(), ResourceError> { + if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { + proof_size_meter.record_external_dynamic_opcode_cost( + opcode, + target, + contract_size_limit, + )?; + } + // Record ref_time + // TODO benchmark opcodes, until this is done we do used_gas to weight conversion for ref_time + + Ok(()) + } + + /// Computes the effective gas for the transaction. Effective gas is the maximum between the + /// gas used and resource usage. + pub fn effective_gas(&self, gas: u64) -> U256 { + let proof_size_usage = self + .proof_size_meter + .as_ref() + .map_or(0, |meter| meter.usage()) + .saturating_mul(T::GasLimitPovSizeRatio::get()); + + // TODO: use the actual ref time usage + // let ref_time_usage = self + // .ref_time_meter + // .map_or(0, |meter| meter.usage()) + // .saturating_mul(T::GasLimitPovRefTimeRatio::get()); + + // TODO get the Storage Gas ratio + let storage_usage = self.storage_meter.as_ref().map_or(0, |meter| meter.usage()); + + let effective_gas = + sp_std::cmp::max(sp_std::cmp::max(proof_size_usage, storage_usage), gas); + + U256::from(effective_gas) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_init() { + let resource = Resource::::new(0, 100).unwrap(); + assert_eq!(resource.limit, 100); + assert_eq!(resource.usage, 0); + + // base cost > limit + let resource = Resource::::new(100, 0).err(); + assert_eq!(resource, Some(ResourceError::InvalidBaseCost)); + } + + #[test] + fn test_record_cost() { + let mut resource = Resource::::new(0, 100).unwrap(); + assert_eq!(resource.record_cost(10), Ok(())); + assert_eq!(resource.usage, 10); + assert_eq!(resource.record_cost(90), Ok(())); + assert_eq!(resource.usage, 100); + + // exceed limit + assert_eq!(resource.record_cost(1), Err(ResourceError::LimitExceeded)); + assert_eq!(resource.usage, 100); + } + + #[test] + fn test_refund() { + let mut resource = Resource::::new(0, 100).unwrap(); + assert_eq!(resource.record_cost(10), Ok(())); + assert_eq!(resource.usage, 10); + resource.refund(10); + assert_eq!(resource.usage, 0); + + // refund more than usage + resource.refund(10); + assert_eq!(resource.usage, 0); + } + + #[test] + fn test_storage_resource() { + let mut resource = StorageMeter::new(100).unwrap(); + assert_eq!(resource.0.usage, 0); + assert_eq!(resource.0.limit, 100); + assert_eq!(resource.0.record_cost(10), Ok(())); + assert_eq!(resource.0.usage, 10); + assert_eq!(resource.0.record_cost(90), Ok(())); + assert_eq!(resource.0.usage, 100); + assert_eq!(resource.0.record_cost(1), Err(ResourceError::LimitExceeded)); + assert_eq!(resource.0.usage, 100); + resource.0.refund(10); + assert_eq!(resource.0.usage, 90); + resource._refund(10); + assert_eq!(resource.0.usage, 80); + } +} diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index d2e2bb3137..14c739eaeb 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -20,7 +20,7 @@ use evm::{ backend::Backend as BackendT, executor::stack::{Accessed, StackExecutor, StackState as StackStateT, StackSubstateMetadata}, - gasometer::{GasCost, StorageTarget}, + gasometer::GasCost, ExitError, ExitReason, Opcode, Transfer, }; // Substrate @@ -42,15 +42,13 @@ use sp_std::{ }; // Frontier use fp_evm::{ - AccessedStorage, CallInfo, CreateInfo, ExecutionInfoV2, IsPrecompileResult, Log, PrecompileSet, - Vicinity, WeightInfo, ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_CODES_METADATA_PROOF_SIZE, - ACCOUNT_STORAGE_PROOF_SIZE, IS_EMPTY_CHECK_PROOF_SIZE, WRITE_PROOF_SIZE, + CallInfo, CreateInfo, ExecutionInfoV2, IsPrecompileResult, Log, PrecompileSet, Vicinity, }; use crate::{ - runner::Runner as RunnerT, AccountCodes, AccountCodesMetadata, AccountStorages, AddressMapping, - BalanceOf, BlockHashMapping, Config, Error, Event, FeeCalculator, OnChargeEVMTransaction, - OnCreate, Pallet, RunnerError, + resource::ResourceInfo, runner::Runner as RunnerT, AccountCodes, AccountStorages, + AddressMapping, BalanceOf, BlockHashMapping, Config, Error, Event, FeeCalculator, + OnChargeEVMTransaction, OnCreate, Pallet, RunnerError, }; #[cfg(feature = "forbid-evm-reentrancy")] @@ -181,17 +179,17 @@ where { // Used to record the external costs in the evm through the StackState implementation - let mut weight_info = WeightInfo::new(); + let mut resource_info = ResourceInfo::new(); match weight_limit { Some(weight_limit) => { - weight_info + resource_info .add_ref_time_meter(weight_limit.ref_time()) .map_err(|_| RunnerError { error: Error::::Undefined, weight, })?; if let Some(proof_size_base_cost) = proof_size_base_cost { - weight_info + resource_info .add_proof_size_meter(proof_size_base_cost, weight_limit.proof_size()) .map_err(|_| RunnerError { error: Error::::Undefined, @@ -204,22 +202,22 @@ where // TODO Compute the limit of storage per tx let storage_limit = 0; - weight_info.add_storage_meter(storage_limit).map_err(|_| RunnerError { - error: Error::::Undefined, - weight, - })?; + resource_info + .add_storage_meter(storage_limit) + .map_err(|_| RunnerError { + error: Error::::Undefined, + weight, + })?; - let weight_info = if weight_info.ref_time_meter.is_none() - && weight_info.proof_size_meter.is_none() - && weight_info.storage_meter.is_none() + let resource_info = if resource_info.ref_time_meter.is_none() + && resource_info.proof_size_meter.is_none() + && resource_info.storage_meter.is_none() { None - } - else { - Some(weight_info) + } else { + Some(resource_info) }; - // The precompile check is only used for transactional invocations. However, here we always // execute the check, because the check has side effects. match precompiles.is_precompile(source, gas_limit) { @@ -234,7 +232,7 @@ where standard: gas_limit.into(), effective: gas_limit.into(), }, - weight_info, + weight_info: resource_info.map(|r| r.weight_info()), logs: Default::default(), }) } @@ -303,20 +301,15 @@ where }; let metadata = StackSubstateMetadata::new(gas_limit, config); - let state = SubstrateStackState::new(&vicinity, metadata, weight_info); + let state = SubstrateStackState::new(&vicinity, metadata, resource_info); let mut executor = StackExecutor::new_with_precompiles(state, config, precompiles); let (reason, retv) = f(&mut executor); // Post execution. let used_gas = executor.used_gas(); - let effective_gas = match executor.state().weight_info() { - Some(weight_info) => U256::from(sp_std::cmp::max( - used_gas, - weight_info - .proof_size_usage() - .saturating_mul(T::GasLimitPovSizeRatio::get()), - )), + let effective_gas = match executor.state().resource_info() { + Some(resource_info) => resource_info.effective_gas(used_gas), _ => used_gas.into(), }; let actual_fee = effective_gas.saturating_mul(total_fee_per_gas); @@ -405,7 +398,7 @@ where standard: used_gas.into(), effective: effective_gas, }, - weight_info: state.weight_info(), + weight_info: state.resource_info.as_ref().map(|r| r.weight_info()), logs: state.substate.logs, }) } @@ -727,19 +720,12 @@ impl<'config> SubstrateStackSubstate<'config> { } } -#[derive(Default, Clone, Eq, PartialEq)] -pub struct Recorded { - account_codes: Vec, - account_storages: BTreeMap<(H160, H256), bool>, -} - /// Substrate backend for EVM. pub struct SubstrateStackState<'vicinity, 'config, T> { vicinity: &'vicinity Vicinity, substate: SubstrateStackSubstate<'config>, original_storage: BTreeMap<(H160, H256), H256>, - recorded: Recorded, - weight_info: Option, + resource_info: Option>, _marker: PhantomData, } @@ -748,7 +734,7 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { pub fn new( vicinity: &'vicinity Vicinity, metadata: StackSubstateMetadata<'config>, - weight_info: Option, + resource_info: Option>, ) -> Self { Self { vicinity, @@ -760,21 +746,12 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { }, _marker: PhantomData, original_storage: BTreeMap::new(), - recorded: Default::default(), - weight_info, + resource_info, } } - pub fn weight_info(&self) -> Option { - self.weight_info - } - - pub fn recorded(&self) -> &Recorded { - &self.recorded - } - - pub fn info_mut(&mut self) -> (&mut Option, &mut Recorded) { - (&mut self.weight_info, &mut self.recorded) + pub fn resource_info(&self) -> &Option> { + &self.resource_info } } @@ -1011,35 +988,7 @@ where >::account_code_metadata(address).hash } - fn record_external_dynamic_opcode_cost( - &mut self, - opcode: Opcode, - _gas_cost: GasCost, - target: evm::gasometer::StorageTarget, - ) -> Result<(), ExitError> { - // If account code or storage slot is in the overlay it is already accounted for and early exit - let mut accessed_storage: Option = match target { - StorageTarget::Address(address) => { - if self.recorded().account_codes.contains(&address) { - return Ok(()); - } else { - Some(AccessedStorage::AccountCodes(address)) - } - } - StorageTarget::Slot(address, index) => { - if self - .recorded() - .account_storages - .contains_key(&(address, index)) - { - return Ok(()); - } else { - Some(AccessedStorage::AccountStorages((address, index))) - } - } - _ => None, - }; - + fn record_external_operation(&mut self, op: evm::ExternalOperation) -> Result<(), ExitError> { let size_limit: u64 = self .metadata() .gasometer() @@ -1047,162 +996,43 @@ where .create_contract_limit .unwrap_or_default() as u64; - let (weight_info, recorded) = { - let (weight_info, recorded) = self.info_mut(); - if let Some(weight_info) = weight_info { - (weight_info, recorded) - } else { - return Ok(()); - } - }; - - // Record ref_time first - // TODO benchmark opcodes, until this is done we do used_gas to weight conversion for ref_time - - // Record proof_size - // Return if proof size recording is disabled - let proof_size_limit = if let Some(proof_size_meter) = weight_info.proof_size_meter { - proof_size_meter.limit() - } else { - return Ok(()); - }; - - let mut maybe_record_and_refund = |with_empty_check: bool| -> Result<(), ExitError> { - let address = if let Some(AccessedStorage::AccountCodes(address)) = accessed_storage { - address - } else { - // This must be unreachable, a valid target must be set. - // TODO decide how do we want to gracefully handle. - return Err(ExitError::OutOfGas); - }; - // First try to record fixed sized `AccountCodesMetadata` read - // Tentatively 20 + 8 + 32 - let mut base_cost = ACCOUNT_CODES_METADATA_PROOF_SIZE; - if with_empty_check { - base_cost = base_cost.saturating_add(IS_EMPTY_CHECK_PROOF_SIZE); - } - weight_info.try_record_proof_size_or_fail(base_cost)?; - if let Some(meta) = >::get(address) { - weight_info.try_record_proof_size_or_fail(meta.size)?; - } else { - // If it does not exist, try to record `create_contract_limit` first. - weight_info.try_record_proof_size_or_fail(size_limit)?; - let meta = Pallet::::account_code_metadata(address); - let actual_size = meta.size; - // Refund if applies - weight_info.refund_proof_size(size_limit.saturating_sub(actual_size)); - } - recorded.account_codes.push(address); - // Already recorded, return - Ok(()) - }; - - // Proof size is fixed length for writes (a 32-byte hash in a merkle trie), and - // the full key/value for reads. For read and writes over the same storage, the full value - // is included. - // For cold reads involving code (call, callcode, staticcall and delegatecall): - // - We depend on https://github.com/paritytech/frontier/pull/893 - // - Try to get the cached size or compute it on the fly - // - We record the actual size after caching, refunding the difference between it and the initially deducted - // contract size limit. - let opcode_proof_size = match opcode { - // Basic account fixed length - Opcode::BALANCE => { - accessed_storage = None; - U256::from(ACCOUNT_BASIC_PROOF_SIZE) - } - Opcode::EXTCODESIZE | Opcode::EXTCODECOPY | Opcode::EXTCODEHASH => { - return maybe_record_and_refund(false) - } - Opcode::CALLCODE | Opcode::CALL | Opcode::DELEGATECALL | Opcode::STATICCALL => { - return maybe_record_and_refund(true) - } - // (H160, H256) double map blake2 128 concat key size (68) + value 32 - Opcode::SLOAD => U256::from(ACCOUNT_STORAGE_PROOF_SIZE), - Opcode::SSTORE => { - let (address, index) = - if let Some(AccessedStorage::AccountStorages((address, index))) = - accessed_storage - { - (address, index) - } else { - // This must be unreachable, a valid target must be set. - // TODO decide how do we want to gracefully handle. - return Err(ExitError::OutOfGas); - }; - let mut cost = WRITE_PROOF_SIZE; - let maybe_record = !recorded.account_storages.contains_key(&(address, index)); - // If the slot is yet to be accessed we charge for it, as the evm reads - // it prior to the opcode execution. - // Skip if the address and index has been already recorded this block. - if maybe_record { - cost = cost.saturating_add(ACCOUNT_STORAGE_PROOF_SIZE); - } - U256::from(cost) - } - // Fixed trie 32 byte hash - Opcode::CREATE | Opcode::CREATE2 => U256::from(WRITE_PROOF_SIZE), - // When calling SUICIDE a target account will receive the self destructing - // address's balance. We need to account for both: - // - Target basic account read - // - 5 bytes of `decode_len` - Opcode::SUICIDE => { - accessed_storage = None; - U256::from(IS_EMPTY_CHECK_PROOF_SIZE) - } - // Rest of dynamic opcodes that do not involve proof size recording, do nothing - _ => return Ok(()), - }; - - if opcode_proof_size > U256::from(u64::MAX) { - weight_info.try_record_proof_size_or_fail(proof_size_limit)?; - return Err(ExitError::OutOfGas); + if let Some(resource_info) = self.resource_info.as_mut() { + resource_info + .record_external_operation(op, size_limit) + .map_err(|_| ExitError::OutOfGas)?; } - // Cache the storage access - match accessed_storage { - Some(AccessedStorage::AccountStorages((address, index))) => { - recorded.account_storages.insert((address, index), true); - } - Some(AccessedStorage::AccountCodes(address)) => { - recorded.account_codes.push(address); - } - _ => {} - } - - // Record cost - self.record_external_cost(None, Some(opcode_proof_size.low_u64()))?; Ok(()) } - fn record_external_cost( + fn record_external_dynamic_opcode_cost( &mut self, - ref_time: Option, - proof_size: Option, + opcode: Opcode, + _gas_cost: GasCost, + target: evm::gasometer::StorageTarget, ) -> Result<(), ExitError> { - let weight_info = if let (Some(weight_info), _) = self.info_mut() { - weight_info - } else { - return Ok(()); - }; - // Record ref_time first - // TODO benchmark opcodes, until this is done we do used_gas to weight conversion for ref_time - if let Some(amount) = ref_time { - weight_info.try_record_ref_time_or_fail(amount)?; - } - if let Some(amount) = proof_size { - weight_info.try_record_proof_size_or_fail(amount)?; + let size_limit: u64 = self + .metadata() + .gasometer() + .config() + .create_contract_limit + .unwrap_or_default() as u64; + + if let Some(resource_info) = self.resource_info.as_mut() { + resource_info + .record_external_dynamic_opcode_cost(opcode, target, size_limit) + .map_err(|_| ExitError::OutOfGas)?; } Ok(()) } fn refund_external_cost(&mut self, ref_time: Option, proof_size: Option) { - if let Some(mut weight_info) = self.weight_info { + if let Some(resource_info) = self.resource_info.as_mut() { if let Some(amount) = ref_time { - weight_info.refund_ref_time(amount); + resource_info.refund_ref_time(amount); } if let Some(amount) = proof_size { - weight_info.refund_proof_size(amount); + resource_info.refund_proof_size(amount); } } } diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index 6fb1ea6f58..4a39bc0fb7 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -18,8 +18,13 @@ #![cfg(test)] use super::*; -use crate::mock::*; - +use crate::{ + mock::*, + resource::{ + ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_CODES_METADATA_PROOF_SIZE, ACCOUNT_STORAGE_PROOF_SIZE, + IS_EMPTY_CHECK_PROOF_SIZE, WRITE_PROOF_SIZE, + }, +}; use frame_support::{ assert_ok, traits::{LockIdentifier, LockableCurrency, WithdrawReasons}, @@ -29,10 +34,7 @@ use std::{collections::BTreeMap, str::FromStr}; mod proof_size_test { use super::*; - use fp_evm::{ - CreateInfo, ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_CODES_METADATA_PROOF_SIZE, - ACCOUNT_STORAGE_PROOF_SIZE, IS_EMPTY_CHECK_PROOF_SIZE, WRITE_PROOF_SIZE, - }; + use fp_evm::CreateInfo; use frame_support::traits::StorageInfoTrait; // pragma solidity ^0.8.2; // contract Callee { @@ -182,7 +184,11 @@ mod proof_size_test { let nonce_increases = ACCOUNT_BASIC_PROOF_SIZE * 2; let expected_proof_size = write_cost + is_empty_check + nonce_increases; - let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); + let actual_proof_size = result + .weight_info + .expect("weight info") + .proof_size_usage + .expect("proof size usage"); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -239,7 +245,11 @@ mod proof_size_test { + reading_main_contract_len + is_empty_check + increase_nonce) as u64; - let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); + let actual_proof_size = result + .weight_info + .expect("weight info") + .proof_size_usage + .expect("proof size usage"); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -292,7 +302,11 @@ mod proof_size_test { + reading_main_contract_len + is_empty_check + increase_nonce) as u64; - let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); + let actual_proof_size = result + .weight_info + .expect("weight info") + .proof_size_usage + .expect("proof size usage"); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -337,7 +351,11 @@ mod proof_size_test { + IS_EMPTY_CHECK_PROOF_SIZE + (ACCOUNT_BASIC_PROOF_SIZE * 2); - let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); + let actual_proof_size = result + .weight_info + .expect("weight info") + .proof_size_usage + .expect("proof size usage"); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -383,7 +401,11 @@ mod proof_size_test { + IS_EMPTY_CHECK_PROOF_SIZE + (ACCOUNT_BASIC_PROOF_SIZE * 2); - let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); + let actual_proof_size = result + .weight_info + .expect("weight info") + .proof_size_usage + .expect("proof size usage"); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -436,7 +458,11 @@ mod proof_size_test { let expected_proof_size = overhead + (number_balance_reads * ACCOUNT_BASIC_PROOF_SIZE) as u64; - let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); + let actual_proof_size = result + .weight_info + .expect("weight info") + .proof_size_usage + .expect("proof size usage"); assert_eq!(expected_proof_size, actual_proof_size); }); } @@ -501,7 +527,11 @@ mod proof_size_test { + reading_main_contract_len + is_empty_check + increase_nonce) as u64; - let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); + let actual_proof_size = result + .weight_info + .expect("weight info") + .proof_size_usage + .expect("proof size usage"); assert_eq!(expected_proof_size, actual_proof_size); }); @@ -584,7 +614,11 @@ mod proof_size_test { let ratio = <::GasLimitPovSizeRatio as Get>::get(); let used_gas = result.used_gas; - let actual_proof_size = result.weight_info.expect("weight info").proof_size_usage(); + let actual_proof_size = result + .weight_info + .expect("weight info") + .proof_size_usage + .expect("proof size usage"); assert_eq!(used_gas.standard, U256::from(21_000)); assert_eq!(used_gas.effective, U256::from(actual_proof_size * ratio)); diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 4265a3b328..5c34350a96 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -17,13 +17,10 @@ #![cfg_attr(not(feature = "std"), no_std)] #![deny(unused_crate_dependencies)] - -mod resource; mod precompile; mod validation; use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight}; -use resource::{ProofSizeMeter, RefTimeMeter, StorageMeter}; use scale_codec::{Decode, Encode}; use scale_info::TypeInfo; #[cfg(feature = "serde")] @@ -59,91 +56,13 @@ pub struct Vicinity { pub origin: H160, } -/// `System::Account` 16(hash) + 20 (key) + 60 (AccountInfo::max_encoded_len) -pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 96; -/// `AccountCodesMetadata` read, temptatively 16 (hash) + 20 (key) + 40 (CodeMetadata). -pub const ACCOUNT_CODES_METADATA_PROOF_SIZE: u64 = 76; -/// 16 (hash1) + 20 (key1) + 16 (hash2) + 32 (key2) + 32 (value) -pub const ACCOUNT_STORAGE_PROOF_SIZE: u64 = 116; -/// Fixed trie 32 byte hash. -pub const WRITE_PROOF_SIZE: u64 = 32; -/// Account basic proof size + 5 bytes max of `decode_len` call. -pub const IS_EMPTY_CHECK_PROOF_SIZE: u64 = 93; - -pub enum AccessedStorage { - AccountCodes(H160), - AccountStorages((H160, H256)), -} - #[derive(Clone, Copy, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct WeightInfo { - pub ref_time_meter: Option, - pub proof_size_meter: Option, - pub storage_meter: Option, -} - -impl WeightInfo { - pub fn new() -> Self { - Self { - ref_time_meter: None, - proof_size_meter: None, - storage_meter: None, - } - } - - pub fn add_ref_time_meter(&mut self, limit: u64) -> Result<(), &'static str> { - self.ref_time_meter = Some(RefTimeMeter::new(limit).map_err(|_| "Invalid parameters")?); - Ok(()) - } - - pub fn add_proof_size_meter(&mut self, base_cost: u64, limit: u64) -> Result<(), &'static str> { - self.proof_size_meter = - Some(ProofSizeMeter::new(base_cost, limit).map_err(|_| "Invalid parameters")?); - Ok(()) - } - - pub fn add_storage_meter(&mut self, limit: u64) -> Result<(), &'static str> { - self.storage_meter = - Some(StorageMeter::new(limit).map_err(|_| "Invalid parameters")?); - Ok(()) - } - - pub fn try_record_ref_time_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { - if let Some(ref_time_meter) = self.ref_time_meter.as_mut() { - ref_time_meter - .record_ref_time(cost) - .map_err(|_| ExitError::OutOfGas)?; - } - - Ok(()) - } - pub fn try_record_proof_size_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { - if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { - proof_size_meter - .record_proof_size(cost) - .map_err(|_| ExitError::OutOfGas)?; - } - - Ok(()) - } - - pub fn refund_proof_size(&mut self, amount: u64) { - self.proof_size_meter.as_mut().map(|proof_size_meter| { - proof_size_meter.refund(amount); - }); - } - - pub fn proof_size_usage(&self) -> u64 { - self.proof_size_meter - .map_or(0, |proof_size_meter| proof_size_meter.usage()) - } - - pub fn refund_ref_time(&mut self, amount: u64) { - self.ref_time_meter.as_mut().map(|ref_time_meter| { - ref_time_meter.refund(amount); - }); - } + pub ref_time_usage: Option, + pub ref_time_limit: Option, + pub proof_size_usage: Option, + pub proof_size_limit: Option, } #[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] diff --git a/primitives/evm/src/resource.rs b/primitives/evm/src/resource.rs deleted file mode 100644 index 4d80f60b08..0000000000 --- a/primitives/evm/src/resource.rs +++ /dev/null @@ -1,241 +0,0 @@ -use evm::{gasometer::GasCost, Opcode}; -use scale_codec::{Decode, Encode}; -use scale_info::TypeInfo; -#[cfg(feature = "serde")] -use serde::{Deserialize, Serialize}; -use sp_runtime::{traits::CheckedAdd, Saturating}; - -#[derive(Debug, PartialEq)] -/// Resource error. -pub enum ResourceError { - /// The Resource usage exceeds the limit. - LimitExceeded, - /// Invalid Base Cost. - InvalidBaseCost, -} - -/// A struct that keeps track of resource usage and limit. -#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct Resource { - limit: T, - usage: T, -} - -impl Resource -where - T: CheckedAdd + Saturating + PartialOrd + Copy, -{ - /// Creates a new `Resource` instance with the given base cost and limit. - /// - /// # Errors - /// - /// Returns `ResourceError::InvalidBaseCost` if the base cost is greater than the limit. - pub fn new(base_cost: T, limit: T) -> Result { - if base_cost > limit { - return Err(ResourceError::InvalidBaseCost); - } - Ok(Self { - limit, - usage: base_cost, - }) - } - - /// Records the cost of an operation and updates the usage. - /// - /// # Errors - /// - /// Returns `ResourceError::LimitExceeded` if the Resource usage exceeds the limit. - fn record_cost(&mut self, cost: T) -> Result<(), ResourceError> { - let usage = self - .usage - .checked_add(&cost) - .ok_or(ResourceError::LimitExceeded)?; - - if usage > self.limit { - return Err(ResourceError::LimitExceeded); - } - self.usage = usage; - Ok(()) - } - - /// Refunds the given amount. - fn refund(&mut self, amount: T) { - self.usage = self.usage.saturating_sub(amount); - } - - /// Returns the usage. - fn usage(&self) -> T { - self.usage - } -} - -/// A struct that keeps track of the proof size and limit. -#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct ProofSizeMeter(Resource); - -impl ProofSizeMeter { - /// Creates a new `ProofSizeResource` instance with the given limit. - pub fn new(base_cost: u64, limit: u64) -> Result { - Ok(Self(Resource::new(base_cost, limit)?)) - } - - /// Records the size of the proof and updates the usage. - /// - /// # Errors - /// - /// Returns `ResourceError::LimitExceeded` if the proof size exceeds the limit. - pub fn record_proof_size(&mut self, size: u64) -> Result<(), ResourceError> { - self.0.record_cost(size) - } - - /// Refunds the given amount of proof size. - pub fn refund(&mut self, amount: u64) { - self.0.refund(amount) - } - - /// Returns the proof size usage. - pub fn usage(&self) -> u64 { - self.0.usage() - } - - /// Returns the proof size limit. - pub fn limit(&self) -> u64 { - self.0.limit - } -} - -/// A struct that keeps track of the ref_time usage and limit. -#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct RefTimeMeter(Resource); - -impl RefTimeMeter { - /// Creates a new `RefTimeResource` instance with the given limit. - pub fn new(limit: u64) -> Result { - Ok(Self(Resource::new(0, limit)?)) - } - - /// Records the ref_time and updates the usage. - pub fn record_ref_time(&mut self, ref_time: u64) -> Result<(), ResourceError> { - self.0.record_cost(ref_time) - } - - /// Refunds the given amount of ref_time. - pub fn refund(&mut self, amount: u64) { - self.0.refund(amount) - } -} -/// A struct that keeps track of storage usage (newly created storage) and limit. -#[derive(Clone, Copy, Encode, Decode, PartialEq, Eq, Debug, TypeInfo)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct StorageMeter(Resource); - -impl StorageMeter { - /// Creates a new `StorageResource` instance with the given limit. - pub fn new(limit: u64) -> Result { - Ok(Self(Resource::new(0, limit)?)) - } - - /// Refunds the given amount of storage. - fn refund(&mut self, amount: u64) { - self.0.refund(amount) - } - - /// Records the dynamic opcode cost and updates the storage usage. - /// - /// # Errors - /// - /// Returns `ResourceError::LimitExceeded` if the storage usage exceeds the storage limit. - fn record_dynamic_opcode_cost( - &mut self, - _opcode: Opcode, - gas_cost: GasCost, - ) -> Result<(), ResourceError> { - let cost = match gas_cost { - GasCost::Create => { - // TODO record cost for create - 0 - } - GasCost::Create2 { len } => { - // len in bytes ?? - len.try_into().map_err(|_| ResourceError::LimitExceeded)? - } - GasCost::SStore { .. } => { - // TODO record cost for sstore - 0 - } - _ => return Ok(()), - }; - self.0.record_cost(cost) - } - - fn record_external_operation(&mut self, operation: evm::ExternalOperation) { - match operation { - evm::ExternalOperation::Write => { - // Todo record cost for write - } - _ => {} - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_init() { - let resource = Resource::::new(0, 100).unwrap(); - assert_eq!(resource.limit, 100); - assert_eq!(resource.usage, 0); - - // base cost > limit - let resource = Resource::::new(100, 0).err(); - assert_eq!(resource, Some(ResourceError::InvalidBaseCost)); - } - - #[test] - fn test_record_cost() { - let mut resource = Resource::::new(0, 100).unwrap(); - assert_eq!(resource.record_cost(10), Ok(())); - assert_eq!(resource.usage, 10); - assert_eq!(resource.record_cost(90), Ok(())); - assert_eq!(resource.usage, 100); - - // exceed limit - assert_eq!(resource.record_cost(1), Err(ResourceError::LimitExceeded)); - assert_eq!(resource.usage, 100); - } - - #[test] - fn test_refund() { - let mut resource = Resource::::new(0, 100).unwrap(); - assert_eq!(resource.record_cost(10), Ok(())); - assert_eq!(resource.usage, 10); - resource.refund(10); - assert_eq!(resource.usage, 0); - - // refund more than usage - resource.refund(10); - assert_eq!(resource.usage, 0); - } - - #[test] - fn test_storage_resource() { - let mut resource = StorageMeter::new(100).unwrap(); - assert_eq!(resource.0.usage, 0); - assert_eq!(resource.0.limit, 100); - assert_eq!(resource.0.record_cost(10), Ok(())); - assert_eq!(resource.0.usage, 10); - assert_eq!(resource.0.record_cost(90), Ok(())); - assert_eq!(resource.0.usage, 100); - assert_eq!(resource.0.record_cost(1), Err(ResourceError::LimitExceeded)); - assert_eq!(resource.0.usage, 100); - resource.0.refund(10); - assert_eq!(resource.0.usage, 90); - resource.refund(10); - assert_eq!(resource.0.usage, 80); - } -} From e23b0673c5985d29fff29a881ed676c273de2b7c Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Tue, 8 Aug 2023 10:41:36 +0300 Subject: [PATCH 21/46] remove unused functions --- frame/evm/src/resource.rs | 20 -------------------- primitives/evm/src/lib.rs | 4 ++-- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/frame/evm/src/resource.rs b/frame/evm/src/resource.rs index db07f775df..1c1066b21e 100644 --- a/frame/evm/src/resource.rs +++ b/frame/evm/src/resource.rs @@ -454,26 +454,6 @@ impl ResourceInfo { Ok(()) } - pub fn try_record_ref_time_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { - if let Some(ref_time_meter) = self.ref_time_meter.as_mut() { - ref_time_meter - .record_ref_time(cost) - .map_err(|_| ExitError::OutOfGas)?; - } - - Ok(()) - } - - pub fn try_record_proof_size_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { - if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { - proof_size_meter - .record_proof_size(cost) - .map_err(|_| ExitError::OutOfGas)?; - } - - Ok(()) - } - pub fn refund_proof_size(&mut self, amount: u64) { self.proof_size_meter.as_mut().map(|proof_size_meter| { proof_size_meter.refund(amount); diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 5c34350a96..a442c9fa8e 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -59,10 +59,10 @@ pub struct Vicinity { #[derive(Clone, Copy, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct WeightInfo { - pub ref_time_usage: Option, pub ref_time_limit: Option, - pub proof_size_usage: Option, pub proof_size_limit: Option, + pub ref_time_usage: Option, + pub proof_size_usage: Option, } #[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] From fc51e2dbf52c35ad1547a4865fe5f2d068574101 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Tue, 8 Aug 2023 10:52:15 +0300 Subject: [PATCH 22/46] make clippy happy --- frame/evm/src/resource.rs | 20 +++++++++----------- frame/evm/src/runner/stack.rs | 23 +++++++++++------------ frame/evm/src/tests.rs | 1 + 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/frame/evm/src/resource.rs b/frame/evm/src/resource.rs index 1c1066b21e..24a1a2c80b 100644 --- a/frame/evm/src/resource.rs +++ b/frame/evm/src/resource.rs @@ -3,7 +3,7 @@ use crate::{AccountCodes, AccountCodesMetadata, Config, Pallet}; use core::marker::PhantomData; use evm::{ gasometer::{GasCost, StorageTarget}, - ExitError, Opcode, + Opcode, }; use fp_evm::WeightInfo; use sp_core::{Get, H160, H256, U256}; @@ -148,7 +148,7 @@ impl ProofSizeMeter { self.record_proof_size(ACCOUNT_BASIC_PROOF_SIZE)? } evm::ExternalOperation::AddressCodeRead(address) => { - let maybe_record = !self.recorded.account_codes.contains(&address); + let maybe_record = !self.recorded.account_codes.contains(address); // Skip if the address has been already recorded this block if maybe_record { // First we record account emptiness check. @@ -414,15 +414,13 @@ impl StorageMeter { operation: &evm::ExternalOperation, _contract_size_limit: u64, ) { - match operation { - evm::ExternalOperation::Write => { - // Todo record cost for write - } - _ => {} + if let evm::ExternalOperation::Write = operation { + // Todo record cost for write } } } +#[derive(Default)] pub struct ResourceInfo { pub ref_time_meter: Option, pub proof_size_meter: Option>, @@ -455,15 +453,15 @@ impl ResourceInfo { } pub fn refund_proof_size(&mut self, amount: u64) { - self.proof_size_meter.as_mut().map(|proof_size_meter| { + if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { proof_size_meter.refund(amount); - }); + } } pub fn refund_ref_time(&mut self, amount: u64) { - self.ref_time_meter.as_mut().map(|ref_time_meter| { + if let Some(ref_time_meter) = self.ref_time_meter.as_mut() { ref_time_meter.refund(amount); - }); + } } /// Returns WeightInfo for the resource. diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 14c739eaeb..492750a27f 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -180,24 +180,23 @@ where // Used to record the external costs in the evm through the StackState implementation let mut resource_info = ResourceInfo::new(); - match weight_limit { - Some(weight_limit) => { + + if let Some(weight_limit) = weight_limit { + resource_info + .add_ref_time_meter(weight_limit.ref_time()) + .map_err(|_| RunnerError { + error: Error::::Undefined, + weight, + })?; + + if let Some(proof_size_base_cost) = proof_size_base_cost { resource_info - .add_ref_time_meter(weight_limit.ref_time()) + .add_proof_size_meter(proof_size_base_cost, weight_limit.proof_size()) .map_err(|_| RunnerError { error: Error::::Undefined, weight, })?; - if let Some(proof_size_base_cost) = proof_size_base_cost { - resource_info - .add_proof_size_meter(proof_size_base_cost, weight_limit.proof_size()) - .map_err(|_| RunnerError { - error: Error::::Undefined, - weight, - })?; - } } - None => (), } // TODO Compute the limit of storage per tx diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index 4a39bc0fb7..d6c4813eee 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -463,6 +463,7 @@ mod proof_size_test { .expect("weight info") .proof_size_usage .expect("proof size usage"); + assert_eq!(expected_proof_size, actual_proof_size); }); } From 534fd4c50f4053b43a5f1b2a4de0c0788d78a22c Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Wed, 9 Aug 2023 12:48:51 +0300 Subject: [PATCH 23/46] minor improvements --- frame/evm/src/resource.rs | 33 ++++++++++++++++--------------- frame/evm/src/runner/stack.rs | 37 ++++++++++++----------------------- primitives/evm/src/lib.rs | 1 + 3 files changed, 30 insertions(+), 41 deletions(-) diff --git a/frame/evm/src/resource.rs b/frame/evm/src/resource.rs index 24a1a2c80b..e1c63e4651 100644 --- a/frame/evm/src/resource.rs +++ b/frame/evm/src/resource.rs @@ -3,7 +3,7 @@ use crate::{AccountCodes, AccountCodesMetadata, Config, Pallet}; use core::marker::PhantomData; use evm::{ gasometer::{GasCost, StorageTarget}, - Opcode, + ExitError, Opcode, }; use fp_evm::WeightInfo; use sp_core::{Get, H160, H256, U256}; @@ -32,6 +32,12 @@ pub enum ResourceError { Unreachable, } +impl From for ExitError { + fn from(_error: ResourceError) -> Self { + ExitError::OutOfGas + } +} + /// A struct that keeps track of resource usage and limit. pub struct Resource { limit: T, @@ -521,22 +527,11 @@ impl ResourceInfo { Ok(()) } - /// Computes the effective gas for the transaction. Effective gas is the maximum between the - /// gas used and resource usage. pub fn effective_gas(&self, gas: u64) -> U256 { - let proof_size_usage = self - .proof_size_meter - .as_ref() - .map_or(0, |meter| meter.usage()) - .saturating_mul(T::GasLimitPovSizeRatio::get()); - - // TODO: use the actual ref time usage - // let ref_time_usage = self - // .ref_time_meter - // .map_or(0, |meter| meter.usage()) - // .saturating_mul(T::GasLimitPovRefTimeRatio::get()); - - // TODO get the Storage Gas ratio + let proof_size_usage = self.proof_size_meter.as_ref().map_or(0, |meter| { + meter.usage().saturating_mul(T::GasLimitPovSizeRatio::get()) + }); + let storage_usage = self.storage_meter.as_ref().map_or(0, |meter| meter.usage()); let effective_gas = @@ -544,6 +539,12 @@ impl ResourceInfo { U256::from(effective_gas) } + + pub fn is_empty(&self) -> bool { + self.ref_time_meter.is_none() + && self.proof_size_meter.is_none() + && self.storage_meter.is_none() + } } #[cfg(test)] diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 492750a27f..05af6d5e5b 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -181,37 +181,28 @@ where let mut resource_info = ResourceInfo::new(); + let map_error = |_e| RunnerError { + error: Error::::Undefined, + weight, + }; + if let Some(weight_limit) = weight_limit { resource_info .add_ref_time_meter(weight_limit.ref_time()) - .map_err(|_| RunnerError { - error: Error::::Undefined, - weight, - })?; + .map_err(map_error)?; if let Some(proof_size_base_cost) = proof_size_base_cost { resource_info .add_proof_size_meter(proof_size_base_cost, weight_limit.proof_size()) - .map_err(|_| RunnerError { - error: Error::::Undefined, - weight, - })?; + .map_err(map_error)?; } } - // TODO Compute the limit of storage per tx - let storage_limit = 0; resource_info - .add_storage_meter(storage_limit) - .map_err(|_| RunnerError { - error: Error::::Undefined, - weight, - })?; + .add_storage_meter(0) // TODO Compute the limit of storage per tx + .map_err(map_error)?; - let resource_info = if resource_info.ref_time_meter.is_none() - && resource_info.proof_size_meter.is_none() - && resource_info.storage_meter.is_none() - { + let resource_info = if resource_info.is_empty() { None } else { Some(resource_info) @@ -996,9 +987,7 @@ where .unwrap_or_default() as u64; if let Some(resource_info) = self.resource_info.as_mut() { - resource_info - .record_external_operation(op, size_limit) - .map_err(|_| ExitError::OutOfGas)?; + resource_info.record_external_operation(op, size_limit)? } Ok(()) @@ -1018,9 +1007,7 @@ where .unwrap_or_default() as u64; if let Some(resource_info) = self.resource_info.as_mut() { - resource_info - .record_external_dynamic_opcode_cost(opcode, target, size_limit) - .map_err(|_| ExitError::OutOfGas)?; + resource_info.record_external_dynamic_opcode_cost(opcode, target, size_limit)? } Ok(()) } diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index a442c9fa8e..0b02fecb5b 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -17,6 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![deny(unused_crate_dependencies)] + mod precompile; mod validation; From 5d5d5b0695564aa120c97cb02427058d0307f266 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Wed, 9 Aug 2023 15:54:58 +0300 Subject: [PATCH 24/46] rename meter to resource --- frame/evm/src/resource.rs | 76 +++++++++++++++++------------------ frame/evm/src/runner/stack.rs | 6 +-- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/frame/evm/src/resource.rs b/frame/evm/src/resource.rs index e1c63e4651..049613a06f 100644 --- a/frame/evm/src/resource.rs +++ b/frame/evm/src/resource.rs @@ -104,13 +104,13 @@ pub struct Recorded { } /// A struct that keeps track of the proof size and limit. -pub struct ProofSizeMeter { +pub struct ProofSizeResource { resource: Resource, recorded: Recorded, _marker: PhantomData, } -impl ProofSizeMeter { +impl ProofSizeResource { /// Creates a new `ProofSizeResource` instance with the given limit. pub fn new(base_cost: u64, limit: u64) -> Result { Ok(Self { @@ -339,9 +339,9 @@ impl ProofSizeMeter { } /// A struct that keeps track of the ref_time usage and limit. -pub struct RefTimeMeter(Resource); +pub struct RefTimeResource(Resource); -impl RefTimeMeter { +impl RefTimeResource { /// Creates a new `RefTimeResource` instance with the given limit. pub fn new(limit: u64) -> Result { Ok(Self(Resource::new(0, limit)?)) @@ -369,9 +369,9 @@ impl RefTimeMeter { } /// A struct that keeps track of storage usage (newly created storage) and limit. -pub struct StorageMeter(Resource); +pub struct StorageGrowthResource(Resource); -impl StorageMeter { +impl StorageGrowthResource { /// Creates a new `StorageResource` instance with the given limit. pub fn new(limit: u64) -> Result { Ok(Self(Resource::new(0, limit)?)) @@ -428,45 +428,45 @@ impl StorageMeter { #[derive(Default)] pub struct ResourceInfo { - pub ref_time_meter: Option, - pub proof_size_meter: Option>, - pub storage_meter: Option, + pub ref_time_resource: Option, + pub proof_size_resource: Option>, + pub storage_resource: Option, } impl ResourceInfo { pub fn new() -> Self { Self { - ref_time_meter: None, - proof_size_meter: None, - storage_meter: None, + ref_time_resource: None, + proof_size_resource: None, + storage_resource: None, } } - pub fn add_ref_time_meter(&mut self, limit: u64) -> Result<(), &'static str> { - self.ref_time_meter = Some(RefTimeMeter::new(limit).map_err(|_| "Invalid parameters")?); + pub fn add_ref_time_resource(&mut self, limit: u64) -> Result<(), &'static str> { + self.ref_time_resource = Some(RefTimeResource::new(limit).map_err(|_| "Invalid pararesources")?); Ok(()) } - pub fn add_proof_size_meter(&mut self, base_cost: u64, limit: u64) -> Result<(), &'static str> { - self.proof_size_meter = - Some(ProofSizeMeter::new(base_cost, limit).map_err(|_| "Invalid parameters")?); + pub fn add_proof_size_resource(&mut self, base_cost: u64, limit: u64) -> Result<(), &'static str> { + self.proof_size_resource = + Some(ProofSizeResource::new(base_cost, limit).map_err(|_| "Invalid pararesources")?); Ok(()) } - pub fn add_storage_meter(&mut self, limit: u64) -> Result<(), &'static str> { - self.storage_meter = Some(StorageMeter::new(limit).map_err(|_| "Invalid parameters")?); + pub fn add_storage_growth_resource(&mut self, limit: u64) -> Result<(), &'static str> { + self.storage_resource = Some(StorageGrowthResource::new(limit).map_err(|_| "Invalid pararesources")?); Ok(()) } pub fn refund_proof_size(&mut self, amount: u64) { - if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { - proof_size_meter.refund(amount); + if let Some(proof_size_resource) = self.proof_size_resource.as_mut() { + proof_size_resource.refund(amount); } } pub fn refund_ref_time(&mut self, amount: u64) { - if let Some(ref_time_meter) = self.ref_time_meter.as_mut() { - ref_time_meter.refund(amount); + if let Some(ref_time_resource) = self.ref_time_resource.as_mut() { + ref_time_resource.refund(amount); } } @@ -481,8 +481,8 @@ impl ResourceInfo { }; } - let (proof_size_usage, proof_size_limit) = usage_and_limit!(self.proof_size_meter); - let (ref_time_usage, ref_time_limit) = usage_and_limit!(self.ref_time_meter); + let (proof_size_usage, proof_size_limit) = usage_and_limit!(self.proof_size_resource); + let (ref_time_usage, ref_time_limit) = usage_and_limit!(self.ref_time_resource); WeightInfo { proof_size_usage, @@ -497,12 +497,12 @@ impl ResourceInfo { operation: evm::ExternalOperation, contract_size_limit: u64, ) -> Result<(), ResourceError> { - if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { - proof_size_meter.record_external_operation(&operation, contract_size_limit)?; + if let Some(proof_size_resource) = self.proof_size_resource.as_mut() { + proof_size_resource.record_external_operation(&operation, contract_size_limit)?; } - if let Some(storage_meter) = self.storage_meter.as_mut() { - storage_meter.record_external_operation(&operation, contract_size_limit) + if let Some(storage_resource) = self.storage_resource.as_mut() { + storage_resource.record_external_operation(&operation, contract_size_limit) } Ok(()) @@ -514,8 +514,8 @@ impl ResourceInfo { target: evm::gasometer::StorageTarget, contract_size_limit: u64, ) -> Result<(), ResourceError> { - if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { - proof_size_meter.record_external_dynamic_opcode_cost( + if let Some(proof_size_resource) = self.proof_size_resource.as_mut() { + proof_size_resource.record_external_dynamic_opcode_cost( opcode, target, contract_size_limit, @@ -528,11 +528,11 @@ impl ResourceInfo { } pub fn effective_gas(&self, gas: u64) -> U256 { - let proof_size_usage = self.proof_size_meter.as_ref().map_or(0, |meter| { - meter.usage().saturating_mul(T::GasLimitPovSizeRatio::get()) + let proof_size_usage = self.proof_size_resource.as_ref().map_or(0, |resource| { + resource.usage().saturating_mul(T::GasLimitPovSizeRatio::get()) }); - let storage_usage = self.storage_meter.as_ref().map_or(0, |meter| meter.usage()); + let storage_usage = self.storage_resource.as_ref().map_or(0, |resource| resource.usage()); let effective_gas = sp_std::cmp::max(sp_std::cmp::max(proof_size_usage, storage_usage), gas); @@ -541,9 +541,9 @@ impl ResourceInfo { } pub fn is_empty(&self) -> bool { - self.ref_time_meter.is_none() - && self.proof_size_meter.is_none() - && self.storage_meter.is_none() + self.ref_time_resource.is_none() + && self.proof_size_resource.is_none() + && self.storage_resource.is_none() } } @@ -590,7 +590,7 @@ mod tests { #[test] fn test_storage_resource() { - let mut resource = StorageMeter::new(100).unwrap(); + let mut resource = StorageGrowthResource::new(100).unwrap(); assert_eq!(resource.0.usage, 0); assert_eq!(resource.0.limit, 100); assert_eq!(resource.0.record_cost(10), Ok(())); diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 05af6d5e5b..1513c9da35 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -188,18 +188,18 @@ where if let Some(weight_limit) = weight_limit { resource_info - .add_ref_time_meter(weight_limit.ref_time()) + .add_ref_time_resource(weight_limit.ref_time()) .map_err(map_error)?; if let Some(proof_size_base_cost) = proof_size_base_cost { resource_info - .add_proof_size_meter(proof_size_base_cost, weight_limit.proof_size()) + .add_proof_size_resource(proof_size_base_cost, weight_limit.proof_size()) .map_err(map_error)?; } } resource_info - .add_storage_meter(0) // TODO Compute the limit of storage per tx + .add_storage_growth_resource(0) // TODO Compute the limit of storage per tx .map_err(map_error)?; let resource_info = if resource_info.is_empty() { From faa442481f879a7f5a57c6504cb9f33b12baadce Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Thu, 10 Aug 2023 15:35:04 +0300 Subject: [PATCH 25/46] compute new storage created by SSTORE --- frame/evm/src/resource.rs | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/frame/evm/src/resource.rs b/frame/evm/src/resource.rs index 049613a06f..f914b049df 100644 --- a/frame/evm/src/resource.rs +++ b/frame/evm/src/resource.rs @@ -20,6 +20,8 @@ pub const ACCOUNT_STORAGE_PROOF_SIZE: u64 = 116; pub const WRITE_PROOF_SIZE: u64 = 32; /// Account basic proof size + 5 bytes max of `decode_len` call. pub const IS_EMPTY_CHECK_PROOF_SIZE: u64 = 93; +/// Storage: Set a new value. (32 bytes) +pub const STORAGE_NEW_COST: u64 = 32; #[derive(Debug, PartialEq)] /// Resource error. @@ -406,9 +408,16 @@ impl StorageGrowthResource { // len in bytes ?? len.try_into().map_err(|_| ResourceError::LimitExceeded)? } - GasCost::SStore { .. } => { - // TODO record cost for sstore - 0 + GasCost::SStore { + current, + new, + .. + } => { + if current.is_zero() && !new.is_zero() { + STORAGE_NEW_COST + } else { + 0 + } } _ => return Ok(()), }; @@ -443,18 +452,24 @@ impl ResourceInfo { } pub fn add_ref_time_resource(&mut self, limit: u64) -> Result<(), &'static str> { - self.ref_time_resource = Some(RefTimeResource::new(limit).map_err(|_| "Invalid pararesources")?); + self.ref_time_resource = + Some(RefTimeResource::new(limit).map_err(|_| "Invalid parameters")?); Ok(()) } - pub fn add_proof_size_resource(&mut self, base_cost: u64, limit: u64) -> Result<(), &'static str> { + pub fn add_proof_size_resource( + &mut self, + base_cost: u64, + limit: u64, + ) -> Result<(), &'static str> { self.proof_size_resource = - Some(ProofSizeResource::new(base_cost, limit).map_err(|_| "Invalid pararesources")?); + Some(ProofSizeResource::new(base_cost, limit).map_err(|_| "Invalid parameters")?); Ok(()) } pub fn add_storage_growth_resource(&mut self, limit: u64) -> Result<(), &'static str> { - self.storage_resource = Some(StorageGrowthResource::new(limit).map_err(|_| "Invalid pararesources")?); + self.storage_resource = + Some(StorageGrowthResource::new(limit).map_err(|_| "Invalid parameters")?); Ok(()) } @@ -529,10 +544,15 @@ impl ResourceInfo { pub fn effective_gas(&self, gas: u64) -> U256 { let proof_size_usage = self.proof_size_resource.as_ref().map_or(0, |resource| { - resource.usage().saturating_mul(T::GasLimitPovSizeRatio::get()) + resource + .usage() + .saturating_mul(T::GasLimitPovSizeRatio::get()) }); - let storage_usage = self.storage_resource.as_ref().map_or(0, |resource| resource.usage()); + let storage_usage = self + .storage_resource + .as_ref() + .map_or(0, |resource| resource.usage()); let effective_gas = sp_std::cmp::max(sp_std::cmp::max(proof_size_usage, storage_usage), gas); From 8ae7446eebe9b8a2e9912b1fe804ff01f1bea320 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 14 Aug 2023 14:53:23 +0300 Subject: [PATCH 26/46] revert changes --- frame/evm/src/lib.rs | 3 +- frame/evm/src/resource.rs | 100 ++++++----- frame/evm/src/runner/stack.rs | 313 ++++++++++++++++++++++++++++------ frame/evm/src/tests.rs | 14 +- primitives/evm/src/lib.rs | 87 ++++++++++ 5 files changed, 403 insertions(+), 114 deletions(-) diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index d281f1b873..0a5a287f09 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -60,7 +60,6 @@ pub mod benchmarking; #[cfg(test)] mod mock; -pub mod resource; pub mod runner; #[cfg(test)] mod tests; @@ -1049,4 +1048,4 @@ impl OnCreate for Tuple { Tuple::on_create(owner, contract); )*) } -} +} \ No newline at end of file diff --git a/frame/evm/src/resource.rs b/frame/evm/src/resource.rs index f914b049df..415d590821 100644 --- a/frame/evm/src/resource.rs +++ b/frame/evm/src/resource.rs @@ -106,13 +106,13 @@ pub struct Recorded { } /// A struct that keeps track of the proof size and limit. -pub struct ProofSizeResource { +pub struct ProofSizeMeter { resource: Resource, recorded: Recorded, _marker: PhantomData, } -impl ProofSizeResource { +impl ProofSizeMeter { /// Creates a new `ProofSizeResource` instance with the given limit. pub fn new(base_cost: u64, limit: u64) -> Result { Ok(Self { @@ -341,9 +341,9 @@ impl ProofSizeResource { } /// A struct that keeps track of the ref_time usage and limit. -pub struct RefTimeResource(Resource); +pub struct RefTimeMeter(Resource); -impl RefTimeResource { +impl RefTimeMeter { /// Creates a new `RefTimeResource` instance with the given limit. pub fn new(limit: u64) -> Result { Ok(Self(Resource::new(0, limit)?)) @@ -371,12 +371,15 @@ impl RefTimeResource { } /// A struct that keeps track of storage usage (newly created storage) and limit. -pub struct StorageGrowthResource(Resource); +pub struct StorageMeter { + usage: u64, + limit: u64, +} -impl StorageGrowthResource { +impl StorageMeter { /// Creates a new `StorageResource` instance with the given limit. - pub fn new(limit: u64) -> Result { - Ok(Self(Resource::new(0, limit)?)) + pub fn new(limit: u64) -> Self { + Self(Resource::new(0, limit)) } /// Refunds the given amount of storage. @@ -389,6 +392,11 @@ impl StorageGrowthResource { self.0.usage() } + /// Increments the storage usage by the given amount. + pub fn record(&mut self, cost: u64) -> Result<(), ResourceError> { + self.0.record_cost(cost) + } + /// Records the dynamic opcode cost and updates the storage usage. /// /// # Errors @@ -408,11 +416,7 @@ impl StorageGrowthResource { // len in bytes ?? len.try_into().map_err(|_| ResourceError::LimitExceeded)? } - GasCost::SStore { - current, - new, - .. - } => { + GasCost::SStore { current, new, .. } => { if current.is_zero() && !new.is_zero() { STORAGE_NEW_COST } else { @@ -437,51 +441,45 @@ impl StorageGrowthResource { #[derive(Default)] pub struct ResourceInfo { - pub ref_time_resource: Option, - pub proof_size_resource: Option>, - pub storage_resource: Option, + pub ref_time_meter: Option, + pub proof_size_meter: Option>, + pub storage_meter: Option, } impl ResourceInfo { pub fn new() -> Self { Self { - ref_time_resource: None, - proof_size_resource: None, - storage_resource: None, + ref_time_meter: None, + proof_size_meter: None, + storage_meter: None, } } - pub fn add_ref_time_resource(&mut self, limit: u64) -> Result<(), &'static str> { - self.ref_time_resource = - Some(RefTimeResource::new(limit).map_err(|_| "Invalid parameters")?); + pub fn add_ref_time_meter(&mut self, limit: u64) -> Result<(), &'static str> { + self.ref_time_meter = Some(RefTimeMeter::new(limit).map_err(|_| "Invalid parameters")?); Ok(()) } - pub fn add_proof_size_resource( - &mut self, - base_cost: u64, - limit: u64, - ) -> Result<(), &'static str> { - self.proof_size_resource = - Some(ProofSizeResource::new(base_cost, limit).map_err(|_| "Invalid parameters")?); + pub fn add_proof_size_meter(&mut self, base_cost: u64, limit: u64) -> Result<(), &'static str> { + self.proof_size_meter = + Some(ProofSizeMeter::new(base_cost, limit).map_err(|_| "Invalid parameters")?); Ok(()) } - pub fn add_storage_growth_resource(&mut self, limit: u64) -> Result<(), &'static str> { - self.storage_resource = - Some(StorageGrowthResource::new(limit).map_err(|_| "Invalid parameters")?); + pub fn add_storage_meter(&mut self, limit: u64) -> Result<(), &'static str> { + self.storage_meter = Some(StorageMeter::new(limit).map_err(|_| "Invalid parameters")?); Ok(()) } pub fn refund_proof_size(&mut self, amount: u64) { - if let Some(proof_size_resource) = self.proof_size_resource.as_mut() { - proof_size_resource.refund(amount); + if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { + proof_size_meter.refund(amount); } } pub fn refund_ref_time(&mut self, amount: u64) { - if let Some(ref_time_resource) = self.ref_time_resource.as_mut() { - ref_time_resource.refund(amount); + if let Some(ref_time_meter) = self.ref_time_meter.as_mut() { + ref_time_meter.refund(amount); } } @@ -496,8 +494,8 @@ impl ResourceInfo { }; } - let (proof_size_usage, proof_size_limit) = usage_and_limit!(self.proof_size_resource); - let (ref_time_usage, ref_time_limit) = usage_and_limit!(self.ref_time_resource); + let (proof_size_usage, proof_size_limit) = usage_and_limit!(self.proof_size_meter); + let (ref_time_usage, ref_time_limit) = usage_and_limit!(self.ref_time_meter); WeightInfo { proof_size_usage, @@ -512,12 +510,12 @@ impl ResourceInfo { operation: evm::ExternalOperation, contract_size_limit: u64, ) -> Result<(), ResourceError> { - if let Some(proof_size_resource) = self.proof_size_resource.as_mut() { - proof_size_resource.record_external_operation(&operation, contract_size_limit)?; + if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { + proof_size_meter.record_external_operation(&operation, contract_size_limit)?; } - if let Some(storage_resource) = self.storage_resource.as_mut() { - storage_resource.record_external_operation(&operation, contract_size_limit) + if let Some(storage_meter) = self.storage_meter.as_mut() { + storage_meter.record_external_operation(&operation, contract_size_limit) } Ok(()) @@ -529,8 +527,8 @@ impl ResourceInfo { target: evm::gasometer::StorageTarget, contract_size_limit: u64, ) -> Result<(), ResourceError> { - if let Some(proof_size_resource) = self.proof_size_resource.as_mut() { - proof_size_resource.record_external_dynamic_opcode_cost( + if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { + proof_size_meter.record_external_dynamic_opcode_cost( opcode, target, contract_size_limit, @@ -543,14 +541,14 @@ impl ResourceInfo { } pub fn effective_gas(&self, gas: u64) -> U256 { - let proof_size_usage = self.proof_size_resource.as_ref().map_or(0, |resource| { + let proof_size_usage = self.proof_size_meter.as_ref().map_or(0, |resource| { resource .usage() .saturating_mul(T::GasLimitPovSizeRatio::get()) }); let storage_usage = self - .storage_resource + .storage_meter .as_ref() .map_or(0, |resource| resource.usage()); @@ -561,9 +559,9 @@ impl ResourceInfo { } pub fn is_empty(&self) -> bool { - self.ref_time_resource.is_none() - && self.proof_size_resource.is_none() - && self.storage_resource.is_none() + self.ref_time_meter.is_none() + && self.proof_size_meter.is_none() + && self.storage_meter.is_none() } } @@ -609,8 +607,8 @@ mod tests { } #[test] - fn test_storage_resource() { - let mut resource = StorageGrowthResource::new(100).unwrap(); + fn test_storage_meter() { + let mut resource = StorageMeter::new(100).unwrap(); assert_eq!(resource.0.usage, 0); assert_eq!(resource.0.limit, 100); assert_eq!(resource.0.record_cost(10), Ok(())); diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 1513c9da35..1bfc8453d2 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -20,7 +20,7 @@ use evm::{ backend::Backend as BackendT, executor::stack::{Accessed, StackExecutor, StackState as StackStateT, StackSubstateMetadata}, - gasometer::GasCost, + gasometer::{GasCost, StorageTarget}, ExitError, ExitReason, Opcode, Transfer, }; // Substrate @@ -42,13 +42,15 @@ use sp_std::{ }; // Frontier use fp_evm::{ - CallInfo, CreateInfo, ExecutionInfoV2, IsPrecompileResult, Log, PrecompileSet, Vicinity, + AccessedStorage, CallInfo, CreateInfo, ExecutionInfoV2, IsPrecompileResult, Log, PrecompileSet, + Vicinity, WeightInfo, ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_CODES_METADATA_PROOF_SIZE, + ACCOUNT_STORAGE_PROOF_SIZE, IS_EMPTY_CHECK_PROOF_SIZE, WRITE_PROOF_SIZE, }; use crate::{ - resource::ResourceInfo, runner::Runner as RunnerT, AccountCodes, AccountStorages, - AddressMapping, BalanceOf, BlockHashMapping, Config, Error, Event, FeeCalculator, - OnChargeEVMTransaction, OnCreate, Pallet, RunnerError, + runner::Runner as RunnerT, AccountCodes, AccountCodesMetadata, AccountStorages, AddressMapping, + BalanceOf, BlockHashMapping, Config, Error, Event, FeeCalculator, OnChargeEVMTransaction, + OnCreate, Pallet, RunnerError, }; #[cfg(feature = "forbid-evm-reentrancy")] @@ -178,36 +180,13 @@ where R: Default, { // Used to record the external costs in the evm through the StackState implementation - - let mut resource_info = ResourceInfo::new(); - - let map_error = |_e| RunnerError { - error: Error::::Undefined, - weight, - }; - - if let Some(weight_limit) = weight_limit { - resource_info - .add_ref_time_resource(weight_limit.ref_time()) - .map_err(map_error)?; - - if let Some(proof_size_base_cost) = proof_size_base_cost { - resource_info - .add_proof_size_resource(proof_size_base_cost, weight_limit.proof_size()) - .map_err(map_error)?; - } - } - - resource_info - .add_storage_growth_resource(0) // TODO Compute the limit of storage per tx - .map_err(map_error)?; - - let resource_info = if resource_info.is_empty() { - None - } else { - Some(resource_info) - }; - + let maybe_weight_info = + WeightInfo::new_from_weight_limit(weight_limit, proof_size_base_cost).map_err( + |_| RunnerError { + error: Error::::Undefined, + weight, + }, + )?; // The precompile check is only used for transactional invocations. However, here we always // execute the check, because the check has side effects. match precompiles.is_precompile(source, gas_limit) { @@ -222,7 +201,7 @@ where standard: gas_limit.into(), effective: gas_limit.into(), }, - weight_info: resource_info.map(|r| r.weight_info()), + weight_info: maybe_weight_info, logs: Default::default(), }) } @@ -291,15 +270,21 @@ where }; let metadata = StackSubstateMetadata::new(gas_limit, config); - let state = SubstrateStackState::new(&vicinity, metadata, resource_info); + let state = SubstrateStackState::new(&vicinity, metadata, maybe_weight_info); let mut executor = StackExecutor::new_with_precompiles(state, config, precompiles); let (reason, retv) = f(&mut executor); // Post execution. let used_gas = executor.used_gas(); - let effective_gas = match executor.state().resource_info() { - Some(resource_info) => resource_info.effective_gas(used_gas), + let effective_gas = match executor.state().weight_info() { + Some(weight_info) => U256::from(sp_std::cmp::max( + used_gas, + weight_info + .proof_size_usage + .unwrap_or_default() + .saturating_mul(T::GasLimitPovSizeRatio::get()), + )), _ => used_gas.into(), }; let actual_fee = effective_gas.saturating_mul(total_fee_per_gas); @@ -388,7 +373,7 @@ where standard: used_gas.into(), effective: effective_gas, }, - weight_info: state.resource_info.as_ref().map(|r| r.weight_info()), + weight_info: state.weight_info(), logs: state.substate.logs, }) } @@ -710,12 +695,19 @@ impl<'config> SubstrateStackSubstate<'config> { } } +#[derive(Default, Clone, Eq, PartialEq)] +pub struct Recorded { + account_codes: Vec, + account_storages: BTreeMap<(H160, H256), bool>, +} + /// Substrate backend for EVM. pub struct SubstrateStackState<'vicinity, 'config, T> { vicinity: &'vicinity Vicinity, substate: SubstrateStackSubstate<'config>, original_storage: BTreeMap<(H160, H256), H256>, - resource_info: Option>, + recorded: Recorded, + weight_info: Option, _marker: PhantomData, } @@ -724,7 +716,7 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { pub fn new( vicinity: &'vicinity Vicinity, metadata: StackSubstateMetadata<'config>, - resource_info: Option>, + weight_info: Option, ) -> Self { Self { vicinity, @@ -736,12 +728,21 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { }, _marker: PhantomData, original_storage: BTreeMap::new(), - resource_info, + recorded: Default::default(), + weight_info, } } - pub fn resource_info(&self) -> &Option> { - &self.resource_info + pub fn weight_info(&self) -> Option { + self.weight_info + } + + pub fn recorded(&self) -> &Recorded { + &self.recorded + } + + pub fn info_mut(&mut self) -> (&mut Option, &mut Recorded) { + (&mut self.weight_info, &mut self.recorded) } } @@ -986,10 +987,50 @@ where .create_contract_limit .unwrap_or_default() as u64; - if let Some(resource_info) = self.resource_info.as_mut() { - resource_info.record_external_operation(op, size_limit)? - } + let (weight_info, recorded) = self.info_mut(); + if let Some(weight_info) = weight_info { + match op { + evm::ExternalOperation::AccountBasicRead => { + weight_info.try_record_proof_size_or_fail(ACCOUNT_BASIC_PROOF_SIZE)? + } + evm::ExternalOperation::AddressCodeRead(address) => { + let maybe_record = !recorded.account_codes.contains(&address); + // Skip if the address has been already recorded this block + if maybe_record { + // First we record account emptiness check. + // Transfers to EOAs with standard 21_000 gas limit are able to + // pay for this pov size. + weight_info.try_record_proof_size_or_fail(IS_EMPTY_CHECK_PROOF_SIZE)?; + + if >::decode_len(address).unwrap_or(0) == 0 { + return Ok(()); + } + // Try to record fixed sized `AccountCodesMetadata` read + // Tentatively 16 + 20 + 40 + weight_info + .try_record_proof_size_or_fail(ACCOUNT_CODES_METADATA_PROOF_SIZE)?; + if let Some(meta) = >::get(address) { + weight_info.try_record_proof_size_or_fail(meta.size)?; + } else { + // If it does not exist, try to record `create_contract_limit` first. + weight_info.try_record_proof_size_or_fail(size_limit)?; + let meta = Pallet::::account_code_metadata(address); + let actual_size = meta.size; + // Refund if applies + weight_info.refund_proof_size(size_limit.saturating_sub(actual_size)); + } + recorded.account_codes.push(address); + } + } + evm::ExternalOperation::IsEmpty => { + weight_info.try_record_proof_size_or_fail(IS_EMPTY_CHECK_PROOF_SIZE)? + } + evm::ExternalOperation::Write => { + weight_info.try_record_proof_size_or_fail(WRITE_PROOF_SIZE)? + } + }; + } Ok(()) } @@ -999,6 +1040,29 @@ where _gas_cost: GasCost, target: evm::gasometer::StorageTarget, ) -> Result<(), ExitError> { + // If account code or storage slot is in the overlay it is already accounted for and early exit + let mut accessed_storage: Option = match target { + StorageTarget::Address(address) => { + if self.recorded().account_codes.contains(&address) { + return Ok(()); + } else { + Some(AccessedStorage::AccountCodes(address)) + } + } + StorageTarget::Slot(address, index) => { + if self + .recorded() + .account_storages + .contains_key(&(address, index)) + { + return Ok(()); + } else { + Some(AccessedStorage::AccountStorages((address, index))) + } + } + _ => None, + }; + let size_limit: u64 = self .metadata() .gasometer() @@ -1006,19 +1070,162 @@ where .create_contract_limit .unwrap_or_default() as u64; - if let Some(resource_info) = self.resource_info.as_mut() { - resource_info.record_external_dynamic_opcode_cost(opcode, target, size_limit)? + let (weight_info, recorded) = { + let (weight_info, recorded) = self.info_mut(); + if let Some(weight_info) = weight_info { + (weight_info, recorded) + } else { + return Ok(()); + } + }; + + // Record ref_time first + // TODO benchmark opcodes, until this is done we do used_gas to weight conversion for ref_time + + // Record proof_size + // Return if proof size recording is disabled + let proof_size_limit = if let Some(proof_size_limit) = weight_info.proof_size_limit { + proof_size_limit + } else { + return Ok(()); + }; + + let mut maybe_record_and_refund = |with_empty_check: bool| -> Result<(), ExitError> { + let address = if let Some(AccessedStorage::AccountCodes(address)) = accessed_storage { + address + } else { + // This must be unreachable, a valid target must be set. + // TODO decide how do we want to gracefully handle. + return Err(ExitError::OutOfGas); + }; + // First try to record fixed sized `AccountCodesMetadata` read + // Tentatively 20 + 8 + 32 + let mut base_cost = ACCOUNT_CODES_METADATA_PROOF_SIZE; + if with_empty_check { + base_cost = base_cost.saturating_add(IS_EMPTY_CHECK_PROOF_SIZE); + } + weight_info.try_record_proof_size_or_fail(base_cost)?; + if let Some(meta) = >::get(address) { + weight_info.try_record_proof_size_or_fail(meta.size)?; + } else { + // If it does not exist, try to record `create_contract_limit` first. + weight_info.try_record_proof_size_or_fail(size_limit)?; + let meta = Pallet::::account_code_metadata(address); + let actual_size = meta.size; + // Refund if applies + weight_info.refund_proof_size(size_limit.saturating_sub(actual_size)); + } + recorded.account_codes.push(address); + // Already recorded, return + Ok(()) + }; + + // Proof size is fixed length for writes (a 32-byte hash in a merkle trie), and + // the full key/value for reads. For read and writes over the same storage, the full value + // is included. + // For cold reads involving code (call, callcode, staticcall and delegatecall): + // - We depend on https://github.com/paritytech/frontier/pull/893 + // - Try to get the cached size or compute it on the fly + // - We record the actual size after caching, refunding the difference between it and the initially deducted + // contract size limit. + let opcode_proof_size = match opcode { + // Basic account fixed length + Opcode::BALANCE => { + accessed_storage = None; + U256::from(ACCOUNT_BASIC_PROOF_SIZE) + } + Opcode::EXTCODESIZE | Opcode::EXTCODECOPY | Opcode::EXTCODEHASH => { + return maybe_record_and_refund(false) + } + Opcode::CALLCODE | Opcode::CALL | Opcode::DELEGATECALL | Opcode::STATICCALL => { + return maybe_record_and_refund(true) + } + // (H160, H256) double map blake2 128 concat key size (68) + value 32 + Opcode::SLOAD => U256::from(ACCOUNT_STORAGE_PROOF_SIZE), + Opcode::SSTORE => { + let (address, index) = + if let Some(AccessedStorage::AccountStorages((address, index))) = + accessed_storage + { + (address, index) + } else { + // This must be unreachable, a valid target must be set. + // TODO decide how do we want to gracefully handle. + return Err(ExitError::OutOfGas); + }; + let mut cost = WRITE_PROOF_SIZE; + let maybe_record = !recorded.account_storages.contains_key(&(address, index)); + // If the slot is yet to be accessed we charge for it, as the evm reads + // it prior to the opcode execution. + // Skip if the address and index has been already recorded this block. + if maybe_record { + cost = cost.saturating_add(ACCOUNT_STORAGE_PROOF_SIZE); + } + U256::from(cost) + } + // Fixed trie 32 byte hash + Opcode::CREATE | Opcode::CREATE2 => U256::from(WRITE_PROOF_SIZE), + // When calling SUICIDE a target account will receive the self destructing + // address's balance. We need to account for both: + // - Target basic account read + // - 5 bytes of `decode_len` + Opcode::SUICIDE => { + accessed_storage = None; + U256::from(IS_EMPTY_CHECK_PROOF_SIZE) + } + // Rest of dynamic opcodes that do not involve proof size recording, do nothing + _ => return Ok(()), + }; + + if opcode_proof_size > U256::from(u64::MAX) { + weight_info.try_record_proof_size_or_fail(proof_size_limit)?; + return Err(ExitError::OutOfGas); + } + + // Cache the storage access + match accessed_storage { + Some(AccessedStorage::AccountStorages((address, index))) => { + recorded.account_storages.insert((address, index), true); + } + Some(AccessedStorage::AccountCodes(address)) => { + recorded.account_codes.push(address); + } + _ => {} + } + + // Record cost + self.record_external_cost(None, Some(opcode_proof_size.low_u64()))?; + Ok(()) + } + + fn record_external_cost( + &mut self, + ref_time: Option, + proof_size: Option, + ) -> Result<(), ExitError> { + let weight_info = if let (Some(weight_info), _) = self.info_mut() { + weight_info + } else { + return Ok(()); + }; + // Record ref_time first + // TODO benchmark opcodes, until this is done we do used_gas to weight conversion for ref_time + if let Some(amount) = ref_time { + weight_info.try_record_ref_time_or_fail(amount)?; + } + if let Some(amount) = proof_size { + weight_info.try_record_proof_size_or_fail(amount)?; } Ok(()) } fn refund_external_cost(&mut self, ref_time: Option, proof_size: Option) { - if let Some(resource_info) = self.resource_info.as_mut() { + if let Some(mut weight_info) = self.weight_info { if let Some(amount) = ref_time { - resource_info.refund_ref_time(amount); + weight_info.refund_ref_time(amount); } if let Some(amount) = proof_size { - resource_info.refund_proof_size(amount); + weight_info.refund_proof_size(amount); } } } diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index d6c4813eee..7efae3ca92 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -18,13 +18,8 @@ #![cfg(test)] use super::*; -use crate::{ - mock::*, - resource::{ - ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_CODES_METADATA_PROOF_SIZE, ACCOUNT_STORAGE_PROOF_SIZE, - IS_EMPTY_CHECK_PROOF_SIZE, WRITE_PROOF_SIZE, - }, -}; +use crate::mock::*; + use frame_support::{ assert_ok, traits::{LockIdentifier, LockableCurrency, WithdrawReasons}, @@ -34,7 +29,10 @@ use std::{collections::BTreeMap, str::FromStr}; mod proof_size_test { use super::*; - use fp_evm::CreateInfo; + use fp_evm::{ + CreateInfo, ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_CODES_METADATA_PROOF_SIZE, + ACCOUNT_STORAGE_PROOF_SIZE, IS_EMPTY_CHECK_PROOF_SIZE, WRITE_PROOF_SIZE, + }; use frame_support::traits::StorageInfoTrait; // pragma solidity ^0.8.2; // contract Callee { diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 0b02fecb5b..4a4902ba27 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -57,6 +57,22 @@ pub struct Vicinity { pub origin: H160, } +/// `System::Account` 16(hash) + 20 (key) + 60 (AccountInfo::max_encoded_len) +pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 96; +/// `AccountCodesMetadata` read, temptatively 16 (hash) + 20 (key) + 40 (CodeMetadata). +pub const ACCOUNT_CODES_METADATA_PROOF_SIZE: u64 = 76; +/// 16 (hash1) + 20 (key1) + 16 (hash2) + 32 (key2) + 32 (value) +pub const ACCOUNT_STORAGE_PROOF_SIZE: u64 = 116; +/// Fixed trie 32 byte hash. +pub const WRITE_PROOF_SIZE: u64 = 32; +/// Account basic proof size + 5 bytes max of `decode_len` call. +pub const IS_EMPTY_CHECK_PROOF_SIZE: u64 = 93; + +pub enum AccessedStorage { + AccountCodes(H160), + AccountStorages((H160, H256)), +} + #[derive(Clone, Copy, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct WeightInfo { @@ -66,6 +82,77 @@ pub struct WeightInfo { pub proof_size_usage: Option, } +impl WeightInfo { + pub fn new_from_weight_limit( + weight_limit: Option, + proof_size_base_cost: Option, + ) -> Result, &'static str> { + Ok(match (weight_limit, proof_size_base_cost) { + (None, _) => None, + (Some(weight_limit), Some(proof_size_base_cost)) + if weight_limit.proof_size() >= proof_size_base_cost => + { + Some(WeightInfo { + ref_time_limit: Some(weight_limit.ref_time()), + proof_size_limit: Some(weight_limit.proof_size()), + ref_time_usage: Some(0u64), + proof_size_usage: Some(proof_size_base_cost), + }) + } + (Some(weight_limit), None) => Some(WeightInfo { + ref_time_limit: Some(weight_limit.ref_time()), + proof_size_limit: None, + ref_time_usage: Some(0u64), + proof_size_usage: None, + }), + _ => return Err("must provide Some valid weight limit or None"), + }) + } + fn try_consume(&self, cost: u64, limit: u64, usage: u64) -> Result { + let usage = usage.checked_add(cost).ok_or(ExitError::OutOfGas)?; + if usage > limit { + return Err(ExitError::OutOfGas); + } + Ok(usage) + } + pub fn try_record_ref_time_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { + if let (Some(ref_time_usage), Some(ref_time_limit)) = + (self.ref_time_usage, self.ref_time_limit) + { + let ref_time_usage = self.try_consume(cost, ref_time_limit, ref_time_usage)?; + if ref_time_usage > ref_time_limit { + return Err(ExitError::OutOfGas); + } + self.ref_time_usage = Some(ref_time_usage); + } + Ok(()) + } + pub fn try_record_proof_size_or_fail(&mut self, cost: u64) -> Result<(), ExitError> { + if let (Some(proof_size_usage), Some(proof_size_limit)) = + (self.proof_size_usage, self.proof_size_limit) + { + let proof_size_usage = self.try_consume(cost, proof_size_limit, proof_size_usage)?; + if proof_size_usage > proof_size_limit { + return Err(ExitError::OutOfGas); + } + self.proof_size_usage = Some(proof_size_usage); + } + Ok(()) + } + pub fn refund_proof_size(&mut self, amount: u64) { + if let Some(proof_size_usage) = self.proof_size_usage { + let proof_size_usage = proof_size_usage.saturating_sub(amount); + self.proof_size_usage = Some(proof_size_usage); + } + } + pub fn refund_ref_time(&mut self, amount: u64) { + if let Some(ref_time_usage) = self.ref_time_usage { + let ref_time_usage = ref_time_usage.saturating_sub(amount); + self.ref_time_usage = Some(ref_time_usage); + } + } +} + #[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct UsedGas { From 9236488d5dd5683ab947b396ac7ce8c88db66a96 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Thu, 17 Aug 2023 12:23:55 +0200 Subject: [PATCH 27/46] compute storage growth for opcodes --- frame/evm/src/resource.rs | 625 ---------------------------------- frame/evm/src/runner/meter.rs | 136 ++++++++ frame/evm/src/runner/mod.rs | 1 + frame/evm/src/runner/stack.rs | 60 +++- 4 files changed, 191 insertions(+), 631 deletions(-) delete mode 100644 frame/evm/src/resource.rs create mode 100644 frame/evm/src/runner/meter.rs diff --git a/frame/evm/src/resource.rs b/frame/evm/src/resource.rs deleted file mode 100644 index 415d590821..0000000000 --- a/frame/evm/src/resource.rs +++ /dev/null @@ -1,625 +0,0 @@ -use crate::{AccountCodes, AccountCodesMetadata, Config, Pallet}; - -use core::marker::PhantomData; -use evm::{ - gasometer::{GasCost, StorageTarget}, - ExitError, Opcode, -}; -use fp_evm::WeightInfo; -use sp_core::{Get, H160, H256, U256}; -use sp_runtime::{traits::CheckedAdd, Saturating}; -use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; - -/// `System::Account` 16(hash) + 20 (key) + 60 (AccountInfo::max_encoded_len) -pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 96; -/// `AccountCodesMetadata` read, temptatively 16 (hash) + 20 (key) + 40 (CodeMetadata). -pub const ACCOUNT_CODES_METADATA_PROOF_SIZE: u64 = 76; -/// 16 (hash1) + 20 (key1) + 16 (hash2) + 32 (key2) + 32 (value) -pub const ACCOUNT_STORAGE_PROOF_SIZE: u64 = 116; -/// Fixed trie 32 byte hash. -pub const WRITE_PROOF_SIZE: u64 = 32; -/// Account basic proof size + 5 bytes max of `decode_len` call. -pub const IS_EMPTY_CHECK_PROOF_SIZE: u64 = 93; -/// Storage: Set a new value. (32 bytes) -pub const STORAGE_NEW_COST: u64 = 32; - -#[derive(Debug, PartialEq)] -/// Resource error. -pub enum ResourceError { - /// The Resource usage exceeds the limit. - LimitExceeded, - /// Invalid Base Cost. - InvalidBaseCost, - ///Used to indicate that the code should be unreachable. - Unreachable, -} - -impl From for ExitError { - fn from(_error: ResourceError) -> Self { - ExitError::OutOfGas - } -} - -/// A struct that keeps track of resource usage and limit. -pub struct Resource { - limit: T, - usage: T, -} - -impl Resource -where - T: CheckedAdd + Saturating + PartialOrd + Copy, -{ - /// Creates a new `Resource` instance with the given base cost and limit. - /// - /// # Errors - /// - /// Returns `ResourceError::InvalidBaseCost` if the base cost is greater than the limit. - pub fn new(base_cost: T, limit: T) -> Result { - if base_cost > limit { - return Err(ResourceError::InvalidBaseCost); - } - Ok(Self { - limit, - usage: base_cost, - }) - } - - /// Records the cost of an operation and updates the usage. - /// - /// # Errors - /// - /// Returns `ResourceError::LimitExceeded` if the Resource usage exceeds the limit. - fn record_cost(&mut self, cost: T) -> Result<(), ResourceError> { - let usage = self - .usage - .checked_add(&cost) - .ok_or(ResourceError::LimitExceeded)?; - - if usage > self.limit { - return Err(ResourceError::LimitExceeded); - } - self.usage = usage; - Ok(()) - } - - /// Refunds the given amount. - fn refund(&mut self, amount: T) { - self.usage = self.usage.saturating_sub(amount); - } - - /// Returns the usage. - fn usage(&self) -> T { - self.usage - } -} - -pub enum AccessedStorage { - AccountCodes(H160), - AccountStorages((H160, H256)), -} - -#[derive(Default, Clone, Eq, PartialEq)] -pub struct Recorded { - account_codes: Vec, - account_storages: BTreeMap<(H160, H256), bool>, -} - -/// A struct that keeps track of the proof size and limit. -pub struct ProofSizeMeter { - resource: Resource, - recorded: Recorded, - _marker: PhantomData, -} - -impl ProofSizeMeter { - /// Creates a new `ProofSizeResource` instance with the given limit. - pub fn new(base_cost: u64, limit: u64) -> Result { - Ok(Self { - resource: Resource::new(base_cost, limit)?, - recorded: Recorded::default(), - _marker: PhantomData, - }) - } - - /// Records the size of the proof and updates the usage. - /// - /// # Errors - /// - /// Returns `ResourceError::LimitExceeded` if the proof size exceeds the limit. - pub fn record_proof_size(&mut self, size: u64) -> Result<(), ResourceError> { - self.resource.record_cost(size) - } - - /// Refunds the given amount of proof size. - pub fn refund(&mut self, amount: u64) { - self.resource.refund(amount) - } - - /// Returns the proof size usage. - pub fn usage(&self) -> u64 { - self.resource.usage() - } - - /// Returns the proof size limit. - pub fn limit(&self) -> u64 { - self.resource.limit - } - - pub fn record_external_operation( - &mut self, - op: &evm::ExternalOperation, - contract_size_limit: u64, - ) -> Result<(), ResourceError> { - match op { - evm::ExternalOperation::AccountBasicRead => { - self.record_proof_size(ACCOUNT_BASIC_PROOF_SIZE)? - } - evm::ExternalOperation::AddressCodeRead(address) => { - let maybe_record = !self.recorded.account_codes.contains(address); - // Skip if the address has been already recorded this block - if maybe_record { - // First we record account emptiness check. - // Transfers to EOAs with standard 21_000 gas limit are able to - // pay for this pov size. - self.record_proof_size(IS_EMPTY_CHECK_PROOF_SIZE)?; - - if >::decode_len(address).unwrap_or(0) == 0 { - return Ok(()); - } - // Try to record fixed sized `AccountCodesMetadata` read - // Tentatively 16 + 20 + 40 - self.record_proof_size(ACCOUNT_CODES_METADATA_PROOF_SIZE)?; - if let Some(meta) = >::get(address) { - self.record_proof_size(meta.size)?; - } else { - // If it does not exist, try to record `create_contract_limit` first. - self.record_proof_size(contract_size_limit)?; - let meta = Pallet::::account_code_metadata(*address); - let actual_size = meta.size; - // Refund if applies - self.refund(contract_size_limit.saturating_sub(actual_size)); - } - self.recorded.account_codes.push(*address); - } - } - evm::ExternalOperation::IsEmpty => self.record_proof_size(IS_EMPTY_CHECK_PROOF_SIZE)?, - evm::ExternalOperation::Write => self.record_proof_size(WRITE_PROOF_SIZE)?, - }; - Ok(()) - } - - pub fn record_external_dynamic_opcode_cost( - &mut self, - opcode: Opcode, - target: evm::gasometer::StorageTarget, - contract_size_limit: u64, - ) -> Result<(), ResourceError> { - // If account code or storage slot is in the overlay it is already accounted for and early exit - let mut accessed_storage: Option = match target { - StorageTarget::Address(address) => { - if self.recorded.account_codes.contains(&address) { - return Ok(()); - } else { - Some(AccessedStorage::AccountCodes(address)) - } - } - StorageTarget::Slot(address, index) => { - if self - .recorded - .account_storages - .contains_key(&(address, index)) - { - return Ok(()); - } else { - Some(AccessedStorage::AccountStorages((address, index))) - } - } - _ => None, - }; - - let mut maybe_record_and_refund = |with_empty_check: bool| -> Result<(), ResourceError> { - let address = if let Some(AccessedStorage::AccountCodes(address)) = accessed_storage { - address - } else { - // This must be unreachable, a valid target must be set. - // TODO decide how do we want to gracefully handle. - return Err(ResourceError::Unreachable); - }; - // First try to record fixed sized `AccountCodesMetadata` read - // Tentatively 20 + 8 + 32 - let mut base_cost = ACCOUNT_CODES_METADATA_PROOF_SIZE; - if with_empty_check { - base_cost = base_cost.saturating_add(IS_EMPTY_CHECK_PROOF_SIZE); - } - self.record_proof_size(base_cost)?; - if let Some(meta) = >::get(address) { - self.record_proof_size(meta.size)?; - } else { - // If it does not exist, try to record `create_contract_limit` first. - self.record_proof_size(contract_size_limit)?; - let meta = Pallet::::account_code_metadata(address); - let actual_size = meta.size; - // Refund if applies - self.refund(contract_size_limit.saturating_sub(actual_size)); - } - self.recorded.account_codes.push(address); - // Already recorded, return - Ok(()) - }; - - // Proof size is fixed length for writes (a 32-byte hash in a merkle trie), and - // the full key/value for reads. For read and writes over the same storage, the full value - // is included. - // For cold reads involving code (call, callcode, staticcall and delegatecall): - // - We depend on https://github.com/paritytech/frontier/pull/893 - // - Try to get the cached size or compute it on the fly - // - We record the actual size after caching, refunding the difference between it and the initially deducted - // contract size limit. - let opcode_proof_size = match opcode { - // Basic account fixed length - Opcode::BALANCE => { - accessed_storage = None; - U256::from(ACCOUNT_BASIC_PROOF_SIZE) - } - Opcode::EXTCODESIZE | Opcode::EXTCODECOPY | Opcode::EXTCODEHASH => { - return maybe_record_and_refund(false) - } - Opcode::CALLCODE | Opcode::CALL | Opcode::DELEGATECALL | Opcode::STATICCALL => { - return maybe_record_and_refund(true) - } - // (H160, H256) double map blake2 128 concat key size (68) + value 32 - Opcode::SLOAD => U256::from(ACCOUNT_STORAGE_PROOF_SIZE), - Opcode::SSTORE => { - let (address, index) = - if let Some(AccessedStorage::AccountStorages((address, index))) = - accessed_storage - { - (address, index) - } else { - // This must be unreachable, a valid target must be set. - // TODO decide how do we want to gracefully handle. - return Err(ResourceError::Unreachable); - }; - let mut cost = WRITE_PROOF_SIZE; - let maybe_record = !self - .recorded - .account_storages - .contains_key(&(address, index)); - // If the slot is yet to be accessed we charge for it, as the evm reads - // it prior to the opcode execution. - // Skip if the address and index has been already recorded this block. - if maybe_record { - cost = cost.saturating_add(ACCOUNT_STORAGE_PROOF_SIZE); - } - U256::from(cost) - } - // Fixed trie 32 byte hash - Opcode::CREATE | Opcode::CREATE2 => U256::from(WRITE_PROOF_SIZE), - // When calling SUICIDE a target account will receive the self destructing - // address's balance. We need to account for both: - // - Target basic account read - // - 5 bytes of `decode_len` - Opcode::SUICIDE => { - accessed_storage = None; - U256::from(IS_EMPTY_CHECK_PROOF_SIZE) - } - // Rest of dynamic opcodes that do not involve proof size recording, do nothing - _ => return Ok(()), - }; - - if opcode_proof_size > U256::from(u64::MAX) { - self.record_proof_size(self.limit())?; - return Err(ResourceError::LimitExceeded); - } - - // Cache the storage access - match accessed_storage { - Some(AccessedStorage::AccountStorages((address, index))) => { - self.recorded - .account_storages - .insert((address, index), true); - } - Some(AccessedStorage::AccountCodes(address)) => { - self.recorded.account_codes.push(address); - } - _ => {} - } - - // Record cost - self.record_proof_size(opcode_proof_size.low_u64())?; - Ok(()) - } - - pub fn record_external_static_opcode_cost( - &mut self, - _opcode: Opcode, - _gas_cost: GasCost, - ) -> Result<(), ResourceError> { - Ok(()) - } -} - -/// A struct that keeps track of the ref_time usage and limit. -pub struct RefTimeMeter(Resource); - -impl RefTimeMeter { - /// Creates a new `RefTimeResource` instance with the given limit. - pub fn new(limit: u64) -> Result { - Ok(Self(Resource::new(0, limit)?)) - } - - /// Records the ref_time and updates the usage. - pub fn record_ref_time(&mut self, ref_time: u64) -> Result<(), ResourceError> { - self.0.record_cost(ref_time) - } - - /// Returns the ref time usage. - pub fn usage(&self) -> u64 { - self.0.usage() - } - - /// Returns the ref time limit. - pub fn limit(&self) -> u64 { - self.0.limit - } - - /// Refunds the given amount of ref_time. - pub fn refund(&mut self, amount: u64) { - self.0.refund(amount) - } -} - -/// A struct that keeps track of storage usage (newly created storage) and limit. -pub struct StorageMeter { - usage: u64, - limit: u64, -} - -impl StorageMeter { - /// Creates a new `StorageResource` instance with the given limit. - pub fn new(limit: u64) -> Self { - Self(Resource::new(0, limit)) - } - - /// Refunds the given amount of storage. - fn _refund(&mut self, amount: u64) { - self.0.refund(amount) - } - - /// Returns the storage usage. - pub fn usage(&self) -> u64 { - self.0.usage() - } - - /// Increments the storage usage by the given amount. - pub fn record(&mut self, cost: u64) -> Result<(), ResourceError> { - self.0.record_cost(cost) - } - - /// Records the dynamic opcode cost and updates the storage usage. - /// - /// # Errors - /// - /// Returns `ResourceError::LimitExceeded` if the storage usage exceeds the storage limit. - fn _record_dynamic_opcode_cost( - &mut self, - _opcode: Opcode, - gas_cost: GasCost, - ) -> Result<(), ResourceError> { - let cost = match gas_cost { - GasCost::Create => { - // TODO record cost for create - 0 - } - GasCost::Create2 { len } => { - // len in bytes ?? - len.try_into().map_err(|_| ResourceError::LimitExceeded)? - } - GasCost::SStore { current, new, .. } => { - if current.is_zero() && !new.is_zero() { - STORAGE_NEW_COST - } else { - 0 - } - } - _ => return Ok(()), - }; - self.0.record_cost(cost) - } - - fn record_external_operation( - &mut self, - operation: &evm::ExternalOperation, - _contract_size_limit: u64, - ) { - if let evm::ExternalOperation::Write = operation { - // Todo record cost for write - } - } -} - -#[derive(Default)] -pub struct ResourceInfo { - pub ref_time_meter: Option, - pub proof_size_meter: Option>, - pub storage_meter: Option, -} - -impl ResourceInfo { - pub fn new() -> Self { - Self { - ref_time_meter: None, - proof_size_meter: None, - storage_meter: None, - } - } - - pub fn add_ref_time_meter(&mut self, limit: u64) -> Result<(), &'static str> { - self.ref_time_meter = Some(RefTimeMeter::new(limit).map_err(|_| "Invalid parameters")?); - Ok(()) - } - - pub fn add_proof_size_meter(&mut self, base_cost: u64, limit: u64) -> Result<(), &'static str> { - self.proof_size_meter = - Some(ProofSizeMeter::new(base_cost, limit).map_err(|_| "Invalid parameters")?); - Ok(()) - } - - pub fn add_storage_meter(&mut self, limit: u64) -> Result<(), &'static str> { - self.storage_meter = Some(StorageMeter::new(limit).map_err(|_| "Invalid parameters")?); - Ok(()) - } - - pub fn refund_proof_size(&mut self, amount: u64) { - if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { - proof_size_meter.refund(amount); - } - } - - pub fn refund_ref_time(&mut self, amount: u64) { - if let Some(ref_time_meter) = self.ref_time_meter.as_mut() { - ref_time_meter.refund(amount); - } - } - - /// Returns WeightInfo for the resource. - pub fn weight_info(&self) -> WeightInfo { - macro_rules! usage_and_limit { - ($x:expr) => { - ( - $x.as_ref().map(|x| x.usage()), - $x.as_ref().map(|x| x.limit()), - ) - }; - } - - let (proof_size_usage, proof_size_limit) = usage_and_limit!(self.proof_size_meter); - let (ref_time_usage, ref_time_limit) = usage_and_limit!(self.ref_time_meter); - - WeightInfo { - proof_size_usage, - proof_size_limit, - ref_time_usage, - ref_time_limit, - } - } - - pub fn record_external_operation( - &mut self, - operation: evm::ExternalOperation, - contract_size_limit: u64, - ) -> Result<(), ResourceError> { - if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { - proof_size_meter.record_external_operation(&operation, contract_size_limit)?; - } - - if let Some(storage_meter) = self.storage_meter.as_mut() { - storage_meter.record_external_operation(&operation, contract_size_limit) - } - - Ok(()) - } - - pub fn record_external_dynamic_opcode_cost( - &mut self, - opcode: Opcode, - target: evm::gasometer::StorageTarget, - contract_size_limit: u64, - ) -> Result<(), ResourceError> { - if let Some(proof_size_meter) = self.proof_size_meter.as_mut() { - proof_size_meter.record_external_dynamic_opcode_cost( - opcode, - target, - contract_size_limit, - )?; - } - // Record ref_time - // TODO benchmark opcodes, until this is done we do used_gas to weight conversion for ref_time - - Ok(()) - } - - pub fn effective_gas(&self, gas: u64) -> U256 { - let proof_size_usage = self.proof_size_meter.as_ref().map_or(0, |resource| { - resource - .usage() - .saturating_mul(T::GasLimitPovSizeRatio::get()) - }); - - let storage_usage = self - .storage_meter - .as_ref() - .map_or(0, |resource| resource.usage()); - - let effective_gas = - sp_std::cmp::max(sp_std::cmp::max(proof_size_usage, storage_usage), gas); - - U256::from(effective_gas) - } - - pub fn is_empty(&self) -> bool { - self.ref_time_meter.is_none() - && self.proof_size_meter.is_none() - && self.storage_meter.is_none() - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_init() { - let resource = Resource::::new(0, 100).unwrap(); - assert_eq!(resource.limit, 100); - assert_eq!(resource.usage, 0); - - // base cost > limit - let resource = Resource::::new(100, 0).err(); - assert_eq!(resource, Some(ResourceError::InvalidBaseCost)); - } - - #[test] - fn test_record_cost() { - let mut resource = Resource::::new(0, 100).unwrap(); - assert_eq!(resource.record_cost(10), Ok(())); - assert_eq!(resource.usage, 10); - assert_eq!(resource.record_cost(90), Ok(())); - assert_eq!(resource.usage, 100); - - // exceed limit - assert_eq!(resource.record_cost(1), Err(ResourceError::LimitExceeded)); - assert_eq!(resource.usage, 100); - } - - #[test] - fn test_refund() { - let mut resource = Resource::::new(0, 100).unwrap(); - assert_eq!(resource.record_cost(10), Ok(())); - assert_eq!(resource.usage, 10); - resource.refund(10); - assert_eq!(resource.usage, 0); - - // refund more than usage - resource.refund(10); - assert_eq!(resource.usage, 0); - } - - #[test] - fn test_storage_meter() { - let mut resource = StorageMeter::new(100).unwrap(); - assert_eq!(resource.0.usage, 0); - assert_eq!(resource.0.limit, 100); - assert_eq!(resource.0.record_cost(10), Ok(())); - assert_eq!(resource.0.usage, 10); - assert_eq!(resource.0.record_cost(90), Ok(())); - assert_eq!(resource.0.usage, 100); - assert_eq!(resource.0.record_cost(1), Err(ResourceError::LimitExceeded)); - assert_eq!(resource.0.usage, 100); - resource.0.refund(10); - assert_eq!(resource.0.usage, 90); - resource._refund(10); - assert_eq!(resource.0.usage, 80); - } -} diff --git a/frame/evm/src/runner/meter.rs b/frame/evm/src/runner/meter.rs new file mode 100644 index 0000000000..cf4b582751 --- /dev/null +++ b/frame/evm/src/runner/meter.rs @@ -0,0 +1,136 @@ +/// The size of a storage key and storage value in bytes. +pub const STORAGE_SIZE: u64 = 64; + +/// A meter for tracking the storage growth. +#[derive(Clone, Copy)] +pub struct StorageMeter { + usage: u64, + limit: u64, +} + +/// An error that is returned when the storage limit has been exceeded. +#[derive(Debug, PartialEq)] +pub enum MeterError { + LimitExceeded, +} + +impl StorageMeter { + /// Creates a new storage meter with the given limit. + pub fn new(limit: u64) -> Self { + Self { usage: 0, limit } + } + + /// Records the given amount of storage usage. The amount is added to the current usage. + /// The usage will saturate at `u64::MAX`. + pub fn record(&mut self, amount: u64) { + self.usage = self.usage.saturating_add(amount); + } + + /// Returns the current usage of storage. + pub fn usage(&self) -> u64 { + self.usage + } + + /// Returns the amount of storage that is available before the limit is reached. + pub fn available(&self) -> u64 { + self.limit.saturating_sub(self.usage) + } + + /// Merge the given storage meter into the current one. + pub fn merge(&mut self, other: Option) { + self.usage = self + .usage + .saturating_add(other.map_or(0, |meter| meter.usage)); + } + + /// Map storage usage to the gas cost. + pub fn gas_cost(&self) -> u64 { + 0 + } + + /// Checks if the current usage of storage is within the limit. + /// + /// # Errors + /// + /// Returns `MeterError::ResourceLimitExceeded` if the limit has been exceeded. + pub fn check_limit(&self) -> Result<(), MeterError> { + if self.usage > self.limit { + Err(MeterError::LimitExceeded) + } else { + Ok(()) + } + } +} + +// Generate a comprehensive unit test suite for the StorageMeter: +// - Make sure to cover all the edge cases. +// - Group the tests into a module so that they are not included in the crate documentation. +// - Group similar or related tests in seperate functions. +// - Document the different tests explaining the use case +#[cfg(test)] +mod test { + use super::*; + + #[cfg(test)] + mod tests { + use super::*; + + /// Tests the basic functionality of StorageMeter. + #[test] + fn test_basic_functionality() { + let limit = 100; + let mut meter = StorageMeter::new(limit); + + assert_eq!(meter.usage(), 0); + assert_eq!(meter.available(), limit); + + let amount = 10; + meter.record(amount); + assert_eq!(meter.usage(), amount); + assert_eq!(meter.available(), limit - amount); + + assert!(meter.check_limit().is_ok()); + } + + /// Tests the behavior of StorageMeter when reaching the limit. + #[test] + fn test_reaching_limit() { + let limit = 100; + let mut meter = StorageMeter::new(limit); + + // Approaching the limit without exceeding + meter.record(limit - 1); + assert_eq!(meter.usage(), limit - 1); + assert!(meter.check_limit().is_ok()); + + // Reaching the limit exactly + meter.record(1); + assert_eq!(meter.usage(), limit); + assert!(meter.check_limit().is_ok()); + + // Exceeding the limit + meter.record(1); + assert_eq!(meter.usage(), limit + 1); + assert_eq!(meter.check_limit(), Err(MeterError::LimitExceeded)); + } + + /// Tests the behavior of StorageMeter with saturation. + #[test] + fn test_saturation_behavior() { + let limit = u64::MAX; + let mut meter = StorageMeter::new(limit); + + // Reaching the limit + meter.record(limit); + assert_eq!(meter.usage(), limit); + assert_eq!(meter.available(), 0); + assert!(meter.check_limit().is_ok()); + + // Exceeding the limit using saturating_add + meter.record(1); + assert_eq!(meter.usage(), limit); + assert_eq!(meter.available(), 0); + assert!(meter.check_limit().is_ok()); + } + } +} diff --git a/frame/evm/src/runner/mod.rs b/frame/evm/src/runner/mod.rs index bda922d39c..bd1304e01e 100644 --- a/frame/evm/src/runner/mod.rs +++ b/frame/evm/src/runner/mod.rs @@ -16,6 +16,7 @@ // limitations under the License. pub mod stack; +pub mod meter; use crate::{Config, Weight}; use fp_evm::{CallInfo, CreateInfo}; diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 1bfc8453d2..b58d06c612 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -32,7 +32,7 @@ use frame_support::{ weights::Weight, }; use sp_core::{H160, H256, U256}; -use sp_runtime::traits::UniqueSaturatedInto; +use sp_runtime::{traits::UniqueSaturatedInto, DispatchError}; use sp_std::{ boxed::Box, collections::{btree_map::BTreeMap, btree_set::BTreeSet}, @@ -47,10 +47,12 @@ use fp_evm::{ ACCOUNT_STORAGE_PROOF_SIZE, IS_EMPTY_CHECK_PROOF_SIZE, WRITE_PROOF_SIZE, }; +use super::meter::StorageMeter; use crate::{ - runner::Runner as RunnerT, AccountCodes, AccountCodesMetadata, AccountStorages, AddressMapping, - BalanceOf, BlockHashMapping, Config, Error, Event, FeeCalculator, OnChargeEVMTransaction, - OnCreate, Pallet, RunnerError, + runner::{meter::STORAGE_SIZE, Runner as RunnerT}, + AccountCodes, AccountCodesMetadata, AccountStorages, AddressMapping, BalanceOf, + BlockHashMapping, Config, Error, Event, FeeCalculator, OnChargeEVMTransaction, OnCreate, + Pallet, RunnerError, }; #[cfg(feature = "forbid-evm-reentrancy")] @@ -269,12 +271,21 @@ where origin: source, }; + // TODO get Storage Limit Quota for the transaction + let storage_limit = Some(u64::MAX); + let metadata = StackSubstateMetadata::new(gas_limit, config); - let state = SubstrateStackState::new(&vicinity, metadata, maybe_weight_info); + let state = SubstrateStackState::new(&vicinity, metadata, maybe_weight_info, storage_limit); let mut executor = StackExecutor::new_with_precompiles(state, config, precompiles); let (reason, retv) = f(&mut executor); + let storage_usage = if let Some(storage_meter) = executor.state().substate.storage_meter { + storage_meter.usage() + } else { + 0 + }; + // Post execution. let used_gas = executor.used_gas(); let effective_gas = match executor.state().weight_info() { @@ -603,6 +614,7 @@ struct SubstrateStackSubstate<'config> { deletes: BTreeSet, logs: Vec, parent: Option>>, + storage_meter: Option, } impl<'config> SubstrateStackSubstate<'config> { @@ -615,11 +627,18 @@ impl<'config> SubstrateStackSubstate<'config> { } pub fn enter(&mut self, gas_limit: u64, is_static: bool) { + let storage_meter = if let Some(meter) = self.storage_meter { + Some(StorageMeter::new(meter.available())) + } else { + None + }; + let mut entering = Self { metadata: self.metadata.spit_child(gas_limit, is_static), parent: None, deletes: BTreeSet::new(), logs: Vec::new(), + storage_meter, }; mem::swap(&mut entering, self); @@ -636,6 +655,14 @@ impl<'config> SubstrateStackSubstate<'config> { self.logs.append(&mut exited.logs); self.deletes.append(&mut exited.deletes); + if let Some(storage_meter) = self.storage_meter.as_mut() { + storage_meter.merge(exited.storage_meter); + // TODO Check for storage limit here ?? + storage_meter + .check_limit() + .map_err(|_| ExitError::OutOfGas)?; + } + sp_io::storage::commit_transaction(); Ok(()) } @@ -717,7 +744,9 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { vicinity: &'vicinity Vicinity, metadata: StackSubstateMetadata<'config>, weight_info: Option, + storage_limit: Option, ) -> Self { + let storage_meter = storage_limit.map(|limit| StorageMeter::new(limit)); Self { vicinity, substate: SubstrateStackSubstate { @@ -725,6 +754,7 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { deletes: BTreeSet::new(), logs: Vec::new(), parent: None, + storage_meter, }, _marker: PhantomData, original_storage: BTreeMap::new(), @@ -878,8 +908,9 @@ where // We cache the current value if this is the first time we modify it // in the transaction. use sp_std::collections::btree_map::Entry::Vacant; + let original = >::get(address, index); + if let Vacant(e) = self.original_storage.entry((address, index)) { - let original = >::get(address, index); // No need to cache if same value. if original != value { e.insert(original); @@ -904,6 +935,15 @@ where value, ); >::insert(address, index, value); + + // If the original value was zero, and the new value is non-zero, + // then this is a new storage entry. We need to record the storage + // size. + if original.is_zero() { + if let Some(storage_meter) = self.substate.storage_meter.as_mut() { + storage_meter.record(STORAGE_SIZE); + } + } } } @@ -927,6 +967,14 @@ where code.len(), address ); + + if let Some(storage_meter) = self.substate.storage_meter.as_mut() { + let storage_usage = code.len() as u64; + + // TODO record storage usage for new account code creation + storage_meter.record(storage_usage); + } + Pallet::::create_account(address, code); } From aa640bf4acbc4cfb632d7c30e86bfc4ae8d81097 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Fri, 18 Aug 2023 08:50:17 +0200 Subject: [PATCH 28/46] compute the storage quota per tx --- frame/ethereum/src/mock.rs | 4 +++ frame/evm/precompile/dispatch/src/mock.rs | 1 + frame/evm/src/lib.rs | 3 +++ frame/evm/src/mock.rs | 4 +++ frame/evm/src/runner/meter.rs | 4 +-- frame/evm/src/runner/stack.rs | 33 ++++++++++++++--------- template/runtime/src/lib.rs | 4 +++ 7 files changed, 39 insertions(+), 14 deletions(-) diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index 72ab96fb9a..907ba10375 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -131,6 +131,8 @@ impl FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 150_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; +/// The maximum storage growth per block in bytes (40 Kb). +const MAX_STORAGE_GROWTH: u64 = 40 * 1024; parameter_types! { pub const TransactionByteFee: u64 = 1; @@ -138,6 +140,7 @@ parameter_types! { pub const EVMModuleId: PalletId = PalletId(*b"py/evmpa"); pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); + pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); pub const WeightPerGas: Weight = Weight::from_parts(20_000, 0); } @@ -169,6 +172,7 @@ impl pallet_evm::Config for Test { type OnCreate = (); type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type Timestamp = Timestamp; type WeightInfo = (); } diff --git a/frame/evm/precompile/dispatch/src/mock.rs b/frame/evm/precompile/dispatch/src/mock.rs index cb55296bda..ba6868205b 100644 --- a/frame/evm/precompile/dispatch/src/mock.rs +++ b/frame/evm/precompile/dispatch/src/mock.rs @@ -153,6 +153,7 @@ impl pallet_evm::Config for Test { type OnCreate = (); type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = (); + type GasLimitStorageGrowthRatio = (); type Timestamp = Timestamp; type WeightInfo = (); } diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 0a5a287f09..e7d0b91d55 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -167,6 +167,9 @@ pub mod pallet { /// Gas limit Pov size ratio. type GasLimitPovSizeRatio: Get; + /// Gas limit storage growth ratio. + type GasLimitStorageGrowthRatio: Get; + /// Get the timestamp for the current block. type Timestamp: Time; diff --git a/frame/evm/src/mock.rs b/frame/evm/src/mock.rs index 2ba1495eb4..ef63b17f18 100644 --- a/frame/evm/src/mock.rs +++ b/frame/evm/src/mock.rs @@ -122,10 +122,13 @@ impl FindAuthor for FindAuthorTruncated { } const BLOCK_GAS_LIMIT: u64 = 150_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; +/// The maximum storage growth per block in bytes (40 Kb). +const MAX_STORAGE_GROWTH: u64 = 40 * 1024; parameter_types! { pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); + pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); pub WeightPerGas: Weight = Weight::from_parts(20_000, 0); pub MockPrecompiles: MockPrecompileSet = MockPrecompileSet; } @@ -151,6 +154,7 @@ impl crate::Config for Test { type OnCreate = (); type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type Timestamp = Timestamp; type WeightInfo = (); } diff --git a/frame/evm/src/runner/meter.rs b/frame/evm/src/runner/meter.rs index cf4b582751..9f36dd7819 100644 --- a/frame/evm/src/runner/meter.rs +++ b/frame/evm/src/runner/meter.rs @@ -44,8 +44,8 @@ impl StorageMeter { } /// Map storage usage to the gas cost. - pub fn gas_cost(&self) -> u64 { - 0 + pub fn storage_to_gas(&self, ratio: u64) -> u64 { + self.usage.saturating_mul(ratio) } /// Checks if the current usage of storage is within the limit. diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index b58d06c612..3e49b69028 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -32,7 +32,7 @@ use frame_support::{ weights::Weight, }; use sp_core::{H160, H256, U256}; -use sp_runtime::{traits::UniqueSaturatedInto, DispatchError}; +use sp_runtime::traits::UniqueSaturatedInto; use sp_std::{ boxed::Box, collections::{btree_map::BTreeMap, btree_set::BTreeSet}, @@ -271,8 +271,14 @@ where origin: source, }; - // TODO get Storage Limit Quota for the transaction - let storage_limit = Some(u64::MAX); + // Compute the storage limit based on the gas limit and the storage growth ratio. + let storage_growth_ratio = T::GasLimitStorageGrowthRatio::get(); + let storage_limit = if storage_growth_ratio > 0 { + let storage_limit = gas_limit.saturating_div(storage_growth_ratio); + Some(storage_limit) + } else { + None + }; let metadata = StackSubstateMetadata::new(gas_limit, config); let state = SubstrateStackState::new(&vicinity, metadata, maybe_weight_info, storage_limit); @@ -280,21 +286,24 @@ where let (reason, retv) = f(&mut executor); - let storage_usage = if let Some(storage_meter) = executor.state().substate.storage_meter { - storage_meter.usage() - } else { - 0 + // Compute the storage gas cost based on the storage growth. + let storage_gas = match executor.state().substate.storage_meter { + Some(storage_meter) => storage_meter.storage_to_gas(storage_growth_ratio), + None => 0, }; // Post execution. let used_gas = executor.used_gas(); let effective_gas = match executor.state().weight_info() { Some(weight_info) => U256::from(sp_std::cmp::max( - used_gas, - weight_info - .proof_size_usage - .unwrap_or_default() - .saturating_mul(T::GasLimitPovSizeRatio::get()), + sp_std::cmp::max( + used_gas, + weight_info + .proof_size_usage + .unwrap_or_default() + .saturating_mul(T::GasLimitPovSizeRatio::get()), + ), + storage_gas, )), _ => used_gas.into(), }; diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index 2d7804a904..70db5bdf51 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -317,10 +317,13 @@ impl> FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 75_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; +/// The maximum storage growth per block in bytes (40 Kb). +const MAX_STORAGE_GROWTH: u64 = 40 * 1024; parameter_types! { pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); + pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); pub PrecompilesValue: FrontierPrecompiles = FrontierPrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK), 0); } @@ -344,6 +347,7 @@ impl pallet_evm::Config for Runtime { type OnCreate = (); type FindAuthor = FindAuthorTruncated; type GasLimitPovSizeRatio = GasLimitPovSizeRatio; + type GasLimitStorageGrowthRatio = GasLimitStorageGrowthRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; } From 8adaac2de83d1652ffcbf2f69d4ea927090041a2 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Sun, 20 Aug 2023 14:38:10 +0200 Subject: [PATCH 29/46] pin evm temporarily --- Cargo.lock | 10 +++++----- Cargo.toml | 3 ++- frame/evm/src/runner/stack.rs | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f5b59965a..e4c32c8a27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2152,8 +2152,8 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "evm" -version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm?branch=tgm-record-external-cost#53315e22da8494dbcb6b54a18e09775e956b7c73" +version = "0.39.1" +source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#8ea64228cd02da080c2b3053a77a21bdd3871b36" dependencies = [ "auto_impl", "environmental", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm?branch=tgm-record-external-cost#53315e22da8494dbcb6b54a18e09775e956b7c73" +source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#8ea64228cd02da080c2b3053a77a21bdd3871b36" dependencies = [ "parity-scale-codec", "primitive-types", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm?branch=tgm-record-external-cost#53315e22da8494dbcb6b54a18e09775e956b7c73" +source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#8ea64228cd02da080c2b3053a77a21bdd3871b36" dependencies = [ "environmental", "evm-core", @@ -2195,7 +2195,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm?branch=tgm-record-external-cost#53315e22da8494dbcb6b54a18e09775e956b7c73" +source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#8ea64228cd02da080c2b3053a77a21bdd3871b36" dependencies = [ "auto_impl", "environmental", diff --git a/Cargo.toml b/Cargo.toml index 4d49e460cc..7f24ac9d5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,8 @@ clap = { version = "4.3", features = ["derive", "deprecated"] } environmental = { version = "1.1.4", default-features = false } ethereum = { version = "0.14.0", default-features = false } ethereum-types = { version = "0.14.1", default-features = false } -evm = { git = "https://github.com/moonbeam-foundation/evm", branch = "tgm-record-external-cost", default-features = false } +# evm = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false } +evm = { git = "https://github.com/moonbeam-foundation/evm.git", branch = "ahmad-update-external-operation", default-features = false } futures = "0.3.28" hex = { version = "0.4.3", default-features = false, features = ["alloc"] } hex-literal = "0.4.1" diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 3e49b69028..fc057e3fbc 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -1083,8 +1083,8 @@ where evm::ExternalOperation::IsEmpty => { weight_info.try_record_proof_size_or_fail(IS_EMPTY_CHECK_PROOF_SIZE)? } - evm::ExternalOperation::Write => { - weight_info.try_record_proof_size_or_fail(WRITE_PROOF_SIZE)? + evm::ExternalOperation::Write(len) => { + weight_info.try_record_proof_size_or_fail(WRITE_PROOF_SIZE)?; } }; } From 71d9356b3dca706ebcf2d9a84a5bc6cb131b3142 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Sun, 20 Aug 2023 14:43:07 +0200 Subject: [PATCH 30/46] record storage growth for opcodes --- frame/evm/src/runner/meter.rs | 195 +++++++++++++++++++--------------- frame/evm/src/runner/stack.rs | 73 +++++-------- primitives/evm/src/lib.rs | 2 + 3 files changed, 137 insertions(+), 133 deletions(-) diff --git a/frame/evm/src/runner/meter.rs b/frame/evm/src/runner/meter.rs index 9f36dd7819..fa047d471f 100644 --- a/frame/evm/src/runner/meter.rs +++ b/frame/evm/src/runner/meter.rs @@ -1,5 +1,6 @@ -/// The size of a storage key and storage value in bytes. -pub const STORAGE_SIZE: u64 = 64; +use evm::{gasometer::GasCost, Opcode}; +use fp_evm::ACCOUNT_STORAGE_PROOF_SIZE; +use sp_core::H256; /// A meter for tracking the storage growth. #[derive(Clone, Copy)] @@ -21,9 +22,33 @@ impl StorageMeter { } /// Records the given amount of storage usage. The amount is added to the current usage. - /// The usage will saturate at `u64::MAX`. - pub fn record(&mut self, amount: u64) { - self.usage = self.usage.saturating_add(amount); + /// If the limit is reached, an error is returned. + pub fn record(&mut self, amount: u64) -> Result<(), MeterError> { + self.usage = self.usage.checked_add(amount).ok_or_else(|| { + self.usage = self.limit; + MeterError::LimitExceeded + })?; + + if self.usage > self.limit { + return Err(MeterError::LimitExceeded); + } + Ok(()) + } + + /// Records the storage growth for the given Opcode. + pub fn record_dynamic_opcode_cost( + &mut self, + _opcode: Opcode, + gas_cost: GasCost, + ) -> Result<(), MeterError> { + match gas_cost { + GasCost::SStore { original, new, .. } + if original == H256::default() && !new.is_zero() => + { + self.record(ACCOUNT_STORAGE_PROOF_SIZE) + } + _ => Ok(()), + } } /// Returns the current usage of storage. @@ -31,106 +56,100 @@ impl StorageMeter { self.usage } + /// Returns the limit of storage. + pub fn limit(&self) -> u64 { + self.limit + } + /// Returns the amount of storage that is available before the limit is reached. pub fn available(&self) -> u64 { self.limit.saturating_sub(self.usage) } - /// Merge the given storage meter into the current one. - pub fn merge(&mut self, other: Option) { - self.usage = self - .usage - .saturating_add(other.map_or(0, |meter| meter.usage)); - } - /// Map storage usage to the gas cost. pub fn storage_to_gas(&self, ratio: u64) -> u64 { self.usage.saturating_mul(ratio) } - - /// Checks if the current usage of storage is within the limit. - /// - /// # Errors - /// - /// Returns `MeterError::ResourceLimitExceeded` if the limit has been exceeded. - pub fn check_limit(&self) -> Result<(), MeterError> { - if self.usage > self.limit { - Err(MeterError::LimitExceeded) - } else { - Ok(()) - } - } } - -// Generate a comprehensive unit test suite for the StorageMeter: -// - Make sure to cover all the edge cases. -// - Group the tests into a module so that they are not included in the crate documentation. -// - Group similar or related tests in seperate functions. -// - Document the different tests explaining the use case #[cfg(test)] mod test { use super::*; - #[cfg(test)] - mod tests { - use super::*; - - /// Tests the basic functionality of StorageMeter. - #[test] - fn test_basic_functionality() { - let limit = 100; - let mut meter = StorageMeter::new(limit); - - assert_eq!(meter.usage(), 0); - assert_eq!(meter.available(), limit); + /// Tests the basic functionality of StorageMeter. + #[test] + fn test_basic_functionality() { + let limit = 100; + let mut meter = StorageMeter::new(limit); - let amount = 10; - meter.record(amount); - assert_eq!(meter.usage(), amount); - assert_eq!(meter.available(), limit - amount); + assert_eq!(meter.usage(), 0); + assert_eq!(meter.limit(), limit); - assert!(meter.check_limit().is_ok()); - } + let amount = 10; + meter.record(amount).unwrap(); + assert_eq!(meter.usage(), amount); + } - /// Tests the behavior of StorageMeter when reaching the limit. - #[test] - fn test_reaching_limit() { - let limit = 100; - let mut meter = StorageMeter::new(limit); - - // Approaching the limit without exceeding - meter.record(limit - 1); - assert_eq!(meter.usage(), limit - 1); - assert!(meter.check_limit().is_ok()); - - // Reaching the limit exactly - meter.record(1); - assert_eq!(meter.usage(), limit); - assert!(meter.check_limit().is_ok()); - - // Exceeding the limit - meter.record(1); - assert_eq!(meter.usage(), limit + 1); - assert_eq!(meter.check_limit(), Err(MeterError::LimitExceeded)); - } + /// Tests the behavior of StorageMeter when reaching the limit. + #[test] + fn test_reaching_limit() { + let limit = 100; + let mut meter = StorageMeter::new(limit); + + // Approaching the limit without exceeding + meter.record(limit - 1).unwrap(); + assert_eq!(meter.usage(), limit - 1); + + // Reaching the limit exactly + meter.record(1).unwrap(); + assert_eq!(meter.usage(), limit); + + // Exceeding the limit + let res = meter.record(1); + assert_eq!(meter.usage(), limit + 1); + assert!(res.is_err()); + assert_eq!(res, Err(MeterError::LimitExceeded)); + } - /// Tests the behavior of StorageMeter with saturation. - #[test] - fn test_saturation_behavior() { - let limit = u64::MAX; - let mut meter = StorageMeter::new(limit); - - // Reaching the limit - meter.record(limit); - assert_eq!(meter.usage(), limit); - assert_eq!(meter.available(), 0); - assert!(meter.check_limit().is_ok()); - - // Exceeding the limit using saturating_add - meter.record(1); - assert_eq!(meter.usage(), limit); - assert_eq!(meter.available(), 0); - assert!(meter.check_limit().is_ok()); - } + /// Tests the record of dynamic opcode cost. + #[test] + fn test_record_dynamic_opcode_cost() { + let limit = 200; + let mut meter = StorageMeter::new(limit); + + // Existing storage entry is updated. No change in storage growth. + let gas_cost = GasCost::SStore { + original: H256::from_low_u64_be(1), + current: Default::default(), + new: H256::from_low_u64_be(2), + target_is_cold: false, + }; + meter + .record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost) + .unwrap(); + assert_eq!(meter.usage(), 0); + + // New storage entry is created. Storage growth is recorded. + let gas_cost = GasCost::SStore { + original: H256::default(), + current: Default::default(), + new: H256::from_low_u64_be(1), + target_is_cold: false, + }; + meter + .record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost) + .unwrap(); + assert_eq!(meter.usage(), ACCOUNT_STORAGE_PROOF_SIZE); + + // New storage entry is created. Storage growth is recorded. The limit is reached. + let gas_cost = GasCost::SStore { + original: H256::default(), + current: Default::default(), + new: H256::from_low_u64_be(2), + target_is_cold: false, + }; + let res = meter.record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost); + assert!(res.is_err()); + assert_eq!(res, Err(MeterError::LimitExceeded)); + assert_eq!(meter.usage(), 232); } } diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index fc057e3fbc..55d978941b 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -43,16 +43,16 @@ use sp_std::{ // Frontier use fp_evm::{ AccessedStorage, CallInfo, CreateInfo, ExecutionInfoV2, IsPrecompileResult, Log, PrecompileSet, - Vicinity, WeightInfo, ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_CODES_METADATA_PROOF_SIZE, - ACCOUNT_STORAGE_PROOF_SIZE, IS_EMPTY_CHECK_PROOF_SIZE, WRITE_PROOF_SIZE, + Vicinity, WeightInfo, ACCOUNT_BASIC_PROOF_SIZE, ACCOUNT_CODES_KEY_SIZE, + ACCOUNT_CODES_METADATA_PROOF_SIZE, ACCOUNT_STORAGE_PROOF_SIZE, IS_EMPTY_CHECK_PROOF_SIZE, + WRITE_PROOF_SIZE, }; use super::meter::StorageMeter; use crate::{ - runner::{meter::STORAGE_SIZE, Runner as RunnerT}, - AccountCodes, AccountCodesMetadata, AccountStorages, AddressMapping, BalanceOf, - BlockHashMapping, Config, Error, Event, FeeCalculator, OnChargeEVMTransaction, OnCreate, - Pallet, RunnerError, + runner::Runner as RunnerT, AccountCodes, AccountCodesMetadata, AccountStorages, AddressMapping, + BalanceOf, BlockHashMapping, Config, Error, Event, FeeCalculator, OnChargeEVMTransaction, + OnCreate, Pallet, RunnerError, }; #[cfg(feature = "forbid-evm-reentrancy")] @@ -287,7 +287,7 @@ where let (reason, retv) = f(&mut executor); // Compute the storage gas cost based on the storage growth. - let storage_gas = match executor.state().substate.storage_meter { + let storage_gas = match executor.state().storage_meter { Some(storage_meter) => storage_meter.storage_to_gas(storage_growth_ratio), None => 0, }; @@ -623,7 +623,6 @@ struct SubstrateStackSubstate<'config> { deletes: BTreeSet, logs: Vec, parent: Option>>, - storage_meter: Option, } impl<'config> SubstrateStackSubstate<'config> { @@ -636,18 +635,11 @@ impl<'config> SubstrateStackSubstate<'config> { } pub fn enter(&mut self, gas_limit: u64, is_static: bool) { - let storage_meter = if let Some(meter) = self.storage_meter { - Some(StorageMeter::new(meter.available())) - } else { - None - }; - let mut entering = Self { metadata: self.metadata.spit_child(gas_limit, is_static), parent: None, deletes: BTreeSet::new(), logs: Vec::new(), - storage_meter, }; mem::swap(&mut entering, self); @@ -664,14 +656,6 @@ impl<'config> SubstrateStackSubstate<'config> { self.logs.append(&mut exited.logs); self.deletes.append(&mut exited.deletes); - if let Some(storage_meter) = self.storage_meter.as_mut() { - storage_meter.merge(exited.storage_meter); - // TODO Check for storage limit here ?? - storage_meter - .check_limit() - .map_err(|_| ExitError::OutOfGas)?; - } - sp_io::storage::commit_transaction(); Ok(()) } @@ -744,6 +728,7 @@ pub struct SubstrateStackState<'vicinity, 'config, T> { original_storage: BTreeMap<(H160, H256), H256>, recorded: Recorded, weight_info: Option, + storage_meter: Option, _marker: PhantomData, } @@ -755,7 +740,7 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { weight_info: Option, storage_limit: Option, ) -> Self { - let storage_meter = storage_limit.map(|limit| StorageMeter::new(limit)); + let storage_meter = storage_limit.map(StorageMeter::new); Self { vicinity, substate: SubstrateStackSubstate { @@ -763,12 +748,12 @@ impl<'vicinity, 'config, T: Config> SubstrateStackState<'vicinity, 'config, T> { deletes: BTreeSet::new(), logs: Vec::new(), parent: None, - storage_meter, }, _marker: PhantomData, original_storage: BTreeMap::new(), recorded: Default::default(), weight_info, + storage_meter, } } @@ -917,9 +902,8 @@ where // We cache the current value if this is the first time we modify it // in the transaction. use sp_std::collections::btree_map::Entry::Vacant; - let original = >::get(address, index); - if let Vacant(e) = self.original_storage.entry((address, index)) { + let original = >::get(address, index); // No need to cache if same value. if original != value { e.insert(original); @@ -944,15 +928,6 @@ where value, ); >::insert(address, index, value); - - // If the original value was zero, and the new value is non-zero, - // then this is a new storage entry. We need to record the storage - // size. - if original.is_zero() { - if let Some(storage_meter) = self.substate.storage_meter.as_mut() { - storage_meter.record(STORAGE_SIZE); - } - } } } @@ -976,14 +951,6 @@ where code.len(), address ); - - if let Some(storage_meter) = self.substate.storage_meter.as_mut() { - let storage_usage = code.len() as u64; - - // TODO record storage usage for new account code creation - storage_meter.record(storage_usage); - } - Pallet::::create_account(address, code); } @@ -1085,6 +1052,16 @@ where } evm::ExternalOperation::Write(len) => { weight_info.try_record_proof_size_or_fail(WRITE_PROOF_SIZE)?; + + if let Some(storage_meter) = self.storage_meter.as_mut() { + // Record the number of bytes written to storage when deploying a contract. + let storage_growth = ACCOUNT_CODES_KEY_SIZE + + ACCOUNT_CODES_METADATA_PROOF_SIZE + + len.as_u64(); + storage_meter + .record(storage_growth) + .map_err(|_| ExitError::OutOfGas)?; + } } }; } @@ -1094,9 +1071,15 @@ where fn record_external_dynamic_opcode_cost( &mut self, opcode: Opcode, - _gas_cost: GasCost, + gas_cost: GasCost, target: evm::gasometer::StorageTarget, ) -> Result<(), ExitError> { + if let Some(storage_meter) = self.storage_meter.as_mut() { + storage_meter + .record_dynamic_opcode_cost(opcode, gas_cost) + .map_err(|_| ExitError::OutOfGas)?; + } + // If account code or storage slot is in the overlay it is already accounted for and early exit let mut accessed_storage: Option = match target { StorageTarget::Address(address) => { diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 4a4902ba27..6468ece781 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -67,6 +67,8 @@ pub const ACCOUNT_STORAGE_PROOF_SIZE: u64 = 116; pub const WRITE_PROOF_SIZE: u64 = 32; /// Account basic proof size + 5 bytes max of `decode_len` call. pub const IS_EMPTY_CHECK_PROOF_SIZE: u64 = 93; +/// `AccountCodes` key size. 16 (hash) + 20 (key) +pub const ACCOUNT_CODES_KEY_SIZE: u64 = 36; pub enum AccessedStorage { AccountCodes(H160), From a8cd2a0198f362ccbc808663e4255b505b2ef7a3 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 21 Aug 2023 15:53:39 +0200 Subject: [PATCH 31/46] update GAS_LIMIT_STORAGE_GROWTH_RATIO for tests --- frame/ethereum/src/mock.rs | 6 +++--- frame/evm/src/mock.rs | 5 +++-- template/runtime/src/lib.rs | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index 907ba10375..01aaefb652 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -132,15 +132,15 @@ impl FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 150_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; /// The maximum storage growth per block in bytes (40 Kb). -const MAX_STORAGE_GROWTH: u64 = 40 * 1024; - +const MAX_STORAGE_GROWTH: u64 = 80 * 1024; +const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); parameter_types! { pub const TransactionByteFee: u64 = 1; pub const ChainId: u64 = 42; pub const EVMModuleId: PalletId = PalletId(*b"py/evmpa"); pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); + pub const GasLimitStorageGrowthRatio: u64 = GAS_LIMIT_STORAGE_GROWTH_RATIO; pub const WeightPerGas: Weight = Weight::from_parts(20_000, 0); } diff --git a/frame/evm/src/mock.rs b/frame/evm/src/mock.rs index ef63b17f18..ca7588ee85 100644 --- a/frame/evm/src/mock.rs +++ b/frame/evm/src/mock.rs @@ -123,12 +123,13 @@ impl FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 150_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; /// The maximum storage growth per block in bytes (40 Kb). -const MAX_STORAGE_GROWTH: u64 = 40 * 1024; +const MAX_STORAGE_GROWTH: u64 = 80 * 1024; +const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); parameter_types! { pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); + pub const GasLimitStorageGrowthRatio: u64 = GAS_LIMIT_STORAGE_GROWTH_RATIO; pub WeightPerGas: Weight = Weight::from_parts(20_000, 0); pub MockPrecompiles: MockPrecompileSet = MockPrecompileSet; } diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index 70db5bdf51..feb00f3445 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -318,12 +318,13 @@ impl> FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 75_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; /// The maximum storage growth per block in bytes (40 Kb). -const MAX_STORAGE_GROWTH: u64 = 40 * 1024; +const MAX_STORAGE_GROWTH: u64 = 80 * 1024; +const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); parameter_types! { pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); + pub const GasLimitStorageGrowthRatio: u64 = GAS_LIMIT_STORAGE_GROWTH_RATIO; pub PrecompilesValue: FrontierPrecompiles = FrontierPrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK), 0); } From d094584ce3de1883280a57ba1afbbac1e8ebdf9e Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 21 Aug 2023 16:16:18 +0200 Subject: [PATCH 32/46] add support to record storage growth for precompiles --- Cargo.lock | 8 +-- frame/evm/precompile/dispatch/src/lib.rs | 2 +- frame/evm/src/res/erc20_contract_bytecode.txt | 1 + frame/evm/src/runner/stack.rs | 10 ++- frame/evm/src/tests.rs | 62 +++++++++++++++++++ frame/evm/test-vector-support/src/lib.rs | 2 +- 6 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 frame/evm/src/res/erc20_contract_bytecode.txt diff --git a/Cargo.lock b/Cargo.lock index e4c32c8a27..eca1482155 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2153,7 +2153,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "evm" version = "0.39.1" -source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#8ea64228cd02da080c2b3053a77a21bdd3871b36" +source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#6bd1f61d38e33aab44b6b52cb14deaf9668755b5" dependencies = [ "auto_impl", "environmental", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#8ea64228cd02da080c2b3053a77a21bdd3871b36" +source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#6bd1f61d38e33aab44b6b52cb14deaf9668755b5" dependencies = [ "parity-scale-codec", "primitive-types", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#8ea64228cd02da080c2b3053a77a21bdd3871b36" +source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#6bd1f61d38e33aab44b6b52cb14deaf9668755b5" dependencies = [ "environmental", "evm-core", @@ -2195,7 +2195,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#8ea64228cd02da080c2b3053a77a21bdd3871b36" +source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#6bd1f61d38e33aab44b6b52cb14deaf9668755b5" dependencies = [ "auto_impl", "environmental", diff --git a/frame/evm/precompile/dispatch/src/lib.rs b/frame/evm/precompile/dispatch/src/lib.rs index f73349bf31..4763dbf4e9 100644 --- a/frame/evm/precompile/dispatch/src/lib.rs +++ b/frame/evm/precompile/dispatch/src/lib.rs @@ -82,7 +82,7 @@ where } handle - .record_external_cost(Some(info.weight.ref_time()), Some(info.weight.proof_size()))?; + .record_external_cost(Some(info.weight.ref_time()), Some(info.weight.proof_size()), None)?; match call.dispatch(Some(origin).into()) { Ok(post_info) => { diff --git a/frame/evm/src/res/erc20_contract_bytecode.txt b/frame/evm/src/res/erc20_contract_bytecode.txt new file mode 100644 index 0000000000..1e31f671dd --- /dev/null +++ b/frame/evm/src/res/erc20_contract_bytecode.txt @@ -0,0 +1 @@ +608060405234801561001057600080fd5b50610041337fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61004660201b60201c565b610291565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156100e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6101028160025461020960201b610c7c1790919060201c565b60028190555061015d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461020960201b610c7c1790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600080828401905083811015610287576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b610e3a806102a06000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101fd578063a457c2d714610255578063a9059cbb146102bb578063dd62ed3e1461032157610088565b8063095ea7b31461008d57806318160ddd146100f357806323b872dd146101115780633950935114610197575b600080fd5b6100d9600480360360408110156100a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610399565b604051808215151515815260200191505060405180910390f35b6100fb6103b7565b6040518082815260200191505060405180910390f35b61017d6004803603606081101561012757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b6101e3600480360360408110156101ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061049a565b604051808215151515815260200191505060405180910390f35b61023f6004803603602081101561021357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061054d565b6040518082815260200191505060405180910390f35b6102a16004803603604081101561026b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610595565b604051808215151515815260200191505060405180910390f35b610307600480360360408110156102d157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610662565b604051808215151515815260200191505060405180910390f35b6103836004803603604081101561033757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610680565b6040518082815260200191505060405180910390f35b60006103ad6103a6610707565b848461070f565b6001905092915050565b6000600254905090565b60006103ce848484610906565b61048f846103da610707565b61048a85604051806060016040528060288152602001610d7060289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610440610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b600190509392505050565b60006105436104a7610707565b8461053e85600160006104b8610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b61070f565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006106586105a2610707565b8461065385604051806060016040528060258152602001610de160259139600160006105cc610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b6001905092915050565b600061067661066f610707565b8484610906565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610795576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180610dbd6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561081b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610d286022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561098c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180610d986025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610d056023913960400191505060405180910390fd5b610a7d81604051806060016040528060268152602001610d4a602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b10816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610c69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c2e578082015181840152602081019050610c13565b50505050905090810190601f168015610c5b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610cfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820c7a5ffabf642bda14700b2de42f8c57b36621af020441df825de45fd2b3e1c5c64736f6c63430005100032 \ No newline at end of file diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 55d978941b..34d5e37c05 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -1234,7 +1234,7 @@ where } // Record cost - self.record_external_cost(None, Some(opcode_proof_size.low_u64()))?; + self.record_external_cost(None, Some(opcode_proof_size.low_u64()), None)?; Ok(()) } @@ -1242,6 +1242,7 @@ where &mut self, ref_time: Option, proof_size: Option, + storage_growth: Option, ) -> Result<(), ExitError> { let weight_info = if let (Some(weight_info), _) = self.info_mut() { weight_info @@ -1256,6 +1257,13 @@ where if let Some(amount) = proof_size { weight_info.try_record_proof_size_or_fail(amount)?; } + if let Some(storage_meter) = self.storage_meter.as_mut() { + if let Some(amount) = storage_growth { + storage_meter + .record(amount) + .map_err(|_| ExitError::OutOfGas)?; + } + } Ok(()) } diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index 7efae3ca92..bcd419df1d 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -625,6 +625,68 @@ mod proof_size_test { } } +mod storage_growth_test { + use super::*; + use std::env; + + pub const ERC20_CONTRACT_BYTECODE: &str = include_str!("./res/proof_size_test_contract_bytecode.txt"); + + fn setup_logger() { + if env::var("RUST_LOG").is_err() { + env::set_var("RUST_LOG", "debug"); // Set log level here + } + let _ = env_logger::builder().is_test(true).try_init(); + } + + fn create_erc20_test_contract( + gas_limit: u64, + ) -> Result>> { + ::Runner::create( + H160::default(), + hex::decode(ERC20_CONTRACT_BYTECODE.trim_end()).unwrap(), + U256::zero(), + gas_limit, + Some(FixedGasPrice::min_gas_price().0), + None, + None, + Vec::new(), + true, // transactional + true, // must be validated + Some(FixedGasWeightMapping::::gas_to_weight( + gas_limit, true, + )), + Some(0), + &::config().clone(), + ) + } + + // This test is to ensure that the storage growth is accounted for correctly when deploying a + // a new contract. In this scenario, the contract is deployed with a gas limit that is not enough + // to cover the storage growth. + #[test] + fn contract_deployement_should_fail_oog() { + setup_logger(); + new_test_ext().execute_with(|| { + let gas_limit: u64 = 4_700_000; + + let result = create_erc20_test_contract(gas_limit).expect("create succeeds"); + // The contract is deployed with a gas limit that is not enough to cover the storage + // growth. The contract creation should fail. + // assert_eq!( + // result.exit_reason, + // crate::ExitReason::Error(crate::ExitError::OutOfGas) + // ); + + // // The contract is deployed with a gas limit that is enough to cover the storage + // // growth. The contract creation should succeed. + // let gas_limit: u64 = 1_500_000; + // let result = create_erc20_test_contract(gas_limit).expect("create succeeds"); + + // assert_eq!(result.exit_reason, crate::ExitReason::Succeed(ExitSucceed::Returned)); + }); + } +} + type Balances = pallet_balances::Pallet; type EVM = Pallet; diff --git a/frame/evm/test-vector-support/src/lib.rs b/frame/evm/test-vector-support/src/lib.rs index 3566840969..8d71bf01be 100644 --- a/frame/evm/test-vector-support/src/lib.rs +++ b/frame/evm/test-vector-support/src/lib.rs @@ -80,7 +80,7 @@ impl PrecompileHandle for MockHandle { Ok(()) } - fn record_external_cost(&mut self, _: Option, _: Option) -> Result<(), ExitError> { + fn record_external_cost(&mut self, _: Option, _: Option, _: Option) -> Result<(), ExitError> { Ok(()) } From 82075c4af189cb066af6d5ca1d2db96532435e5e Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 21 Aug 2023 16:25:53 +0200 Subject: [PATCH 33/46] fix tests --- frame/evm/precompile/dispatch/src/mock.rs | 1 + frame/evm/src/res/erc20_contract_bytecode.txt | 1 - frame/evm/src/tests.rs | 12 ++---------- 3 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 frame/evm/src/res/erc20_contract_bytecode.txt diff --git a/frame/evm/precompile/dispatch/src/mock.rs b/frame/evm/precompile/dispatch/src/mock.rs index ba6868205b..9da7bc80d4 100644 --- a/frame/evm/precompile/dispatch/src/mock.rs +++ b/frame/evm/precompile/dispatch/src/mock.rs @@ -184,6 +184,7 @@ impl PrecompileHandle for MockHandle { &mut self, _ref_time: Option, _proof_size: Option, + _storage_growth: Option, ) -> Result<(), ExitError> { Ok(()) } diff --git a/frame/evm/src/res/erc20_contract_bytecode.txt b/frame/evm/src/res/erc20_contract_bytecode.txt deleted file mode 100644 index 1e31f671dd..0000000000 --- a/frame/evm/src/res/erc20_contract_bytecode.txt +++ /dev/null @@ -1 +0,0 @@ -608060405234801561001057600080fd5b50610041337fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61004660201b60201c565b610291565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156100e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b6101028160025461020960201b610c7c1790919060201c565b60028190555061015d816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461020960201b610c7c1790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b600080828401905083811015610287576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b610e3a806102a06000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806370a082311161005b57806370a08231146101fd578063a457c2d714610255578063a9059cbb146102bb578063dd62ed3e1461032157610088565b8063095ea7b31461008d57806318160ddd146100f357806323b872dd146101115780633950935114610197575b600080fd5b6100d9600480360360408110156100a357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610399565b604051808215151515815260200191505060405180910390f35b6100fb6103b7565b6040518082815260200191505060405180910390f35b61017d6004803603606081101561012757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506103c1565b604051808215151515815260200191505060405180910390f35b6101e3600480360360408110156101ad57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061049a565b604051808215151515815260200191505060405180910390f35b61023f6004803603602081101561021357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061054d565b6040518082815260200191505060405180910390f35b6102a16004803603604081101561026b57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610595565b604051808215151515815260200191505060405180910390f35b610307600480360360408110156102d157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610662565b604051808215151515815260200191505060405180910390f35b6103836004803603604081101561033757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610680565b6040518082815260200191505060405180910390f35b60006103ad6103a6610707565b848461070f565b6001905092915050565b6000600254905090565b60006103ce848484610906565b61048f846103da610707565b61048a85604051806060016040528060288152602001610d7060289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610440610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b600190509392505050565b60006105436104a7610707565b8461053e85600160006104b8610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b61070f565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60006106586105a2610707565b8461065385604051806060016040528060258152602001610de160259139600160006105cc610707565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b61070f565b6001905092915050565b600061067661066f610707565b8484610906565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610795576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180610dbd6024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561081b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610d286022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561098c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180610d986025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610a12576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526023815260200180610d056023913960400191505060405180910390fd5b610a7d81604051806060016040528060268152602001610d4a602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610bbc9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610b10816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610c7c90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610c69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610c2e578082015181840152602081019050610c13565b50505050905090810190601f168015610c5b5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b600080828401905083811015610cfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a72315820c7a5ffabf642bda14700b2de42f8c57b36621af020441df825de45fd2b3e1c5c64736f6c63430005100032 \ No newline at end of file diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index bcd419df1d..a11a9b3341 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -629,21 +629,14 @@ mod storage_growth_test { use super::*; use std::env; - pub const ERC20_CONTRACT_BYTECODE: &str = include_str!("./res/proof_size_test_contract_bytecode.txt"); - - fn setup_logger() { - if env::var("RUST_LOG").is_err() { - env::set_var("RUST_LOG", "debug"); // Set log level here - } - let _ = env_logger::builder().is_test(true).try_init(); - } + pub const STORAGE_GROWTH_TEST_CONTRACT: &str = include_str!("./res/proof_size_test_contract_bytecode.txt"); fn create_erc20_test_contract( gas_limit: u64, ) -> Result>> { ::Runner::create( H160::default(), - hex::decode(ERC20_CONTRACT_BYTECODE.trim_end()).unwrap(), + hex::decode(STORAGE_GROWTH_TEST_CONTRACT.trim_end()).unwrap(), U256::zero(), gas_limit, Some(FixedGasPrice::min_gas_price().0), @@ -665,7 +658,6 @@ mod storage_growth_test { // to cover the storage growth. #[test] fn contract_deployement_should_fail_oog() { - setup_logger(); new_test_ext().execute_with(|| { let gas_limit: u64 = 4_700_000; From c26aaf2e81c1cf72e0f7f65f9391e6fb10392e7c Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 21 Aug 2023 16:27:04 +0200 Subject: [PATCH 34/46] fix formatting --- frame/evm/precompile/dispatch/src/lib.rs | 7 +++++-- frame/evm/src/lib.rs | 2 +- frame/evm/src/runner/mod.rs | 2 +- frame/evm/src/tests.rs | 3 ++- frame/evm/test-vector-support/src/lib.rs | 7 ++++++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frame/evm/precompile/dispatch/src/lib.rs b/frame/evm/precompile/dispatch/src/lib.rs index 4763dbf4e9..d3427b692f 100644 --- a/frame/evm/precompile/dispatch/src/lib.rs +++ b/frame/evm/precompile/dispatch/src/lib.rs @@ -81,8 +81,11 @@ where return Err(err); } - handle - .record_external_cost(Some(info.weight.ref_time()), Some(info.weight.proof_size()), None)?; + handle.record_external_cost( + Some(info.weight.ref_time()), + Some(info.weight.proof_size()), + None, + )?; match call.dispatch(Some(origin).into()) { Ok(post_info) => { diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index e7d0b91d55..323ad141f1 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -1051,4 +1051,4 @@ impl OnCreate for Tuple { Tuple::on_create(owner, contract); )*) } -} \ No newline at end of file +} diff --git a/frame/evm/src/runner/mod.rs b/frame/evm/src/runner/mod.rs index bd1304e01e..3a95a3d763 100644 --- a/frame/evm/src/runner/mod.rs +++ b/frame/evm/src/runner/mod.rs @@ -15,8 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub mod stack; pub mod meter; +pub mod stack; use crate::{Config, Weight}; use fp_evm::{CallInfo, CreateInfo}; diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index a11a9b3341..567db8486c 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -629,7 +629,8 @@ mod storage_growth_test { use super::*; use std::env; - pub const STORAGE_GROWTH_TEST_CONTRACT: &str = include_str!("./res/proof_size_test_contract_bytecode.txt"); + pub const STORAGE_GROWTH_TEST_CONTRACT: &str = + include_str!("./res/proof_size_test_contract_bytecode.txt"); fn create_erc20_test_contract( gas_limit: u64, diff --git a/frame/evm/test-vector-support/src/lib.rs b/frame/evm/test-vector-support/src/lib.rs index 8d71bf01be..beb87c6f98 100644 --- a/frame/evm/test-vector-support/src/lib.rs +++ b/frame/evm/test-vector-support/src/lib.rs @@ -80,7 +80,12 @@ impl PrecompileHandle for MockHandle { Ok(()) } - fn record_external_cost(&mut self, _: Option, _: Option, _: Option) -> Result<(), ExitError> { + fn record_external_cost( + &mut self, + _: Option, + _: Option, + _: Option, + ) -> Result<(), ExitError> { Ok(()) } From 91b8d02e61710fb1271c2a2c1ebb2ebaf3aedc96 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Tue, 22 Aug 2023 17:37:30 +0200 Subject: [PATCH 35/46] fix storage growth parameters for tests --- frame/ethereum/src/mock.rs | 2 +- frame/evm/src/mock.rs | 2 +- template/runtime/src/lib.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index 01aaefb652..b3dbd96ebc 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -131,7 +131,7 @@ impl FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 150_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; -/// The maximum storage growth per block in bytes (40 Kb). +/// The maximum storage growth per block in bytes (80 Kb). const MAX_STORAGE_GROWTH: u64 = 80 * 1024; const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); parameter_types! { diff --git a/frame/evm/src/mock.rs b/frame/evm/src/mock.rs index ca7588ee85..894d25bfac 100644 --- a/frame/evm/src/mock.rs +++ b/frame/evm/src/mock.rs @@ -123,7 +123,7 @@ impl FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 150_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; /// The maximum storage growth per block in bytes (40 Kb). -const MAX_STORAGE_GROWTH: u64 = 80 * 1024; +const MAX_STORAGE_GROWTH: u64 = 40 * 1024; const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); parameter_types! { diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index feb00f3445..d7d37f9511 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -317,8 +317,8 @@ impl> FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 75_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; -/// The maximum storage growth per block in bytes (40 Kb). -const MAX_STORAGE_GROWTH: u64 = 80 * 1024; +/// The maximum storage growth per block in bytes (3 Mb). +const MAX_STORAGE_GROWTH: u64 = 3 * 1024 * 1024; const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); parameter_types! { From 359d900de71fd8b11dcaa27cd7c9f5e64a9a0f52 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Wed, 23 Aug 2023 12:29:54 +0200 Subject: [PATCH 36/46] add rust integration tests --- frame/evm/src/res/StorageGrowthTest.sol | 27 ++ .../storage_growth_test_contract_bytecode.txt | 1 + frame/evm/src/runner/stack.rs | 26 +- frame/evm/src/tests.rs | 236 ++++++++++++++++-- 4 files changed, 251 insertions(+), 39 deletions(-) create mode 100644 frame/evm/src/res/StorageGrowthTest.sol create mode 100644 frame/evm/src/res/storage_growth_test_contract_bytecode.txt diff --git a/frame/evm/src/res/StorageGrowthTest.sol b/frame/evm/src/res/StorageGrowthTest.sol new file mode 100644 index 0000000000..7a66d33369 --- /dev/null +++ b/frame/evm/src/res/StorageGrowthTest.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity ^0.8.2; + +contract StorageGrowthTest { + mapping(uint256 => uint256) public map; + uint256 foo; + uint256 bar; + uint256 baz; + + constructor() { + foo = 1; + bar = 2; + baz = 3; + } + + function store() public { + map[0] = 1; + map[1] = 2; + map[2] = 3; + } + + function update() public { + foo = 2; + bar = 3; + baz = 4; + } +} diff --git a/frame/evm/src/res/storage_growth_test_contract_bytecode.txt b/frame/evm/src/res/storage_growth_test_contract_bytecode.txt new file mode 100644 index 0000000000..e0ba9113b0 --- /dev/null +++ b/frame/evm/src/res/storage_growth_test_contract_bytecode.txt @@ -0,0 +1 @@ +608060405234801561001057600080fd5b506001808190555060028081905550600380819055506101c7806100356000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063975057e714610046578063a2e6204514610050578063b8dda9c71461005a575b600080fd5b61004e61008a565b005b6100586100d6565b005b610074600480360381019061006f919061011d565b6100f0565b6040516100819190610155565b60405180910390f35b6001600080808152602001908152602001600020819055506002600080600181526020019081526020016000208190555060036000806002815260200190815260200160002081905550565b600260018190555060036002819055506004600381905550565b60006020528060005260406000206000915090505481565b6000813590506101178161017a565b92915050565b60006020828403121561012f57600080fd5b600061013d84828501610108565b91505092915050565b61014f81610170565b82525050565b600060208201905061016a6000830184610146565b92915050565b6000819050919050565b61018381610170565b811461018e57600080fd5b5056fea2646970667358221220b25685afab962e465f0b43f6c4de10c82a565f50f6995c1cd444b002bcdd43e964736f6c63430008020033 \ No newline at end of file diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 34d5e37c05..21e226ad8c 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -292,21 +292,21 @@ where None => 0, }; + let pov_gas = match executor.state().weight_info() { + Some(weight_info) => weight_info + .proof_size_usage + .unwrap_or_default() + .saturating_mul(T::GasLimitPovSizeRatio::get()), + None => 0, + }; + // Post execution. let used_gas = executor.used_gas(); - let effective_gas = match executor.state().weight_info() { - Some(weight_info) => U256::from(sp_std::cmp::max( - sp_std::cmp::max( - used_gas, - weight_info - .proof_size_usage - .unwrap_or_default() - .saturating_mul(T::GasLimitPovSizeRatio::get()), - ), - storage_gas, - )), - _ => used_gas.into(), - }; + let effective_gas = U256::from(sp_std::cmp::max( + sp_std::cmp::max(used_gas, pov_gas), + storage_gas, + )); + let actual_fee = effective_gas.saturating_mul(total_fee_per_gas); let actual_base_fee = effective_gas.saturating_mul(base_fee); diff --git a/frame/evm/src/tests.rs b/frame/evm/src/tests.rs index 567db8486c..48622bbaf4 100644 --- a/frame/evm/src/tests.rs +++ b/frame/evm/src/tests.rs @@ -627,17 +627,24 @@ mod proof_size_test { mod storage_growth_test { use super::*; - use std::env; + use crate::tests::proof_size_test::PROOF_SIZE_TEST_CALLEE_CONTRACT_BYTECODE; + use fp_evm::{ + ACCOUNT_CODES_KEY_SIZE, ACCOUNT_CODES_METADATA_PROOF_SIZE, ACCOUNT_STORAGE_PROOF_SIZE, + }; - pub const STORAGE_GROWTH_TEST_CONTRACT: &str = - include_str!("./res/proof_size_test_contract_bytecode.txt"); + const PROOF_SIZE_CALLEE_CONTRACT_BYTECODE_LEN: u64 = 116; + // The contract bytecode stored on chain. + const STORAGE_GROWTH_TEST_CONTRACT: &str = + include_str!("./res/storage_growth_test_contract_bytecode.txt"); + const STORAGE_GROWTH_TEST_CONTRACT_BYTECODE_LEN: u64 = 455; - fn create_erc20_test_contract( + fn create_test_contract( + contract: &str, gas_limit: u64, ) -> Result>> { ::Runner::create( H160::default(), - hex::decode(STORAGE_GROWTH_TEST_CONTRACT.trim_end()).unwrap(), + hex::decode(contract.trim_end()).expect("Failed to decode contract"), U256::zero(), gas_limit, Some(FixedGasPrice::min_gas_price().0), @@ -650,32 +657,209 @@ mod storage_growth_test { gas_limit, true, )), Some(0), - &::config().clone(), + &::config(), ) } - // This test is to ensure that the storage growth is accounted for correctly when deploying a - // a new contract. In this scenario, the contract is deployed with a gas limit that is not enough - // to cover the storage growth. + // Calls the given contract + fn call_test_contract( + contract_addr: H160, + call_data: &[u8], + value: U256, + gas_limit: u64, + ) -> Result>> { + ::Runner::call( + H160::default(), + contract_addr, + call_data.to_vec(), + value, + gas_limit, + Some(FixedGasPrice::min_gas_price().0), + None, + None, + Vec::new(), + true, // transactional + true, // must be validated + None, + Some(0), + &::config(), + ) + } + + // Computes the expected gas for contract creation (related to storage growth). + // `byte_code_len` represents the length of the contract bytecode stored on-chain. + fn expected_contract_create_storage_growth_gas(bytecode_len: u64) -> u64 { + let ratio = <::GasLimitStorageGrowthRatio as Get>::get(); + (ACCOUNT_CODES_KEY_SIZE + ACCOUNT_CODES_METADATA_PROOF_SIZE + bytecode_len) * ratio + } + + // Verifies that contract deployment fails when the necessary storage growth gas isn't + // provided, even if the gas limit surpasses the standard gas usage measured by the + // gasometer. + #[test] + fn contract_deployment_should_fail_oog() { + new_test_ext().execute_with(|| { + let gas_limit: u64 = 80_000; + + let result = create_test_contract(PROOF_SIZE_TEST_CALLEE_CONTRACT_BYTECODE, gas_limit) + .expect("create succeeds"); + + // Assert that the legacy gas is lower than the gas limit. + assert!(result.used_gas.standard < U256::from(gas_limit)); + assert_eq!( + result.exit_reason, + crate::ExitReason::Error(crate::ExitError::OutOfGas) + ); + assert_eq!( + result.used_gas.effective.as_u64(), + expected_contract_create_storage_growth_gas( + PROOF_SIZE_CALLEE_CONTRACT_BYTECODE_LEN + ) + ); + // Assert that the contract entry does not exists in the storage. + assert!(!AccountCodes::::contains_key(result.value)); + }); + } + + /// Test that contract deployment succeeds when the necessary storage growth gas is provided. + #[test] + fn contract_deployment_should_succeed() { + new_test_ext().execute_with(|| { + let gas_limit: u64 = 85_000; + + let result = create_test_contract(PROOF_SIZE_TEST_CALLEE_CONTRACT_BYTECODE, gas_limit) + .expect("create succeeds"); + + assert_eq!( + result.used_gas.effective.as_u64(), + expected_contract_create_storage_growth_gas( + PROOF_SIZE_CALLEE_CONTRACT_BYTECODE_LEN + ) + ); + assert_eq!( + result.exit_reason, + crate::ExitReason::Succeed(ExitSucceed::Returned) + ); + // Assert that the contract entry exists in the storage. + assert!(AccountCodes::::contains_key(result.value)); + }); + } + + // Test that contract creation with code initialization that results in new storage entries + // succeeds when the necessary storage growth gas is provided. + #[test] + fn contract_creation_with_code_initialization_should_succeed() { + new_test_ext().execute_with(|| { + let gas_limit: u64 = 863_394; + let ratio = <::GasLimitStorageGrowthRatio as Get>::get(); + // The constructor of the contract creates 3 new storage entries (uint256). So, + // the expected gas is the gas for contract creation + 3 * ACCOUNT_STORAGE_PROOF_SIZE. + let expected_storage_growth_gas = expected_contract_create_storage_growth_gas( + STORAGE_GROWTH_TEST_CONTRACT_BYTECODE_LEN, + ) + (3 * ACCOUNT_STORAGE_PROOF_SIZE * ratio); + + // Deploy the contract. + let result = create_test_contract(STORAGE_GROWTH_TEST_CONTRACT, gas_limit) + .expect("create succeeds"); + + assert_eq!( + result.used_gas.effective.as_u64(), + expected_storage_growth_gas + ); + assert_eq!( + result.exit_reason, + crate::ExitReason::Succeed(ExitSucceed::Returned) + ); + }); + } + + // Verify that saving new entries fails when insufficient storage growth gas is supplied. + #[test] + fn store_new_entries_should_fail_oog() { + new_test_ext().execute_with(|| { + let gas_limit: u64 = 863_394; + // Deploy the contract. + let res = create_test_contract(STORAGE_GROWTH_TEST_CONTRACT, gas_limit) + .expect("create succeeds"); + let contract_addr = res.value; + + let gas_limit = 120_000; + // Call the contract method store to store new entries. + let result = call_test_contract( + contract_addr, + &hex::decode("975057e7").unwrap(), + U256::zero(), + gas_limit, + ) + .expect("call should succeed"); + + assert_eq!( + result.exit_reason, + crate::ExitReason::Error(crate::ExitError::OutOfGas) + ); + }); + } + + // Verify that saving new entries succeeds when sufficient storage growth gas is supplied. #[test] - fn contract_deployement_should_fail_oog() { + fn store_new_entries_should_succeeds() { new_test_ext().execute_with(|| { - let gas_limit: u64 = 4_700_000; - - let result = create_erc20_test_contract(gas_limit).expect("create succeeds"); - // The contract is deployed with a gas limit that is not enough to cover the storage - // growth. The contract creation should fail. - // assert_eq!( - // result.exit_reason, - // crate::ExitReason::Error(crate::ExitError::OutOfGas) - // ); - - // // The contract is deployed with a gas limit that is enough to cover the storage - // // growth. The contract creation should succeed. - // let gas_limit: u64 = 1_500_000; - // let result = create_erc20_test_contract(gas_limit).expect("create succeeds"); - - // assert_eq!(result.exit_reason, crate::ExitReason::Succeed(ExitSucceed::Returned)); + let gas_limit: u64 = 863_394; + // Deploy the contract. + let res = create_test_contract(STORAGE_GROWTH_TEST_CONTRACT, gas_limit) + .expect("create succeeds"); + let contract_addr = res.value; + + let gas_limit = 128_000; + // Call the contract method store to store new entries. + let result = call_test_contract( + contract_addr, + &hex::decode("975057e7").unwrap(), + U256::zero(), + gas_limit, + ) + .expect("call should succeed"); + + let expected_storage_growth_gas = 3 + * ACCOUNT_STORAGE_PROOF_SIZE + * <::GasLimitStorageGrowthRatio as Get>::get(); + assert_eq!( + result.exit_reason, + crate::ExitReason::Succeed(ExitSucceed::Stopped) + ); + assert_eq!( + result.used_gas.effective.as_u64(), + expected_storage_growth_gas + ); + }); + } + + // Verify that updating existing storage entries does not incur any storage growth charges. + #[test] + fn update_exisiting_entries_succeeds() { + new_test_ext().execute_with(|| { + let gas_limit: u64 = 863_394; + // Deploy the contract. + let res = create_test_contract(STORAGE_GROWTH_TEST_CONTRACT, gas_limit) + .expect("create succeeds"); + let contract_addr = res.value; + + // Providing gas limit of 37_000 is enough to update existing entries, but not enough + // to store new entries. + let gas_limit = 37_000; + // Call the contract method update to update existing entries. + let result = call_test_contract( + contract_addr, + &hex::decode("a2e62045").unwrap(), + U256::zero(), + gas_limit, + ) + .expect("call should succeed"); + + assert_eq!( + result.exit_reason, + crate::ExitReason::Succeed(ExitSucceed::Stopped) + ); }); } } From 51f03bf9a192ad2f04e5218b16e04c275e5f5362 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Wed, 23 Aug 2023 19:19:50 +0200 Subject: [PATCH 37/46] fix typo --- primitives/evm/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/primitives/evm/src/lib.rs b/primitives/evm/src/lib.rs index 6468ece781..fb2da2884b 100644 --- a/primitives/evm/src/lib.rs +++ b/primitives/evm/src/lib.rs @@ -59,7 +59,7 @@ pub struct Vicinity { /// `System::Account` 16(hash) + 20 (key) + 60 (AccountInfo::max_encoded_len) pub const ACCOUNT_BASIC_PROOF_SIZE: u64 = 96; -/// `AccountCodesMetadata` read, temptatively 16 (hash) + 20 (key) + 40 (CodeMetadata). +/// `AccountCodesMetadata` read, temtatively 16 (hash) + 20 (key) + 40 (CodeMetadata). pub const ACCOUNT_CODES_METADATA_PROOF_SIZE: u64 = 76; /// 16 (hash1) + 20 (key1) + 16 (hash2) + 32 (key2) + 32 (value) pub const ACCOUNT_STORAGE_PROOF_SIZE: u64 = 116; From 222225915911166ff120de93ec44583fe11327ba Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 28 Aug 2023 02:10:14 +0200 Subject: [PATCH 38/46] fix recording storage growth of a special use case of SSTORE --- frame/evm/src/runner/meter.rs | 75 ++++++++++++++++++++++++++--------- frame/evm/src/runner/stack.rs | 4 +- 2 files changed, 59 insertions(+), 20 deletions(-) diff --git a/frame/evm/src/runner/meter.rs b/frame/evm/src/runner/meter.rs index fa047d471f..df229d2a73 100644 --- a/frame/evm/src/runner/meter.rs +++ b/frame/evm/src/runner/meter.rs @@ -1,13 +1,10 @@ -use evm::{gasometer::GasCost, Opcode}; +use evm::{ + gasometer::{GasCost, StorageTarget}, + Opcode, +}; use fp_evm::ACCOUNT_STORAGE_PROOF_SIZE; -use sp_core::H256; - -/// A meter for tracking the storage growth. -#[derive(Clone, Copy)] -pub struct StorageMeter { - usage: u64, - limit: u64, -} +use sp_core::{H160, H256}; +use sp_std::collections::btree_map::BTreeMap; /// An error that is returned when the storage limit has been exceeded. #[derive(Debug, PartialEq)] @@ -15,10 +12,22 @@ pub enum MeterError { LimitExceeded, } +/// A meter for tracking the storage growth. +#[derive(Clone)] +pub struct StorageMeter { + usage: u64, + limit: u64, + recorded_new_entries: BTreeMap<(H160, H256), ()>, +} + impl StorageMeter { /// Creates a new storage meter with the given limit. pub fn new(limit: u64) -> Self { - Self { usage: 0, limit } + Self { + usage: 0, + limit, + recorded_new_entries: BTreeMap::new(), + } } /// Records the given amount of storage usage. The amount is added to the current usage. @@ -40,15 +49,29 @@ impl StorageMeter { &mut self, _opcode: Opcode, gas_cost: GasCost, + target: StorageTarget, ) -> Result<(), MeterError> { match gas_cost { - GasCost::SStore { original, new, .. } - if original == H256::default() && !new.is_zero() => - { - self.record(ACCOUNT_STORAGE_PROOF_SIZE) + GasCost::SStore { original, new, .. } => { + // Validate if storage growth for the current slot has been accounted for within this transaction. + // Comparing Original and new to determine if a new entry is being created is not sufficient, because + // 'original' updates only at the end of the transaction. So, if a new entry + // is created and updated multiple times within the same transaction, the storage growth is + // accounted for multiple times, because 'original' is always zero for the subsequent updates. + // To avoid this, we keep track of the new entries that are created within the transaction. + let (address, index) = match target { + StorageTarget::Slot(address, index) => (address, index), + _ => return Ok(()), + }; + let recorded = self.recorded_new_entries.contains_key(&(address, index)); + if !recorded && original == H256::default() && !new.is_zero() { + self.record(ACCOUNT_STORAGE_PROOF_SIZE)?; + self.recorded_new_entries.insert((address, index), ()); + } } - _ => Ok(()), + _ => {} } + Ok(()) } /// Returns the current usage of storage. @@ -123,8 +146,10 @@ mod test { new: H256::from_low_u64_be(2), target_is_cold: false, }; + let target = StorageTarget::Slot(H160::default(), H256::from_low_u64_be(1)); + meter - .record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost) + .record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost, target) .unwrap(); assert_eq!(meter.usage(), 0); @@ -136,7 +161,19 @@ mod test { target_is_cold: false, }; meter - .record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost) + .record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost, target) + .unwrap(); + assert_eq!(meter.usage(), ACCOUNT_STORAGE_PROOF_SIZE); + + // Try to record the same storage growth again. No change in storage growth. + let gas_cost = GasCost::SStore { + original: H256::default(), + current: Default::default(), + new: H256::from_low_u64_be(1), + target_is_cold: false, + }; + meter + .record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost, target) .unwrap(); assert_eq!(meter.usage(), ACCOUNT_STORAGE_PROOF_SIZE); @@ -147,7 +184,9 @@ mod test { new: H256::from_low_u64_be(2), target_is_cold: false, }; - let res = meter.record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost); + let target = StorageTarget::Slot(H160::default(), H256::from_low_u64_be(2)); + + let res = meter.record_dynamic_opcode_cost(Opcode::SSTORE, gas_cost, target); assert!(res.is_err()); assert_eq!(res, Err(MeterError::LimitExceeded)); assert_eq!(meter.usage(), 232); diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 21e226ad8c..dcd3a5f88e 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -287,7 +287,7 @@ where let (reason, retv) = f(&mut executor); // Compute the storage gas cost based on the storage growth. - let storage_gas = match executor.state().storage_meter { + let storage_gas = match &executor.state().storage_meter { Some(storage_meter) => storage_meter.storage_to_gas(storage_growth_ratio), None => 0, }; @@ -1076,7 +1076,7 @@ where ) -> Result<(), ExitError> { if let Some(storage_meter) = self.storage_meter.as_mut() { storage_meter - .record_dynamic_opcode_cost(opcode, gas_cost) + .record_dynamic_opcode_cost(opcode, gas_cost, target) .map_err(|_| ExitError::OutOfGas)?; } From 01899fca5ddb3ecc989715398ff8ec663e7f7f3f Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 28 Aug 2023 02:12:44 +0200 Subject: [PATCH 39/46] use saturating add --- frame/evm/src/runner/stack.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index dcd3a5f88e..e1ca293d29 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -1056,8 +1056,8 @@ where if let Some(storage_meter) = self.storage_meter.as_mut() { // Record the number of bytes written to storage when deploying a contract. let storage_growth = ACCOUNT_CODES_KEY_SIZE - + ACCOUNT_CODES_METADATA_PROOF_SIZE - + len.as_u64(); + .saturating_add(ACCOUNT_CODES_METADATA_PROOF_SIZE) + .saturating_add(len.as_u64()); storage_meter .record(storage_growth) .map_err(|_| ExitError::OutOfGas)?; From c9290186c9d39ff09f54d1076eda7cda807bd233 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 28 Aug 2023 03:22:22 +0200 Subject: [PATCH 40/46] minor improvements --- frame/ethereum/src/mock.rs | 7 +++---- frame/evm/src/mock.rs | 7 +++---- template/runtime/src/lib.rs | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index b3dbd96ebc..42ecd33b5d 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -131,16 +131,15 @@ impl FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 150_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; -/// The maximum storage growth per block in bytes (80 Kb). -const MAX_STORAGE_GROWTH: u64 = 80 * 1024; -const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); +/// The maximum storage growth per block in bytes. +const MAX_STORAGE_GROWTH: u64 = 800 * 1024; parameter_types! { pub const TransactionByteFee: u64 = 1; pub const ChainId: u64 = 42; pub const EVMModuleId: PalletId = PalletId(*b"py/evmpa"); pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub const GasLimitStorageGrowthRatio: u64 = GAS_LIMIT_STORAGE_GROWTH_RATIO; + pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); pub const WeightPerGas: Weight = Weight::from_parts(20_000, 0); } diff --git a/frame/evm/src/mock.rs b/frame/evm/src/mock.rs index 894d25bfac..ef31429699 100644 --- a/frame/evm/src/mock.rs +++ b/frame/evm/src/mock.rs @@ -122,14 +122,13 @@ impl FindAuthor for FindAuthorTruncated { } const BLOCK_GAS_LIMIT: u64 = 150_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; -/// The maximum storage growth per block in bytes (40 Kb). -const MAX_STORAGE_GROWTH: u64 = 40 * 1024; -const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); +/// The maximum storage growth per block in bytes. +const MAX_STORAGE_GROWTH: u64 = 400 * 1024; parameter_types! { pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub const GasLimitStorageGrowthRatio: u64 = GAS_LIMIT_STORAGE_GROWTH_RATIO; + pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); pub WeightPerGas: Weight = Weight::from_parts(20_000, 0); pub MockPrecompiles: MockPrecompileSet = MockPrecompileSet; } diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index d7d37f9511..df88dc285d 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -317,14 +317,13 @@ impl> FindAuthor for FindAuthorTruncated { const BLOCK_GAS_LIMIT: u64 = 75_000_000; const MAX_POV_SIZE: u64 = 5 * 1024 * 1024; -/// The maximum storage growth per block in bytes (3 Mb). -const MAX_STORAGE_GROWTH: u64 = 3 * 1024 * 1024; -const GAS_LIMIT_STORAGE_GROWTH_RATIO: u64 = 15_000_000u64.saturating_div(MAX_STORAGE_GROWTH); +/// The maximum storage growth per block in bytes. +const MAX_STORAGE_GROWTH: u64 = 400 * 1024; parameter_types! { pub BlockGasLimit: U256 = U256::from(BLOCK_GAS_LIMIT); pub const GasLimitPovSizeRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_POV_SIZE); - pub const GasLimitStorageGrowthRatio: u64 = GAS_LIMIT_STORAGE_GROWTH_RATIO; + pub const GasLimitStorageGrowthRatio: u64 = BLOCK_GAS_LIMIT.saturating_div(MAX_STORAGE_GROWTH); pub PrecompilesValue: FrontierPrecompiles = FrontierPrecompiles::<_>::new(); pub WeightPerGas: Weight = Weight::from_parts(weight_per_gas(BLOCK_GAS_LIMIT, NORMAL_DISPATCH_RATIO, WEIGHT_MILLISECS_PER_BLOCK), 0); } From 9e47f699878ab2333fb8a7c10db84e0fb20f5daf Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 28 Aug 2023 03:22:46 +0200 Subject: [PATCH 41/46] add license to meter.rs --- frame/evm/src/runner/meter.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frame/evm/src/runner/meter.rs b/frame/evm/src/runner/meter.rs index df229d2a73..5a6a880995 100644 --- a/frame/evm/src/runner/meter.rs +++ b/frame/evm/src/runner/meter.rs @@ -1,3 +1,21 @@ +// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 +// This file is part of Frontier. +// +// Copyright (c) 2021-2022 Parity Technologies (UK) Ltd. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + use evm::{ gasometer::{GasCost, StorageTarget}, Opcode, From 8924c076a77bc2d38a18568e5467e8d4cb7bc1b8 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 28 Aug 2023 09:31:46 +0200 Subject: [PATCH 42/46] fix clippy warnings --- frame/evm/src/runner/meter.rs | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/frame/evm/src/runner/meter.rs b/frame/evm/src/runner/meter.rs index 5a6a880995..927a3f2879 100644 --- a/frame/evm/src/runner/meter.rs +++ b/frame/evm/src/runner/meter.rs @@ -69,25 +69,22 @@ impl StorageMeter { gas_cost: GasCost, target: StorageTarget, ) -> Result<(), MeterError> { - match gas_cost { - GasCost::SStore { original, new, .. } => { - // Validate if storage growth for the current slot has been accounted for within this transaction. - // Comparing Original and new to determine if a new entry is being created is not sufficient, because - // 'original' updates only at the end of the transaction. So, if a new entry - // is created and updated multiple times within the same transaction, the storage growth is - // accounted for multiple times, because 'original' is always zero for the subsequent updates. - // To avoid this, we keep track of the new entries that are created within the transaction. - let (address, index) = match target { - StorageTarget::Slot(address, index) => (address, index), - _ => return Ok(()), - }; - let recorded = self.recorded_new_entries.contains_key(&(address, index)); - if !recorded && original == H256::default() && !new.is_zero() { - self.record(ACCOUNT_STORAGE_PROOF_SIZE)?; - self.recorded_new_entries.insert((address, index), ()); - } + if let GasCost::SStore { original, new, .. } = gas_cost { + // Validate if storage growth for the current slot has been accounted for within this transaction. + // Comparing Original and new to determine if a new entry is being created is not sufficient, because + // 'original' updates only at the end of the transaction. So, if a new entry + // is created and updated multiple times within the same transaction, the storage growth is + // accounted for multiple times, because 'original' is always zero for the subsequent updates. + // To avoid this, we keep track of the new entries that are created within the transaction. + let (address, index) = match target { + StorageTarget::Slot(address, index) => (address, index), + _ => return Ok(()), + }; + let recorded = self.recorded_new_entries.contains_key(&(address, index)); + if !recorded && original == H256::default() && !new.is_zero() { + self.record(ACCOUNT_STORAGE_PROOF_SIZE)?; + self.recorded_new_entries.insert((address, index), ()); } - _ => {} } Ok(()) } From 18d907104d3fced8773cfbeb60208e0e90e19598 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Mon, 28 Aug 2023 16:59:07 +0200 Subject: [PATCH 43/46] pin evm to master --- Cargo.lock | 8 ++++---- Cargo.toml | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eca1482155..256d586930 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2153,7 +2153,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "evm" version = "0.39.1" -source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#6bd1f61d38e33aab44b6b52cb14deaf9668755b5" +source = "git+https://github.com/rust-blockchain/evm?rev=44bb77c27be9ee615eaa576ad914fbb461537276#44bb77c27be9ee615eaa576ad914fbb461537276" dependencies = [ "auto_impl", "environmental", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#6bd1f61d38e33aab44b6b52cb14deaf9668755b5" +source = "git+https://github.com/rust-blockchain/evm?rev=44bb77c27be9ee615eaa576ad914fbb461537276#44bb77c27be9ee615eaa576ad914fbb461537276" dependencies = [ "parity-scale-codec", "primitive-types", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#6bd1f61d38e33aab44b6b52cb14deaf9668755b5" +source = "git+https://github.com/rust-blockchain/evm?rev=44bb77c27be9ee615eaa576ad914fbb461537276#44bb77c27be9ee615eaa576ad914fbb461537276" dependencies = [ "environmental", "evm-core", @@ -2195,7 +2195,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.39.0" -source = "git+https://github.com/moonbeam-foundation/evm.git?branch=ahmad-update-external-operation#6bd1f61d38e33aab44b6b52cb14deaf9668755b5" +source = "git+https://github.com/rust-blockchain/evm?rev=44bb77c27be9ee615eaa576ad914fbb461537276#44bb77c27be9ee615eaa576ad914fbb461537276" dependencies = [ "auto_impl", "environmental", diff --git a/Cargo.toml b/Cargo.toml index 7f24ac9d5d..1ba3575cfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,8 +45,7 @@ clap = { version = "4.3", features = ["derive", "deprecated"] } environmental = { version = "1.1.4", default-features = false } ethereum = { version = "0.14.0", default-features = false } ethereum-types = { version = "0.14.1", default-features = false } -# evm = { git = "https://github.com/rust-blockchain/evm", rev = "b7b82c7e1fc57b7449d6dfa6826600de37cc1e65", default-features = false } -evm = { git = "https://github.com/moonbeam-foundation/evm.git", branch = "ahmad-update-external-operation", default-features = false } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "44bb77c27be9ee615eaa576ad914fbb461537276", default-features = false } futures = "0.3.28" hex = { version = "0.4.3", default-features = false, features = ["alloc"] } hex-literal = "0.4.1" From 4564774987f213cefc402d8e485b53e9aba64be4 Mon Sep 17 00:00:00 2001 From: Ahmad Kaouk Date: Tue, 29 Aug 2023 10:14:40 +0200 Subject: [PATCH 44/46] update evm to the latest commit --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 256d586930..9aba149b44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2153,7 +2153,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "evm" version = "0.39.1" -source = "git+https://github.com/rust-blockchain/evm?rev=44bb77c27be9ee615eaa576ad914fbb461537276#44bb77c27be9ee615eaa576ad914fbb461537276" +source = "git+https://github.com/rust-blockchain/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" dependencies = [ "auto_impl", "environmental", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=44bb77c27be9ee615eaa576ad914fbb461537276#44bb77c27be9ee615eaa576ad914fbb461537276" +source = "git+https://github.com/rust-blockchain/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" dependencies = [ "parity-scale-codec", "primitive-types", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=44bb77c27be9ee615eaa576ad914fbb461537276#44bb77c27be9ee615eaa576ad914fbb461537276" +source = "git+https://github.com/rust-blockchain/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" dependencies = [ "environmental", "evm-core", @@ -2195,7 +2195,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=44bb77c27be9ee615eaa576ad914fbb461537276#44bb77c27be9ee615eaa576ad914fbb461537276" +source = "git+https://github.com/rust-blockchain/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" dependencies = [ "auto_impl", "environmental", diff --git a/Cargo.toml b/Cargo.toml index 1ba3575cfd..14aaa4928d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ clap = { version = "4.3", features = ["derive", "deprecated"] } environmental = { version = "1.1.4", default-features = false } ethereum = { version = "0.14.0", default-features = false } ethereum-types = { version = "0.14.1", default-features = false } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "44bb77c27be9ee615eaa576ad914fbb461537276", default-features = false } +evm = { git = "https://github.com/rust-blockchain/evm", rev = "a33ac87ad7462b7e7029d12c385492b2a8311d1c", default-features = false } futures = "0.3.28" hex = { version = "0.4.3", default-features = false, features = ["alloc"] } hex-literal = "0.4.1" From cc8c93d3af7bf37c430dfad48540fa5a724cfc2d Mon Sep 17 00:00:00 2001 From: Andrea Giacobino Date: Tue, 29 Aug 2023 11:27:37 +0200 Subject: [PATCH 45/46] use the moonbeam-foundation org for the evm dependency this change applies only to this branch (moonbeam-polkadot-v0.9.43), and it is done to avoid dependencies conflict in the moonbeam repository that also uses moonbeam-foundation org for the evm dependency. --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9aba149b44..1056c7a116 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2153,7 +2153,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "evm" version = "0.39.1" -source = "git+https://github.com/rust-blockchain/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" +source = "git+https://github.com/moonbeam-foundation/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" dependencies = [ "auto_impl", "environmental", @@ -2173,7 +2173,7 @@ dependencies = [ [[package]] name = "evm-core" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" +source = "git+https://github.com/moonbeam-foundation/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" dependencies = [ "parity-scale-codec", "primitive-types", @@ -2184,7 +2184,7 @@ dependencies = [ [[package]] name = "evm-gasometer" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" +source = "git+https://github.com/moonbeam-foundation/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" dependencies = [ "environmental", "evm-core", @@ -2195,7 +2195,7 @@ dependencies = [ [[package]] name = "evm-runtime" version = "0.39.0" -source = "git+https://github.com/rust-blockchain/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" +source = "git+https://github.com/moonbeam-foundation/evm?rev=a33ac87ad7462b7e7029d12c385492b2a8311d1c#a33ac87ad7462b7e7029d12c385492b2a8311d1c" dependencies = [ "auto_impl", "environmental", diff --git a/Cargo.toml b/Cargo.toml index 14aaa4928d..f4bc98696e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ clap = { version = "4.3", features = ["derive", "deprecated"] } environmental = { version = "1.1.4", default-features = false } ethereum = { version = "0.14.0", default-features = false } ethereum-types = { version = "0.14.1", default-features = false } -evm = { git = "https://github.com/rust-blockchain/evm", rev = "a33ac87ad7462b7e7029d12c385492b2a8311d1c", default-features = false } +evm = { git = "https://github.com/moonbeam-foundation/evm", rev = "a33ac87ad7462b7e7029d12c385492b2a8311d1c", default-features = false } futures = "0.3.28" hex = { version = "0.4.3", default-features = false, features = ["alloc"] } hex-literal = "0.4.1" From c35e19cd8e36aec2c92a1d9898ade20ed00d23cd Mon Sep 17 00:00:00 2001 From: Cem Eliguzel Date: Thu, 14 Sep 2023 14:00:05 +0000 Subject: [PATCH 46/46] Upgrade dependencies to polkadot-v1.1.0 --- Cargo.lock | 564 +++++++++++++++++------ Cargo.toml | 133 +++--- client/consensus/src/lib.rs | 7 +- client/rpc/src/eth/execute.rs | 8 +- client/rpc/src/lib.rs | 6 +- frame/ethereum/src/lib.rs | 4 +- frame/ethereum/src/mock.rs | 1 - frame/evm/precompile/dispatch/Cargo.toml | 2 + frame/evm/precompile/dispatch/src/lib.rs | 5 +- frame/evm/src/benchmarking.rs | 2 +- frame/evm/src/lib.rs | 3 +- primitives/rpc/src/lib.rs | 6 +- template/node/Cargo.toml | 2 - template/node/src/client.rs | 7 - template/node/src/eth.rs | 8 +- template/node/src/service.rs | 51 +- template/runtime/Cargo.toml | 1 + template/runtime/src/lib.rs | 7 +- 18 files changed, 538 insertions(+), 279 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1056c7a116..a079a9aa37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -272,6 +272,20 @@ dependencies = [ "num-traits", ] +[[package]] +name = "aquamarine" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df752953c49ce90719c7bf1fc587bc8227aed04732ea0c0f85e5397d7fdbd1a1" +dependencies = [ + "include_dir", + "itertools 0.10.5", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "arc-swap" version = "1.6.0" @@ -289,6 +303,18 @@ dependencies = [ "ark-std", ] +[[package]] +name = "ark-bls12-381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", +] + [[package]] name = "ark-bw6-761" version = "0.4.0" @@ -318,6 +344,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ark-ed-on-bls12-381-bandersnatch" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9cde0f2aa063a2a5c28d39b47761aa102bda7c13c84fc118a61b87c7b2f785c" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-std", +] + [[package]] name = "ark-ff" version = "0.4.2" @@ -374,6 +412,34 @@ dependencies = [ "hashbrown 0.13.2", ] +[[package]] +name = "ark-scale" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49b08346a3e38e2be792ef53ee168623c9244d968ff00cd70fb9932f6fe36393" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "parity-scale-codec", +] + +[[package]] +name = "ark-secret-scalar" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "ark-transcript", + "digest 0.10.7", + "rand_core 0.6.4", + "zeroize", +] + [[package]] name = "ark-serialize" version = "0.4.2" @@ -407,6 +473,19 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "ark-transcript" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "digest 0.10.7", + "rand_core 0.6.4", + "sha3", +] + [[package]] name = "array-bytes" version = "6.1.0" @@ -627,6 +706,28 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "bandersnatch_vrfs" +version = "0.0.1" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ed-on-bls12-381-bandersnatch", + "ark-ff", + "ark-scale", + "ark-serialize", + "ark-std", + "dleq_vrf", + "fflonk", + "merlin 3.0.0", + "rand_chacha 0.3.1", + "rand_core 0.6.4", + "ring 0.1.0", + "sha2 0.10.7", + "zeroize", +] + [[package]] name = "base-x" version = "0.2.11" @@ -843,6 +944,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] + [[package]] name = "bstr" version = "1.6.2" @@ -1150,6 +1260,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "common" +version = "0.1.0" +source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "fflonk", + "merlin 3.0.0", +] + +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + [[package]] name = "concurrent-queue" version = "2.2.0" @@ -1856,6 +1986,50 @@ dependencies = [ "syn 2.0.33", ] +[[package]] +name = "dleq_vrf" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=3119f51#3119f51b54b69308abfb0671f6176cb125ae1bf1" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-scale", + "ark-secret-scalar", + "ark-serialize", + "ark-std", + "ark-transcript", + "arrayvec 0.7.4", + "rand_core 0.6.4", + "zeroize", +] + +[[package]] +name = "docify" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c69c651fd3125396ad00fca5abd4b2681708bfe486a91b81fdbeed583888756" +dependencies = [ + "docify_macros", +] + +[[package]] +name = "docify_macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c5fd210c8f0446a9d4768cdd125a0de528f159dd71d301891f7e2b8fe40b0d" +dependencies = [ + "common-path", + "derive-syn-parse", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.33", + "termcolor", + "toml 0.7.8", + "walkdir", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -2477,6 +2651,19 @@ dependencies = [ "subtle", ] +[[package]] +name = "fflonk" +version = "0.1.0" +source = "git+https://github.com/w3f/fflonk#26a5045b24e169cffc1f9328ca83d71061145c40" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "merlin 3.0.0", +] + [[package]] name = "fiat-crypto" version = "0.2.1" @@ -2595,7 +2782,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", ] @@ -2718,7 +2905,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-support", "frame-support-procedural", @@ -2743,7 +2930,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "Inflector", "array-bytes", @@ -2791,11 +2978,12 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-support", "frame-system", "frame-try-runtime", + "log", "parity-scale-codec", "scale-info", "sp-core", @@ -2820,9 +3008,11 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ + "aquamarine", "bitflags 1.3.2", + "docify", "environmental", "frame-metadata", "frame-support-procedural", @@ -2834,27 +3024,31 @@ dependencies = [ "paste", "scale-info", "serde", + "serde_json", "smallvec", "sp-api", "sp-arithmetic", "sp-core", "sp-core-hashing-proc-macro", "sp-debug-derive", + "sp-genesis-builder", "sp-inherents", "sp-io", + "sp-metadata-ir", "sp-runtime", "sp-staking", "sp-state-machine", "sp-std", "sp-tracing", "sp-weights", + "static_assertions", "tt-call", ] [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "Inflector", "cfg-expr", @@ -2872,7 +3066,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2884,7 +3078,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "proc-macro2", "quote", @@ -2894,7 +3088,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "cfg-if", "frame-support", @@ -2913,7 +3107,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-benchmarking", "frame-support", @@ -2928,7 +3122,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "sp-api", @@ -2937,7 +3131,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-support", "parity-scale-codec", @@ -2986,7 +3180,6 @@ dependencies = [ "sc-consensus-manual-seal", "sc-executor", "sc-network", - "sc-network-common", "sc-network-sync", "sc-offchain", "sc-rpc", @@ -3009,7 +3202,6 @@ dependencies = [ "sp-state-machine", "sp-timestamp", "sp-transaction-pool", - "sp-trie", "substrate-build-script-utils", "substrate-frame-rpc-system", "substrate-prometheus-endpoint", @@ -3056,6 +3248,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-std", + "sp-storage", "sp-transaction-pool", "sp-version", "substrate-wasm-builder", @@ -3754,6 +3947,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "include_dir" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18762faeff7122e89e0857b02f7ce6fcc0d101d5e9ad2ad7846cc01d61b7f19e" +dependencies = [ + "include_dir_macros", +] + +[[package]] +name = "include_dir_macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b139284b5cf57ecfa712bcc66950bb635b31aff41c188e8a4cfc758eca374a3f" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -4211,7 +4423,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ - "bs58", + "bs58 0.4.0", "ed25519-dalek 2.0.0", "log", "multiaddr", @@ -4423,7 +4635,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "rcgen 0.10.0", - "ring", + "ring 0.16.20", "rustls 0.20.9", "thiserror", "webpki 0.22.1", @@ -4873,6 +5085,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "merlin" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.6.4", + "zeroize", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -5404,10 +5628,11 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-support", "frame-system", + "log", "pallet-timestamp", "parity-scale-codec", "scale-info", @@ -5420,7 +5645,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-support", "frame-system", @@ -5434,7 +5659,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5458,7 +5683,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5690,7 +5915,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5729,7 +5954,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-support", "frame-system", @@ -5743,6 +5968,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", + "sp-state-machine", "sp-std", "sp-trie", ] @@ -5750,7 +5976,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5765,7 +5991,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-benchmarking", "frame-support", @@ -5777,13 +6003,14 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "sp-storage", "sp-timestamp", ] [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-support", "frame-system", @@ -5799,7 +6026,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -5815,7 +6042,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -5827,7 +6054,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-benchmarking", "frame-support", @@ -6466,7 +6693,7 @@ checksum = "f31999cfc7927c4e212e60fd50934ab40e8e8bfd2d493d6095d2d306bc0764d9" dependencies = [ "bytes", "rand 0.8.5", - "ring", + "ring 0.16.20", "rustc-hash", "rustls 0.20.9", "slab", @@ -6606,7 +6833,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", - "ring", + "ring 0.16.20", "time", "x509-parser 0.13.2", "yasna", @@ -6619,7 +6846,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", - "ring", + "ring 0.16.20", "time", "yasna", ] @@ -6760,6 +6987,21 @@ dependencies = [ "subtle", ] +[[package]] +name = "ring" +version = "0.1.0" +source = "git+https://github.com/w3f/ring-proof?rev=0e948f3#0e948f3c28cbacecdd3020403c4841c0eb339213" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "common", + "fflonk", + "merlin 3.0.0", +] + [[package]] name = "ring" version = "0.16.20" @@ -6962,7 +7204,7 @@ checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" dependencies = [ "base64 0.13.1", "log", - "ring", + "ring 0.16.20", "sct 0.6.1", "webpki 0.21.4", ] @@ -6974,7 +7216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", - "ring", + "ring 0.16.20", "sct 0.7.0", "webpki 0.22.1", ] @@ -6986,7 +7228,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", - "ring", + "ring 0.16.20", "rustls-webpki", "sct 0.7.0", ] @@ -7018,7 +7260,7 @@ version = "0.101.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" dependencies = [ - "ring", + "ring 0.16.20", "untrusted", ] @@ -7066,7 +7308,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "log", "sp-core", @@ -7077,7 +7319,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "futures", "futures-timer", @@ -7100,7 +7342,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -7115,7 +7357,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -7134,7 +7376,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7145,7 +7387,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "chrono", @@ -7184,7 +7426,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "fnv", "futures", @@ -7210,7 +7452,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "hash-db 0.16.0", "kvdb", @@ -7236,7 +7478,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "futures", @@ -7261,7 +7503,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "futures", @@ -7290,7 +7532,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "fork-tree", @@ -7326,7 +7568,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "fork-tree", "parity-scale-codec", @@ -7339,7 +7581,7 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "ahash 0.8.3", "array-bytes", @@ -7380,7 +7622,7 @@ dependencies = [ [[package]] name = "sc-consensus-manual-seal" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "assert_matches", "async-trait", @@ -7415,7 +7657,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "futures", @@ -7438,7 +7680,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", @@ -7460,7 +7702,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -7472,7 +7714,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "anyhow", "cfg-if", @@ -7489,7 +7731,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "ansi_term", "futures", @@ -7505,7 +7747,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "parking_lot 0.12.1", @@ -7519,7 +7761,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "async-channel", @@ -7560,7 +7802,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-channel", "cid", @@ -7580,7 +7822,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "bitflags 1.3.2", @@ -7597,7 +7839,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "ahash 0.8.3", "futures", @@ -7615,7 +7857,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "async-channel", @@ -7636,7 +7878,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "async-channel", @@ -7670,7 +7912,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "futures", @@ -7688,7 +7930,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "bytes", @@ -7722,7 +7964,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -7731,7 +7973,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "futures", "jsonrpsee", @@ -7762,7 +8004,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -7781,7 +8023,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "http", "jsonrpsee", @@ -7796,7 +8038,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "futures", @@ -7809,6 +8051,7 @@ dependencies = [ "sc-chain-spec", "sc-client-api", "sc-transaction-pool-api", + "sc-utils", "serde", "sp-api", "sp-blockchain", @@ -7816,13 +8059,14 @@ dependencies = [ "sp-runtime", "sp-version", "thiserror", + "tokio", "tokio-stream", ] [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "directories", @@ -7886,7 +8130,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "log", "parity-scale-codec", @@ -7897,7 +8141,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "futures", "libc", @@ -7916,7 +8160,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "chrono", "futures", @@ -7935,7 +8179,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "ansi_term", "atty", @@ -7964,7 +8208,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7975,7 +8219,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "futures", @@ -8001,7 +8245,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "futures", @@ -8017,7 +8261,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-channel", "futures", @@ -8085,7 +8329,7 @@ dependencies = [ "arrayvec 0.5.2", "curve25519-dalek 2.1.3", "getrandom 0.1.16", - "merlin", + "merlin 2.0.1", "rand 0.7.3", "rand_core 0.5.1", "sha2 0.8.2", @@ -8111,7 +8355,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" dependencies = [ - "ring", + "ring 0.16.20", "untrusted", ] @@ -8121,7 +8365,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", + "ring 0.16.20", "untrusted", ] @@ -8450,7 +8694,7 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek 4.1.0", "rand_core 0.6.4", - "ring", + "ring 0.16.20", "rustc_version", "sha2 0.10.7", "subtle", @@ -8496,7 +8740,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "hash-db 0.16.0", "log", @@ -8517,7 +8761,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "Inflector", "blake2", @@ -8531,7 +8775,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "scale-info", @@ -8544,7 +8788,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "integer-sqrt", "num-traits", @@ -8558,7 +8802,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "sp-api", "sp-inherents", @@ -8569,7 +8813,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "futures", "log", @@ -8587,7 +8831,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "futures", @@ -8602,7 +8846,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "parity-scale-codec", @@ -8619,7 +8863,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "parity-scale-codec", @@ -8638,7 +8882,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "finality-grandpa", "log", @@ -8656,7 +8900,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "scale-info", @@ -8668,13 +8912,15 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", + "arrayvec 0.7.4", + "bandersnatch_vrfs", "bitflags 1.3.2", "blake2", "bounded-collections", - "bs58", + "bs58 0.5.0", "dyn-clonable", "ed25519-zebra", "futures", @@ -8684,7 +8930,7 @@ dependencies = [ "lazy_static", "libsecp256k1", "log", - "merlin", + "merlin 2.0.1", "parity-scale-codec", "parking_lot 0.12.1", "paste", @@ -8713,7 +8959,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "blake2b_simd", "byteorder", @@ -8726,7 +8972,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "quote", "sp-core-hashing", @@ -8736,7 +8982,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -8745,7 +8991,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "proc-macro2", "quote", @@ -8755,7 +9001,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "environmental", "parity-scale-codec", @@ -8763,10 +9009,21 @@ dependencies = [ "sp-storage", ] +[[package]] +name = "sp-genesis-builder" +version = "0.1.0" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" +dependencies = [ + "serde_json", + "sp-api", + "sp-runtime", + "sp-std", +] + [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -8780,11 +9037,10 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "bytes", - "ed25519 1.5.3", - "ed25519-dalek 1.0.1", + "ed25519-dalek 2.0.0", "libsecp256k1", "log", "parity-scale-codec", @@ -8805,7 +9061,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "24.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "lazy_static", "sp-core", @@ -8816,7 +9072,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", @@ -8828,7 +9084,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "thiserror", "zstd 0.12.4", @@ -8837,7 +9093,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -8848,7 +9104,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "sp-api", "sp-core", @@ -8858,7 +9114,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "backtrace", "lazy_static", @@ -8868,7 +9124,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "rustc-hash", "serde", @@ -8878,7 +9134,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "either", "hash256-std-hasher", @@ -8900,7 +9156,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -8918,7 +9174,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "Inflector", "proc-macro-crate", @@ -8930,7 +9186,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "scale-info", @@ -8945,7 +9201,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -8959,7 +9215,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "hash-db 0.16.0", "log", @@ -8980,10 +9236,16 @@ dependencies = [ [[package]] name = "sp-statement-store" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ + "aes-gcm 0.10.2", + "curve25519-dalek 4.1.0", + "ed25519-dalek 2.0.0", + "hkdf", "parity-scale-codec", + "rand 0.8.5", "scale-info", + "sha2 0.10.7", "sp-api", "sp-application-crypto", "sp-core", @@ -8992,17 +9254,18 @@ dependencies = [ "sp-runtime-interface", "sp-std", "thiserror", + "x25519-dalek 2.0.0", ] [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9015,7 +9278,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "parity-scale-codec", @@ -9028,7 +9291,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "sp-std", @@ -9040,7 +9303,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "sp-api", "sp-runtime", @@ -9049,7 +9312,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "async-trait", "parity-scale-codec", @@ -9064,7 +9327,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "ahash 0.8.3", "hash-db 0.16.0", @@ -9087,7 +9350,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "impl-serde", "parity-scale-codec", @@ -9104,7 +9367,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -9115,7 +9378,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -9128,7 +9391,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "parity-scale-codec", "scale-info", @@ -9390,7 +9653,7 @@ dependencies = [ "lazy_static", "md-5", "rand 0.8.5", - "ring", + "ring 0.16.20", "subtle", "thiserror", "tokio", @@ -9427,12 +9690,12 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -9451,7 +9714,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "hyper", "log", @@ -9463,7 +9726,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "async-trait", @@ -9489,7 +9752,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "array-bytes", "frame-executive", @@ -9503,6 +9766,8 @@ dependencies = [ "parity-scale-codec", "sc-service", "scale-info", + "serde", + "serde_json", "sp-api", "sp-application-crypto", "sp-block-builder", @@ -9511,6 +9776,7 @@ dependencies = [ "sp-consensus-grandpa", "sp-core", "sp-externalities", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-keyring", @@ -9529,7 +9795,7 @@ dependencies = [ [[package]] name = "substrate-test-runtime-client" version = "2.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "futures", "sc-block-builder", @@ -9547,7 +9813,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +source = "git+https://github.com/moonbeam-foundation/polkadot-sdk?branch=cem-upgrade-to-polkadot-1.1.0#893898cb26c2d279877288f6cf67799905c7cca0" dependencies = [ "ansi_term", "build-helper", @@ -10149,7 +10415,7 @@ dependencies = [ "log", "md-5", "rand 0.8.5", - "ring", + "ring 0.16.20", "stun", "thiserror", "tokio", @@ -10448,9 +10714,9 @@ dependencies = [ [[package]] name = "wasm-opt" -version = "0.112.0" +version = "0.114.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87fef6d0d508f08334e0ab0e6877feb4c0ecb3956bcf2cb950699b22fedf3e9c" +checksum = "4d005a95f934878a1fb446a816d51c3601a0120ff929005ba3bab3c749cfd1c7" dependencies = [ "anyhow", "libc", @@ -10464,9 +10730,9 @@ dependencies = [ [[package]] name = "wasm-opt-cxx-sys" -version = "0.112.0" +version = "0.114.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc816bbc1596c8f2e8127e137a760c798023ef3d378f2ae51f0f1840e2dfa445" +checksum = "6d04e240598162810fad3b2e96fa0dec6dba1eb65a03f3bd99a9248ab8b56caa" dependencies = [ "anyhow", "cxx", @@ -10476,9 +10742,9 @@ dependencies = [ [[package]] name = "wasm-opt-sys" -version = "0.112.0" +version = "0.114.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40199e4f68ef1071b3c6d0bd8026a12b481865d4b9e49c156932ea9a6234dd14" +checksum = "2efd2aaca519d64098c4faefc8b7433a97ed511caf4c9e516384eb6aef1ff4f9" dependencies = [ "anyhow", "cc", @@ -10722,7 +10988,7 @@ version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" dependencies = [ - "ring", + "ring 0.16.20", "untrusted", ] @@ -10732,7 +10998,7 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" dependencies = [ - "ring", + "ring 0.16.20", "untrusted", ] @@ -10761,7 +11027,7 @@ dependencies = [ "rand 0.8.5", "rcgen 0.9.3", "regex", - "ring", + "ring 0.16.20", "rtcp", "rtp", "rustls 0.19.1", @@ -10825,7 +11091,7 @@ dependencies = [ "rand 0.8.5", "rand_core 0.6.4", "rcgen 0.10.0", - "ring", + "ring 0.16.20", "rustls 0.19.1", "sec1 0.3.0", "serde", @@ -11260,7 +11526,7 @@ dependencies = [ "lazy_static", "nom", "oid-registry 0.4.0", - "ring", + "ring 0.16.20", "rusticata-macros", "thiserror", "time", diff --git a/Cargo.toml b/Cargo.toml index f4bc98696e..d0249a5755 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ ethereum = { version = "0.14.0", default-features = false } ethereum-types = { version = "0.14.1", default-features = false } evm = { git = "https://github.com/moonbeam-foundation/evm", rev = "a33ac87ad7462b7e7029d12c385492b2a8311d1c", default-features = false } futures = "0.3.28" +hash-db = { version = "0.16.0", default-features = false } hex = { version = "0.4.3", default-features = false, features = ["alloc"] } hex-literal = "0.4.1" impl-serde = { version = "0.4.0", default-features = false } @@ -65,75 +66,75 @@ sqlx = { version = "0.7.1", default-features = false, features = ["macros"] } thiserror = "1.0" tokio = "1.29.1" # Substrate Client -sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-cli = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sc-client-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-client-db = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sc-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-consensus-grandpa = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-consensus-manual-seal = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-executor = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-keystore = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-network = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-network-common = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-offchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-service = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sc-utils = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } +sc-basic-authorship = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-cli = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sc-client-api = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-client-db = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sc-consensus = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-consensus-grandpa = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-consensus-manual-seal = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-executor = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-keystore = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-network = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-network-common = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-offchain = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-rpc = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-rpc-api = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-service = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sc-telemetry = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-transaction-pool-api = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sc-utils = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } # Substrate Primitive -sp-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sp-consensus = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sp-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-consensus-grandpa = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-core = { version = "21.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-database = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sp-inherents = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-io = { version = "23.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-keyring = { version = "24.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -sp-offchain = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-runtime = { version = "24.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-runtime-interface = { version = "17.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-session = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-state-machine = { version = "0.28.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-std = { version = "8.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-storage = { version = "13.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-trie = { version = "22.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -sp-version = { version = "22.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } +sp-api = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sp-consensus-aura = { version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-consensus-grandpa = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-core = { version = "21.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-database = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sp-inherents = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-io = { version = "23.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-keyring = { version = "24.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +sp-offchain = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-runtime = { version = "24.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-runtime-interface = { version = "17.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-session = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-state-machine = { version = "0.28.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-std = { version = "8.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-storage = { version = "13.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-timestamp = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-trie = { version = "22.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +sp-version = { version = "22.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } # Substrate FRAME -frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -frame-executive = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -frame-support = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -frame-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -frame-system-benchmarking = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -frame-system-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -pallet-aura = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -pallet-balances = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -pallet-grandpa = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -pallet-sudo = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -pallet-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } -pallet-utility = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0", default-features = false } +frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +frame-executive = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +frame-support = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +frame-system = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +frame-system-benchmarking = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +frame-system-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +pallet-aura = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +pallet-balances = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +pallet-grandpa = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +pallet-sudo = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +pallet-timestamp = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } +pallet-utility = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0", default-features = false } # Substrate Utility -frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } -substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/paritytech/substrate", branch = "polkadot-v1.0.0" } +frame-benchmarking-cli = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +substrate-test-runtime-client = { version = "2.0.0", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } +substrate-wasm-builder = { version = "5.0.0-dev", git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "cem-upgrade-to-polkadot-1.1.0" } # Frontier Client fc-cli = { version = "1.0.0-dev", path = "client/cli", default-features = false } fc-consensus = { version = "2.0.0-dev", path = "client/consensus" } diff --git a/client/consensus/src/lib.rs b/client/consensus/src/lib.rs index d58bd722db..440908d171 100644 --- a/client/consensus/src/lib.rs +++ b/client/consensus/src/lib.rs @@ -80,7 +80,7 @@ impl, C> Clone for FrontierBlockImp impl FrontierBlockImport where B: BlockT, - I: BlockImport>, + I: BlockImport, I::Error: Into, C: ProvideRuntimeApi, C::Api: BlockBuilderApi + EthereumRuntimeRPCApi, @@ -98,13 +98,12 @@ where impl BlockImport for FrontierBlockImport where B: BlockT, - I: BlockImport> + Send + Sync, + I: BlockImport + 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, @@ -115,7 +114,7 @@ where async fn import_block( &mut self, - block: BlockImportParams, + block: BlockImportParams, ) -> Result { // We validate that there are only one frontier log. No other // actions are needed and mapping syncing is delegated to a separate diff --git a/client/rpc/src/eth/execute.rs b/client/rpc/src/eth/execute.rs index 6858bfda38..26b7e5f724 100644 --- a/client/rpc/src/eth/execute.rs +++ b/client/rpc/src/eth/execute.rs @@ -27,13 +27,12 @@ use sc_client_api::backend::{Backend, StorageProvider}; use sc_transaction_pool::ChainApi; use sp_api::{ ApiExt, CallApiAt, CallApiAtParams, CallContext, Extensions, ProvideRuntimeApi, - StorageTransactionCache, }; use sp_block_builder::BlockBuilder as BlockBuilderApi; use sp_blockchain::HeaderBackend; use sp_inherents::CreateInherentDataProviders; use sp_io::hashing::{blake2_128, twox_128}; -use sp_runtime::{traits::Block as BlockT, DispatchError, SaturatedConversion}; +use sp_runtime::{traits::{Block as BlockT, HashingFor}, DispatchError, SaturatedConversion}; use sp_state_machine::OverlayedChanges; // Frontier use fc_rpc_core::types::*; @@ -241,14 +240,11 @@ where api_version, state_overrides, )?; - let storage_transaction_cache = - RefCell::>::default(); let params = CallApiAtParams { at: substrate_hash, function: "EthereumRuntimeRPCApi_call", arguments: encoded_params, overlayed_changes: &RefCell::new(overlayed_changes), - storage_transaction_cache: &storage_transaction_cache, call_context: CallContext::Offchain, recorder: &None, extensions: &RefCell::new(Extensions::new()), @@ -888,7 +884,7 @@ where block_hash: B::Hash, api_version: u32, state_overrides: Option>, - ) -> RpcResult { + ) -> RpcResult>> { let mut overlayed_changes = OverlayedChanges::default(); if let Some(state_overrides) = state_overrides { for (address, state_override) in state_overrides { diff --git a/client/rpc/src/lib.rs b/client/rpc/src/lib.rs index 7c56bdc610..63da2b60e8 100644 --- a/client/rpc/src/lib.rs +++ b/client/rpc/src/lib.rs @@ -72,7 +72,7 @@ pub mod frontier_backend_client { use sp_io::hashing::{blake2_128, twox_128}; use sp_runtime::{ generic::BlockId, - traits::{Block as BlockT, UniqueSaturatedInto, Zero}, + traits::{Block as BlockT, UniqueSaturatedInto, Zero, HashingFor}, }; use sp_state_machine::OverlayedChanges; // Frontier @@ -95,7 +95,7 @@ pub mod frontier_backend_client { fn set_overlayed_changes( client: &C, - overlayed_changes: &mut OverlayedChanges, + overlayed_changes: &mut OverlayedChanges>, block: B::Hash, _version: u32, address: H160, @@ -148,7 +148,7 @@ pub mod frontier_backend_client { fn set_overlayed_changes( client: &C, - overlayed_changes: &mut OverlayedChanges, + overlayed_changes: &mut OverlayedChanges>, block: B::Hash, _version: u32, address: H160, diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 9b933bd0ee..b2d43bb205 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -44,14 +44,14 @@ use fp_evm::{ }; use fp_storage::{EthereumStorageSchema, PALLET_ETHEREUM_SCHEMA}; use frame_support::{ - codec::{Decode, Encode, MaxEncodedLen}, dispatch::{DispatchInfo, DispatchResultWithPostInfo, Pays, PostDispatchInfo}, - scale_info::TypeInfo, + pallet_prelude::TypeInfo, traits::{EnsureOrigin, Get, PalletInfoAccess, Time}, weights::Weight, }; use frame_system::{pallet_prelude::OriginFor, CheckWeight, WeightInfo}; use pallet_evm::{BlockHashMapping, FeeCalculator, GasWeightMapping, Runner}; +use scale_codec::{Decode, Encode, MaxEncodedLen}; use sp_runtime::{ generic::DigestItem, traits::{DispatchInfoOf, Dispatchable, One, Saturating, UniqueSaturatedInto, Zero}, diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index 42ecd33b5d..61a4f2df7d 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -19,7 +19,6 @@ use ethereum::{TransactionAction, TransactionSignature}; use frame_support::{ - dispatch::Dispatchable, parameter_types, traits::{ConstU32, FindAuthor}, weights::Weight, diff --git a/frame/evm/precompile/dispatch/Cargo.toml b/frame/evm/precompile/dispatch/Cargo.toml index 06ab329ce9..9c9e2f6c82 100644 --- a/frame/evm/precompile/dispatch/Cargo.toml +++ b/frame/evm/precompile/dispatch/Cargo.toml @@ -13,6 +13,8 @@ frame-support = { workspace = true } # Frontier fp-evm = { workspace = true } pallet-evm = { workspace = true } +sp-runtime = { workspace = true } +scale-codec = { package = "parity-scale-codec", workspace = true } [dev-dependencies] scale-codec = { package = "parity-scale-codec", workspace = true } diff --git a/frame/evm/precompile/dispatch/src/lib.rs b/frame/evm/precompile/dispatch/src/lib.rs index d3427b692f..b573d60183 100644 --- a/frame/evm/precompile/dispatch/src/lib.rs +++ b/frame/evm/precompile/dispatch/src/lib.rs @@ -27,14 +27,15 @@ mod mock; mod tests; use alloc::format; +use scale_codec::{Decode, DecodeLimit}; +use sp_runtime::traits::Dispatchable; use core::marker::PhantomData; use fp_evm::{ ExitError, ExitSucceed, Precompile, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, }; use frame_support::{ - codec::{Decode, DecodeLimit as _}, - dispatch::{DispatchClass, Dispatchable, GetDispatchInfo, Pays, PostDispatchInfo}, + dispatch::{DispatchClass, GetDispatchInfo, Pays, PostDispatchInfo}, traits::{ConstU32, Get}, }; use pallet_evm::{AddressMapping, GasWeightMapping}; diff --git a/frame/evm/src/benchmarking.rs b/frame/evm/src/benchmarking.rs index 8ee4280100..a2aab2c0d2 100644 --- a/frame/evm/src/benchmarking.rs +++ b/frame/evm/src/benchmarking.rs @@ -33,7 +33,7 @@ benchmarks! { let x in 1..10000000; - use frame_benchmarking::vec; + use sp_std::vec; use rlp::RlpStream; use sp_core::{H160, U256}; diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 323ad141f1..f6df9bac3a 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -72,7 +72,8 @@ use impl_trait_for_tuples::impl_for_tuples; use scale_info::TypeInfo; // Substrate use frame_support::{ - dispatch::{DispatchResultWithPostInfo, MaxEncodedLen, Pays, PostDispatchInfo}, + dispatch::{DispatchResultWithPostInfo, Pays, PostDispatchInfo}, + pallet_prelude::MaxEncodedLen, traits::{ tokens::{ currency::Currency, diff --git a/primitives/rpc/src/lib.rs b/primitives/rpc/src/lib.rs index 045402fdf5..eff6a48bf1 100644 --- a/primitives/rpc/src/lib.rs +++ b/primitives/rpc/src/lib.rs @@ -25,7 +25,7 @@ use scale_codec::{Decode, Encode}; use scale_info::TypeInfo; // Substrate use sp_core::{H160, H256, U256}; -use sp_runtime::{traits::Block as BlockT, Permill, RuntimeDebug}; +use sp_runtime::{traits::{Block as BlockT, HashingFor}, Permill, RuntimeDebug}; use sp_state_machine::OverlayedChanges; use sp_std::vec::Vec; @@ -51,7 +51,7 @@ pub trait RuntimeStorageOverride: Send + Sync { fn set_overlayed_changes( client: &C, - overlayed_changes: &mut OverlayedChanges, + overlayed_changes: &mut OverlayedChanges>, block: B::Hash, version: u32, address: H160, @@ -69,7 +69,7 @@ impl RuntimeStorageOverride for () { fn set_overlayed_changes( _client: &C, - _overlayed_changes: &mut OverlayedChanges, + _overlayed_changes: &mut OverlayedChanges>, _block: B::Hash, _version: u32, _address: H160, diff --git a/template/node/Cargo.toml b/template/node/Cargo.toml index 4acaec944b..497f51127a 100644 --- a/template/node/Cargo.toml +++ b/template/node/Cargo.toml @@ -34,7 +34,6 @@ sc-consensus-grandpa = { workspace = true } sc-consensus-manual-seal = { workspace = true } sc-executor = { workspace = true } sc-network = { workspace = true } -sc-network-common = { workspace = true } sc-network-sync = { workspace = true } sc-offchain = { workspace = true } sc-rpc = { workspace = true } @@ -56,7 +55,6 @@ sp-session = { workspace = true, features = ["default"] } sp-state-machine = { workspace = true, features = ["default"] } sp-timestamp = { workspace = true, features = ["default"] } sp-transaction-pool = { workspace = true, features = ["default"] } -sp-trie = { workspace = true, features = ["default"] } # These dependencies are used for RPC frame-system-rpc-runtime-api = { workspace = true } pallet-transaction-payment-rpc = { workspace = true } diff --git a/template/node/src/client.rs b/template/node/src/client.rs index 7d9d1c227c..29f9c10946 100644 --- a/template/node/src/client.rs +++ b/template/node/src/client.rs @@ -1,7 +1,6 @@ // Substrate use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch, NativeVersion}; use sp_consensus_aura::sr25519::AuthorityId as AuraId; -use sp_runtime::traits::BlakeTwo256; // Local use frontier_template_runtime::{opaque::Block, AccountId, Balance, Nonce}; @@ -43,8 +42,6 @@ pub trait BaseRuntimeApiCollection: + sp_offchain::OffchainWorkerApi + sp_session::SessionKeys + sp_transaction_pool::runtime_api::TaggedTransactionQueue -where - >::StateBackend: sp_api::StateBackend, { } @@ -56,7 +53,6 @@ where + sp_offchain::OffchainWorkerApi + sp_session::SessionKeys + sp_transaction_pool::runtime_api::TaggedTransactionQueue, - >::StateBackend: sp_api::StateBackend, { } @@ -68,8 +64,6 @@ pub trait RuntimeApiCollection: + sp_consensus_grandpa::GrandpaApi + frame_system_rpc_runtime_api::AccountNonceApi + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi -where - >::StateBackend: sp_api::StateBackend, { } @@ -81,6 +75,5 @@ where + sp_consensus_grandpa::GrandpaApi + frame_system_rpc_runtime_api::AccountNonceApi + pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi, - >::StateBackend: sp_api::StateBackend, { } diff --git a/template/node/src/eth.rs b/template/node/src/eth.rs index 33b451ac8d..6eb125b6d7 100644 --- a/template/node/src/eth.rs +++ b/template/node/src/eth.rs @@ -7,12 +7,11 @@ use std::{ use futures::{future, prelude::*}; // Substrate -use sc_client_api::{BlockchainEvents, StateBackendFor}; +use sc_client_api::BlockchainEvents; use sc_executor::NativeExecutionDispatch; use sc_network_sync::SyncingService; use sc_service::{error::Error as ServiceError, Configuration, TaskManager}; use sp_api::ConstructRuntimeApi; -use sp_runtime::traits::BlakeTwo256; // Frontier pub use fc_consensus::FrontierBlockImport; use fc_rpc::{EthTask, OverrideHandle}; @@ -113,8 +112,6 @@ pub trait EthCompatRuntimeApiCollection: sp_api::ApiExt + fp_rpc::ConvertTransactionRuntimeApi + fp_rpc::EthereumRuntimeRPCApi -where - >::StateBackend: sp_api::StateBackend, { } @@ -123,7 +120,6 @@ where Api: sp_api::ApiExt + fp_rpc::ConvertTransactionRuntimeApi + fp_rpc::EthereumRuntimeRPCApi, - >::StateBackend: sp_api::StateBackend, { } @@ -146,7 +142,7 @@ pub async fn spawn_frontier_tasks( RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, RuntimeApi::RuntimeApi: - EthCompatRuntimeApiCollection>, + EthCompatRuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, { // Spawn main mapping sync worker background task. diff --git a/template/node/src/service.rs b/template/node/src/service.rs index 24e5f5ecb0..6e9fc619a0 100644 --- a/template/node/src/service.rs +++ b/template/node/src/service.rs @@ -5,18 +5,16 @@ use std::{cell::RefCell, path::Path, sync::Arc, time::Duration}; use futures::{channel::mpsc, prelude::*}; // Substrate use prometheus_endpoint::Registry; -use sc_client_api::{Backend, BlockBackend, StateBackendFor}; +use sc_client_api::{Backend, BlockBackend}; use sc_consensus::BasicQueue; use sc_executor::NativeExecutionDispatch; -use sc_network_common::sync::warp::WarpSyncParams; +use sc_network_sync::warp::WarpSyncParams; use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker}; use sc_transaction_pool_api::OffchainTransactionPoolFactory; -use sp_api::{ConstructRuntimeApi, TransactionFor}; +use sp_api::ConstructRuntimeApi; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use sp_core::U256; -use sp_runtime::traits::BlakeTwo256; -use sp_trie::PrefixedMemoryDB; // Runtime use frontier_template_runtime::{opaque::Block, Hash, TransactionConverter}; @@ -33,14 +31,18 @@ pub use crate::{ eth::{db_config_dir, EthConfiguration}, }; -type BasicImportQueue = sc_consensus::DefaultImportQueue; +type BasicImportQueue = sc_consensus::DefaultImportQueue; type FullPool = sc_transaction_pool::FullPool; type FullSelectChain = sc_consensus::LongestChain; type GrandpaBlockImport = sc_consensus_grandpa::GrandpaBlockImport; type GrandpaLinkHalf = sc_consensus_grandpa::LinkHalf; -type BoxBlockImport = sc_consensus::BoxBlockImport>; +type BoxBlockImport = sc_consensus::BoxBlockImport; + +/// The minimum period of blocks on which justifications will be +/// imported and generated. +const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512; pub fn new_partial( config: &Configuration, @@ -51,11 +53,11 @@ pub fn new_partial( FullClient, FullBackend, FullSelectChain, - BasicImportQueue>, + BasicImportQueue, FullPool>, ( Option, - BoxBlockImport>, + BoxBlockImport, GrandpaLinkHalf>, FrontierBackend, Arc>, @@ -66,8 +68,8 @@ pub fn new_partial( where RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, - RuntimeApi::RuntimeApi: BaseRuntimeApiCollection> - + EthCompatRuntimeApiCollection>, + RuntimeApi::RuntimeApi: BaseRuntimeApiCollection + + EthCompatRuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, BIQ: FnOnce( Arc>, @@ -78,8 +80,8 @@ where GrandpaBlockImport>, ) -> Result< ( - BasicImportQueue>, - BoxBlockImport>, + BasicImportQueue, + BoxBlockImport, ), ServiceError, >, @@ -115,6 +117,7 @@ where let select_chain = sc_consensus::LongestChain::new(backend.clone()); let (grandpa_block_import, grandpa_link) = sc_consensus_grandpa::block_import( client.clone(), + GRANDPA_JUSTIFICATION_PERIOD, &client, select_chain.clone(), telemetry.as_ref().map(|x| x.handle()), @@ -195,8 +198,8 @@ pub fn build_aura_grandpa_import_queue( grandpa_block_import: GrandpaBlockImport>, ) -> Result< ( - BasicImportQueue>, - BoxBlockImport>, + BasicImportQueue, + BoxBlockImport, ), ServiceError, > @@ -204,7 +207,7 @@ where RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, RuntimeApi::RuntimeApi: - RuntimeApiCollection>, + RuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, { let frontier_block_import = @@ -251,8 +254,8 @@ pub fn build_manual_seal_import_queue( _grandpa_block_import: GrandpaBlockImport>, ) -> Result< ( - BasicImportQueue>, - BoxBlockImport>, + BasicImportQueue, + BoxBlockImport, ), ServiceError, > @@ -260,7 +263,7 @@ where RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, RuntimeApi::RuntimeApi: - RuntimeApiCollection>, + RuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, { let frontier_block_import = FrontierBlockImport::new(client.clone(), client); @@ -284,7 +287,7 @@ where RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, RuntimeApi::RuntimeApi: - RuntimeApiCollection>, + RuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, { let build_import_queue = if sealing.is_some() { @@ -574,7 +577,7 @@ where let grandpa_config = sc_consensus_grandpa::Config { // FIXME #1578 make this available through chainspec gossip_duration: Duration::from_millis(333), - justification_period: 512, + justification_generation_period: 512, name: Some(name), observer_enabled: false, keystore, @@ -619,7 +622,7 @@ fn run_manual_seal_authorship( client: Arc>, transaction_pool: Arc>>, select_chain: FullSelectChain, - block_import: BoxBlockImport>, + block_import: BoxBlockImport, task_manager: &TaskManager, prometheus_registry: Option<&Registry>, telemetry: Option<&Telemetry>, @@ -629,7 +632,7 @@ where RuntimeApi: ConstructRuntimeApi>, RuntimeApi: Send + Sync + 'static, RuntimeApi::RuntimeApi: - RuntimeApiCollection>, + RuntimeApiCollection, Executor: NativeExecutionDispatch + 'static, { let proposer_factory = sc_basic_authorship::ProposerFactory::new( @@ -726,7 +729,7 @@ pub fn new_chain_ops( ( Arc, Arc, - BasicQueue>, + BasicQueue, TaskManager, FrontierBackend, ), diff --git a/template/runtime/Cargo.toml b/template/runtime/Cargo.toml index 5547dee3b9..6aa715d832 100644 --- a/template/runtime/Cargo.toml +++ b/template/runtime/Cargo.toml @@ -25,6 +25,7 @@ sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } sp-std = { workspace = true } +sp-storage = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } # Substrate FRAME diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index df88dc285d..b8c25248f2 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -232,6 +232,8 @@ impl pallet_grandpa::Config for Runtime { type KeyOwnerProof = sp_core::Void; type EquivocationReportSystem = (); + + type MaxNominators = (); } parameter_types! { @@ -977,7 +979,8 @@ impl_runtime_apis! { fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { - use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey}; + use frame_benchmarking::{baseline, Benchmarking, BenchmarkBatch, add_benchmark}; + use sp_storage::TrackedStorageKey; use pallet_evm::Pallet as PalletEvmBench; use pallet_hotfix_sufficients::Pallet as PalletHotfixSufficientsBench; @@ -988,7 +991,7 @@ impl_runtime_apis! { let whitelist: Vec = vec![]; let mut batches = Vec::::new(); - let params = (&config, &whitelist); + let params = (&config, &whitelist[..]); add_benchmark!(params, batches, pallet_evm, PalletEvmBench::); add_benchmark!(params, batches, pallet_hotfix_sufficients, PalletHotfixSufficientsBench::);