diff --git a/.gitignore b/.gitignore index 0500924..2a299be 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ reports # IntelliJ IDEA .idea + +# Gomu gomu reports +report.json diff --git a/Cargo.lock b/Cargo.lock index 21e6633..57ea35f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" @@ -101,70 +101,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ark-ff" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" -dependencies = [ - "ark-ff-asm", - "ark-ff-macros", - "ark-serialize", - "ark-std", - "derivative", - "digest", - "itertools 0.10.5", - "num-bigint", - "num-traits", - "paste", - "rustc_version", - "zeroize", -] - -[[package]] -name = "ark-ff-asm" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-macros" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-serialize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" -dependencies = [ - "ark-std", - "digest", - "num-bigint", -] - -[[package]] -name = "ark-std" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" -dependencies = [ - "num-traits", - "rand", -] - [[package]] name = "arrayvec" version = "0.7.4" @@ -227,12 +163,6 @@ dependencies = [ "rustc-demangle", ] -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.7" @@ -240,16 +170,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] -name = "bigdecimal" -version = "0.3.1" +name = "base64" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6773ddc0eafc0e509fb60e48dff7f450f8e674a0686ae8605e8d9901bd5eefa" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", - "serde", -] +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bitflags" @@ -354,9 +278,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -364,9 +288,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -376,9 +300,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -667,17 +591,6 @@ dependencies = [ "serde", ] -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -725,29 +638,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "humantime", - "log", -] - [[package]] name = "equivalent" version = "1.0.1" @@ -901,9 +791,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -916,9 +806,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -926,15 +816,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -943,15 +833,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -960,21 +850,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -997,17 +887,17 @@ dependencies = [ "config", "crossbeam-queue", "dotenvy", - "env_logger", "futures", "goose", "lazy_static", - "log", "rand", "serde", "serde_json", "starknet", "sysinfo", "tokio", + "tracing", + "tracing-subscriber", "url", ] @@ -1054,7 +944,7 @@ dependencies = [ "futures", "gumdrop", "http", - "itertools 0.11.0", + "itertools", "lazy_static", "log", "num-format", @@ -1196,12 +1086,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "hyper" version = "0.14.28" @@ -1365,6 +1249,7 @@ checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.5", + "serde", ] [[package]] @@ -1388,15 +1273,6 @@ version = "1.70.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.11.0" @@ -1441,11 +1317,33 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "lambdaworks-crypto" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbc2a4da0d9e52ccfe6306801a112e81a8fc0c76aa3e4449fefeda7fef72bb34" +dependencies = [ + "lambdaworks-math", + "serde", + "sha2", + "sha3", +] + +[[package]] +name = "lambdaworks-math" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1bd2632acbd9957afc5aeec07ad39f078ae38656654043bf16e046fa2730e23" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" @@ -1510,13 +1408,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.11" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1577,6 +1476,16 @@ dependencies = [ "winapi", ] +[[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-bigint" version = "0.4.5" @@ -1621,16 +1530,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "num_threads" version = "0.1.7" @@ -1709,6 +1608,12 @@ dependencies = [ "hashbrown 0.13.2", ] +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "owo-colors" version = "3.5.0" @@ -1764,12 +1669,6 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "paste" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" - [[package]] name = "pathdiff" version = "0.2.1" @@ -2133,15 +2032,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "rustix" version = "0.38.34" @@ -2267,26 +2157,20 @@ dependencies = [ "libc", ] -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - [[package]] name = "serde" -version = "1.0.202" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.202" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -2295,12 +2179,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "indexmap 2.2.6", "itoa", + "memchr", "ryu", "serde", ] @@ -2339,15 +2224,17 @@ dependencies = [ [[package]] name = "serde_with" -version = "2.3.3" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" dependencies = [ - "base64 0.13.1", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", + "indexmap 2.2.6", "serde", + "serde_derive", "serde_json", "serde_with_macros", "time", @@ -2355,9 +2242,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "2.3.3" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ "darling", "proc-macro2", @@ -2462,14 +2349,14 @@ dependencies = [ [[package]] name = "starknet" -version = "0.10.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0c9ac3809cc7630784e8c8565fa3013af819d83c97aa2720d566016d439011" dependencies = [ "starknet-accounts", "starknet-contract", "starknet-core", "starknet-crypto", - "starknet-ff", "starknet-macros", "starknet-providers", "starknet-signers", @@ -2477,12 +2364,14 @@ dependencies = [ [[package]] name = "starknet-accounts" -version = "0.9.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee27ded58ade61da410fccafd57ed5429b0e79a9d62a4ae8b65818cb9d6f400" dependencies = [ "async-trait", "auto_impl", "starknet-core", + "starknet-crypto", "starknet-providers", "starknet-signers", "thiserror", @@ -2490,8 +2379,9 @@ dependencies = [ [[package]] name = "starknet-contract" -version = "0.9.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6ee5762d24c4f06ab7e9406550925df406712e73719bd2de905c879c674a87" dependencies = [ "serde", "serde_json", @@ -2504,10 +2394,12 @@ dependencies = [ [[package]] name = "starknet-core" -version = "0.10.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538240cbe6663c673fe77465f294da707080f39678dd7066761554899e46100" dependencies = [ "base64 0.21.7", + "crypto-bigint", "flate2", "hex", "serde", @@ -2516,13 +2408,14 @@ dependencies = [ "serde_with", "sha3", "starknet-crypto", - "starknet-ff", + "starknet-types-core", ] [[package]] name = "starknet-crypto" -version = "0.6.2" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a5064173a8e8d2675e67744fd07f310de44573924b6b7af225a6bdd8102913" dependencies = [ "crypto-bigint", "hex", @@ -2532,48 +2425,25 @@ dependencies = [ "num-traits", "rfc6979", "sha2", - "starknet-crypto-codegen", "starknet-curve", - "starknet-ff", + "starknet-types-core", "zeroize", ] -[[package]] -name = "starknet-crypto-codegen" -version = "0.3.3" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" -dependencies = [ - "starknet-curve", - "starknet-ff", - "syn 2.0.65", -] - [[package]] name = "starknet-curve" -version = "0.4.2" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" -dependencies = [ - "starknet-ff", -] - -[[package]] -name = "starknet-ff" -version = "0.3.7" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcde6bd74269b8161948190ace6cf069ef20ac6e79cd2ba09b320efa7500b6de" dependencies = [ - "ark-ff", - "bigdecimal", - "crypto-bigint", - "getrandom", - "hex", - "num-bigint", - "serde", + "starknet-types-core", ] [[package]] name = "starknet-macros" -version = "0.1.7" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8986a940af916fc0a034f4e42c6ba76d94f1e97216d75447693dfd7aefaf3ef2" dependencies = [ "starknet-core", "syn 2.0.65", @@ -2581,13 +2451,15 @@ dependencies = [ [[package]] name = "starknet-providers" -version = "0.10.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e8e69ba7a36dea2d28333be82b4011f8784333d3ae5618482b6587c1ffb66c" dependencies = [ "async-trait", "auto_impl", "ethereum-types", "flate2", + "getrandom", "log", "reqwest", "serde", @@ -2600,19 +2472,35 @@ dependencies = [ [[package]] name = "starknet-signers" -version = "0.8.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs.git?rev=2d59636911628260fa460179010bbd00e89de06e#2d59636911628260fa460179010bbd00e89de06e" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70b9e01b61ae51d722e2b100d6ef913c5a2e70d1ea672733d385f7296d6055ef" dependencies = [ "async-trait", "auto_impl", "crypto-bigint", "eth-keystore", + "getrandom", "rand", "starknet-core", "starknet-crypto", "thiserror", ] +[[package]] +name = "starknet-types-core" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa1b9e01ccb217ab6d475c5cda05dbb22c30029f7bb52b192a010a00d77a3d74" +dependencies = [ + "lambdaworks-crypto", + "lambdaworks-math", + "num-bigint", + "num-integer", + "num-traits", + "serde", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -2680,9 +2568,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sysinfo" -version = "0.30.12" +version = "0.30.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732ffa00f53e6b2af46208fba5718d9662a421049204e156328b66791ffa15ae" +checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3" dependencies = [ "cfg-if", "core-foundation-sys", @@ -2830,28 +2718,27 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -2961,9 +2848,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.65", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -2984,15 +2883,29 @@ dependencies = [ "tracing-subscriber", ] +[[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]] name = "tracing-subscriber" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "nu-ansi-term", "sharded-slab", + "smallvec", "thread_local", "tracing-core", + "tracing-log", ] [[package]] @@ -3079,9 +2992,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna 0.5.0", @@ -3465,17 +3378,3 @@ name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.65", -] diff --git a/Cargo.toml b/Cargo.toml index 9710116..a145a74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,26 +13,23 @@ description = "Gomu Gomu No Gatling is a blazing fast tool to benchmark Starknet opt-level = 3 [dependencies] -# Starknet dependencies, currently the same starknet revision as the one in -# madara https://github.com/keep-starknet-strange/madara/blob/main/Cargo.toml#L268 -starknet = { git = "https://github.com/xJonathanLEI/starknet-rs.git", rev = "2d59636911628260fa460179010bbd00e89de06e" } - -goose = "0.17.2" -env_logger = "0.11.3" -log = "0.4.21" -tokio = { version = "1", features = ["full"] } -futures = "0.3" -clap = { version = "4.5.4", features = ["derive"] } +clap = { version = "4.5.20", features = ["derive"] } color-eyre = "0.6.3" config = "0.14.0" +crossbeam-queue = "0.3.11" dotenvy = "0.15.7" -serde = { version = "1.0.202", features = ["derive"] } -serde_json = { version = "1.0.117", features = ["preserve_order"] } -url = "2.5.0" +futures = "0.3.31" +goose = "0.17.2" +lazy_static = "1.5.0" rand = { version = "0.8.5", features = ["rand_chacha"] } -lazy_static = "1.4.0" +serde = { version = "1.0.210", features = ["derive"] } +serde_json = { version = "1.0.128", features = ["preserve_order"] } +starknet = "0.12.0" sysinfo = "0.30.12" -crossbeam-queue = "0.3.11" +tokio = { version = "1.40", features = ["full"] } +tracing = "0.1.40" +tracing-subscriber = "0.3.18" +url = "2.5.2" [features] default = [] diff --git a/config/devnet.madara.yaml b/config/devnet.madara.yaml new file mode 100644 index 0000000..3106e5c --- /dev/null +++ b/config/devnet.madara.yaml @@ -0,0 +1,38 @@ +rpc: + url: "http://127.0.0.1:9944" + +setup: + erc20_contract: + v0: contracts/v0/ERC20.json + + erc721_contract: + v0: contracts/v0/ERC721.json + + account_contract: + v0: contracts/v0/OpenzeppelinAccount.json + + fee_token_address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7" + chain_id: "MADARA_DEVNET" + +run: + concurrency: 5 + shooters: + - name: "transfer" + shoot: 10000 + - name: "mint" + shoot: 10000 + read_benches: + - name: "Get Events" + num_requests: 100 + method: "starknet_getEvents" + parameters_location: "config/read_params/get_events.json" + +report: + num_blocks: 4 + output_location: "report" + +deployer: + salt: "0x42" + address: "0x021ae26856dbb24032cac6bba14a776741331dc031f0dc43efb5f333e6a64da2" + signing_key: "0x077e56c6dc32d40a67f6f7e6625c8dc5e570abe49c0a24e9202e4ae906abcc07" + legacy_account: false diff --git a/config/read_params/get_events.json b/config/read_params/get_events.json index 59beec5..f87329d 100644 --- a/config/read_params/get_events.json +++ b/config/read_params/get_events.json @@ -5,6 +5,6 @@ "address": null, "keys": [], "continuation_token": null, - "chunk_size": 10 + "chunk_size": 1 } ] diff --git a/src/actions/goose.rs b/src/actions/goose.rs index ec59d11..12401eb 100644 --- a/src/actions/goose.rs +++ b/src/actions/goose.rs @@ -12,14 +12,16 @@ use crossbeam_queue::ArrayQueue; use goose::{config::GooseConfiguration, metrics::GooseRequestMetric, prelude::*}; use rand::prelude::SliceRandom; use serde::{de::DeserializeOwned, Serialize}; -use starknet::core::types::{SequencerTransactionStatus, TransactionReceipt, TransactionStatus}; use starknet::{ - accounts::{ - Account, Call, ConnectedAccount, ExecutionEncoder, RawExecution, SingleOwnerAccount, + accounts::RawExecutionV1, + core::types::{ + Call, SequencerTransactionStatus, TransactionReceiptWithBlockInfo, TransactionStatus, }, +}; +use starknet::{ + accounts::{Account, ConnectedAccount, ExecutionEncoder, SingleOwnerAccount}, core::types::{ - BroadcastedInvokeTransaction, BroadcastedInvokeTransactionV1, ExecutionResult, - FieldElement, MaybePendingTransactionReceipt, + BroadcastedInvokeTransaction, BroadcastedInvokeTransactionV1, ExecutionResult, Felt, }, providers::{ jsonrpc::{HttpTransport, JsonRpcError, JsonRpcMethod, JsonRpcResponse}, @@ -52,7 +54,7 @@ pub fn make_goose_config( // If these are not equal that means user_iterations was truncated if total_transactions != amount { - log::warn!("Number of {name} is not evenly divisble by concurrency, doing {total_transactions} calls instead"); + tracing::warn!("Number of {name} is not evenly divisble by concurrency, doing {total_transactions} calls instead"); } Ok({ @@ -67,8 +69,8 @@ pub fn make_goose_config( #[derive(Debug, Clone)] pub struct GooseWriteUserState { pub account: StarknetAccount, - pub nonce: FieldElement, - pub prev_tx: Vec, + pub nonce: Felt, + pub prev_tx: Vec, } impl GooseWriteUserState { @@ -202,17 +204,15 @@ pub async fn verify_transactions( } SequencerTransactionStatus::AcceptedOnL1 | SequencerTransactionStatus::AcceptedOnL2 => { if index == 0 || index == transactions.len() - 1 { - let (receipt, mut metrics) = send_request::( + let (tx, mut metrics) = send_request::( user, JsonRpcMethod::GetTransactionReceipt, tx, ) .await?; - let block_number = match receipt { - MaybePendingTransactionReceipt::Receipt(TransactionReceipt::Invoke( - receipt, - )) => receipt.block_number, - _ => { + let block_number = match tx.block.block_number() { + Some(block_number) => block_number, + None => { return user.set_failure( "Receipt is not of type InvokeTransactionReceipt or is Pending", &mut metrics, @@ -242,7 +242,7 @@ const WAIT_FOR_TX_TIMEOUT: Duration = Duration::from_secs(600); /// This function is different then `crate::utils::wait_for_tx` due to it using the goose requester pub async fn wait_for_tx_with_goose( user: &mut GooseUser, - tx_hash: FieldElement, + tx_hash: Felt, ) -> Result<(), Box> { let start = SystemTime::now(); @@ -261,7 +261,7 @@ pub async fn wait_for_tx_with_goose( match receipt { JsonRpcResponse::Success { - result: MaybePendingTransactionReceipt::Receipt(receipt), + result: TransactionReceiptWithBlockInfo { receipt, block: _ }, .. } => match receipt.execution_result() { ExecutionResult::Succeeded => { @@ -276,21 +276,6 @@ pub async fn wait_for_tx_with_goose( ); } }, - JsonRpcResponse::Success { - result: MaybePendingTransactionReceipt::PendingReceipt(pending), - .. - } => { - if let ExecutionResult::Reverted { reason } = pending.execution_result() { - return user.set_failure( - &(reverted_tag() + reason), - &mut metric, - None, - Some(reason), - ); - } - log::debug!("Waiting for transaction {tx_hash:#064x} to be accepted"); - tokio::time::sleep(CHECK_INTERVAL).await; - } JsonRpcResponse::Error { error: JsonRpcError { @@ -299,7 +284,7 @@ pub async fn wait_for_tx_with_goose( }, .. } => { - log::debug!("Waiting for transaction {tx_hash:#064x} to show up"); + tracing::debug!("Waiting for transaction {tx_hash:#064x} to show up"); tokio::time::sleep(CHECK_INTERVAL).await; } JsonRpcResponse::Error { @@ -307,7 +292,6 @@ pub async fn wait_for_tx_with_goose( .. } => { let tag = format!("Error Code {code} while waiting for tx {tx_hash:#064x}"); - return user.set_failure(&tag, &mut metric, None, Some(&message)); } } @@ -318,7 +302,7 @@ pub async fn wait_for_tx_with_goose( pub async fn send_execution( user: &mut GooseUser, calls: Vec, - nonce: FieldElement, + nonce: Felt, from_account: &SingleOwnerAccount>, LocalWallet>, method: JsonRpcMethod, ) -> Result<(T, GooseRequestMetric), Box> { @@ -327,8 +311,8 @@ pub async fn send_execution( #[allow(dead_code)] // Removes warning for unused fields, we need them to properly transmute struct FakeRawExecution { calls: Vec, - nonce: FieldElement, - max_fee: FieldElement, + nonce: Felt, + max_fee: Felt, } let raw_exec = FakeRawExecution { @@ -339,14 +323,14 @@ pub async fn send_execution( // TODO: We cannot right now construct RawExecution directly and need to use this hack // see https://github.com/xJonathanLEI/starknet-rs/issues/538 - let raw_exec = unsafe { mem::transmute::(raw_exec) }; + let raw_exec = unsafe { mem::transmute::(raw_exec) }; let param = BroadcastedInvokeTransaction::V1(BroadcastedInvokeTransactionV1 { sender_address: from_account.address(), calldata, max_fee: MAX_FEE, signature: from_account - .sign_execution(&raw_exec, false) + .sign_execution_v1(&raw_exec, false) .await .expect("Raw Execution should be correctly constructed for signature"), nonce, @@ -386,7 +370,7 @@ pub async fn raw_send_request( method: JsonRpcMethod, param: impl Serialize, ) -> Result<(JsonRpcResponse, GooseRequestMetric), Box> { - // Copied from https://docs.rs/starknet-providers/0.9.0/src/starknet_providers/jsonrpc/transports/http.rs.html#21-27 + // Copied from https://docs.rs/starknet-providers/0.12.0/src/starknet_providers/jsonrpc/transports/http.rs.html#21-27 #[derive(Debug, Serialize)] struct JsonRpcRequest { id: u64, diff --git a/src/actions/mod.rs b/src/actions/mod.rs index 1585b04..e75c74e 100644 --- a/src/actions/mod.rs +++ b/src/actions/mod.rs @@ -1,7 +1,7 @@ use std::{fs::File, mem, sync::Arc}; use color_eyre::eyre::bail; -use log::info; +use tracing::info; use crate::{ config::GatlingConfig, @@ -35,7 +35,7 @@ pub async fn shoot(mut config: GatlingConfig) -> color_eyre::Result<()> { for shooter in shooters { if shooter.shoot == 0 { - log::info!("Skipping {} transfers", shooter.name); + tracing::info!("Skipping {} transfers", shooter.name); continue; } @@ -66,7 +66,7 @@ pub async fn shoot(mut config: GatlingConfig) -> color_eyre::Result<()> { global_report.all_bench_report = Some(all_bench_report); if let Err(error) = rpc_result { - log::error!("Failed to get block range: {error}") + tracing::error!("Failed to get block range: {error}") } } @@ -105,7 +105,7 @@ async fn make_report_over_shooter( let num_blocks = setup.config().report.num_blocks; if let Err(error) = rpc_result { - log::error!("Failed to get block range: {error}") + tracing::error!("Failed to get block range: {error}") } else if num_blocks != 0 { report .with_last_x_blocks(setup.rpc_client(), num_blocks) diff --git a/src/actions/setup.rs b/src/actions/setup.rs index e6a581d..fa88b00 100644 --- a/src/actions/setup.rs +++ b/src/actions/setup.rs @@ -7,18 +7,18 @@ use color_eyre::{ Result, }; -use log::{debug, info, warn}; use starknet::core::types::contract::SierraClass; +use starknet::core::types::Call; use tokio::task::JoinSet; use std::path::Path; use starknet::accounts::{ - Account, AccountFactory, Call, ConnectedAccount, ExecutionEncoding, OpenZeppelinAccountFactory, + Account, AccountFactory, ConnectedAccount, ExecutionEncoding, OpenZeppelinAccountFactory, SingleOwnerAccount, }; use starknet::core::types::{ - contract::legacy::LegacyContractClass, BlockId, BlockTag, FieldElement, StarknetError, + contract::legacy::LegacyContractClass, BlockId, BlockTag, Felt, StarknetError, }; use starknet::macros::{felt, selector}; use starknet::providers::ProviderError; @@ -30,7 +30,7 @@ use std::time::Duration; use url::Url; // Used to bypass validation -pub static MAX_FEE: FieldElement = felt!("0x6efb28c75a0000"); +pub static MAX_FEE: Felt = felt!("0x6efb28c75a0000"); pub static CHECK_INTERVAL: Duration = Duration::from_millis(500); pub type StarknetAccount = SingleOwnerAccount>, LocalWallet>; @@ -39,7 +39,7 @@ pub struct GatlingSetup { config: GatlingConfig, starknet_rpc: Arc>, signer: LocalWallet, - account: StarknetAccount, + deployer: StarknetAccount, accounts: Vec, } @@ -49,8 +49,7 @@ impl GatlingSetup { Arc::new(starknet_rpc_provider(Url::parse(&config.clone().rpc.url)?)); let signer = LocalWallet::from(SigningKey::from_secret_scalar(config.deployer.signing_key)); - - let account = SingleOwnerAccount::new( + let mut deployer = SingleOwnerAccount::new( starknet_rpc.clone(), signer.clone(), config.deployer.address, @@ -61,12 +60,13 @@ impl GatlingSetup { ExecutionEncoding::New }, ); + deployer.set_block_id(BlockId::Tag(BlockTag::Pending)); Ok(Self { config, starknet_rpc, signer, - account, + deployer, accounts: vec![], }) } @@ -80,7 +80,7 @@ impl GatlingSetup { } pub fn deployer_account(&self) -> &StarknetAccount { - &self.account + &self.deployer } pub fn accounts(&self) -> &[StarknetAccount] { @@ -113,13 +113,13 @@ impl GatlingSetup { pub async fn transfer( &self, - contract_address: FieldElement, - account: StarknetAccount, - recipient: FieldElement, - amount: FieldElement, - nonce: FieldElement, - ) -> Result { - transfer(account, nonce, amount, contract_address, recipient).await + contract_address: Felt, + deployer: StarknetAccount, + recipient: Felt, + amount: Felt, + nonce: Felt, + ) -> Result { + transfer(deployer, nonce, amount, contract_address, recipient).await } /// Create accounts. @@ -129,30 +129,23 @@ impl GatlingSetup { /// * `class_hash` - The class hash of the account contract. /// * `num_accounts` - The number of accounts to create. /// * `execution_encoding` - Execution encoding to use, `Legacy` for Cairo Zero and `New` for Cairo - /// * `erc20_address` - The address of the ERC20 contract to use for funding the accounts. /// /// # Returns /// /// A vector of the created accounts. async fn create_accounts<'a>( &mut self, - class_hash: FieldElement, + class_hash: Felt, num_accounts: usize, execution_encoding: ExecutionEncoding, ) -> Result> { - info!("Creating {} accounts", num_accounts); + tracing::info!("Creating {} accounts", num_accounts); + let mut nonce = self.deployer.get_nonce().await?; let mut deployed_accounts: Vec = Vec::with_capacity(num_accounts); - let mut nonce = self.account.get_nonce().await?; - let mut deployment_joinset = JoinSet::new(); - for i in 0..num_accounts { - self.account.set_block_id(BlockId::Tag(BlockTag::Pending)); - - let fee_token_address = self.config.setup.fee_token_address; - // TODO: Check if OpenZepplinAccountFactory could be used with other type of accounts ? or should we require users to use OpenZepplinAccountFactory ? let signer = self.signer.clone(); let provider = self.starknet_rpc.clone(); @@ -164,11 +157,11 @@ impl GatlingSetup { ) .await?; - let salt = self.config.deployer.salt + FieldElement::from(i); + let salt = self.config.deployer.salt + Felt::from(i); - let deploy = account_factory.deploy(salt).max_fee(MAX_FEE); + let deploy = account_factory.deploy_v1(salt).max_fee(MAX_FEE); let address = deploy.address(); - info!("Deploying account {i} with salt {salt} at address {address:#064x}"); + tracing::info!("Deploying account {i} with salt {salt} at address {address:#064x}"); if let Ok(account_class_hash) = self .starknet_rpc @@ -176,52 +169,53 @@ impl GatlingSetup { .await { if account_class_hash == class_hash { - warn!("Account {i} already deployed at address {address:#064x}"); - let account = SingleOwnerAccount::new( + tracing::warn!("Account {i} already deployed at address {address:#064x}"); + let mut already_deployed_account = SingleOwnerAccount::new( self.starknet_rpc.clone(), signer.clone(), address, self.config.setup.chain_id, execution_encoding, ); - deployed_accounts.push(account); + already_deployed_account.set_block_id(BlockId::Tag(BlockTag::Pending)); + deployed_accounts.push(already_deployed_account); continue; } else { bail!("Account {i} already deployed at address {address:#064x} with a different class hash {account_class_hash:#064x}, expected {class_hash:#064x}"); } } + let fee_token_address = self.config.setup.fee_token_address; let tx_hash = self .transfer( fee_token_address, - self.account.clone(), + self.deployer.clone(), address, - felt!("0xFFFFFFFFFFFFFFFFFFFF"), + felt!("0xFFFFFFFFFFFFFFF"), nonce, ) .await?; - nonce += FieldElement::ONE; + nonce += Felt::ONE; wait_for_tx(&self.starknet_rpc, tx_hash, CHECK_INTERVAL).await?; let result = deploy.send().await?; - let account = SingleOwnerAccount::new( + let mut new_account = SingleOwnerAccount::new( self.starknet_rpc.clone(), signer.clone(), result.contract_address, self.config.setup.chain_id, execution_encoding, ); - - deployed_accounts.push(account); + new_account.set_block_id(BlockId::Tag(BlockTag::Pending)); + deployed_accounts.push(new_account); let starknet_rpc = self.starknet_rpc.clone(); - deployment_joinset.spawn(async move { wait_for_tx(&starknet_rpc, result.transaction_hash, CHECK_INTERVAL).await }); - info!("Account {i} deployed at address {address:#064x}"); + tracing::info!("Account {i} deployed at address {address:#064x}"); } while let Some(result) = deployment_joinset.join_next().await { @@ -231,14 +225,14 @@ impl GatlingSetup { Ok(deployed_accounts) } - async fn check_already_declared(&self, class_hash: FieldElement) -> Result { + async fn check_already_declared(&self, class_hash: Felt) -> Result { match self .starknet_rpc .get_class(BlockId::Tag(BlockTag::Pending), class_hash) .await { Ok(_) => { - warn!("Contract already declared at {class_hash:#064x}"); + tracing::warn!("Contract already declared at {class_hash:#064x}"); Ok(true) } Err(ProviderError::StarknetError(StarknetError::ClassHashNotFound)) => Ok(false), @@ -249,8 +243,8 @@ impl GatlingSetup { async fn declare_contract_legacy<'a>( &mut self, contract_path: impl AsRef, - ) -> Result { - info!( + ) -> Result { + tracing::info!( "Declaring contract from path {}", contract_path.as_ref().display() ); @@ -262,11 +256,9 @@ impl GatlingSetup { return Ok(class_hash); } - self.account.set_block_id(BlockId::Tag(BlockTag::Pending)); - let nonce = self.account.get_nonce().await?; - + let nonce = self.deployer.get_nonce().await?; let tx_resp = self - .account + .deployer .declare_legacy(Arc::new(contract_artifact)) .max_fee(MAX_FEE) .nonce(nonce) @@ -276,7 +268,7 @@ impl GatlingSetup { wait_for_tx(&self.starknet_rpc, tx_resp.transaction_hash, CHECK_INTERVAL).await?; - info!( + tracing::info!( "Contract declared successfully at {:#064x}", tx_resp.class_hash ); @@ -287,34 +279,32 @@ impl GatlingSetup { async fn declare_contract_v1<'a>( &mut self, contract_path: impl AsRef, - casm_class_hash: FieldElement, - ) -> Result { + casm_class_hash: Felt, + ) -> Result { let file = std::fs::File::open(contract_path.as_ref())?; let contract_artifact: SierraClass = serde_json::from_reader(file)?; let class_hash = contract_artifact.class_hash()?; // Sierra class artifact. Output of the `starknet-compile` command - info!( + tracing::info!( "Declaring contract v1 from path {} with class hash {:#064x}", contract_path.as_ref().display(), class_hash ); - let nonce = self.account.get_nonce().await?; + let nonce = self.deployer.get_nonce().await?; if self.check_already_declared(class_hash).await? { return Ok(class_hash); } - // `SingleOwnerAccount` defaults to checking nonce and estimating fees against the latest - // block. Optionally change the target block to pending with the following line: - self.account.set_block_id(BlockId::Tag(BlockTag::Pending)); + self.deployer.set_block_id(BlockId::Tag(BlockTag::Pending)); // We need to flatten the ABI into a string first let flattened_class = contract_artifact.flatten()?; let tx_resp = self - .account - .declare(Arc::new(flattened_class), casm_class_hash) + .deployer + .declare_v2(Arc::new(flattened_class), casm_class_hash) .max_fee(MAX_FEE) .nonce(nonce) .send() @@ -323,7 +313,7 @@ impl GatlingSetup { wait_for_tx(&self.starknet_rpc, tx_resp.transaction_hash, CHECK_INTERVAL).await?; - info!( + tracing::info!( "Contract declared successfully at {:#064x}", tx_resp.class_hash ); @@ -334,7 +324,7 @@ impl GatlingSetup { pub async fn declare_contract( &mut self, contract_source: &crate::config::ContractSourceConfig, - ) -> Result { + ) -> Result { match contract_source { ContractSourceConfig::V0(path) => self.declare_contract_legacy(&path).await, ContractSourceConfig::V1(config) => { @@ -347,15 +337,15 @@ impl GatlingSetup { pub async fn transfer( account: StarknetAccount, - nonce: FieldElement, - amount: FieldElement, - contract_address: FieldElement, - recipient: FieldElement, -) -> color_eyre::Result { + nonce: Felt, + amount: Felt, + contract_address: Felt, + recipient: Felt, +) -> color_eyre::Result { let from_address = account.address(); - debug!( - "Transferring {amount} of {contract_address:#064x} from address {from_address:#064x} to address {recipient:#064x} with nonce={}", + tracing::info!( + "Transfering {amount} of {contract_address:#064x} from address {from_address:#064x} to address {recipient:#064x} with nonce={}", nonce, ); @@ -368,7 +358,7 @@ pub async fn transfer( }; let result = account - .execute(vec![call]) + .execute_v1(vec![call]) .max_fee(MAX_FEE) .nonce(nonce) .send() diff --git a/src/actions/shooters.rs b/src/actions/shooters.rs index 9b35c98..7e51b2f 100644 --- a/src/actions/shooters.rs +++ b/src/actions/shooters.rs @@ -8,8 +8,7 @@ use goose::{ GooseAttack, }; use starknet::{ - accounts::Call, - core::types::{FieldElement, InvokeTransactionResult}, + core::types::{Call, Felt, InvokeTransactionResult}, providers::jsonrpc::JsonRpcMethod, }; @@ -134,7 +133,7 @@ pub trait Shooter { "Should be successful as we already asserted that the session data is a GooseUserState", ); - *nonce += FieldElement::ONE; + *nonce += Felt::ONE; prev_tx.push(response.transaction_hash); diff --git a/src/actions/shooters/mint.rs b/src/actions/shooters/mint.rs index 1c099c6..4056321 100644 --- a/src/actions/shooters/mint.rs +++ b/src/actions/shooters/mint.rs @@ -1,11 +1,13 @@ use std::{collections::HashMap, sync::Arc}; use color_eyre::eyre::bail; -use log::{debug, info, warn}; use starknet::{ - accounts::{Account, Call, ConnectedAccount}, + accounts::{Account, ConnectedAccount}, contract::ContractFactory, - core::types::{BlockId, BlockTag, FieldElement}, + core::{ + types::{BlockId, BlockTag, Call, Felt}, + utils::{get_udc_deployed_address, UdcUniqueness}, + }, macros::{felt, selector}, providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}, }; @@ -14,13 +16,14 @@ use tokio::task::JoinSet; use crate::{ actions::setup::{GatlingSetup, StarknetAccount, CHECK_INTERVAL, MAX_FEE}, generators::get_rng, - utils::{compute_contract_address, wait_for_tx}, + utils::wait_for_tx, }; use super::Shooter; pub struct MintShooter { - pub account_to_erc721_addresses: HashMap, + pub account_to_erc721_addresses: HashMap, + #[allow(unused)] pub recipient: StarknetAccount, } @@ -76,47 +79,53 @@ impl Shooter for MintShooter { impl MintShooter { async fn deploy_erc721( starknet_rpc: Arc>, - deployer_salt: FieldElement, - class_hash: FieldElement, + deployer_salt: Felt, + class_hash: Felt, recipient: StarknetAccount, - ) -> color_eyre::Result { + ) -> color_eyre::Result { let contract_factory = ContractFactory::new(class_hash, &recipient); let name = selector!("TestNFT"); let symbol = selector!("TNFT"); let constructor_args = vec![name, symbol, recipient.address()]; - let unique = false; - let address = compute_contract_address(deployer_salt, class_hash, &constructor_args); + let udc_uniqueness = UdcUniqueness::NotUnique; + let unique = matches!(udc_uniqueness, UdcUniqueness::Unique(_)); + let address = get_udc_deployed_address( + deployer_salt, + class_hash, + &UdcUniqueness::NotUnique, + &constructor_args, + ); if let Ok(contract_class_hash) = starknet_rpc .get_class_hash_at(BlockId::Tag(BlockTag::Pending), address) .await { if contract_class_hash == class_hash { - warn!("ERC721 contract already deployed at address {address:#064x}"); + tracing::warn!("ERC721 contract already deployed at address {address:#064x}"); return Ok(address); } else { bail!("ERC721 contract {address:#064x} already deployed with a different class hash {contract_class_hash:#064x}, expected {class_hash:#064x}"); } } - let deploy = contract_factory.deploy(constructor_args, deployer_salt, unique); + let deploy = contract_factory.deploy_v1(constructor_args, deployer_salt, unique); let nonce = recipient.get_nonce().await?; - info!("Deploying ERC721 with nonce={}, address={address}", nonce); + tracing::info!("Deploying ERC721 with nonce={}, address={address}", nonce); let result = deploy.nonce(nonce).max_fee(MAX_FEE).send().await?; wait_for_tx(&starknet_rpc, result.transaction_hash, CHECK_INTERVAL).await?; - debug!( + tracing::info!( "Deploy ERC721 transaction accepted {:#064x}", result.transaction_hash ); - info!("ERC721 contract deployed at address {:#064x}", address); + tracing::info!("ERC721 contract deployed at address {:#064x}", address); Ok(address) } } diff --git a/src/actions/shooters/transfer.rs b/src/actions/shooters/transfer.rs index baccab2..37e3013 100644 --- a/src/actions/shooters/transfer.rs +++ b/src/actions/shooters/transfer.rs @@ -1,9 +1,11 @@ use color_eyre::eyre::bail; -use log::{debug, info, warn}; use starknet::{ - accounts::{Account, Call, ConnectedAccount}, + accounts::{Account, ConnectedAccount}, contract::ContractFactory, - core::types::{BlockId, BlockTag, FieldElement}, + core::{ + types::{BlockId, BlockTag, Call, Felt}, + utils::{get_udc_deployed_address, UdcUniqueness}, + }, macros::{felt, selector}, providers::Provider, }; @@ -11,13 +13,14 @@ use tokio::task::JoinSet; use crate::{ actions::setup::{self, GatlingSetup, StarknetAccount, CHECK_INTERVAL, MAX_FEE}, - utils::{compute_contract_address, wait_for_tx}, + utils::wait_for_tx, }; use super::Shooter; pub struct TransferShooter { - pub erc20_address: FieldElement, + pub erc20_address: Felt, + #[allow(unused)] pub account: StarknetAccount, } @@ -50,10 +53,16 @@ impl Shooter for TransferShooter { initial_supply_high, recipient, ]; - let unique = false; - let address = - compute_contract_address(setup.config().deployer.salt, class_hash, &constructor_args); + let deployer = setup.config().deployer.clone(); + let udc_uniqueness = UdcUniqueness::NotUnique; + let unique = matches!(udc_uniqueness, UdcUniqueness::Unique(_)); + let address = get_udc_deployed_address( + deployer.salt, + class_hash, + &UdcUniqueness::NotUnique, + &constructor_args, + ); if let Ok(contract_class_hash) = setup .rpc_client() @@ -61,7 +70,7 @@ impl Shooter for TransferShooter { .await { if contract_class_hash == class_hash { - warn!("ERC20 contract already deployed at address {address:#064x}"); + tracing::warn!("ERC20 contract already deployed at address {address:#064x}"); return Ok(TransferShooter { erc20_address: address, account: setup.deployer_account().clone(), @@ -72,28 +81,29 @@ impl Shooter for TransferShooter { } let deploy = - contract_factory.deploy(constructor_args, setup.config().deployer.salt, unique); + contract_factory.deploy_v1(constructor_args, setup.config().deployer.salt, unique); - info!( + tracing::info!( "Deploying ERC20 contract with nonce={}, address={:#064x}", - nonce, address + nonce, + address ); let result = deploy.nonce(nonce).max_fee(MAX_FEE).send().await?; - nonce += FieldElement::ONE; + nonce += Felt::ONE; wait_for_tx(setup.rpc_client(), result.transaction_hash, CHECK_INTERVAL).await?; - debug!( + tracing::info!( "Deploy ERC20 transaction accepted {:#064x}", result.transaction_hash ); - info!("ERC20 contract deployed at address {:#064x}", address); + tracing::info!("ERC20 contract deployed at address {:#064x}", address); let mut joinset = JoinSet::new(); for account in setup.accounts() { - info!("Funding account at address {address:#064x}"); + tracing::info!("Funding account at address {address:#064x}"); let tx_hash = setup::transfer( setup.deployer_account().clone(), @@ -104,7 +114,7 @@ impl Shooter for TransferShooter { ) .await?; - nonce += FieldElement::ONE; + nonce += Felt::ONE; let rpc_client = setup.rpc_client().clone(); joinset.spawn(async move { wait_for_tx(&rpc_client, tx_hash, CHECK_INTERVAL).await }); } @@ -120,17 +130,8 @@ impl Shooter for TransferShooter { } fn get_execution_data(&self, _account: &StarknetAccount) -> Call { + const VOID_ADDRESS: Felt = felt!("0xdead"); let (amount_low, amount_high) = (felt!("1"), felt!("0")); - - // Hex: 0xdead - // from_hex_be isn't const whereas from_mont is - const VOID_ADDRESS: FieldElement = FieldElement::from_mont([ - 18446744073707727457, - 18446744073709551615, - 18446744073709551615, - 576460752272412784, - ]); - Call { to: self.erc20_address, selector: selector!("transfer"), diff --git a/src/config.rs b/src/config.rs index cbb0e4b..55e5676 100644 --- a/src/config.rs +++ b/src/config.rs @@ -12,7 +12,7 @@ use serde::{de::Error as DeError, Deserializer}; use serde_json::{Map, Value}; use starknet::{ core::{ - types::{contract::CompiledClass, FieldElement}, + types::{contract::CompiledClass, Felt}, utils::{cairo_short_string_to_felt, CairoShortStringToFeltError}, }, providers::jsonrpc::JsonRpcMethod, @@ -54,7 +54,7 @@ pub struct ContractSourceConfigV1 { } impl ContractSourceConfigV1 { - pub fn get_casm_hash(&self) -> Result { + pub fn get_casm_hash(&self) -> Result { let mut casm_file = std::fs::File::open(&self.casm_path)?; let casm_class = serde_json::from_reader::<_, CompiledClass>(&mut casm_file)?; let casm_hash = casm_class.class_hash()?; @@ -77,7 +77,7 @@ impl ContractSourceConfig { } } - pub fn get_casm_hash(&self) -> Result> { + pub fn get_casm_hash(&self) -> Result> { if let ContractSourceConfig::V1(config) = self { let mut casm_file = std::fs::File::open(&config.casm_path)?; let casm_class = serde_json::from_reader::<_, CompiledClass>(&mut casm_file)?; @@ -94,16 +94,16 @@ pub struct SetupConfig { pub erc20_contract: ContractSourceConfig, pub erc721_contract: ContractSourceConfig, pub account_contract: ContractSourceConfig, - pub fee_token_address: FieldElement, + pub fee_token_address: Felt, #[serde(deserialize_with = "from_str_deserializer")] - pub chain_id: FieldElement, + pub chain_id: Felt, } #[derive(Debug, Deserialize, Clone)] pub struct DeployerConfig { - pub salt: FieldElement, - pub address: FieldElement, - pub signing_key: FieldElement, + pub salt: Felt, + pub address: Felt, + pub signing_key: Felt, pub legacy_account: bool, } @@ -165,15 +165,11 @@ fn base_config_builder() -> ConfigBuilder { .add_source(config::Environment::with_prefix("gatling")) } -fn from_str_deserializer<'de, D>(deserializer: D) -> Result +fn from_str_deserializer<'de, D>(deserializer: D) -> Result where D: serde::Deserializer<'de>, { - // Deserialize a string using the deserializer. let s = String::deserialize(deserializer)?; - - // Use your custom function to try to create a FieldElement from the string. - // If there's an error, use the Error::custom method to convert it into a Serde error. cairo_short_string_to_felt(&s).map_err(|e| match e { CairoShortStringToFeltError::NonAsciiCharacter => D::Error::custom("non ascii character"), CairoShortStringToFeltError::StringTooLong => D::Error::custom("string too long"), diff --git a/src/generators/mod.rs b/src/generators/mod.rs index 03d0a55..ca2ec40 100644 --- a/src/generators/mod.rs +++ b/src/generators/mod.rs @@ -1,14 +1,14 @@ use rand::Rng; use starknet::{ - core::types::FieldElement, + core::types::Felt, signers::{LocalWallet, SigningKey}, }; /// generate random number for testing -pub fn get_rng() -> FieldElement { +pub fn get_rng() -> Felt { let mut rng = rand::thread_rng(); - FieldElement::from(rng.gen::()) + Felt::from(rng.gen::()) } pub fn generate_stark_keys() -> LocalWallet { diff --git a/src/main.rs b/src/main.rs index 87d8fbc..f8a583e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -#[macro_use] -extern crate log; use clap::Parser; use color_eyre::eyre::Result; use dotenvy::dotenv; @@ -9,10 +7,21 @@ use gatling::{ config::GatlingConfig, }; +pub fn setup_tracing() { + tracing_subscriber::fmt() + .with_max_level(tracing::Level::INFO) + .compact() + .with_file(false) + .with_line_number(true) + .with_thread_ids(false) + .with_target(false) + .init(); +} + #[tokio::main(flavor = "multi_thread", worker_threads = 10)] async fn main() -> Result<()> { // Initialize the logger. - env_logger::init(); + setup_tracing(); // Initialize the error handler. color_eyre::install()?; @@ -20,7 +29,7 @@ async fn main() -> Result<()> { // Load the environment variables from the .env file. dotenv().ok(); - info!("Starting Gatling..."); + tracing::info!("🔫 Starting Gatling..."); // Parse the command line arguments. let cli = Cli::parse(); diff --git a/src/metrics.rs b/src/metrics.rs index 5352742..8829e10 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -306,7 +306,7 @@ pub fn compute_node_metrics( let total_steps: u64 = blocks_with_txs .iter() .flat_map(|(_, r)| r) - .map(|resource| resource.steps) + .map(|resource| resource.computation_resources.steps) .sum(); metrics.push(MetricResult { diff --git a/src/utils.rs b/src/utils.rs index 0e941bb..c318a84 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -5,14 +5,12 @@ use std::time::SystemTime; use color_eyre::eyre::{bail, OptionExt}; use color_eyre::{eyre::eyre, Result}; use lazy_static::lazy_static; -use log::debug; -use starknet::core::types::MaybePendingTransactionReceipt::{PendingReceipt, Receipt}; +use starknet::core::types::Felt; use starknet::core::types::{ - BlockId, BlockWithTxs, ExecutionResources, ExecutionResult, MaybePendingBlockWithTxs, - StarknetError, + BlockId, BlockWithTxs, ComputationResources, DataAvailabilityResources, DataResources, + ExecutionResources, ExecutionResult, MaybePendingBlockWithTxs, StarknetError, }; -use starknet::core::{crypto::compute_hash_on_elements, types::FieldElement}; use starknet::providers::ProviderError; use starknet::providers::{jsonrpc::HttpTransport, JsonRpcClient, Provider}; use tokio::task::JoinSet; @@ -24,37 +22,6 @@ lazy_static! { pub static ref SYSINFO: SysInfo = SysInfo::new(); } -/// Cairo string for "STARKNET_CONTRACT_ADDRESS" -const PREFIX_CONTRACT_ADDRESS: FieldElement = FieldElement::from_mont([ - 3829237882463328880, - 17289941567720117366, - 8635008616843941496, - 533439743893157637, -]); - -/// 2 ** 251 - 256 -const ADDR_BOUND: FieldElement = FieldElement::from_mont([ - 18446743986131443745, - 160989183, - 18446744073709255680, - 576459263475590224, -]); - -// Copied from starknet-rs since it's not public -pub fn compute_contract_address( - salt: FieldElement, - class_hash: FieldElement, - constructor_calldata: &[FieldElement], -) -> FieldElement { - compute_hash_on_elements(&[ - PREFIX_CONTRACT_ADDRESS, - FieldElement::ZERO, - salt, - class_hash, - compute_hash_on_elements(constructor_calldata), - ]) % ADDR_BOUND -} - #[derive(Debug, Clone)] pub struct SysInfo { pub os_name: String, @@ -112,7 +79,7 @@ const WAIT_FOR_TX_TIMEOUT: Duration = Duration::from_secs(60); pub async fn wait_for_tx( provider: &JsonRpcClient, - tx_hash: FieldElement, + tx_hash: Felt, check_interval: Duration, ) -> Result<()> { let start = SystemTime::now(); @@ -125,7 +92,7 @@ pub async fn wait_for_tx( } match provider.get_transaction_receipt(tx_hash).await { - Ok(Receipt(receipt)) => match receipt.execution_result() { + Ok(tx) => match tx.receipt.execution_result() { ExecutionResult::Succeeded => { return Ok(()); } @@ -135,17 +102,8 @@ pub async fn wait_for_tx( ))); } }, - Ok(PendingReceipt(pending)) => { - if let ExecutionResult::Reverted { reason } = pending.execution_result() { - return Err(eyre!(format!( - "Transaction {tx_hash:#064x} has been rejected/reverted: {reason}" - ))); - } - debug!("Waiting for transaction {tx_hash:#064x} to be accepted"); - tokio::time::sleep(check_interval).await; - } Err(ProviderError::StarknetError(StarknetError::TransactionHashNotFound)) => { - debug!("Waiting for transaction {tx_hash:#064x} to show up"); + tracing::debug!("Waiting for transaction {tx_hash:#064x} to show up"); tokio::time::sleep(check_interval).await; } Err(err) => { @@ -230,16 +188,24 @@ pub async fn get_blocks_with_txs( #[cfg(not(with_sps))] for _ in block_with_txs.transactions.iter() { resources.push(ExecutionResources { - steps: 0, - memory_holes: None, - range_check_builtin_applications: None, - pedersen_builtin_applications: None, - poseidon_builtin_applications: None, - ec_op_builtin_applications: None, - ecdsa_builtin_applications: None, - bitwise_builtin_applications: None, - keccak_builtin_applications: None, - segment_arena_builtin: None, + computation_resources: ComputationResources { + steps: 0, + memory_holes: None, + range_check_builtin_applications: None, + pedersen_builtin_applications: None, + poseidon_builtin_applications: None, + ec_op_builtin_applications: None, + ecdsa_builtin_applications: None, + bitwise_builtin_applications: None, + keccak_builtin_applications: None, + segment_arena_builtin: None, + }, + data_resources: DataResources { + data_availability: DataAvailabilityResources { + l1_data_gas: 0, + l1_gas: 0, + }, + }, }); } diff --git a/taplo/README.md b/taplo/README.md new file mode 100644 index 0000000..0d097bf --- /dev/null +++ b/taplo/README.md @@ -0,0 +1,49 @@ +# Taplo + +[Taplo](https://github.com/tamasfe/taplo) is a TOML validator and formatter. It +provides a command-line interface (CLI) for working with TOML files. + +## Installation + +You can install Taplo using either cargo or Yarn or NPM. + +### Cargo + +```bash +cargo install taplo-cli --locked +``` + +### Yarn + +```bash +yarn global add @taplo/cli +``` + +### NPM + +```bash +npm install -g @taplo/cli +``` + +### Usage + +To check your TOML files for formatting issues, use the following command: + +```bash +npx @taplo/cli fmt --config taplo.toml --check +``` + +To format all TOML files in your project, use the following command: + +```bash +npx @taplo/cli fmt --config taplo.toml +``` + +This command will automatically format the TOML files, ensuring consistent and +readable formatting. + +### Configuration + +Taplo allows you to customize the formatting rules by adding configuration +options. You can find the available options and how to use them +[here](https://taplo.tamasfe.dev/configuration/formatter-options.html). diff --git a/taplo/taplo.toml b/taplo/taplo.toml new file mode 100644 index 0000000..e49b662 --- /dev/null +++ b/taplo/taplo.toml @@ -0,0 +1,11 @@ +include = ["**/*.toml"] +exclude = ["**/bad.toml"] + +[formatting] +align_entries = false + +[[rule]] +keys = ["dependencies"] + +[rule.formatting] +reorder_keys = true