diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1178e69..168e474 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [main] + branches: [main, stage] pull_request_target: - branches: [main] + branches: [main, stage] jobs: fmt: diff --git a/Cargo.lock b/Cargo.lock index 3f33774..78ce451 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,23 @@ dependencies = [ "memchr", ] +[[package]] +name = "alloy-dyn-abi" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44e3b98c37b3218924cd1d2a8570666b89662be54e5b182643855f783ea68b33" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-type-parser", + "alloy-sol-types", + "const-hex", + "itoa", + "serde", + "serde_json", + "winnow", +] + [[package]] name = "alloy-eip2930" version = "0.1.0" @@ -31,10 +48,22 @@ dependencies = [ "alloy-primitives", "alloy-rlp", "derive_more", - "k256 0.13.4", + "k256", "serde", ] +[[package]] +name = "alloy-json-abi" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "731ea743b3d843bc657e120fb1d1e9cc94f5dab8107e35a82125a63e6420a102" +dependencies = [ + "alloy-primitives", + "alloy-sol-type-parser", + "serde", + "serde_json", +] + [[package]] name = "alloy-primitives" version = "0.8.18" @@ -47,10 +76,10 @@ dependencies = [ "const-hex", "derive_more", "foldhash", - "hashbrown 0.15.2", - "indexmap 2.7.0", + "hashbrown", + "indexmap", "itoa", - "k256 0.13.4", + "k256", "keccak-asm", "paste", "proptest", @@ -84,6 +113,125 @@ dependencies = [ "syn 2.0.95", ] +[[package]] +name = "alloy-sol-macro" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a07b74d48661ab2e4b50bb5950d74dbff5e61dd8ed03bb822281b706d54ebacb" +dependencies = [ + "alloy-sol-macro-expander", + "alloy-sol-macro-input", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.95", +] + +[[package]] +name = "alloy-sol-macro-expander" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19cc9c7f20b90f9be1a8f71a3d8e283a43745137b0837b1a1cb13159d37cad72" +dependencies = [ + "alloy-sol-macro-input", + "const-hex", + "heck 0.5.0", + "indexmap", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.95", + "syn-solidity", + "tiny-keccak", +] + +[[package]] +name = "alloy-sol-macro-input" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713b7e6dfe1cb2f55c80fb05fd22ed085a1b4e48217611365ed0ae598a74c6ac" +dependencies = [ + "const-hex", + "dunce", + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.95", + "syn-solidity", +] + +[[package]] +name = "alloy-sol-type-parser" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1eda2711ab2e1fb517fc6e2ffa9728c9a232e296d16810810e6957b781a1b8bc" +dependencies = [ + "serde", + "winnow", +] + +[[package]] +name = "alloy-sol-types" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b478bc9c0c4737a04cd976accde4df7eba0bdc0d90ad6ff43d58bc93cf79c1" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-macro", + "const-hex", + "serde", +] + +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +dependencies = [ + "anstyle", + "windows-sys", +] + [[package]] name = "ark-ff" version = "0.3.0" @@ -252,12 +400,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - [[package]] name = "base16ct" version = "0.2.0" @@ -393,15 +535,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" -dependencies = [ - "num-traits", -] - [[package]] name = "clap" version = "2.34.0" @@ -409,64 +542,55 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "bitflags 1.3.2", - "textwrap 0.11.0", + "textwrap", "unicode-width 0.1.14", ] [[package]] name = "clap" -version = "3.2.25" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ - "atty", - "bitflags 1.3.2", + "clap_builder", "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap 1.9.3", - "once_cell", "strsim", - "termcolor", - "textwrap 0.16.1", ] [[package]] name = "clap_derive" -version = "3.2.25" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6371b8bdc8b7d3959e9cf7b22d4435ef3e79e138688421ec654acf8c81b008" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ - "heck 0.4.1", - "proc-macro-error", + "heck 0.5.0", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.95", ] [[package]] name = "clap_lex" -version = "0.2.4" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" -dependencies = [ - "os_str_bytes", -] +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] -name = "codemap" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24" - -[[package]] -name = "codemap-diagnostic" -version = "0.1.2" +name = "colorchoice" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc20770be05b566a963bf91505e60412c4a2d016d1ef95c5512823bb085a8122" -dependencies = [ - "codemap", - "termcolor", -] +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "comfy-table" @@ -597,18 +721,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array", - "rand_core", - "subtle", - "zeroize", -] - [[package]] name = "crypto-bigint" version = "0.5.5" @@ -652,16 +764,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "zeroize", -] - [[package]] name = "der" version = "0.7.9" @@ -726,22 +828,16 @@ dependencies = [ ] [[package]] -name = "dyn-clone" -version = "1.0.17" +name = "dunce" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] -name = "ecdsa" -version = "0.14.8" +name = "dyn-clone" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der 0.6.1", - "elliptic-curve 0.12.3", - "rfc6979 0.3.1", - "signature 1.6.4", -] +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "ecdsa" @@ -749,12 +845,12 @@ version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "der 0.7.9", + "der", "digest 0.10.7", - "elliptic-curve 0.13.8", - "rfc6979 0.4.0", - "signature 2.2.0", - "spki 0.7.3", + "elliptic-curve", + "rfc6979", + "signature", + "spki", ] [[package]] @@ -763,40 +859,21 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct 0.1.1", - "crypto-bigint 0.4.9", - "der 0.6.1", - "digest 0.10.7", - "ff 0.12.1", - "generic-array", - "group 0.12.1", - "rand_core", - "sec1 0.3.0", - "subtle", - "zeroize", -] - [[package]] name = "elliptic-curve" version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ - "base16ct 0.2.0", - "crypto-bigint 0.5.5", + "base16ct", + "crypto-bigint", "digest 0.10.7", - "ff 0.13.0", + "ff", "generic-array", - "group 0.13.0", - "pkcs8 0.10.2", + "group", + "pkcs8", "rand_core", - "sec1 0.7.3", + "sec1", "subtle", "zeroize", ] @@ -828,80 +905,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror 1.0.69", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash", - "impl-codec", - "impl-rlp", - "impl-serde", - "primitive-types", - "scale-info", - "uint", -] - -[[package]] -name = "ethers-core" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade3e9c97727343984e1ceada4fdab11142d2ee3472d2c67027d56b1251d4f15" -dependencies = [ - "arrayvec", - "bytes", - "chrono", - "elliptic-curve 0.12.3", - "ethabi", - "generic-array", - "hex", - "k256 0.11.6", - "open-fastrlp", - "rand", - "rlp", - "rlp-derive", - "serde", - "serde_json", - "strum 0.24.1", - "thiserror 1.0.69", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "fastrand" version = "2.3.0" @@ -930,16 +933,6 @@ dependencies = [ "bytes", ] -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core", - "subtle", -] - [[package]] name = "ff" version = "0.13.0" @@ -1010,24 +1003,13 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core", - "subtle", -] - [[package]] name = "group" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ - "ff 0.13.0", + "ff", "rand_core", "subtle", ] @@ -1038,12 +1020,6 @@ version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.15.2" @@ -1051,6 +1027,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "foldhash", + "serde", ] [[package]] @@ -1085,6 +1062,9 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] [[package]] name = "hmac" @@ -1099,10 +1079,11 @@ dependencies = [ name = "huff-neo-cli" version = "0.0.1" dependencies = [ + "alloy-dyn-abi", + "alloy-primitives", "atty", - "clap 3.2.25", + "clap 4.5.23", "comfy-table", - "ethers-core", "huff-neo-codegen", "huff-neo-core", "huff-neo-tests", @@ -1117,7 +1098,8 @@ dependencies = [ name = "huff-neo-codegen" version = "0.0.1" dependencies = [ - "ethers-core", + "alloy-dyn-abi", + "alloy-primitives", "hex", "huff-neo-utils", "regex", @@ -1130,9 +1112,9 @@ dependencies = [ name = "huff-neo-core" version = "0.0.1" dependencies = [ - "cfg-if", + "alloy-dyn-abi", + "alloy-primitives", "criterion", - "ethers-core", "getrandom", "huff-neo-codegen", "huff-neo-lexer", @@ -1143,7 +1125,6 @@ dependencies = [ "serde_json", "tracing", "tracing-subscriber", - "tracing-test", "uuid", "walkdir", ] @@ -1202,13 +1183,12 @@ dependencies = [ name = "huff-neo-utils" version = "0.0.1" dependencies = [ + "alloy-dyn-abi", + "alloy-primitives", "cfg-if", - "codemap-diagnostic", - "ethers-core", "itertools 0.14.0", "js-sys", "lazy_static", - "pathdiff", "phf", "regex", "serde", @@ -1231,24 +1211,6 @@ dependencies = [ "parity-scale-codec", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - [[package]] name = "impl-trait-for-tuples" version = "0.2.3" @@ -1260,16 +1222,6 @@ dependencies = [ "syn 2.0.95", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.7.0" @@ -1277,9 +1229,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", - "hashbrown 0.15.2", + "hashbrown", + "serde", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -1314,19 +1273,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "k256" -version = "0.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" -dependencies = [ - "cfg-if", - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2", - "sha3", -] - [[package]] name = "k256" version = "0.13.4" @@ -1334,8 +1280,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", - "ecdsa 0.16.9", - "elliptic-curve 0.13.8", + "ecdsa", + "elliptic-curve", "once_cell", "sha2", ] @@ -1423,16 +1369,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num" version = "0.4.3" @@ -1529,43 +1465,6 @@ version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "os_str_bytes" -version = "6.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "parity-scale-codec" version = "3.6.12" @@ -1621,12 +1520,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "pathdiff" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" - [[package]] name = "pest" version = "2.7.15" @@ -1634,7 +1527,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.9", + "thiserror", "ucd-trie", ] @@ -1686,24 +1579,14 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der 0.6.1", - "spki 0.6.0", -] - [[package]] name = "pkcs8" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.9", - "spki 0.7.3", + "der", + "spki", ] [[package]] @@ -1751,9 +1634,6 @@ checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" dependencies = [ "fixed-hash", "impl-codec", - "impl-rlp", - "impl-serde", - "scale-info", "uint", ] @@ -1767,27 +1647,25 @@ dependencies = [ ] [[package]] -name = "proc-macro-error" -version = "1.0.4" +name = "proc-macro-error-attr2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" dependencies = [ - "proc-macro-error-attr", "proc-macro2", "quote", - "syn 1.0.109", - "version_check", ] [[package]] -name = "proc-macro-error-attr" -version = "1.0.4" +name = "proc-macro-error2" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" dependencies = [ + "proc-macro-error-attr2", "proc-macro2", "quote", - "version_check", + "syn 2.0.95", ] [[package]] @@ -1849,6 +1727,7 @@ dependencies = [ "libc", "rand_chacha", "rand_core", + "serde", ] [[package]] @@ -1987,7 +1866,7 @@ dependencies = [ "blst", "c-kzg", "cfg-if", - "k256 0.13.4", + "k256", "once_cell", "revm-primitives", "ripemd", @@ -2016,17 +1895,6 @@ dependencies = [ "serde", ] -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint 0.4.9", - "hmac", - "zeroize", -] - [[package]] name = "rfc6979" version = "0.4.0" @@ -2056,17 +1924,6 @@ dependencies = [ "rustc-hex", ] -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "ruint" version = "1.12.4" @@ -2175,60 +2032,22 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scale-info" -version = "2.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346a3b32eba2640d17a9cb5927056b08f3de90f65b72fe09402c2ad07d684d0b" -dependencies = [ - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", -] - -[[package]] -name = "scale-info-derive" -version = "2.11.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6630024bf739e2179b91fb424b28898baf819414262c5d376677dbff1fe7ebf" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.95", -] - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct 0.1.1", - "der 0.6.1", - "generic-array", - "pkcs8 0.9.0", - "subtle", - "zeroize", -] - [[package]] name = "sec1" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ - "base16ct 0.2.0", - "der 0.7.9", + "base16ct", + "der", "generic-array", - "pkcs8 0.10.2", + "pkcs8", "subtle", "zeroize", ] @@ -2323,7 +2142,7 @@ version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" dependencies = [ - "indexmap 2.7.0", + "indexmap", "itoa", "memchr", "ryu", @@ -2385,16 +2204,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.7", - "rand_core", -] - [[package]] name = "signature" version = "2.2.0" @@ -2434,16 +2243,6 @@ dependencies = [ "strum 0.24.1", ] -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", -] - [[package]] name = "spki" version = "0.7.3" @@ -2451,7 +2250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.9", + "der", ] [[package]] @@ -2462,9 +2261,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -2548,6 +2347,18 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn-solidity" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e89d8bf2768d277f40573c83a02a099e96d96dd3104e13ea676194e61ac4b0" +dependencies = [ + "paste", + "proc-macro2", + "quote", + "syn 2.0.95", +] + [[package]] name = "tap" version = "1.0.1" @@ -2568,15 +2379,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "termcolor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" -dependencies = [ - "winapi-util", -] - [[package]] name = "textwrap" version = "0.11.0" @@ -2586,39 +2388,13 @@ dependencies = [ "unicode-width 0.1.14", ] -[[package]] -name = "textwrap" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" - -[[package]] -name = "thiserror" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" -dependencies = [ - "thiserror-impl 1.0.69", -] - [[package]] name = "thiserror" version = "2.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f072643fd0190df67a8bab670c20ef5d8737177d6ac6b2e9a236cb096206b2cc" dependencies = [ - "thiserror-impl 2.0.9", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.95", + "thiserror-impl", ] [[package]] @@ -2697,7 +2473,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.7.0", + "indexmap", "serde", "serde_spanned", "toml_datetime", @@ -2733,18 +2509,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", ] [[package]] @@ -2754,36 +2518,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", - "nu-ansi-term", "once_cell", "regex", "sharded-slab", - "smallvec", "thread_local", "tracing", "tracing-core", - "tracing-log", -] - -[[package]] -name = "tracing-test" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "557b891436fe0d5e0e363427fc7f217abf9ccd510d5136549847bdcbcd011d68" -dependencies = [ - "tracing-core", - "tracing-subscriber", - "tracing-test-macro", -] - -[[package]] -name = "tracing-test-macro" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" -dependencies = [ - "quote", - "syn 2.0.95", ] [[package]] @@ -2840,6 +2580,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" version = "1.11.0" diff --git a/Cargo.toml b/Cargo.toml index ad91b4f..5cff428 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,10 +30,9 @@ huff-neo-tests = { path = "crates/tests" } huff-neo-js = { path = "crates/js" } -clap = { version = "3.1.18", features = ["derive"] } +clap = { version = "4.5.23", features = ["derive"] } comfy-table = "7.1" tracing = "0.1.34" -ethers-core = "1.0.2" yansi = "1.0.1" spinners = "4.1.0" uuid = { version = "1.1.1", features = ["v4"] } @@ -42,7 +41,6 @@ serde_json = "1.0.81" hex = "0.4.3" regex = "1.6.0" tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt"] } -tracing-test = "0.2.2" walkdir = "2" cfg-if = "1" serde = { version = "1.0", features = ["derive", "rc"] } @@ -52,22 +50,35 @@ revm = "19.1.0" phf = { version = "0.11.1", features = ["macros"] } strum = "0.26.3" strum_macros = "0.26.4" -codemap-diagnostic = "0.1.1" lazy_static = "1" -pathdiff = "0.2.1" itertools = "0.14.0" tiny-keccak = { version = "2.0.2", features = ["keccak"] } toml = "0.8.19" js-sys = { version = "0.3" } alloy-primitives = "0.8" +alloy-dyn-abi = "0.8" +rand = "0.8.5" #dev +rayon = "1.5.3" criterion = "0.3.5" -rand = "0.8.5" +tracing-test = "0.2.2" + +[profile.test] +debug = 1 +incremental = true [profile.release] -opt-level = "z" -lto = true +debug = "line-tables-only" +codegen-units = 32 +lto = "thin" +opt-level = 3 +panic = "unwind" +strip = true # stripping of debuginfo + +# https://deterministic.space/high-performance-rust.html +[profile.maxperf] +# set parallel codegen to 1 to increase performance codegen-units = 1 -panic = "abort" -debug = true +inherits = "release" +lto = "fat" diff --git a/Makefile b/Makefile index 1520d2f..45f9c18 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,51 @@ -.PHONY: build run test clean fmt fmt-check clippy taplo taplo-check deny-check docs - +.PHONY: build build: cargo build --all +.PHONY: release release: - cargo build --release + RUSTFLAGS="-D warnings -C target-cpu=native" cargo build --bin huff-neo --release + +.PHONY: maxperf +maxperf: + RUSTFLAGS="-D warnings -C target-cpu=native" cargo build --bin huff-neo --profile maxperf +.PHONY: run run: cargo run +.PHONY: test test: cargo test --workspace --bins --lib --tests +.PHONY: clean clean: cargo clean +.PHONY: fmt fmt: cargo fmt --all +.PHONY: fmt-check fmt-check: cargo fmt --all --check +.PHONY: clippy clippy: cargo clippy --all --all-features --lib --tests --benches -- -D warnings +.PHONY: taplo taplo: taplo format +.PHONY: taplo-check taplo-check: taplo format --check +.PHONY: deny-check deny-check: cargo deny --all-features check +.PHONY: doc doc: cargo doc --workspace --all-features --no-deps \ No newline at end of file diff --git a/bin/huff-neo/Cargo.toml b/bin/huff-neo/Cargo.toml index c788220..401106b 100644 --- a/bin/huff-neo/Cargo.toml +++ b/bin/huff-neo/Cargo.toml @@ -16,10 +16,11 @@ huff-neo-core.workspace = true huff-neo-tests.workspace = true huff-neo-utils.workspace = true +alloy-dyn-abi.workspace = true +alloy-primitives.workspace = true atty.workspace = true clap.workspace = true comfy-table.workspace = true -ethers-core.workspace = true spinners.workspace = true tracing.workspace = true uuid.workspace = true diff --git a/bin/huff-neo/src/huff_neo.rs b/bin/huff-neo/src/huff_neo.rs index 860b9bf..68eeef3 100644 --- a/bin/huff-neo/src/huff_neo.rs +++ b/bin/huff-neo/src/huff_neo.rs @@ -6,10 +6,10 @@ #![forbid(unsafe_code)] #![allow(deprecated)] +use alloy_primitives::hex; use atty::Stream; -use clap::{App, CommandFactory, Parser as ClapParser, Subcommand}; +use clap::{CommandFactory, Parser as ClapParser, Subcommand}; use comfy_table::{modifiers::UTF8_ROUND_CORNERS, presets::UTF8_FULL, Cell, Color, Row, Table}; -use ethers_core::utils::hex; use huff_neo_codegen::Codegen; use huff_neo_core::Compiler; use huff_neo_tests::{ @@ -47,7 +47,7 @@ struct Huff { outputdir: String, /// The input constructor arguments - #[clap(short = 'i', long = "inputs", multiple_values = true)] + #[clap(short = 'i', long = "inputs", num_args = 1..)] inputs: Option>, /// Interactively input the constructor args @@ -63,7 +63,7 @@ struct Huff { optimize: bool, /// Generate solidity interface for a Huff artifact - #[clap(short = 'g', min_values = 0, long = "interface")] + #[clap(short = 'g', num_args = 0.., long = "interface")] interface: Option, /// Generate and log bytecode. @@ -87,7 +87,7 @@ struct Huff { label_indices: bool, /// Override / set constants for the compilation environment. - #[clap(short = 'c', long = "constants", multiple_values = true)] + #[clap(short = 'c', long = "constants", num_args = 1..)] constants: Option>, /// Compile a specific macro @@ -121,10 +121,8 @@ enum TestCommands { }, } -/// Helper function to read an stdin input +/// Helper function to read a stdin input pub(crate) fn get_input(prompt: &str) -> String { - // let mut sp = Spinner::new(Spinners::Line, format!("{}{}", - // Paint::blue("[INTERACTIVE]".to_string()), prompt)); print!("{} {prompt} ", Paint::blue(&"[INTERACTIVE]".to_string())); let mut input = String::new(); let _ = std::io::stdout().flush(); @@ -134,8 +132,7 @@ pub(crate) fn get_input(prompt: &str) -> String { } fn main() { - // Into App - let mut app: App = Huff::into_app(); + let mut command = Huff::command(); // Parse the command line arguments let mut cli = Huff::parse(); @@ -148,7 +145,7 @@ fn main() { // Check if no argument is provided if cli.path.is_none() { // Print help and exit - app.print_help().unwrap(); + command.print_help().unwrap(); return; } @@ -359,7 +356,7 @@ fn main() { std::process::exit(1); } - if app.get_matches().is_present("interface") { + if command.get_matches().contains_id("interface") { let mut interface: Option = None; if artifacts.len() == 1 { let gen_interface: Option = match artifacts[0].file.path.split('/').last() { @@ -415,7 +412,7 @@ fn main() { )); let encoded = Codegen::encode_constructor_args(vec![arg_input]).iter().fold(String::default(), |acc, str| { - let inner: Vec = ethers_core::abi::encode(&[str.clone()]); + let inner: Vec = str.abi_encode(); let hex_args: String = hex::encode(inner.as_slice()); format!("{acc}{hex_args}") }); diff --git a/crates/codegen/Cargo.toml b/crates/codegen/Cargo.toml index 6d32d93..c82d6a3 100644 --- a/crates/codegen/Cargo.toml +++ b/crates/codegen/Cargo.toml @@ -13,7 +13,8 @@ keywords = ["bytecode", "compiler", "ethereum", "huff", "rust"] [dependencies] huff-neo-utils.workspace = true -ethers-core.workspace = true +alloy-dyn-abi.workspace = true +alloy-primitives.workspace = true hex.workspace = true regex.workspace = true serde_json.workspace = true diff --git a/crates/codegen/src/lib.rs b/crates/codegen/src/lib.rs index 0f2349a..a9b4733 100644 --- a/crates/codegen/src/lib.rs +++ b/crates/codegen/src/lib.rs @@ -533,7 +533,7 @@ impl Codegen { pub fn churn( &mut self, file: Arc, - mut args: Vec, + mut args: Vec, main_bytecode: &str, constructor_bytecode: &str, has_custom_bootstrap: bool, @@ -568,7 +568,7 @@ impl Codegen { .enumerate() .map(|(i, tok)| { if tok.is_dynamic() { - let encoded = ethers_core::abi::encode(&[tok]); + let encoded = tok.abi_encode(); // Check for "__CODECOPY_DYN_ARG" calls for this specific argument. If any // exist, fill the placeholders. @@ -608,7 +608,7 @@ impl Codegen { // elements in the code. encoded[64..].into() } else { - ethers_core::abi::encode(&[tok]) + tok.abi_encode() } }) .collect(); @@ -653,9 +653,9 @@ impl Codegen { Ok(artifact.clone()) } - /// Encode constructor arguments as ethers_core::abi::token::Token - pub fn encode_constructor_args(args: Vec) -> Vec { - let tokens: Vec = args.iter().map(|tok| EToken::try_from(tok.clone()).unwrap().0).collect(); + /// Encode constructor arguments as alloy_dyn_abi::DynSolValue + pub fn encode_constructor_args(args: Vec) -> Vec { + let tokens: Vec = args.iter().map(|tok| EToken::try_from(tok.clone()).unwrap().0).collect(); tokens } diff --git a/crates/codegen/tests/churn.rs b/crates/codegen/tests/churn.rs index 8e58b07..b3094dc 100644 --- a/crates/codegen/tests/churn.rs +++ b/crates/codegen/tests/churn.rs @@ -1,8 +1,7 @@ -use std::sync::Arc; - -use ethers_core::abi::Token; +use alloy_dyn_abi::DynSolValue; use huff_neo_codegen::Codegen; use huff_neo_utils::prelude::FileSource; +use std::sync::Arc; #[test] fn churns_into_bytecode() { @@ -13,7 +12,7 @@ fn churns_into_bytecode() { assert!(cg.artifact.is_none()); // Churn Contract using the bytecode - let inputs: Vec = vec![]; + let inputs: Vec = vec![]; // ERC20 Bytecode let main_bytecode = "60003560E01c8063a9059cbb1461004857806340c10f19146100de57806370a082311461014e57806318160ddd1461016b578063095ea7b314610177578063dd62ed3e1461018e575b600435336024358160016000526000602001526040600020548082116100d8578190038260016000526000602001526040600020558281906001600052600060200152604060002054018360016000526000602001526040600020556000527fDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF60206000a3600160005260206000f35b60006000fd5b60005433146100ed5760006000fd5b600435600060243582819060016000526000602001526040600020540183600160005260006020015260406000205580600254016002556000527fDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF60206000a35b600435600160005260006020015260406000205460005260206000f35b60025460005260206000f35b602435600435336000526000602001526040600020555b60243560043560005260006020015260406000205460005260206000f3"; let constructor_bytecode = "33600055"; @@ -36,7 +35,7 @@ fn churns_custom_bootstrap() { assert!(cg.artifact.is_none()); // Churn Contract using the bytecode - let inputs: Vec = vec![]; + let inputs: Vec = vec![]; // main bytecode never reached but still included in deploy code let main_bytecode = "6001600216"; @@ -57,7 +56,7 @@ fn churns_constructor_args() { assert!(cg.artifact.is_none()); // Churn Contract using the bytecode - let inputs: Vec = vec![Token::String("tst".to_string())]; + let inputs: Vec = vec![DynSolValue::String("tst".to_string())]; // ERC20 Bytecode let main_bytecode = "60003560E01c8063a9059cbb1461004857806340c10f19146100de57806370a082311461014e57806318160ddd1461016b578063095ea7b314610177578063dd62ed3e1461018e575b600435336024358160016000526000602001526040600020548082116100d8578190038260016000526000602001526040600020558281906001600052600060200152604060002054018360016000526000602001526040600020556000527fDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF60206000a3600160005260206000f35b60006000fd5b60005433146100ed5760006000fd5b600435600060243582819060016000526000602001526040600020540183600160005260006020015260406000205580600254016002556000527fDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF60206000a35b600435600160005260006020015260406000205460005260206000f35b60025460005260206000f35b602435600435336000526000602001526040600020555b60243560043560005260006020015260406000205460005260206000f3"; diff --git a/crates/codegen/tests/constructor_args.rs b/crates/codegen/tests/constructor_args.rs index 5fd997d..6a31066 100644 --- a/crates/codegen/tests/constructor_args.rs +++ b/crates/codegen/tests/constructor_args.rs @@ -1,9 +1,8 @@ -use ethers_core::{ - abi::{Token, Tokenizable}, - types::*, -}; +use alloy_dyn_abi::{DynSolValue, Word}; +use alloy_primitives::{Address, I256, U256}; use huff_neo_codegen::Codegen; use huff_neo_utils::bytes_util::*; +use std::str::FromStr; #[test] fn encode_simple_constructor_args() { @@ -24,13 +23,13 @@ fn encode_simple_constructor_args() { .collect(); let results = Codegen::encode_constructor_args(args); - assert_eq!(results[0], Token::String("Hello".to_string())); - assert_eq!(results[1], Token::Uint(U256::from_dec_str("10000").unwrap())); - assert_eq!(results[2], Token::Bool(false)); - assert_eq!(results[3], Token::Address(H160::from(expected_address))); - assert_eq!(results[4], Token::FixedBytes(expected_bytes32)); - assert_eq!(results[5], "-10".parse::().unwrap().into_token()); - assert_eq!(results[6], "+55".parse::().unwrap().into_token()); + assert_eq!(results[0], DynSolValue::String("Hello".to_string())); + assert_eq!(results[1], DynSolValue::Uint(U256::from_str("10000").unwrap(), 256)); + assert_eq!(results[2], DynSolValue::Bool(false)); + assert_eq!(results[3], DynSolValue::Address(Address::from(expected_address))); + assert_eq!(results[4], DynSolValue::FixedBytes(Word::from_slice(&expected_bytes32), 32)); + assert_eq!(results[5], DynSolValue::Int(I256::from_str("-10").unwrap(), 256)); + assert_eq!(results[6], DynSolValue::Int(I256::from_str("+55").unwrap(), 256)); } #[test] @@ -54,16 +53,25 @@ fn encode_array_constructor_args() { assert_eq!( results[0], - Token::Array(vec![ - Token::Uint(U256::from_dec_str("100").unwrap()), - Token::Uint(U256::from_dec_str("200").unwrap()), - Token::Uint(U256::from_dec_str("300").unwrap()), + DynSolValue::Array(vec![ + DynSolValue::Uint(U256::from_str("100").unwrap(), 256), + DynSolValue::Uint(U256::from_str("200").unwrap(), 256), + DynSolValue::Uint(U256::from_str("300").unwrap(), 256), ]) ); - assert_eq!(results[1], Token::Array(vec![Token::Address(H160::from(expected_address)), Token::Address(H160::from(expected_address)),])); - assert_eq!(results[2], Token::Array(vec![Token::Bool(true), Token::Bool(false), Token::Bool(false),])); - let expected_array = - Token::Array(vec![Token::String("Hello".to_string()), Token::String("World".to_string()), Token::String("Yes".to_string())]); + assert_eq!( + results[1], + DynSolValue::Array(vec![ + DynSolValue::Address(Address::from(expected_address)), + DynSolValue::Address(Address::from(expected_address)), + ]) + ); + assert_eq!(results[2], DynSolValue::Array(vec![DynSolValue::Bool(true), DynSolValue::Bool(false), DynSolValue::Bool(false),])); + let expected_array = DynSolValue::Array(vec![ + DynSolValue::String("Hello".to_string()), + DynSolValue::String("World".to_string()), + DynSolValue::String("Yes".to_string()), + ]); assert_eq!(results[3], expected_array); assert_eq!(results[4], expected_array); assert_eq!(results[5], expected_array); @@ -90,16 +98,25 @@ fn encode_missing_brackets_array_constructor_args() { assert_eq!( results[0], - Token::Array(vec![ - Token::Uint(U256::from_dec_str("100").unwrap()), - Token::Uint(U256::from_dec_str("200").unwrap()), - Token::Uint(U256::from_dec_str("300").unwrap()), + DynSolValue::Array(vec![ + DynSolValue::Uint(U256::from_str("100").unwrap(), 256), + DynSolValue::Uint(U256::from_str("200").unwrap(), 256), + DynSolValue::Uint(U256::from_str("300").unwrap(), 256), + ]) + ); + assert_eq!( + results[1], + DynSolValue::Array(vec![ + DynSolValue::Address(Address::from(expected_address)), + DynSolValue::Address(Address::from(expected_address)), ]) ); - assert_eq!(results[1], Token::Array(vec![Token::Address(H160::from(expected_address)), Token::Address(H160::from(expected_address)),])); - assert_eq!(results[2], Token::Array(vec![Token::Bool(true), Token::Bool(false), Token::Bool(false),])); - let expected_array = - Token::Array(vec![Token::String("Hello".to_string()), Token::String("World".to_string()), Token::String("Yes".to_string())]); + assert_eq!(results[2], DynSolValue::Array(vec![DynSolValue::Bool(true), DynSolValue::Bool(false), DynSolValue::Bool(false),])); + let expected_array = DynSolValue::Array(vec![ + DynSolValue::String("Hello".to_string()), + DynSolValue::String("World".to_string()), + DynSolValue::String("Yes".to_string()), + ]); assert_eq!(results[3], expected_array); assert_eq!(results[4], expected_array); assert_eq!(results[5], expected_array); diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 1aa29de..f68c897 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -16,12 +16,11 @@ huff-neo-lexer.workspace = true huff-neo-parser.workspace = true huff-neo-utils.workspace = true -cfg-if.workspace = true -ethers-core.workspace = true +alloy-dyn-abi.workspace = true +alloy-primitives.workspace = true serde_json.workspace = true tracing.workspace = true tracing-subscriber.workspace = true -tracing-test.workspace = true uuid.workspace = true walkdir.workspace = true @@ -30,7 +29,7 @@ criterion.workspace = true rand.workspace = true [target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies] -rayon = { version = "1.5.3" } +rayon.workspace = true [target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies] getrandom = { version = "0.2", features = ["js"] } diff --git a/crates/core/benches/huff_benchmark.rs b/crates/core/benches/huff_benchmark.rs index 2ad630f..6c95975 100644 --- a/crates/core/benches/huff_benchmark.rs +++ b/crates/core/benches/huff_benchmark.rs @@ -91,7 +91,7 @@ fn codegen_erc20_benchmark(c: &mut Criterion) { cg.churn(file_source.clone(), vec![], &main_bytecode, &constructor_bytecode, has_custom_bootstrap).unwrap(); // Full expected bytecode output (generated from huff-neo) - let expected_bytecode = "336000556101ac80600e3d393df360003560e01c8063a9059cbb1461004857806340c10f19146100de57806370a082311461014e57806318160ddd1461016b578063095ea7b314610177578063dd62ed3e1461018e575b600435336024358160016000526000602001526040600020548082116100d8578190038260016000526000602001526040600020558281906001600052600060200152604060002054018360016000526000602001526040600020556000527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a3600160005260206000f35b60006000fd5b60005433146100ed5760006000fd5b600435600060243582819060016000526000602001526040600020540183600160005260006020015260406000205580600254016002556000527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a35b600435600160005260006020015260406000205460005260206000f35b60025460005260206000f35b602435600435336000526000602001526040600020555b60243560043560005260006020015260406000205460005260206000f3"; + let expected_bytecode = "335f5561019980600d3d393df35f3560e01c8063a9059cbb1461004757806340c10f19146100d757806370a082311461014157806318160ddd1461015c578063095ea7b314610166578063dd62ed3e1461017d575b600435336024358160016000526000602001526040600020548082116100d3578190038260016000526000602001526040600020558281906001600052600060200152604060002054018360016000526000602001526040600020555f527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205fa360015f5260205ff35b5f5ffd5b5f5433146100e3575f5ffd5b6004355f60243582819060016000526000602001526040600020540183600160005260006020015260406000205580600254016002555f527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205fa35b60043560016000526000602001526040600020545f5260205ff35b6002545f5260205ff35b602435600435336000526000602001526040600020555b6024356004356000526000602001526040600020545f5260205ff3"; assert_eq!(artifact.bytecode.to_lowercase(), expected_bytecode.to_lowercase()); })); @@ -138,7 +138,7 @@ fn erc20_compilation_benchmark(c: &mut Criterion) { cg.churn(file_source.clone(), vec![], &main_bytecode, &constructor_bytecode, has_custom_bootstrap).unwrap(); // Full expected bytecode output (generated from huff-neo) - let expected_bytecode = "336000556101ac80600e3d393df360003560e01c8063a9059cbb1461004857806340c10f19146100de57806370a082311461014e57806318160ddd1461016b578063095ea7b314610177578063dd62ed3e1461018e575b600435336024358160016000526000602001526040600020548082116100d8578190038260016000526000602001526040600020558281906001600052600060200152604060002054018360016000526000602001526040600020556000527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a3600160005260206000f35b60006000fd5b60005433146100ed5760006000fd5b600435600060243582819060016000526000602001526040600020540183600160005260006020015260406000205580600254016002556000527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a35b600435600160005260006020015260406000205460005260206000f35b60025460005260206000f35b602435600435336000526000602001526040600020555b60243560043560005260006020015260406000205460005260206000f3"; + let expected_bytecode = "335f5561019980600d3d393df35f3560e01c8063a9059cbb1461004757806340c10f19146100d757806370a082311461014157806318160ddd1461015c578063095ea7b314610166578063dd62ed3e1461017d575b600435336024358160016000526000602001526040600020548082116100d3578190038260016000526000602001526040600020558281906001600052600060200152604060002054018360016000526000602001526040600020555f527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205fa360015f5260205ff35b5f5ffd5b5f5433146100e3575f5ffd5b6004355f60243582819060016000526000602001526040600020540183600160005260006020015260406000205580600254016002555f527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205fa35b60043560016000526000602001526040600020545f5260205ff35b6002545f5260205ff35b602435600435336000526000602001526040600020555b6024356004356000526000602001526040600020545f5260205ff3"; assert_eq!(artifact.bytecode.to_lowercase(), expected_bytecode.to_lowercase()); })); @@ -185,7 +185,7 @@ fn erc721_compilation_benchmark(c: &mut Criterion) { cg.churn(file_source.clone(), vec![], &main_bytecode, &constructor_bytecode, has_custom_bootstrap).unwrap(); // Full expected bytecode output (generated from huff-neo) - let expected_bytecode = "336000556103b180600e3d393df360003560e01c8063a9059cbb146100a057806342842e0e146101a3578063b88d4fde146101a9578063095ea7b31461027b578063a22cb46514610310578063081812fc146102f357806340c10f19146101af57806370a082311461025e5780636352211e1461039457806306fdde031461035e57806395d89b4114610364578063c87b56dd1461036a57806301ffc9a714610370578063e985e9c514610376575b6044356024356004358083600160005260006020015260406000205491146100c75761019d565b8033146101005733816000526000602001526040600020546101005782600260005260006020015260406000205433146101005761019d565b6001816003600052600060200152604060002054038160036000526000602001526040600020558160036000526000602001526040600020546001018260036000526000602001526040600020558183600160005260006020015260406000205560008360026000526000602001526040600020557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60206000a4005b60006000fd5b60006000fd5b60006000fd5b60005433146101be5760006000fd5b6024356004356000826001600052600060200152604060002054156101e257610258565b8160036000526000602001526040600020546001018260036000526000602001526040600020558183600160005260006020015260406000205560008360026000526000602001526040600020557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60006000a4005b60006000fd5b600435600360005260006020015260406000205460005260206000f35b6024358060016000526000602001526040600020548033143382600052600060200152604060002054176102ae576102ed565b60043580836002600052600060200152604060002055907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560006000a4005b60006000fd5b600435600260005260006020015260406000205460005260206000f35b60243560043533600052600060200152604060002055600435336024356000527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160006000a4005b60006000fd5b60006000fd5b60006000fd5b60006000fd5b60006000fd5b60243560043560005260006020015260406000205460005260206000f35b600435600160005260006020015260406000205460005260206000f3"; + let expected_bytecode = "335f5561038680600d3d393df35f3560e01c8063a9059cbb1461009f57806342842e0e1461019e578063b88d4fde146101a2578063095ea7b314610267578063a22cb465146102f6578063081812fc146102db57806340c10f19146101a657806370a082311461024c5780636352211e1461036b57806306fdde031461033f57806395d89b4114610343578063c87b56dd1461034757806301ffc9a71461034b578063e985e9c51461034f575b6044356024356004358083600160005260006020015260406000205491146100c65761019a565b8033146100ff5733816000526000602001526040600020546100ff5782600260005260006020015260406000205433146100ff5761019a565b600181600360005260006020015260406000205403816003600052600060200152604060002055816003600052600060200152604060002054600101826003600052600060200152604060002055818360016000526000602001526040600020555f8360026000526000602001526040600020557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205fa4005b5f5ffd5b5f5ffd5b5f5ffd5b5f5433146101b2575f5ffd5b6024356004355f826001600052600060200152604060002054156101d557610248565b816003600052600060200152604060002054600101826003600052600060200152604060002055818360016000526000602001526040600020555f8360026000526000602001526040600020557fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f5fa4005b5f5ffd5b60043560036000526000602001526040600020545f5260205ff35b60243580600160005260006020015260406000205480331433826000526000602001526040600020541761029a576102d7565b60043580836002600052600060200152604060002055907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f5fa4005b5f5ffd5b60043560026000526000602001526040600020545f5260205ff35b60243560043533600052600060200152604060002055600435336024355f527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c315f5fa4005b5f5ffd5b5f5ffd5b5f5ffd5b5f5ffd5b5f5ffd5b6024356004356000526000602001526040600020545f5260205ff35b60043560016000526000602001526040600020545f5260205ff3"; assert_eq!(artifact.bytecode.to_lowercase(), expected_bytecode.to_lowercase()); })); diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 9a24ff3..d0dc4fc 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -3,7 +3,7 @@ #![warn(unused_extern_crates)] #![forbid(unsafe_code)] -use ethers_core::utils::hex; +use alloy_primitives::hex; use huff_neo_codegen::*; use huff_neo_lexer::*; use huff_neo_parser::*; @@ -206,7 +206,7 @@ impl<'a, 'l> Compiler<'a, 'l> { // Get our constructor arguments as a hex encoded string to compare to the cache let inputs = self.get_constructor_args(); let encoded_inputs = Codegen::encode_constructor_args(inputs); - let encoded: Vec> = encoded_inputs.iter().map(|tok| ethers_core::abi::encode(&[tok.clone()])).collect(); + let encoded: Vec> = encoded_inputs.iter().map(|tok| tok.abi_encode()).collect(); let constructor_args = encoded.iter().map(|tok| hex::encode(tok.as_slice())).collect(); // Get Cached or Generate Artifacts diff --git a/crates/core/tests/compiling.rs b/crates/core/tests/compiling.rs index 566537a..ad85252 100644 --- a/crates/core/tests/compiling.rs +++ b/crates/core/tests/compiling.rs @@ -1,9 +1,9 @@ -use std::sync::Arc; - +use alloy_dyn_abi::DynSolValue; use huff_neo_codegen::*; use huff_neo_lexer::*; use huff_neo_parser::*; use huff_neo_utils::prelude::*; +use std::sync::Arc; const SOURCE: &str = r#" /* Storage */ @@ -86,7 +86,7 @@ fn compiles_runtime_bytecode() { assert_eq!(cbytes, String::from("335f55")); assert!(!cbootstrap); - let inputs: Vec = vec![]; + let inputs: Vec = vec![]; // ERC20 Bytecode let main_bytecode = "5f3560e01c8063a9059cbb1461004757806340c10f19146100d757806370a082311461014157806318160ddd1461015c578063095ea7b314610166578063dd62ed3e1461017d575b600435336024358160016000526000602001526040600020548082116100d3578190038260016000526000602001526040600020558281906001600052600060200152604060002054018360016000526000602001526040600020555f527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205fa360015f5260205ff35b5f5ffd5b5f5433146100e3575f5ffd5b6004355f60243582819060016000526000602001526040600020540183600160005260006020015260406000205580600254016002555f527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60205fa35b60043560016000526000602001526040600020545f5260205ff35b6002545f5260205ff35b602435600435336000526000602001526040600020555b6024356004356000526000602001526040600020545f5260205ff3"; diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 8a29b92..685ab3c 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -11,12 +11,11 @@ Lexical Analysis Crate for the Huff-Language keywords = ["bytecode", "compiler", "evm", "huff", "rust"] [dependencies] +alloy-dyn-abi.workspace = true +alloy-primitives.workspace = true cfg-if.workspace = true -codemap-diagnostic.workspace = true -ethers-core.workspace = true itertools.workspace = true lazy_static.workspace = true -pathdiff.workspace = true phf.workspace = true regex.workspace = true serde.workspace = true diff --git a/crates/utils/src/types.rs b/crates/utils/src/types.rs index f5d62b5..98ef1bf 100644 --- a/crates/utils/src/types.rs +++ b/crates/utils/src/types.rs @@ -1,5 +1,6 @@ use crate::bytes_util::*; -use ethers_core::abi::{ethereum_types::*, token::*, Tokenizable}; +use alloy_dyn_abi::{DynSolValue, Word}; +use alloy_primitives::{Address, I256, U256}; use lazy_static::lazy_static; use regex::Regex; use std::{fmt, str::FromStr}; @@ -106,7 +107,7 @@ lazy_static! { /// Wrap ether-rs Token to allow to derive the TryFrom trait #[derive(Clone)] -pub struct EToken(pub Token); +pub struct EToken(pub DynSolValue); impl TryFrom for EToken { type Error = String; @@ -120,12 +121,12 @@ impl TryFrom for EToken { // could be either address or fixed bytes // if length is 42, assume it's an address match input.len() { - 42 => return Ok(EToken(Token::Address(H160::from_str(cleaned_input).map_err(|e| e.to_string())?))), - _ => return Ok(EToken(Token::FixedBytes(str_to_bytes32(cleaned_input).to_vec()))), + 42 => return Ok(EToken(DynSolValue::Address(Address::from_str(cleaned_input).map_err(|e| e.to_string())?))), + _ => return Ok(EToken(DynSolValue::FixedBytes(Word::from(&str_to_bytes32(cleaned_input)), 32))), } } else { // dyn bytes array - return Ok(EToken(Token::Bytes(str_to_vec(cleaned_input).map_err(|e| e.to_string())?))); + return Ok(EToken(DynSolValue::Bytes(str_to_vec(cleaned_input).map_err(|e| e.to_string())?))); } } // array @@ -133,26 +134,26 @@ impl TryFrom for EToken { let trimmed_input = input.trim_start_matches('[').trim_end_matches(']'); let v: Vec = trimmed_input.split(',').map(|x| x.replace([' ', '"', '\''], "")).collect(); let etokens: Result, _> = v.iter().map(|x| EToken::try_from(x.to_owned())).collect(); - let tokens: Vec = etokens?.iter().map(move |x| x.clone().0).collect(); - return Ok(EToken(Token::Array(tokens))); + let tokens: Vec = etokens?.iter().map(move |x| x.clone().0).collect(); + return Ok(EToken(DynSolValue::Array(tokens))); } if input.starts_with('-') || input.starts_with('+') { - return Ok(EToken(input.parse::().map_err(|e| e.to_string())?.into_token())); + return Ok(EToken(DynSolValue::Int(I256::from_str(&input).map_err(|e| e.to_string())?, 256))); } if input == "true" || input == "false" { - return Ok(EToken(Token::Bool(input == "true"))); + return Ok(EToken(DynSolValue::Bool(input == "true"))); } if input.chars().all(|x| x.is_ascii_digit()) { - return Ok(EToken(Token::Uint(U256::from_str_radix(input.as_str(), 10).map_err(|e| e.to_string())?))); + return Ok(EToken(DynSolValue::Uint(U256::from_str_radix(input.as_str(), 10).map_err(|e| e.to_string())?, 256))); } if input.chars().all(|x| x.is_alphanumeric()) { - Ok(EToken(Token::String(input))) + Ok(EToken(DynSolValue::String(input))) } else if input.contains(',') { // Try to unwrap something like "100,0x123,20" without brackets let e_tokens: Result, _> = input.split(',').map(|x| x.replace([' ', '"', '\''], "")).map(EToken::try_from).collect(); - let tokens: Vec = e_tokens?.into_iter().map(|x| x.0).collect(); - Ok(EToken(Token::Array(tokens))) + let tokens: Vec = e_tokens?.into_iter().map(|x| x.0).collect(); + Ok(EToken(DynSolValue::Array(tokens))) } else { Err(format!("Invalid input: {input}")) }