diff --git a/Cargo.lock b/Cargo.lock index 6edf82c8e..e252bf27e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,6 +89,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if 1.0.0", + "const-random", "getrandom 0.2.12", "once_cell", "version_check", @@ -142,9 +143,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" [[package]] name = "alloy-chains" -version = "0.1.15" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96c81b05c893348760f232c4cc6a6a77fd91cfb09885d4eaad25cd03bd7732e" +checksum = "cd47e5f8545bdf53beb545d3c039b4afa16040bdf69c50100581579b08776afd" dependencies = [ "num_enum 0.7.2", "serde", @@ -697,6 +698,15 @@ dependencies = [ "serde", ] +[[package]] +name = "argminmax" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52424b59d69d69d5056d508b260553afd91c57e21849579cd1f50ee8b8b88eaa" +dependencies = [ + "num-traits", +] + [[package]] name = "ark-bls12-381" version = "0.4.0" @@ -979,6 +989,12 @@ dependencies = [ "rayon", ] +[[package]] +name = "array-init-cursor" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7d0a018de4f6aa429b9d33d69edf69072b1c5b1cb8d3e4a5f7ef898fc3eb76" + [[package]] name = "arrayref" version = "0.3.7" @@ -997,6 +1013,99 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "arrow-array" +version = "52.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d33238427c60271710695f17742f45b1a5dc5bcfc5c15331c25ddfe7abf70d97" +dependencies = [ + "ahash 0.8.11", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "chrono", + "half 2.4.0", + "hashbrown 0.14.3", + "num 0.4.1", +] + +[[package]] +name = "arrow-buffer" +version = "52.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9b95e825ae838efaf77e366c00d3fc8cca78134c9db497d6bda425f2e7b7c1" +dependencies = [ + "bytes", + "half 2.4.0", + "num 0.4.1", +] + +[[package]] +name = "arrow-cast" +version = "52.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cf8385a9d5b5fcde771661dd07652b79b9139fea66193eda6a88664400ccab" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "arrow-select", + "atoi", + "base64 0.22.0", + "chrono", + "half 2.4.0", + "lexical-core", + "num 0.4.1", + "ryu", +] + +[[package]] +name = "arrow-data" +version = "52.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb29be98f987bcf217b070512bb7afba2f65180858bca462edf4a39d84a23e10" +dependencies = [ + "arrow-buffer", + "arrow-schema", + "half 2.4.0", + "num 0.4.1", +] + +[[package]] +name = "arrow-ipc" +version = "52.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc68f6523970aa6f7ce1dc9a33a7d9284cfb9af77d4ad3e617dbe5d79cc6ec8" +dependencies = [ + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-data", + "arrow-schema", + "flatbuffers", +] + +[[package]] +name = "arrow-schema" +version = "52.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32aae6a60458a2389c0da89c9de0b7932427776127da1a738e2efc21d32f3393" + +[[package]] +name = "arrow-select" +version = "52.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de36abaef8767b4220d7b4a8c2fe5ffc78b47db81b03d77e2136091c3ba39102" +dependencies = [ + "ahash 0.8.11", + "arrow-array", + "arrow-buffer", + "arrow-data", + "arrow-schema", + "num 0.4.1", +] + [[package]] name = "as-slice" version = "0.1.5" @@ -1091,7 +1200,7 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "942c7cd7ae39e91bde4820d74132e9862e62c2f386c3aa90ccf55949f5bad63a" dependencies = [ - "brotli", + "brotli 3.5.0", "flate2", "futures-core", "memchr", @@ -1191,6 +1300,21 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ce4f10ea3abcd6617873bae9f91d1c5332b4a778bd9ce34d0cd517474c1de82" +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atoi_simd" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae037714f313c1353189ead58ef9eec30a8e8dc101b2622d461418fd59e28a9" + [[package]] name = "atomic" version = "0.6.0" @@ -2126,7 +2250,18 @@ checksum = "d640d25bc63c50fb1f0b545ffd80207d2e10a4c965530809b40ba3386825c391" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", - "brotli-decompressor", + "brotli-decompressor 2.5.1", +] + +[[package]] +name = "brotli" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor 4.0.1", ] [[package]] @@ -2139,6 +2274,16 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "brotli-decompressor" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a45bd2e4095a8b518033b128020dd4a55aab1c0a381ba4404a472630f4bc362" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + [[package]] name = "bs58" version = "0.4.0" @@ -2243,6 +2388,20 @@ name = "bytemuck" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee891b04274a59bd38b412188e24b849617b2e45a0fd8d057deb63e7403761b" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 2.0.57", +] [[package]] name = "byteorder" @@ -2977,6 +3136,26 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.12", + "once_cell", + "tiny-keccak", +] + [[package]] name = "const-str" version = "0.5.7" @@ -3143,6 +3322,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-queue" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-utils" version = "0.8.19" @@ -4018,9 +4206,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elliptic-curve" @@ -4674,6 +4862,28 @@ dependencies = [ "rand 0.7.3", ] +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] +name = "fancy-regex" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +dependencies = [ + "bit-set", + "regex", +] + +[[package]] +name = "fast-float" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" + [[package]] name = "fastcrypto" version = "0.1.5" @@ -4901,6 +5111,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "flatbuffers" +version = "24.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8add37afff2d4ffa83bc748a70b4b1370984f6980768554182424ef71447c35f" +dependencies = [ + "bitflags 1.3.2", + "rustc_version 0.4.0", +] + [[package]] name = "flate2" version = "1.0.28" @@ -4941,6 +5161,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "foreign_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee1b05cbd864bcaecbd3455d6d967862d446e4ebfc3c2e5e5b9841e53cba6673" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -5726,6 +5952,7 @@ checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" dependencies = [ "cfg-if 1.0.0", "crunchy", + "num-traits", ] [[package]] @@ -5778,6 +6005,7 @@ checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ "ahash 0.8.11", "allocator-api2", + "rayon", "serde", ] @@ -6508,6 +6736,12 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +[[package]] +name = "itoap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" + [[package]] name = "ityfuzz" version = "0.1.0" @@ -6524,6 +6758,7 @@ dependencies = [ "either", "ethers", "evmole", + "eyre", "foundry-cheatcodes", "glob", "handlebars", @@ -6540,7 +6775,11 @@ dependencies = [ "nix 0.27.1", "num_cpus", "once_cell", + "parquet", "permutator", + "polars", + "polars-core", + "polars-utils", "primitive-types 0.12.2", "rand 0.8.5", "regex", @@ -6891,6 +7130,70 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +[[package]] +name = "lexical-core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" +dependencies = [ + "lexical-parse-float", + "lexical-parse-integer", + "lexical-util", + "lexical-write-float", + "lexical-write-integer", +] + +[[package]] +name = "lexical-parse-float" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" +dependencies = [ + "lexical-parse-integer", + "lexical-util", + "static_assertions", +] + +[[package]] +name = "lexical-parse-integer" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" +dependencies = [ + "lexical-util", + "static_assertions", +] + +[[package]] +name = "lexical-util" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" +dependencies = [ + "static_assertions", +] + +[[package]] +name = "lexical-write-float" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" +dependencies = [ + "lexical-util", + "lexical-write-integer", + "static_assertions", +] + +[[package]] +name = "lexical-write-integer" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" +dependencies = [ + "lexical-util", + "static_assertions", +] + [[package]] name = "libafl" version = "0.11.2" @@ -6922,7 +7225,7 @@ dependencies = [ "typed-builder", "uuid 1.8.0", "wait-timeout", - "windows", + "windows 0.51.1", ] [[package]] @@ -6952,7 +7255,7 @@ dependencies = [ "tuple_list", "uds", "uuid 1.8.0", - "windows", + "windows 0.51.1", "xxhash-rust", ] @@ -7120,16 +7423,35 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "lz4" +version = "1.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6eab492fe7f8651add23237ea56dbf11b3c4ff762ab83d40a47f11433421f91" +dependencies = [ + "libc", + "lz4-sys", +] + [[package]] name = "lz4-sys" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +checksum = "e9764018d143cc854c9f17f0b907de70f14393b1f502da6375dce70f00514eb3" dependencies = [ "cc", "libc", ] +[[package]] +name = "lz4_flex" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" +dependencies = [ + "twox-hash", +] + [[package]] name = "mach" version = "0.3.2" @@ -7218,6 +7540,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" +dependencies = [ + "libc", +] + [[package]] name = "memmap2" version = "0.9.4" @@ -8294,6 +8625,28 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +[[package]] +name = "multiversion" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4851161a11d3ad0bf9402d90ffc3967bf231768bfd7aeb61755ad06dbf1a142" +dependencies = [ + "multiversion-macros", + "target-features", +] + +[[package]] +name = "multiversion-macros" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79a74ddee9e0c27d2578323c13905793e91622148f138ba29738f9dddb835e90" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 1.0.109", + "target-features", +] + [[package]] name = "mysten-metrics" version = "0.7.0" @@ -8602,6 +8955,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" +[[package]] +name = "now" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d89e9874397a1f0a52fc1f197a8effd9735223cb2390e9dcc83ac6cd02923d0" +dependencies = [ + "chrono", +] + [[package]] name = "ntapi" version = "0.3.7" @@ -8998,6 +9360,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + [[package]] name = "os_info" version = "3.8.2" @@ -9235,17 +9606,56 @@ dependencies = [ ] [[package]] -name = "parse-zoneinfo" -version = "0.3.0" +name = "parquet" +version = "52.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" +checksum = "29c3b5322cc1bbf67f11c079c42be41a55949099b78732f7dba9e15edde40eab" dependencies = [ - "regex", -] - -[[package]] -name = "password-hash" -version = "0.4.2" + "ahash 0.8.11", + "arrow-array", + "arrow-buffer", + "arrow-cast", + "arrow-data", + "arrow-ipc", + "arrow-schema", + "arrow-select", + "base64 0.22.0", + "brotli 6.0.0", + "bytes", + "chrono", + "flate2", + "half 2.4.0", + "hashbrown 0.14.3", + "lz4_flex", + "num 0.4.1", + "num-bigint 0.4.4", + "paste", + "seq-macro", + "snap", + "thrift", + "twox-hash", + "zstd 0.13.0", + "zstd-sys", +] + +[[package]] +name = "parquet-format-safe" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1131c54b167dd4e4799ce762e1ab01549ebb94d5bdd13e6ec1b467491c378e1f" + +[[package]] +name = "parse-zoneinfo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" +dependencies = [ + "regex", +] + +[[package]] +name = "password-hash" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" dependencies = [ @@ -9586,6 +9996,15 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "planus" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1691dd09e82f428ce8d6310bd6d5da2557c82ff17694d2a32cad7242aea89f" +dependencies = [ + "array-init-cursor", +] + [[package]] name = "plotters" version = "0.3.5" @@ -9614,6 +10033,380 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "polars" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e148396dca5496566880fa19374f3f789a29db94e3eb458afac1497b4bac5442" +dependencies = [ + "getrandom 0.2.12", + "polars-arrow", + "polars-core", + "polars-error", + "polars-io", + "polars-lazy", + "polars-ops", + "polars-parquet", + "polars-sql", + "polars-time", + "polars-utils", + "version_check", +] + +[[package]] +name = "polars-arrow" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cb5e11cd0752ae022fa6ca3afa50a14b0301b7ce53c0135828fbb0f4fa8303e" +dependencies = [ + "ahash 0.8.11", + "atoi", + "atoi_simd", + "bytemuck", + "chrono", + "chrono-tz 0.8.6", + "dyn-clone", + "either", + "ethnum", + "fast-float", + "foreign_vec", + "getrandom 0.2.12", + "hashbrown 0.14.3", + "itoa", + "itoap", + "lz4", + "multiversion", + "num-traits", + "polars-arrow-format", + "polars-error", + "polars-utils", + "ryu", + "simdutf8", + "streaming-iterator", + "strength_reduce", + "version_check", + "zstd 0.13.0", +] + +[[package]] +name = "polars-arrow-format" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b0ef2474af9396b19025b189d96e992311e6a47f90c53cd998b36c4c64b84c" +dependencies = [ + "planus", + "serde", +] + +[[package]] +name = "polars-compute" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89fc4578f826234cdecb782952aa9c479dc49373f81694a7b439c70b6f609ba0" +dependencies = [ + "bytemuck", + "either", + "num-traits", + "polars-arrow", + "polars-error", + "polars-utils", + "strength_reduce", + "version_check", +] + +[[package]] +name = "polars-core" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e490c6bace1366a558feea33d1846f749a8ca90bd72a6748752bc65bb4710b2a" +dependencies = [ + "ahash 0.8.11", + "bitflags 2.5.0", + "bytemuck", + "chrono", + "chrono-tz 0.8.6", + "comfy-table 7.1.0", + "either", + "hashbrown 0.14.3", + "indexmap 2.2.6", + "num-traits", + "once_cell", + "polars-arrow", + "polars-compute", + "polars-error", + "polars-row", + "polars-utils", + "rand 0.8.5", + "rand_distr", + "rayon", + "regex", + "smartstring", + "thiserror", + "version_check", + "xxhash-rust", +] + +[[package]] +name = "polars-error" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08888f58e61599b00f5ea0c2ccdc796b54b9859559cc0d4582733509451fa01a" +dependencies = [ + "polars-arrow-format", + "regex", + "simdutf8", + "thiserror", +] + +[[package]] +name = "polars-expr" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4173591920fe56ad55af025f92eb0d08421ca85705c326a640c43856094e3484" +dependencies = [ + "ahash 0.8.11", + "bitflags 2.5.0", + "once_cell", + "polars-arrow", + "polars-core", + "polars-io", + "polars-ops", + "polars-plan", + "polars-time", + "polars-utils", + "rayon", + "smartstring", +] + +[[package]] +name = "polars-io" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5842896aea46d975b425d63f156f412aed3cfde4c257b64fb1f43ceea288074e" +dependencies = [ + "ahash 0.8.11", + "atoi_simd", + "bytes", + "chrono", + "fast-float", + "home", + "itoa", + "memchr", + "memmap2 0.7.1", + "num-traits", + "once_cell", + "percent-encoding", + "polars-arrow", + "polars-core", + "polars-error", + "polars-time", + "polars-utils", + "rayon", + "regex", + "ryu", + "simdutf8", + "smartstring", +] + +[[package]] +name = "polars-lazy" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e805ea2ebbc6b7749b0afb31b7fc5d32b42b57ba29b984549d43d3a16114c4a5" +dependencies = [ + "ahash 0.8.11", + "bitflags 2.5.0", + "glob", + "once_cell", + "polars-arrow", + "polars-core", + "polars-expr", + "polars-io", + "polars-ops", + "polars-pipe", + "polars-plan", + "polars-time", + "polars-utils", + "rayon", + "smartstring", + "version_check", +] + +[[package]] +name = "polars-ops" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0aed7e169c81b98457641cf82b251f52239a668916c2e683abd1f38df00d58" +dependencies = [ + "ahash 0.8.11", + "argminmax", + "base64 0.22.0", + "bytemuck", + "chrono", + "chrono-tz 0.8.6", + "either", + "hashbrown 0.14.3", + "hex", + "indexmap 2.2.6", + "memchr", + "num-traits", + "polars-arrow", + "polars-compute", + "polars-core", + "polars-error", + "polars-utils", + "rayon", + "regex", + "smartstring", + "unicode-reverse", + "version_check", +] + +[[package]] +name = "polars-parquet" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c70670a9e51cac66d0e77fd20b5cc957dbcf9f2660d410633862bb72f846d5b8" +dependencies = [ + "ahash 0.8.11", + "base64 0.22.0", + "ethnum", + "num-traits", + "parquet-format-safe", + "polars-arrow", + "polars-error", + "polars-utils", + "seq-macro", + "simdutf8", + "streaming-decompression", +] + +[[package]] +name = "polars-pipe" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a40ae1b3c74ee07e2d1f7cbf56c5d6e15969e45d9b6f0903bd2acaf783ba436" +dependencies = [ + "crossbeam-channel", + "crossbeam-queue", + "enum_dispatch", + "hashbrown 0.14.3", + "num-traits", + "polars-arrow", + "polars-compute", + "polars-core", + "polars-expr", + "polars-io", + "polars-ops", + "polars-plan", + "polars-row", + "polars-utils", + "rayon", + "smartstring", + "uuid 1.8.0", + "version_check", +] + +[[package]] +name = "polars-plan" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8daa3541ae7e9af311a4389bc2b21f83349c34c723cc67fa524cdefdaa172d90" +dependencies = [ + "ahash 0.8.11", + "bytemuck", + "chrono-tz 0.8.6", + "either", + "hashbrown 0.14.3", + "once_cell", + "percent-encoding", + "polars-arrow", + "polars-core", + "polars-io", + "polars-ops", + "polars-time", + "polars-utils", + "rayon", + "recursive", + "regex", + "smartstring", + "strum_macros 0.26.2", + "version_check", +] + +[[package]] +name = "polars-row" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb285f2f3a65b00dd06bef16bb9f712dbb5478f941dab5cf74f9f016d382e40" +dependencies = [ + "bytemuck", + "polars-arrow", + "polars-error", + "polars-utils", +] + +[[package]] +name = "polars-sql" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a724f699d194cb02c25124d3832f7d4d77f387f1a89ee42f6b9e88ec561d4ad9" +dependencies = [ + "hex", + "once_cell", + "polars-arrow", + "polars-core", + "polars-error", + "polars-lazy", + "polars-plan", + "rand 0.8.5", + "serde", + "serde_json", + "sqlparser", +] + +[[package]] +name = "polars-time" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ebec238d8b6200d9f0c3ce411c8441e950bd5a7df7806b8172d06c1d5a4b97" +dependencies = [ + "atoi", + "bytemuck", + "chrono", + "chrono-tz 0.8.6", + "now", + "once_cell", + "polars-arrow", + "polars-core", + "polars-error", + "polars-ops", + "polars-utils", + "regex", + "smartstring", +] + +[[package]] +name = "polars-utils" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34e1a907c63abf71e5f21467e2e4ff748896c28196746f631c6c25512ec6102c" +dependencies = [ + "ahash 0.8.11", + "bytemuck", + "hashbrown 0.14.3", + "indexmap 2.2.6", + "num-traits", + "once_cell", + "polars-error", + "raw-cpuid 11.0.2", + "rayon", + "smartstring", + "stacker", + "sysinfo 0.30.12", + "version_check", +] + [[package]] name = "polyval" version = "0.6.2" @@ -10116,6 +10909,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + [[package]] name = "quanta" version = "0.9.3" @@ -10126,7 +10928,7 @@ dependencies = [ "libc", "mach", "once_cell", - "raw-cpuid", + "raw-cpuid 10.7.0", "wasi 0.10.2+wasi-snapshot-preview1", "web-sys", "winapi", @@ -10352,6 +11154,16 @@ dependencies = [ "getrandom 0.2.12", ] +[[package]] +name = "rand_distr" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32cb0b9bc82b0a0876c2dd994a7e7a2683d3e7390ca40e6886785ef0c7e3ee31" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + [[package]] name = "rand_hc" version = "0.2.0" @@ -10405,6 +11217,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "raw-cpuid" +version = "11.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "rayon" version = "1.10.0" @@ -10502,6 +11323,26 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "recursive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0786a43debb760f491b1bc0269fe5e84155353c67482b9e60d0cfb596054b43e" +dependencies = [ + "recursive-proc-macro-impl", + "stacker", +] + +[[package]] +name = "recursive-proc-macro-impl" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76009fbe0614077fc1a2ce255e3a1881a2e3a3527097d5dc6d8212c585e7e38b" +dependencies = [ + "quote 1.0.35", + "syn 2.0.57", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -11005,9 +11846,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.12.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f308135fef9fc398342da5472ce7c484529df23743fb7c734e0f3d472971e62" +checksum = "2c3cc4c2511671f327125da14133d0c5c5d137f006a1017a16f557bc85b16286" dependencies = [ "alloy-rlp", "arbitrary", @@ -11030,9 +11871,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rusb" @@ -11739,6 +12580,12 @@ dependencies = [ "uuid 1.8.0", ] +[[package]] +name = "seq-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" + [[package]] name = "serde" version = "1.0.197" @@ -12157,6 +13004,12 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "simdutf8" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a" + [[package]] name = "similar" version = "2.5.0" @@ -12236,6 +13089,17 @@ version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + [[package]] name = "snap" version = "1.1.1" @@ -12333,12 +13197,34 @@ dependencies = [ "der 0.7.8", ] +[[package]] +name = "sqlparser" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743b4dc2cbde11890ccb254a8fc9d537fa41b36da00de2a1c5e9848c9bc42bd7" +dependencies = [ + "log", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if 1.0.0", + "libc", + "psm", + "winapi", +] + [[package]] name = "static_assertions" version = "1.1.0" @@ -12357,6 +13243,27 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" +[[package]] +name = "streaming-decompression" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf6cc3b19bfb128a8ad11026086e31d3ce9ad23f8ea37354b31383a187c44cf3" +dependencies = [ + "fallible-streaming-iterator", +] + +[[package]] +name = "streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520" + +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + [[package]] name = "string_cache" version = "0.8.7" @@ -12816,6 +13723,20 @@ dependencies = [ "winapi", ] +[[package]] +name = "sysinfo" +version = "0.30.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "732ffa00f53e6b2af46208fba5718d9662a421049204e156328b66791ffa15ae" +dependencies = [ + "cfg-if 1.0.0", + "core-foundation-sys", + "libc", + "ntapi 0.4.1", + "once_cell", + "windows 0.52.0", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -12877,6 +13798,12 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "target-features" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1bbb9f3c5c463a01705937a24fdabc5047929ac764b2d5b9cf681c1f5041ed5" + [[package]] name = "target-lexicon" version = "0.12.14" @@ -13076,6 +14003,17 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "thrift" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e54bc85fc7faa8bc175c4bab5b92ba8d9a3ce893d0e9f42cc455c8ab16a9e09" +dependencies = [ + "byteorder", + "integer-encoding", + "ordered-float", +] + [[package]] name = "time" version = "0.1.43" @@ -14054,6 +14992,15 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-reverse" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b6f4888ebc23094adfb574fdca9fdc891826287a6397d2cd28802ffd6f20c76" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -14493,6 +15440,16 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core 0.52.0", + "windows-targets 0.52.4", +] + [[package]] name = "windows-core" version = "0.51.1" @@ -14895,8 +15852,8 @@ dependencies = [ "block-padding 0.2.1", "block-padding 0.3.3", "blst", - "brotli", - "brotli-decompressor", + "brotli 3.5.0", + "brotli-decompressor 2.5.1", "bs58 0.4.0", "bstr", "bulletproofs", @@ -15394,7 +16351,7 @@ dependencies = [ "rand_core 0.6.4", "rand_xorshift", "rand_xoshiro", - "raw-cpuid", + "raw-cpuid 10.7.0", "rayon", "rayon-core", "rcgen", @@ -15527,7 +16484,7 @@ dependencies = [ "syn 2.0.57", "sync_wrapper", "synstructure", - "sysinfo", + "sysinfo 0.27.8", "tabled", "tabled_derive", "tabular", @@ -15868,6 +16825,15 @@ dependencies = [ "zstd-safe 6.0.6", ] +[[package]] +name = "zstd" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bffb3309596d527cfcba7dfc6ed6052f1d39dfbd7c867aa2e865e4a449c10110" +dependencies = [ + "zstd-safe 7.0.0", +] + [[package]] name = "zstd-safe" version = "5.0.2+zstd.1.5.2" @@ -15888,11 +16854,20 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43747c7422e2924c11144d5229878b98180ef8b06cca4ab5af37afc8a8d8ea3e" +dependencies = [ + "zstd-sys", +] + [[package]] name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" +version = "2.0.9+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index a69f0a342..d40303b1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,6 +119,7 @@ alloy-sol-types = "0.6" alloy-dyn-abi = { version = "0.6", features = ["arbitrary", "eip712"] } alloy-primitives = "0.6" alloy-json-abi = "0.6" + # error handling anyhow = "1.0" thiserror = "1.0" @@ -129,3 +130,9 @@ colored = "2.0" evmole = "0.3.7" semver = "1.0.22" +parquet = "52.0.0" +polars-core = "0.40.0" +polars-utils = "0.40.0" +polars = "0.40.0" + +eyre = "0.6.12" diff --git a/src/evm/abi.rs b/src/evm/abi.rs index 2fb8df9a1..fbc3d9b70 100644 --- a/src/evm/abi.rs +++ b/src/evm/abi.rs @@ -1280,7 +1280,7 @@ mod tests { let mut test_state = FuzzState::new(0); let mutation_result = abi.mutate::(&mut test_state); - debug!("result: {:?} abi: {:?}", mutation_result, hex::encode(abi.get_bytes())); + println!("result: {:?} abi: {:?}", mutation_result, hex::encode(abi.get_bytes())); } #[test] @@ -1412,6 +1412,18 @@ mod tests { debug!("result: {:?} abi: {:?}", mutation_result, hex::encode(abibytes)); } + #[test] + fn test_struct_p() { + let mut abi = get_abi_type_boxed(&String::from( + "((bytes32,uint8,address,address,uint256,bytes),(address,bool,address,bool),uint256,uint256)", + )); + abi.function = [82, 187, 190, 41]; + let tx_data = "52bbbe2900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000b0b401d4761317e272e02c9513771768a10133870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b0b401d4761317e272e02c9513771768a101338700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b3c379d592b75990000000000000000000000000000000000000000000000000000000066675e5edc4a9779d6084c1ab3e815b67ed5e6780ccf4d900002000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086cba7808127d76deac14ec26ef6000aa78b2ebb000000000000000000000000000000000000000000000000000012309ce5400000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000014b0b401d4761317e272e02c9513771768a1013387000000000000000000000000"; + let mut tx_data_vec = hex::decode(tx_data).unwrap(); + abi.set_bytes(tx_data_vec); + println!("abi data is {:?}", abi.get_bytes()); + } + #[test] fn test_100_times() { for _ in 0..100 { diff --git a/src/evm/blaz/mod.rs b/src/evm/blaz/mod.rs index 58d9d05c5..ede2c5960 100644 --- a/src/evm/blaz/mod.rs +++ b/src/evm/blaz/mod.rs @@ -14,6 +14,7 @@ pub mod builder; pub(crate) mod linking; pub mod offchain_artifacts; pub mod offchain_config; +pub mod offchain_cor; fn get_client() -> reqwest::blocking::Client { reqwest::blocking::Client::builder() diff --git a/src/evm/blaz/offchain_cor.rs b/src/evm/blaz/offchain_cor.rs new file mode 100644 index 000000000..265dd73da --- /dev/null +++ b/src/evm/blaz/offchain_cor.rs @@ -0,0 +1,127 @@ +use std::{ + collections::{BTreeMap, HashMap}, + default::Default, + str::FromStr, +}; + +use alloy_sol_types::SolValue; +use bytes::Bytes; +use ethers::{ + abi::{ethereum_types, AbiEncode}, + prelude::{Provider, ProviderExt}, + providers::Middleware, + types::{AccountState, Address, Transaction, U256, U64}, +}; +use foundry_cheatcodes::Vm::VmCalls::rpc; +use libafl::prelude::{Scheduler, StdMapObserver}; +use parquet::{ + data_type::AsBytes, + file::reader::{FileReader, SerializedFileReader}, + record::{Field, Row}, +}; +use primitive_types::H256; +use revm_interpreter::BytecodeLocked; +use revm_primitives::{BlockEnv, Bytecode, Env, B160}; +use tracing::debug; + +use crate::evm::{ + abi::{get_abi_type_boxed, BoxedABI}, + input::{ConciseEVMInput, EVMInput, EVMInputTy::ABI}, + onchain::endpoints::{ + Chain::{BSC, ETH}, + OnChainConfig, + }, + types::EVMAddress, +}; + +pub type CryoTestcases = Vec>; + +#[derive(Clone, Debug, Default)] +pub struct OffchainCor; + +impl OffchainCor { + pub async fn get_call_env(rpc_url: &str, tx_hash: String) -> Env { + let provider = Provider::try_connect(rpc_url).await.expect("rpc connect error"); + let req = H256::from_str(tx_hash.as_str()).unwrap(); + let tx = provider + .get_transaction(req) + .await + .expect("tx_hash or rpc error") + .unwrap(); + let block_id = tx.block_number.unwrap().as_u64(); + let block_rep = provider + .get_block(block_id) + .await + .expect("block_number error ") + .unwrap(); + println!("block number is {:?}", tx.block_number.unwrap().as_usize()); + let block_env = BlockEnv { + number: U256::from(tx.block_number.unwrap().as_usize()).into(), + coinbase: Default::default(), + timestamp: block_rep.clone().timestamp.into(), + difficulty: block_rep.clone().difficulty.into(), + prevrandao: None, + basefee: Default::default(), + gas_limit: Default::default(), + }; + Env { + cfg: Default::default(), + block: block_env, + tx: Default::default(), + } + } + + pub async fn get_transaction(rpc_url: &str, tx_hash: String) -> ConciseEVMInput { + let provider = Provider::try_connect(rpc_url).await.expect("rpc connect error"); + let req = H256::from_str(tx_hash.as_str()).unwrap(); + let env = Self::get_call_env(rpc_url, tx_hash).await; + let tx_info = provider.get_transaction(req).await.expect("rpc error").unwrap(); + + let mut abi = get_abi_type_boxed(&String::from( + "((uint256,uint256,address,address,uint256,bytes),address,bool,address,bool,uint256,uint256)", + )); + abi.function = [82, 187, 190, 41]; + let tx_data = "52bbbe2900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000b0b401d4761317e272e02c9513771768a10133870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b0b401d4761317e272e02c9513771768a101338700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006b3c379d592b75990000000000000000000000000000000000000000000000000000000066675e5edc4a9779d6084c1ab3e815b67ed5e6780ccf4d900002000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086cba7808127d76deac14ec26ef6000aa78b2ebb000000000000000000000000000000000000000000000000000012309ce5400000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000014b0b401d4761317e272e02c9513771768a1013387000000000000000000000000"; + let mut tx_data_vec = hex::decode(tx_data).unwrap(); + // println!("tx_data_vec1 is {:?}", tx_data_vec); + abi.set_bytes(tx_data_vec); + // println!("tx_data_vec2 is {:?}", abi.get_bytes()); + + let to_address = B160::from_slice(&tx_info.to.unwrap().0); + ConciseEVMInput { + input_type: ABI, + caller: tx_info.from.into(), + contract: to_address, + #[cfg(not(feature = "debug"))] + data: Some(abi), + txn_value: Some(tx_info.value.into()), + step: false, + env, + liquidation_percent: 0, + randomness: vec![], + repeat: 1, + layer: 0, + call_leak: 0, + return_data: None, + swap_data: Default::default(), + #[cfg(feature = "debug")] + direct_data: tx_info.input.to_string(), + } + } + + pub fn generate_testcases_from_txhash(rpc_url: &str, tx_hash: String) -> CryoTestcases { + let mut cryo_testcases = vec![]; + let mut test_case: Vec = vec![]; + let rt = tokio::runtime::Runtime::new().unwrap(); + let tx_input = rt.block_on(OffchainCor::get_transaction(rpc_url, tx_hash)); + test_case.push(tx_input); + cryo_testcases.push(test_case); + cryo_testcases + } +} + +mod test { + use revm_primitives::Env; + + use crate::evm::blaz::offchain_cor::OffchainCor; +} diff --git a/src/evm/config.rs b/src/evm/config.rs index d8b96878d..49c7fb5bf 100644 --- a/src/evm/config.rs +++ b/src/evm/config.rs @@ -92,6 +92,7 @@ pub struct Config { pub load_corpus: String, #[cfg(feature = "use_presets")] pub preset_file_path: String, + pub load_crypo_corpus: Option, } impl Debug diff --git a/src/evm/corpus_initializer.rs b/src/evm/corpus_initializer.rs index 9eb9aba85..1c07838e2 100644 --- a/src/evm/corpus_initializer.rs +++ b/src/evm/corpus_initializer.rs @@ -592,3 +592,8 @@ where } } } + +mod test { + #[test] + fn test_load_crypo() {} +} diff --git a/src/evm/host.rs b/src/evm/host.rs index 012dfb1e9..cdffbc648 100644 --- a/src/evm/host.rs +++ b/src/evm/host.rs @@ -17,6 +17,7 @@ use alloy_sol_types::SolValue; use bytes::Bytes; use itertools::Itertools; use libafl::prelude::{HasMetadata, Scheduler}; +use parquet::data_type::AsBytes; use revm::precompile::{Precompile, Precompiles}; use revm_interpreter::{ analysis::to_analysed, @@ -72,7 +73,7 @@ use super::{ use crate::{ evm::{ abi::{get_abi_type_boxed, register_abi_instance}, - contract_utils::extract_sig_from_contract, + contract_utils::{extract_sig_from_contract, to_hex_string}, corpus_initializer::ABIMap, input::{EVMInput, EVMInputTy}, middlewares::middleware::{add_corpus, CallMiddlewareReturn, Middleware, MiddlewareType}, diff --git a/src/evm/mod.rs b/src/evm/mod.rs index 8b5847e0f..f09d16989 100644 --- a/src/evm/mod.rs +++ b/src/evm/mod.rs @@ -100,7 +100,7 @@ struct RPCCall { } /// CLI for ItyFuzz for EVM smart contracts -#[derive(Parser, Debug, Default)] +#[derive(Parser, Debug, Default, Clone)] #[command(author, version, about, long_about = None, trailing_var_arg = true, allow_hyphen_values = true)] pub struct EvmArgs { /// Glob pattern / address to find contracts @@ -269,6 +269,10 @@ pub struct EvmArgs { #[arg(long, default_value = "")] load_corpus: String, + /// Load corpus from crypo. If not specified, will use empty corpus. + #[arg(long, short = 'l', default_value = None)] + load_crypo_corpus: Option, + /// [DEPRECATED] Specify the setup file that deploys all the contract. /// Fuzzer invokes setUp() to deploy. #[arg(long, default_value = "")] @@ -812,6 +816,7 @@ pub fn evm_main(mut args: EvmArgs) { preset_file_path: args.preset_file_path, load_corpus: args.load_corpus, etherscan_api_key, + load_crypo_corpus: args.load_crypo_corpus, }; let mut abis_map: HashMap>> = HashMap::new(); @@ -837,6 +842,7 @@ pub fn evm_main(mut args: EvmArgs) { let abis_json = format!("{}/abis.json", args.work_dir.clone().as_str()); utils::try_write_file(&abis_json, &json_str, true).unwrap(); + evm_fuzzer(config, &mut state) } @@ -987,6 +993,7 @@ fn test_evm_offchain_setup() { preset_file_path: args.preset_file_path, load_corpus: args.load_corpus, etherscan_api_key: String::from(""), + load_crypo_corpus: args.load_crypo_corpus, }; let mut abis_map: HashMap>> = HashMap::new(); diff --git a/src/evm/onchain/endpoints.rs b/src/evm/onchain/endpoints.rs index 27608d3ca..a4272986b 100644 --- a/src/evm/onchain/endpoints.rs +++ b/src/evm/onchain/endpoints.rs @@ -226,7 +226,7 @@ impl Chain { Chain::CELO => "https://rpc.ankr.com/celo", Chain::ZKEVM => "https://rpc.ankr.com/polygon_zkevm", Chain::ZkevmTestnet => "https://rpc.ankr.com/polygon_zkevm_testnet", - Chain::BLAST => "https://rpc.ankr.com/blast", + Chain::BLAST => "https://lb.nodies.app/v1/041287f6f8c549fa8cf6d4f9b745206d", Chain::LINEA => "https://rpc.ankr.com/linea", Chain::IOTEX => "https://rpc.ankr.com/iotex", Chain::LOCAL => "http://localhost:8545", @@ -252,7 +252,7 @@ impl Chain { Chain::CELO => "https://api.celoscan.io/api", Chain::ZKEVM => "https://api-zkevm.polygonscan.com/api", Chain::ZkevmTestnet => "https://api-testnet-zkevm.polygonscan.com/api", - Chain::BLAST => "https://api.routescan.io/v2/network/mainnet/evm/81457/etherscan", + Chain::BLAST => " https://api.blastscan.io/api", Chain::LINEA => "https://api.lineascan.build/api", Chain::LOCAL => "http://localhost:8080/abi/", Chain::IOTEX => "https://babel-api.mainnet.IoTeX.io", diff --git a/src/evm/onchain/mod.rs b/src/evm/onchain/mod.rs index 19c5107e1..536049351 100644 --- a/src/evm/onchain/mod.rs +++ b/src/evm/onchain/mod.rs @@ -482,6 +482,7 @@ impl OnChain { } let mut abi_instance = get_abi_type_boxed(&abi.abi); + abi_instance.set_func_with_signature(abi.function, &abi.function_name, &abi.abi); register_abi_instance(target, abi_instance.clone(), state); @@ -506,3 +507,166 @@ impl OnChain { }); } } + +impl OnChain { + #[allow(clippy::too_many_arguments)] + pub fn load_sep_input( + &mut self, + address_h160: EVMAddress, + host: &mut FuzzHost, + force_cache: bool, + _should_setup_abi: bool, + is_proxy_call: bool, + caller: EVMAddress, + state: &mut EVMFuzzState, + ) -> Vec + where + SC: Scheduler + Clone, + { + let contract_code = self.endpoint.get_contract_code(address_h160, force_cache); + let code = hex::decode(contract_code).unwrap(); + let contract_code = to_analysed(Bytecode::new_raw(Bytes::from(code))); + + let mut parsed_abi = vec![]; + if let Some(abis) = self.address_to_abi.get(&address_h160) { + parsed_abi = abis.clone(); + } else { + let mut abi = None; + if let Some(builder) = &self.builder { + debug!("onchain job {:?}", address_h160); + let build_job = builder.onchain_job(self.endpoint.chain_name.clone(), address_h160); + + if let Some(job) = build_job { + abi = Some(job.abi.clone()); + // replace the code with the one from builder + // debug!("replace code for {:?} with builder's", address_h160); + // host.set_codedata(address_h160, contract_code.clone()); + state + .metadata_map_mut() + .get_mut::() + .expect("artifact info metadata") + .add(address_h160, job.clone()); + + job.save_source_map(&address_h160); + } + } + + if abi.is_none() { + debug!("fetching abi {:?}", address_h160); + abi = self.endpoint.fetch_abi(address_h160); + } + + match abi { + Some(ref abi_ins) => parsed_abi = ContractLoader::parse_abi_str(abi_ins), + None => { + // 1. Extract abi from bytecode, and see do we have any function sig available + // in state + // 2. Use Heimdall to extract abi + // 3. Reconfirm on failures of heimdall + debug!("Contract {:?} has no abi", address_h160); + let contract_code_str = hex::encode(contract_code.bytes()); + let sigs = extract_sig_from_contract(&contract_code_str); + let mut unknown_sigs: usize = 0; + for sig in &sigs { + if let Some(abi) = state.metadata_map().get::().unwrap().get(sig) { + parsed_abi.push(abi.clone()); + } else { + unknown_sigs += 1; + } + } + + if unknown_sigs >= sigs.len() / 30 { + debug!("Too many unknown function signature ({:?}) for {:?}, we are going to decompile this contract using Heimdall", unknown_sigs, address_h160); + let abis = fetch_abi_heimdall(contract_code_str) + .iter() + .map(|abi| { + if let Some(known_abi) = + state.metadata_map().get::().unwrap().get(&abi.function) + { + known_abi + } else { + abi + } + }) + .cloned() + .collect_vec(); + parsed_abi = abis; + } + } + } + } + + println!("parsed_abi is {:?}", parsed_abi); + // set up host + let mut abi_hashes_to_add = HashSet::new(); + if is_proxy_call { + // check caller's hash and see what is missing + let caller_hashes: Vec<[u8; 4]> = match host.address_to_hash.get(&caller) { + Some(v) => v.clone(), + None => vec![], + }; + let caller_hashes_set = caller_hashes.iter().cloned().collect::>(); + let new_hashes = parsed_abi.iter().map(|abi| abi.function).collect::>(); + for hash in new_hashes { + if !caller_hashes_set.contains(&hash) { + abi_hashes_to_add.insert(hash); + host.add_one_hashes(caller, hash); + } + } + } else { + abi_hashes_to_add = parsed_abi.iter().map(|abi| abi.function).collect::>(); + host.add_hashes(address_h160, parsed_abi.iter().map(|abi| abi.function).collect()); + } + let target = if is_proxy_call { caller } else { address_h160 }; + if target != CHEATCODE_ADDRESS { + state.add_address(&target); + } + + // notify flashloan and blacklisting flashloan addresses + { + handle_contract_insertion!( + state, + host, + target, + parsed_abi + .iter() + .filter(|x| abi_hashes_to_add.contains(&x.function)) + .cloned() + .collect::>() + ); + } + + let mut tx_input = vec![]; + + parsed_abi + .iter() + .filter(|v| !v.is_constructor) + .filter(|v| abi_hashes_to_add.contains(&v.function)) + .for_each(|abi| { + let mut abi_instance = get_abi_type_boxed(&abi.abi); + abi_instance.set_func_with_signature(abi.function, &abi.function_name, &abi.abi); + register_abi_instance(target, abi_instance.clone(), state); + + let input = EVMInput { + caller: state.get_rand_caller(), + contract: target, + data: Some(abi_instance), + sstate: StagedVMState::new_uninitialized(), + sstate_idx: 0, + txn_value: if abi.is_payable { Some(EVMU256::ZERO) } else { None }, + step: false, + env: state.metadata_map().get::().unwrap().env.clone(), + access_pattern: Rc::new(RefCell::new(AccessPattern::new())), + liquidation_percent: 0, + input_type: EVMInputTy::ABI, + direct_data: Default::default(), + randomness: vec![0], + repeat: 1, + swap_data: HashMap::new(), + }; + tx_input.push(input); + }); + + tx_input + } +} diff --git a/src/evm/oracles/erc20.rs b/src/evm/oracles/erc20.rs index 0cbabad81..2fb531431 100644 --- a/src/evm/oracles/erc20.rs +++ b/src/evm/oracles/erc20.rs @@ -101,7 +101,7 @@ impl } } - let _path_idx = ctx.input.get_randomness()[0] as usize; + // let _path_idx = ctx.input.get_randomness()[0] as usize; { ctx.executor.deref().borrow_mut().host.evmstate = ctx.post_state.clone(); diff --git a/src/evm/vm.rs b/src/evm/vm.rs index 3802a5ca6..3483f58d0 100644 --- a/src/evm/vm.rs +++ b/src/evm/vm.rs @@ -7,7 +7,7 @@ use std::{ fmt::Debug, hash::{Hash, Hasher}, marker::PhantomData, - ops::Deref, + ops::{Deref, Mul}, rc::Rc, sync::Arc, }; @@ -675,9 +675,14 @@ where { let tx_value = input.get_txn_value().unwrap_or_default(); if tx_value > EVMU256::ZERO { + // tmp modify + vm_state.set_balance(input.get_caller(), tx_value + tx_value); let caller_balance = *vm_state.get_balance(&input.get_caller()).unwrap_or(&EVMU256::ZERO); let contract_balance = *vm_state.get_balance(&input.get_contract()).unwrap_or(&EVMU256::ZERO); if caller_balance < tx_value { + println!("caller_balance is {:?}", caller_balance); + println!("tx_value is {:?}", tx_value); + println!("coming tx_value....."); return ExecutionResult { output: vec![], reverted: true, @@ -693,6 +698,7 @@ where let r; let mut is_step = input.is_step(); let mut data = Bytes::from(input.to_bytes()); + // println!("call data is: {:?}", data); // use direct data (mostly used for debugging) if there is no data if data.is_empty() { data = Bytes::from(input.get_direct_data()); @@ -762,6 +768,7 @@ where } } let mut r = r.unwrap(); + match r.ret { ControlLeak | InstructionResult::ArbitraryExternalCallAddressBounded(_, _, _) | diff --git a/src/fuzzer.rs b/src/fuzzer.rs index ab66e70f7..7007c5e79 100644 --- a/src/fuzzer.rs +++ b/src/fuzzer.rs @@ -434,6 +434,7 @@ where state.get_execution_result_mut().new_state.trace.from_idx = Some(input.get_state_idx()); state.get_execution_result_mut().new_state.trace.derived_time = input.get_staged_state().trace.derived_time + 1; + state .get_execution_result_mut() .new_state diff --git a/src/fuzzers/evm_fuzzer.rs b/src/fuzzers/evm_fuzzer.rs index bac6f5081..a01aa3e80 100644 --- a/src/fuzzers/evm_fuzzer.rs +++ b/src/fuzzers/evm_fuzzer.rs @@ -1,4 +1,14 @@ -use std::{cell::RefCell, collections::HashMap, fs::File, io::Read, ops::Deref, path::Path, process::exit, rc::Rc}; +use std::{ + cell::RefCell, + collections::HashMap, + fs::File, + io::Read, + ops::Deref, + path::Path, + process, + process::exit, + rc::Rc, +}; use bytes::Bytes; use glob::glob; @@ -16,7 +26,7 @@ use tracing::{debug, error, info}; use crate::{ evm::{ abi::{ABIAddressToInstanceMap, BoxedABI}, - blaz::builder::ArtifactInfoMetadata, + blaz::{builder::ArtifactInfoMetadata, offchain_cor::OffchainCor}, concolic::{ concolic_host::CONCOLIC_TIMEOUT, concolic_stage::{ConcolicFeedbackWrapper, ConcolicStage}, @@ -47,7 +57,7 @@ use crate::{ sha3_bypass::{Sha3Bypass, Sha3TaintAnalysis}, }, minimizer::EVMMinimizer, - mutator::FuzzMutator, + mutator::{AccessPattern, FuzzMutator}, onchain::{flashloan::Flashloan, offchain::OffChainConfig, ChainConfig, OnChain, WHITELIST_ADDR}, oracles::{ arb_call::ArbitraryCallOracle, @@ -60,7 +70,7 @@ use crate::{ presets::ExploitTemplate, scheduler::{PowerABIMutationalStage, PowerABIScheduler, UncoveredBranchesMetadata}, types::{fixed_address, EVMAddress, EVMFuzzMutator, EVMFuzzState, EVMQueueExecutor, EVMU256}, - vm::{EVMExecutor, EVMState}, + vm::{EVMExecutor, EVMState, IS_FAST_CALL}, }, executor::FuzzExecutor, feedback::{CmpFeedback, DataflowFeedback, OracleFeedback}, @@ -88,6 +98,7 @@ pub fn evm_fuzzer( state: &mut EVMFuzzState, ) { info!("\n\n ================ EVM Fuzzer Start ===================\n\n"); + // read tx info from crypo_path // create work dir if not exists let _path = Path::new(config.work_dir.as_str()); @@ -104,7 +115,8 @@ pub fn evm_fuzzer( let jmp_observer = unsafe { StdMapObserver::new("jmp", jmps) }; let deployer = fixed_address(FIX_DEPLOYER); - let mut fuzz_host = FuzzHost::new(scheduler.clone(), config.work_dir.clone()); + let mut fuzz_host: FuzzHost> = + FuzzHost::new(scheduler.clone(), config.work_dir.clone()); fuzz_host.set_spec_id(config.spec_id); // **Note**: cheatcode should be the first middleware because it consumes the @@ -194,6 +206,7 @@ pub fn evm_fuzzer( fuzz_host.add_flashloan_middleware(Flashloan::new(true, chain_cfg, config.flashloan_oracle)); } } + let sha3_taint = Rc::new(RefCell::new(Sha3TaintAnalysis::new())); if config.sha3_bypass { @@ -340,7 +353,19 @@ pub fn evm_fuzzer( let mut stages = tuple_list!(std_stage, concolic_stage, coverage_obs_stage); - let mut executor = FuzzExecutor::new(evm_executor_ref.clone(), tuple_list!(jmp_observer)); + let mut executor: FuzzExecutor< + EVMState, + EVMAddress, + Bytecode, + Bytes, + EVMAddress, + EVMU256, + Vec, + EVMInput, + EVMFuzzState, + (StdMapObserver, ()), + ConciseEVMInput, + > = FuzzExecutor::new(evm_executor_ref.clone(), tuple_list!(jmp_observer)); #[cfg(feature = "deployer_is_attacker")] state.add_caller(&deployer); @@ -464,6 +489,7 @@ pub fn evm_fuzzer( ConciseEVMInput, EVMQueueExecutor, > = OracleFeedback::new(&mut oracles, &mut producers, evm_executor_ref.clone()); + let wrapped_feedback = ConcolicFeedbackWrapper::new(Sha3WrappedFeedback::new( feedback, sha3_taint, @@ -529,6 +555,78 @@ pub fn evm_fuzzer( }; } + macro_rules! load_sep_input { + ($txn: expr) => {{ + let result = if let Some(onchain_mid) = onchain_middleware.clone() { + onchain_mid.borrow_mut().load_sep_input( + $txn.contract, + &mut evm_executor_ref.clone().deref().borrow_mut().host, + false, + true, + false, + $txn.caller, + state, + ) + } else { + vec![] + }; + result + }}; + } + + if config.load_crypo_corpus.is_some() { + let crypo_corpus = config.load_crypo_corpus.unwrap(); + let rpc_url = config.onchain.unwrap().endpoint_url; + let testcases = OffchainCor::generate_testcases_from_txhash(rpc_url.as_str(), crypo_corpus); + debug!("start gen testcases"); + unsafe { + IS_FAST_CALL = true; + } + + for testcase in testcases { + let mut vm_state = initial_vm_state.clone(); + for txn in testcase { + load_code!(txn); + let (inp, call_until) = txn.to_input(vm_state.clone()); + println!("data bytes is : {:?}", inp.data.clone().unwrap().get_bytes()); + unsafe { + CALL_UNTIL = call_until; + } + fuzzer + .evaluate_input_events(state, &mut executor, &mut mgr, inp, false) + .unwrap(); + vm_state = state.get_execution_result().new_state.clone(); + // let rets: Vec = load_sep_input!(txn); + // for ret in rets { + // if ret.data.is_some() && + // ret.clone().data.unwrap().function.eq(&[82, 187, 190, 41]) { + // println!("input data is {:?}", + // ret.clone().data.unwrap()); let inp = + // ret; + // + // // let (inp, call_until) = + // txn.to_input(vm_state.clone()); // + // println!("input is {:?}", inp); + // fuzzer + // .evaluate_input_events(state, &mut executor, &mut + // mgr, inp, false) .unwrap(); + // + // vm_state = + // state.get_execution_result().new_state.clone(); + // break; + // } + // } + } + } + unsafe { + CALL_UNTIL = u32::MAX; + IS_FAST_CALL = false; + } + debug!("finish gen testcases"); + } + + // process::exit(1); + match config.replay_file { None => { // load initial corpus diff --git a/tests/evm_manual/foundry1/test/CreateOpcode.sol b/tests/evm_manual/foundry1/test/CreateOpcode.sol new file mode 100644 index 000000000..1b00cf755 --- /dev/null +++ b/tests/evm_manual/foundry1/test/CreateOpcode.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.0; +import "solidity_utils/lib.sol"; + +contract SOL { + Test public tt; + function setUp() public { + tt = new Test(); + } + + function test() public returns (uint) { + address account = address(tt); + uint size; + assembly { + size := extcodesize(account) + } + if (size > 65) { + bug(); + } + return size; + } +} + +contract Test { + +}