diff --git a/Cargo.lock b/Cargo.lock index 3078706fc..8612e3253 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" dependencies = [ "memchr", ] @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" dependencies = [ "anstyle", "windows-sys", @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "ark-ff" @@ -266,6 +266,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + [[package]] name = "bitflags" version = "1.3.2" @@ -274,9 +280,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bitvec" @@ -367,9 +373,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.3.21" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" dependencies = [ "clap_builder", "clap_derive", @@ -378,9 +384,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.21" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" dependencies = [ "anstream", "anstyle", @@ -397,7 +403,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -460,6 +466,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "const-oid" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + [[package]] name = "conta" version = "0.0.0" @@ -493,6 +505,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +dependencies = [ + "generic-array", + "rand_core", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -505,9 +529,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1ba0a82363c553ecb7b4cd58ba6e1c017baef8e3cca4e7d66ca17879201144" +checksum = "666a3ec767f4bbaf0dcfcc3b4ea048b90520b254fdf88813e763f4c762636c14" dependencies = [ "cc", "cxxbridge-flags", @@ -517,9 +541,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac9ec8372f860c6ee7c6463b96a26d08dd590bcbcd9bf2d1894db09ae81410d3" +checksum = "162bec16c4cc28b19e26db0197b60ba5480fdb9a4cbf0f4c6c104a937741b78e" dependencies = [ "cc", "codespan-reporting", @@ -527,24 +551,34 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "cxxbridge-flags" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "409667bbb937bae87f7cfa91ca29e1415bb92d415371e3344b5269c10d90d595" +checksum = "d6e8c238aadc4b9f2c00269d04c87abb23f96dd240803872536eed1a304bb40e" [[package]] name = "cxxbridge-macro" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb2a9757fb085d6d97856b28d4f049141ca4a61a64c697f4426433b5f6caa1f" +checksum = "59d9ffb4193dd22180b8d5747b1e095c3d9c9c665ce39b0483a488948f437e06" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", +] + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", ] [[package]] @@ -587,7 +621,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", + "const-oid", "crypto-common", + "subtle", +] + +[[package]] +name = "ecdsa" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +dependencies = [ + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature", ] [[package]] @@ -596,6 +645,24 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "elliptic-curve" +version = "0.13.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff", + "generic-array", + "group", + "rand_core", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "enumn" version = "0.1.11" @@ -604,7 +671,7 @@ checksum = "b893c4eb2dc092c811165f84dc7447fae16fb66521717968c34c509b39b1a5c5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -674,6 +741,16 @@ dependencies = [ "bytes", ] +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core", + "subtle", +] + [[package]] name = "fixed-hash" version = "0.8.0" @@ -700,6 +777,7 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -719,6 +797,17 @@ version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -764,6 +853,15 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -845,6 +943,18 @@ dependencies = [ "libc", ] +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "sha2", +] + [[package]] name = "keccak" version = "0.1.4" @@ -859,6 +969,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "leb128" @@ -895,9 +1008,9 @@ checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" [[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 = "matchers" @@ -933,6 +1046,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "num" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -944,6 +1071,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-complex" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +dependencies = [ + "num-traits", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -954,6 +1090,29 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.16" @@ -1035,9 +1194,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c516611246607d0c04186886dbb3a754368ef82c79e9827a802c6d836dd111c" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" [[package]] name = "ppv-lite86" @@ -1118,9 +1277,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1223,6 +1382,17 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +[[package]] +name = "revm" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f293f351c4c203d321744e54ed7eed3d2b6eef4c140228910dde3ac9a5ea8031" +dependencies = [ + "auto_impl", + "revm-interpreter", + "revm-precompile", +] + [[package]] name = "revm-interpreter" version = "1.1.2" @@ -1235,6 +1405,23 @@ dependencies = [ "sha3", ] +[[package]] +name = "revm-precompile" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41320af3bd6a65153d38eb1d3638ba89104cc9513c7feedb2d8510e8307dab29" +dependencies = [ + "k256", + "num", + "once_cell", + "revm-primitives", + "ripemd", + "secp256k1", + "sha2", + "sha3", + "substrate-bn", +] + [[package]] name = "revm-primitives" version = "1.1.2" @@ -1256,6 +1443,25 @@ dependencies = [ "sha3", ] +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "rlp" version = "0.5.2" @@ -1327,11 +1533,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.7" +version = "0.38.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "172891ebdceb05aa0005f533a6cbfca599ddd7d966f6f5d4d9b2e70478e70399" +checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "errno", "libc", "linux-raw-sys", @@ -1356,6 +1562,37 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + [[package]] name = "semver" version = "0.11.0" @@ -1400,14 +1637,14 @@ checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -1423,6 +1660,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + [[package]] name = "sha3" version = "0.10.8" @@ -1442,6 +1690,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core", +] + [[package]] name = "smallvec" version = "1.11.0" @@ -1457,6 +1715,12 @@ dependencies = [ "serde", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "static_assertions" version = "1.1.0" @@ -1488,6 +1752,25 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "substrate-bn" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b5bbfa79abbae15dd642ea8176a21a635ff3c00059961d1ea27ad04e5b441c" +dependencies = [ + "byteorder", + "crunchy", + "lazy_static", + "rand", + "rustc-hex", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + [[package]] name = "syn" version = "1.0.109" @@ -1501,9 +1784,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -1540,22 +1823,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1622,7 +1905,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1801,9 +2084,9 @@ dependencies = [ [[package]] name = "wast" -version = "62.0.1" +version = "63.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ae06f09dbe377b889fbd620ff8fa21e1d49d1d9d364983c0cdbf9870cb9f1f" +checksum = "2560471f60a48b77fccefaf40796fda61c97ce1e790b59dfcec9dc3995c9f63a" dependencies = [ "leb128", "memchr", @@ -1813,9 +2096,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "842e15861d203fb4a96d314b0751cdeaf0f6f8b35e8d81d2953af2af5e44e637" +checksum = "3bdc306c2c4c2f2bf2ba69e083731d0d2a77437fc6a350a19db139636e7e416c" dependencies = [ "wast", ] @@ -1862,9 +2145,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1877,51 +2160,51 @@ dependencies = [ [[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" -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" -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" -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" -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.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" -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.5.4" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acaaa1190073b2b101e15083c38ee8ec891b5e05cbee516521e94ec008f61e64" +checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" dependencies = [ "memchr", ] @@ -1952,7 +2235,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1961,6 +2244,7 @@ version = "0.1.2" dependencies = [ "anyhow", "evm-opcodes", + "indexmap 2.0.0", "paste", "smallvec", "thiserror", @@ -2013,7 +2297,6 @@ name = "zint" version = "0.1.2" dependencies = [ "hex", - "revm-interpreter", - "revm-primitives", + "revm", "tracing", ] diff --git a/Cargo.toml b/Cargo.toml index 76e5477fd..24eff93f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,7 @@ etc = "0.1.16" hex = "0.4.3" indexmap = "2.0.0" paste = "1.0.13" -revm-interpreter = "1.1.2" -revm-primitives = "1.1.2" +revm = "3.3.0" semver = "1.0.18" serde = "1.0.171" smallvec = "1.11.0" diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 9e6cbee4d..dba71dbdb 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -11,9 +11,10 @@ repository.workspace = true [dependencies] anyhow.workspace = true -opcodes.workspace = true smallvec.workspace = true thiserror.workspace = true tracing.workspace = true -wasmparser.workspace = true +opcodes.workspace = true paste.workspace = true +wasmparser.workspace = true +indexmap.workspace = true diff --git a/codegen/src/codegen.rs b/codegen/src/codegen.rs index b48fdb7b5..ab3fc6c77 100644 --- a/codegen/src/codegen.rs +++ b/codegen/src/codegen.rs @@ -5,7 +5,7 @@ use crate::{ local::{LocalSlot, LocalSlotType, Locals}, masm::MacroAssembler, validator::ValidateThenVisit, - Buffer, Error, Result, + Buffer, Error, Imports, Result, }; use wasmparser::{FuncType, FuncValidator, LocalsReader, OperatorsReader, ValidatorResources}; @@ -23,13 +23,15 @@ pub struct CodeGen { pub(crate) masm: MacroAssembler, /// The jump table. pub(crate) table: JumpTable, + /// The imported functions. + pub(crate) imports: Imports, /// If this function is the main function. pub(crate) is_main: bool, } impl CodeGen { /// Create a new code generator. - pub fn new(env: FuncType, is_main: bool) -> Result { + pub fn new(env: FuncType, imports: Imports, is_main: bool) -> Result { let mut params_count = 0; if !is_main { params_count = env.params().len() as u8; @@ -41,6 +43,7 @@ impl CodeGen { locals: Default::default(), masm: Default::default(), table: Default::default(), + imports, is_main, }; diff --git a/codegen/src/func.rs b/codegen/src/func.rs new file mode 100644 index 000000000..2b2926663 --- /dev/null +++ b/codegen/src/func.rs @@ -0,0 +1,70 @@ +//! Built-in functions for EVM +use opcodes::ShangHai as OpCode; + +/// Function `select` from WASM which is not avaiable in EVM. +const SELECT: [OpCode; 6] = [ + OpCode::JUMPDEST, + OpCode::POP, + OpCode::PUSH1, + OpCode::Data(0x06), + OpCode::ADD, + OpCode::JUMP, +]; + +/// Function `sload` from EVM which is not avaiable in WASM. +const SLOAD: [OpCode; 7] = [ + OpCode::JUMPDEST, + OpCode::SLOAD, + OpCode::SWAP1, + OpCode::PUSH1, + OpCode::Data(0x05), + OpCode::ADD, + OpCode::JUMP, +]; + +/// Function `sload` from EVM which is not avaiable in WASM. +const SSTORE: [OpCode; 6] = [ + OpCode::JUMPDEST, + OpCode::SSTORE, + OpCode::PUSH1, + OpCode::Data(0x05), + OpCode::ADD, + OpCode::JUMP, +]; + +/// Function selector. +#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)] +pub enum Func { + /// Run function select. + Select, + /// Run function sload. + Sload, + /// Run function sstore. + Sstore, +} + +impl Func { + /// Get the bytecode of the function. + pub fn bytecode(&self) -> Vec { + match self { + Self::Select => SELECT.to_vec(), + Self::Sload => SLOAD.to_vec(), + Self::Sstore => SSTORE.to_vec(), + } + .into_iter() + .map(|op| op.into()) + .collect() + } +} + +impl TryFrom<(&str, &str)> for Func { + type Error = (); + + fn try_from(import: (&str, &str)) -> Result { + match import { + ("zink", "sload") => Ok(Self::Sload), + ("zink", "sstore") => Ok(Self::Sstore), + _ => Err(()), + } + } +} diff --git a/codegen/src/jump/code.rs b/codegen/src/jump/code.rs index f10f60d37..fa79d5616 100644 --- a/codegen/src/jump/code.rs +++ b/codegen/src/jump/code.rs @@ -1,40 +1,14 @@ //! Table for the code section. -use opcodes::ShangHai as OpCode; -use std::collections::HashMap; - -/// Code in code section. -#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)] -pub enum Func { - /// Run select. - Select, -} - -impl Func { - /// Get the bytecode of the function. - pub fn bytecode(&self) -> Vec { - match self { - Self::Select => [ - OpCode::JUMPDEST, - OpCode::POP, - OpCode::PUSH1, - OpCode::Data(0x06), - OpCode::ADD, - OpCode::JUMP, - ], - } - .into_iter() - .map(|op| op.into()) - .collect() - } -} +use crate::func::Func; +use indexmap::IndexMap; /// Code section for EVM. #[derive(Default, Debug)] pub struct Code { offset: usize, /// Function table. - funcs: HashMap, + funcs: IndexMap, } impl Code { @@ -42,7 +16,7 @@ impl Code { pub fn new() -> Self { Self { offset: 0, - funcs: HashMap::new(), + funcs: Default::default(), } } @@ -85,6 +59,7 @@ impl Code { pub fn finish(&self) -> Vec { let mut code = Vec::new(); for func in self.funcs.keys() { + tracing::debug!("add function to code section: {:?}", func); code.extend(func.bytecode()); } code diff --git a/codegen/src/jump/mod.rs b/codegen/src/jump/mod.rs index dbaf855e9..696ff38c9 100644 --- a/codegen/src/jump/mod.rs +++ b/codegen/src/jump/mod.rs @@ -1,7 +1,7 @@ //! Jump table implementation. -use crate::{Error, Result}; -pub use code::{Code, Func}; +use crate::{Error, Func, Result}; +pub use code::Code; use std::collections::BTreeMap; mod code; @@ -60,6 +60,7 @@ impl JumpTable { /// Register a external function. pub fn ext(&mut self, pc: u16, func: Func) { + tracing::debug!("register external function: {:?}", func); self.code.try_add_func(func); self.jump.insert(pc, Jump::ExtFunc(func)); } diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index b31c1f2a0..629305c23 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -7,17 +7,20 @@ pub use crate::{ asm::Assembler, codegen::CodeGen, control::{ControlStack, ControlStackFrame, ControlStackFrameType}, + func::Func, jump::{Code, JumpTable}, local::{LocalSlot, Locals}, masm::MacroAssembler, result::{Error, Result}, }; +// use indexmap::IndexMap; use smallvec::SmallVec; pub mod abi; mod asm; mod codegen; mod control; +mod func; mod jump; mod local; mod masm; @@ -30,3 +33,7 @@ pub const BUFFER_LIMIT: usize = 0x6000; /// Code generation buffer. pub type Buffer = SmallVec<[u8; BUFFER_LIMIT]>; + +/// Imported functions. +/// pub type Imports = IndexMap; +pub type Imports = Vec; diff --git a/codegen/src/result.rs b/codegen/src/result.rs index 2c3a387bb..5fdf4a3ea 100644 --- a/codegen/src/result.rs +++ b/codegen/src/result.rs @@ -18,12 +18,15 @@ pub enum Error { /// Failed to merge jump table. #[error("Program counter {0} already exists in jump table")] DuplicateJump(u16), + /// Failed to find imported function by index in jump table. + #[error("Imported Function {0} not found in jump table")] + ImportedFuncNotFound(u32), /// Failed to find function index in jump table. #[error("Function {0} not found in jump table")] FuncNotFound(u32), /// Failed to find ext function index in jump table. #[error("External function {0:?} not found in jump table")] - ExtNotFound(crate::jump::Func), + ExtNotFound(crate::Func), /// Failed to mark else block for if block. #[error("Invalid else block for if block at {0}")] InvalidElseBlock(u16), diff --git a/codegen/src/visitor/control.rs b/codegen/src/visitor/control.rs index 56ba0e35f..56ccc4356 100644 --- a/codegen/src/visitor/control.rs +++ b/codegen/src/visitor/control.rs @@ -2,8 +2,7 @@ use crate::{ control::{ControlStackFrame, ControlStackFrameType}, - jump::Func, - CodeGen, Result, + CodeGen, Func, Result, }; use wasmparser::{BlockType, BrTable}; @@ -141,8 +140,10 @@ impl CodeGen { if let Ok(frame) = self.control.pop() { self.handle_frame_popping(frame) } else if !self.is_main { + tracing::debug!("end of call"); self.handle_call_return() } else { + tracing::debug!("end of main function"); self.handle_return() } } diff --git a/codegen/src/visitor/handlers.rs b/codegen/src/visitor/handlers.rs index f07a76d23..84a914295 100644 --- a/codegen/src/visitor/handlers.rs +++ b/codegen/src/visitor/handlers.rs @@ -13,8 +13,9 @@ impl CodeGen { /// Handle the end of the function. pub(crate) fn handle_return(&mut self) -> Result<()> { - tracing::debug!("handle return"); let results = self.env.results(); + tracing::debug!("handle return, results: {results:?}"); + if results.is_empty() { return self.handle_empty_return(); } diff --git a/codegen/src/visitor/system.rs b/codegen/src/visitor/system.rs index ee4487967..9dfeb700e 100644 --- a/codegen/src/visitor/system.rs +++ b/codegen/src/visitor/system.rs @@ -1,6 +1,6 @@ //! System instructions -use crate::{CodeGen, Result}; +use crate::{CodeGen, Error, Func, Result}; impl CodeGen { /// The call indirect instruction calls a function indirectly @@ -15,17 +15,56 @@ impl CodeGen { } /// The call instruction calls a function specified by its index. - pub fn _call(&mut self, function_index: u32) -> Result<()> { + pub fn _call(&mut self, index: u32) -> Result<()> { // record the current program counter and // pass it to the callee function. self.masm._pc()?; + // TODO: check the safty of the function index. + let base = self.imports.len() as u32; + + if base > index { + self.call_imported(index) + } else { + self.call_internal(base + index) + } + } + + /// Call internal functions + fn call_internal(&mut self, index: u32) -> Result<()> { + // Call an internal function. + // // register the call index to the jump table. - self.table.call(self.masm.pc_offset(), function_index); + self.table.call(self.masm.pc_offset(), index); // jump to the callee function // // TODO: check the stack output. + self.masm._jump()?; + self.masm._jumpdest()?; + + Ok(()) + } + + /// Call imported functions + fn call_imported(&mut self, index: u32) -> Result<()> { + // call an imported function. + // + // register the imported function index to the jump table. + let func = *self + .imports + .get(index as usize) + .ok_or(Error::ImportedFuncNotFound(index))?; + + tracing::debug!("call imported function {func:?} at index {index}"); + match func { + Func::Sstore => self.masm._swap2()?, + Func::Sload => self.masm._swap1()?, + _ => {} + } + + self.table.ext(self.masm.pc_offset(), func); + self.masm._jump()?; self.masm._jumpdest()?; Ok(()) diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 55c98d655..6fdaa54b5 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -2,10 +2,10 @@ use crate::{Error, Result}; use wasmparser::{ - FuncToValidate, FunctionBody, Parser, ValidPayload, Validator, ValidatorResources, - WasmModuleResources, + FuncToValidate, FunctionBody, Import, Parser, Payload, TypeRef, ValidPayload, Validator, + ValidatorResources, WasmModuleResources, }; -use zingen::{Buffer, CodeGen, JumpTable, BUFFER_LIMIT}; +use zingen::{Buffer, CodeGen, Func, Imports, JumpTable, BUFFER_LIMIT}; /// Zink Compiler #[derive(Default)] @@ -19,10 +19,38 @@ impl Compiler { pub fn compile(mut self, wasm: &[u8]) -> Result { let mut validator = Validator::new(); let mut func_index = 0; + let mut imports = Imports::default(); + + // Compile functions. for payload in Parser::new(0).parse_all(wasm) { - let payload = validator.payload(&payload?)?; - if let ValidPayload::Func(to_validator, body) = payload { - self.compile_func(func_index, to_validator, body)?; + let payload = payload?; + let valid_payload = validator.payload(&payload)?; + + // Get imported functions + // + // NOTE: this is safe here since the import section is + // ahead of the function section after the optimization + // of wasm-opt. + if let Payload::ImportSection(reader) = &payload { + let mut iter = reader.clone().into_iter(); + while let Some(Ok(Import { + module, + name, + ty: TypeRef::Func(index), + })) = iter.next() + { + if let Ok(func) = Func::try_from((module, name)) { + tracing::debug!("imported function: {}::{} at {index}", module, name); + imports.push(func); + } + } + + tracing::debug!("imports: {:?}", imports); + continue; + } + + if let ValidPayload::Func(to_validator, body) = valid_payload { + self.compile_func(func_index, imports.clone(), to_validator, body)?; func_index += 1; } } @@ -34,13 +62,17 @@ impl Compiler { pub fn compile_func( &mut self, func_index: u32, + imports: Imports, validator: FuncToValidate, body: FunctionBody, ) -> Result<()> { let mut func_validator = validator.into_validator(Default::default()); let sig = func_validator .resources() - .type_of_function(func_index) + // NOTE: the functions list is [ [imports] [funcs] ] so + // here we need to add the length of imports to get the + // correct index. + .type_of_function(func_index + imports.len() as u32) // TODO: Add backtrace here for the function index. (#21) .ok_or(Error::InvalidFunctionSignature)? .clone(); @@ -48,7 +80,7 @@ impl Compiler { tracing::debug!("compile function {}: {:?}", func_index, sig); let is_main = func_index == 0; - let mut codegen = CodeGen::new(sig, is_main)?; + let mut codegen = CodeGen::new(sig, imports, is_main)?; let mut locals_reader = body.get_locals_reader()?; let mut ops_reader = body.get_operators_reader()?; diff --git a/compiler/tests/recursion.rs b/compiler/tests/recursion.rs index ec29b7756..458620db0 100644 --- a/compiler/tests/recursion.rs +++ b/compiler/tests/recursion.rs @@ -3,7 +3,6 @@ use zint::{Bytes32, EVM}; mod common; -// #[ignore] #[test] fn fibonacci() -> Result<()> { let bytecode = common::load("recursion", "fibonacci")?; diff --git a/compiler/tests/storage.rs b/compiler/tests/storage.rs index dff03459d..94a4b06a8 100644 --- a/compiler/tests/storage.rs +++ b/compiler/tests/storage.rs @@ -2,11 +2,36 @@ #![cfg(test)] use anyhow::Result; -use zint::{Bytes32, InstructionResult, EVM}; +use zint::{Bytes32, InstructionResult, EVM, U256}; mod common; -#[ignore] +#[test] +fn store() -> Result<()> { + let bytecode = common::load("storage", "store")?; + let key = 0; + let value = 42; + let info = EVM::run(&bytecode, &value.to_bytes32()); + + assert_eq!(info.instr, InstructionResult::Return); + assert_eq!(info.ret, []); + assert_eq!(info.storage.get(&U256::from(key)), Some(&U256::from(value))); + + Ok(()) +} + +#[test] +fn load() -> Result<()> { + let bytecode = common::load("storage", "load")?; + let value = 42.to_bytes32(); + let info = EVM::run(&bytecode, &value); + + assert_eq!(info.instr, InstructionResult::Return); + assert_eq!(info.ret, value); + + Ok(()) +} + #[test] fn basic() -> Result<()> { let bytecode = common::load("storage", "basic")?; diff --git a/compiler/wat/storage/basic.wat b/compiler/wat/storage/basic.wat index 677d83203..b4a09ef4e 100644 --- a/compiler/wat/storage/basic.wat +++ b/compiler/wat/storage/basic.wat @@ -1,8 +1,6 @@ (module (type (;0;) (func (param i64) (result i64))) (type (;1;) (func (param i64 i64))) - (type (;2;) (func (param i64))) - (type (;3;) (func (result i64))) (import "zink" "sstore" (func (;0;) (type 1))) (import "zink" "sload" (func (;1;) (type 0))) (func (;2;) (type 0) (param i64) (result i64) @@ -10,20 +8,4 @@ local.get 0 call 0 i64.const 0 - call 1) - (func (;3;) (type 2) (param i64) - i64.const 0 - local.get 0 - call 0) - (func (;4;) (type 3) (result i64) - i64.const 0 - call 1) - (memory (;0;) 16) - (global (;0;) i32 (i32.const 1048576)) - (global (;1;) i32 (i32.const 1048576)) - (export "memory" (memory 0)) - (export "set_and_get" (func 2)) - (export "set" (func 3)) - (export "get" (func 4)) - (export "__data_end" (global 0)) - (export "__heap_base" (global 1))) + call 1)) diff --git a/compiler/wat/storage/load.wat b/compiler/wat/storage/load.wat new file mode 100644 index 000000000..bdf82d45f --- /dev/null +++ b/compiler/wat/storage/load.wat @@ -0,0 +1,11 @@ +(module + (type (;0;) (func (param i64) (result i64))) + (type (;1;) (func (param i64 i64))) + (import "zink" "sload" (func (;0;) (type 0))) + (import "zink" "sstore" (func (;1;) (type 1))) + (func (type 0) (param i64) (result i64) + i64.const 0 + local.get 0 + call 1 + i64.const 0 + call 0)) diff --git a/compiler/wat/storage/store.wat b/compiler/wat/storage/store.wat new file mode 100644 index 000000000..88527a10f --- /dev/null +++ b/compiler/wat/storage/store.wat @@ -0,0 +1,8 @@ +(module + (type (;0;) (func (param i64 i64))) + (import "zink" "sstore" (func (;0;) (type 0))) + (func (param i64) + i64.const 0 + local.get 0 + call 0) + ) diff --git a/zint/Cargo.toml b/zint/Cargo.toml index 14a9daf66..00b7cf11c 100644 --- a/zint/Cargo.toml +++ b/zint/Cargo.toml @@ -11,6 +11,5 @@ repository.workspace = true [dependencies] hex.workspace = true -revm-interpreter.workspace = true -revm-primitives.workspace = true +revm.workspace = true tracing.workspace = true diff --git a/zint/src/evm.rs b/zint/src/evm.rs index 93761370a..7ec8e7f79 100644 --- a/zint/src/evm.rs +++ b/zint/src/evm.rs @@ -1,8 +1,11 @@ //! Re-export REVM intepreter for testing usages. -pub use revm_interpreter::instruction_result::InstructionResult; -use revm_interpreter::{Contract, DummyHost, Interpreter}; -use revm_primitives::{bytecode::Bytecode, specification::ShanghaiSpec, U256}; +pub use revm::interpreter::{instruction_result::InstructionResult, primitives::U256}; +use revm::interpreter::{ + primitives::{bytecode::Bytecode, specification::ShanghaiSpec}, + Contract, DummyHost, Interpreter, +}; +use std::collections::HashMap; const INITIAL_GAS: u64 = 1_000_000_000; @@ -15,6 +18,8 @@ pub struct Info { pub instr: InstructionResult, /// Return value. pub ret: Vec, + /// The storage. + pub storage: HashMap, } /// EVM interpreter. @@ -35,7 +40,7 @@ impl EVM { ); Self { - interpreter: Interpreter::new(contract, INITIAL_GAS, true), + interpreter: Interpreter::new(contract, INITIAL_GAS, false), host: DummyHost::new(Default::default()), } } @@ -49,10 +54,19 @@ impl EVM { let ret = self.interpreter.return_value().to_vec(); self.interpreter.gas(); + let storage = self + .host + .storage + .clone() + .into_iter() + .map(|(k, v)| (k, U256::from_le_bytes(v.to_le_bytes::<32>()))) + .collect(); + Info { gas: self.interpreter.gas().spend(), instr, ret, + storage, } } diff --git a/zint/src/lib.rs b/zint/src/lib.rs index 32a3d8f26..8e2f791db 100644 --- a/zint/src/lib.rs +++ b/zint/src/lib.rs @@ -6,5 +6,5 @@ mod evm; pub use self::{ bytes::Bytes32, - evm::{Info, InstructionResult, EVM}, + evm::{Info, InstructionResult, EVM, U256}, };