diff --git a/Cargo.lock b/Cargo.lock index b495149..0f7ee12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,59 +35,155 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +[[package]] +name = "alloy" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9134b68e24175eff6c3c4d2bffeefb0a1b7435462130862c88d1524ca376e7e5" +dependencies = [ + "alloy-consensus", + "alloy-core", + "alloy-eips", + "alloy-genesis", + "alloy-network", + "alloy-provider", + "alloy-rpc-client", + "alloy-rpc-types", + "alloy-serde", + "alloy-transport", + "alloy-transport-http", + "reqwest 0.12.5", +] + +[[package]] +name = "alloy-chains" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04e9a1892803b02f53e25bea3e414ddd0501f12d97456c9d5ade4edf88f9516f" +dependencies = [ + "num_enum", + "strum", +] + [[package]] name = "alloy-consensus" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a016bfa21193744d4c38b3f3ab845462284d129e5e23c7cc0fafca7e92d9db37" dependencies = [ "alloy-eips", "alloy-primitives", "alloy-rlp", + "alloy-serde", + "c-kzg", + "serde", +] + +[[package]] +name = "alloy-core" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5af3faff14c12c8b11037e0a093dd157c3702becb8435577a2408534d0758315" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-types", +] + +[[package]] +name = "alloy-dyn-abi" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6e6436a9530f25010d13653e206fab4c9feddacf21a54de8d7311b275bc56b" +dependencies = [ + "alloy-json-abi", + "alloy-primitives", + "alloy-sol-type-parser", + "alloy-sol-types", + "const-hex", + "itoa", + "serde", + "serde_json", + "winnow 0.6.13", ] [[package]] name = "alloy-eips" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32d6d8118b83b0489cfb7e6435106948add2b35217f4a5004ef895f613f60299" dependencies = [ "alloy-primitives", "alloy-rlp", + "alloy-serde", + "c-kzg", + "once_cell", "serde", + "sha2", +] + +[[package]] +name = "alloy-genesis" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "894f33a7822abb018db56b10ab90398e63273ce1b5a33282afd186c132d764a6" +dependencies = [ + "alloy-primitives", + "alloy-serde", + "serde", +] + +[[package]] +name = "alloy-json-abi" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaeaccd50238126e3a0ff9387c7c568837726ad4f4e399b528ca88104d6c25ef" +dependencies = [ + "alloy-primitives", + "alloy-sol-type-parser", + "serde", + "serde_json", ] [[package]] name = "alloy-json-rpc" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61f0ae6e93b885cc70fe8dae449e7fd629751dbee8f59767eaaa7285333c5727" dependencies = [ "alloy-primitives", "serde", "serde_json", "thiserror", + "tracing", ] [[package]] name = "alloy-network" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc122cbee2b8523854cc11d87bcd5773741602c553d2d2d106d82eeb9c16924a" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types-eth", + "alloy-serde", "alloy-signer", + "alloy-sol-types", "async-trait", + "auto_impl", "futures-utils-wasm", - "serde", "thiserror", ] [[package]] name = "alloy-primitives" -version = "0.6.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600d34d8de81e23b6d909c094e23b3d357e01ca36b78a8c5424c501eedbe86f0" +checksum = "f783611babedbbe90db3478c120fb5f5daacceffc210b39adc0af4fe0da70bad" dependencies = [ "alloy-rlp", "bytes", @@ -107,15 +203,18 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d5af289798fe8783acd0c5f10644d9d26f54a12bc52a083e4f3b31718e9bf92" dependencies = [ + "alloy-chains", + "alloy-consensus", + "alloy-eips", "alloy-json-rpc", "alloy-network", "alloy-primitives", "alloy-rpc-client", - "alloy-rpc-trace-types", - "alloy-rpc-types", + "alloy-rpc-types-eth", "alloy-transport", "alloy-transport-http", "async-stream", @@ -123,18 +222,22 @@ dependencies = [ "auto_impl", "dashmap", "futures", + "futures-utils-wasm", "lru", - "reqwest", + "pin-project", + "reqwest 0.12.5", + "serde", "serde_json", "tokio", "tracing", + "url", ] [[package]] name = "alloy-rlp" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" +checksum = "b155716bab55763c95ba212806cf43d05bcc70e5f35b02bad20cf5ec7fe11fed" dependencies = [ "alloy-rlp-derive", "arrayvec", @@ -143,9 +246,9 @@ dependencies = [ [[package]] name = "alloy-rlp-derive" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a047897373be4bbb0224c1afdabca92648dc57a9c9ef6e7b0be3aff7a859c83" +checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" dependencies = [ "proc-macro2", "quote", @@ -154,15 +257,16 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b40fcb53b2a9d0a78a4968b2eca8805a4b7011b9ee3fdfa2acaf137c5128f36b" dependencies = [ "alloy-json-rpc", "alloy-transport", "alloy-transport-http", "futures", "pin-project", - "reqwest", + "reqwest 0.12.5", "serde", "serde_json", "tokio", @@ -173,26 +277,28 @@ dependencies = [ ] [[package]] -name = "alloy-rpc-trace-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +name = "alloy-rpc-types" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f2fbe956a3e0f0975c798f488dc6be96b669544df3737e18f4a325b42f4c86" dependencies = [ - "alloy-primitives", - "alloy-rpc-types", + "alloy-rpc-types-eth", "alloy-serde", - "serde", - "serde_json", ] [[package]] -name = "alloy-rpc-types" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +name = "alloy-rpc-types-eth" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "083f443a83b9313373817236a8f4bea09cca862618e9177d822aee579640a5d6" dependencies = [ + "alloy-consensus", + "alloy-eips", "alloy-primitives", "alloy-rlp", "alloy-serde", - "itertools 0.12.1", + "alloy-sol-types", + "itertools 0.13.0", "serde", "serde_json", "thiserror", @@ -200,8 +306,9 @@ dependencies = [ [[package]] name = "alloy-serde" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d94da1c0c4e27cc344b05626fe22a89dc6b8b531b9475f3b7691dbf6913e4109" dependencies = [ "alloy-primitives", "serde", @@ -210,8 +317,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58d876be3afd8b78979540084ff63995292a26aa527ad0d44276405780aa0ffd" dependencies = [ "alloy-primitives", "async-trait", @@ -221,10 +329,79 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-sol-macro" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bad41a7c19498e3f6079f7744656328699f8ea3e783bdd10d85788cd439f572" +dependencies = [ + "alloy-sol-macro-expander", + "alloy-sol-macro-input", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.58", +] + +[[package]] +name = "alloy-sol-macro-expander" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd9899da7d011b4fe4c406a524ed3e3f963797dbc93b45479d60341d3a27b252" +dependencies = [ + "alloy-sol-macro-input", + "const-hex", + "heck", + "indexmap 2.2.6", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.58", + "syn-solidity", + "tiny-keccak", +] + +[[package]] +name = "alloy-sol-macro-input" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32d595768fdc61331a132b6f65db41afae41b9b97d36c21eb1b955c422a7e60" +dependencies = [ + "const-hex", + "dunce", + "heck", + "proc-macro2", + "quote", + "syn 2.0.58", + "syn-solidity", +] + +[[package]] +name = "alloy-sol-type-parser" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa2fbd22d353d8685bd9fee11ba2d8b5c3b1d11e56adb3265fcf1f32bfdf404" +dependencies = [ + "winnow 0.6.13", +] + +[[package]] +name = "alloy-sol-types" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a49042c6d3b66a9fe6b2b5a8bf0d39fc2ae1ee0310a2a26ffedd79fb097878dd" +dependencies = [ + "alloy-primitives", + "alloy-sol-macro", + "const-hex", + "serde", +] + [[package]] name = "alloy-transport" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245af9541f0a0dbd5258669c80dfe3af118164cacec978a520041fc130550deb" dependencies = [ "alloy-json-rpc", "base64 0.22.0", @@ -236,19 +413,20 @@ dependencies = [ "tokio", "tower", "url", - "wasm-bindgen-futures", ] [[package]] name = "alloy-transport-http" -version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=52d16d3#52d16d33e125670e952b38d888eaefc560738cc2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5619c017e1fdaa1db87f9182f4f0ed97c53d674957f4902fba655e972d359c6c" dependencies = [ "alloy-json-rpc", "alloy-transport", - "reqwest", + "reqwest 0.12.5", "serde_json", "tower", + "tracing", "url", ] @@ -269,47 +447,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -582,6 +761,18 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blst" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62dc83a094a71d43eeadd254b1ec2d24cb6a0bb6cadce00df51f0db594711a32" +dependencies = [ + "cc", + "glob", + "threadpool", + "zeroize", +] + [[package]] name = "bumpalo" version = "3.15.4" @@ -609,6 +800,20 @@ dependencies = [ "serde", ] +[[package]] +name = "c-kzg" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf100c4cea8f207e883ff91ca886d621d8a166cb04971dfaa9bb8fd99ed95df" +dependencies = [ + "blst", + "cc", + "glob", + "hex", + "libc", + "serde", +] + [[package]] name = "cc" version = "1.0.91" @@ -636,9 +841,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", "clap_derive", @@ -646,9 +851,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", @@ -658,9 +863,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck", "proc-macro2", @@ -670,15 +875,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "const-hex" @@ -871,6 +1076,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "ecdsa" version = "0.16.9" @@ -939,20 +1150,13 @@ dependencies = [ name = "eth-trie-proofs" version = "0.1.0" dependencies = [ - "alloy-consensus", - "alloy-eips", - "alloy-network", + "alloy", "alloy-primitives", - "alloy-provider", "alloy-rlp", - "alloy-rpc-client", - "alloy-rpc-types", - "alloy-transport", - "alloy-transport-http", "clap", "eth_trie", "ethereum-types", - "reqwest", + "reqwest 0.11.27", "serde", "serde_json", "serde_with", @@ -1199,6 +1403,12 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "group" version = "0.13.0" @@ -1221,7 +1431,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", "indexmap 2.2.6", "slab", "tokio", @@ -1292,6 +1502,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1299,7 +1520,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", "pin-project-lite", ] @@ -1326,8 +1570,8 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", - "http-body", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1339,6 +1583,25 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -1346,12 +1609,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper", + "hyper 0.14.28", "native-tls", "tokio", "tokio-native-tls", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.3.1", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "hyper 1.3.1", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1457,6 +1756,12 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.10.5" @@ -1468,9 +1773,9 @@ dependencies = [ [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -1501,7 +1806,6 @@ dependencies = [ "elliptic-curve", "once_cell", "sha2", - "signature", ] [[package]] @@ -1669,6 +1973,26 @@ dependencies = [ "libc", ] +[[package]] +name = "num_enum" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "object" version = "0.32.2" @@ -1883,6 +2207,30 @@ dependencies = [ "toml_edit", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.79" @@ -1999,10 +2347,10 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", - "http-body", - "hyper", - "hyper-tls", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.28", + "hyper-tls 0.5.0", "ipnet", "js-sys", "log", @@ -2011,11 +2359,11 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls-pemfile", + "rustls-pemfile 1.0.4", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", "tokio-native-tls", @@ -2024,7 +2372,46 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "winreg 0.50.0", +] + +[[package]] +name = "reqwest" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +dependencies = [ + "base64 0.22.0", + "bytes", + "futures-core", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.3.1", + "hyper-tls 0.6.0", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile 2.1.2", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.1", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg 0.52.0", ] [[package]] @@ -2049,9 +2436,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", "ark-ff 0.3.0", @@ -2073,9 +2460,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 = "rustc-demangle" @@ -2129,6 +2516,28 @@ dependencies = [ "base64 0.21.7", ] +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64 0.22.0", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" + +[[package]] +name = "rustversion" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" + [[package]] name = "rusty-fork" version = "0.3.0" @@ -2380,6 +2789,28 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.58", +] + [[package]] name = "subtle" version = "2.5.0" @@ -2408,12 +2839,30 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn-solidity" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d71e19bca02c807c9faa67b5a47673ff231b6e7449b251695188522f1dc44b2" +dependencies = [ + "paste", + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "sync_wrapper" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -2473,6 +2922,15 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + [[package]] name = "time" version = "0.3.34" @@ -2606,7 +3064,7 @@ checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap 2.2.6", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -2619,6 +3077,7 @@ dependencies = [ "futures-util", "pin-project", "pin-project-lite", + "tokio", "tower-layer", "tower-service", "tracing", @@ -2738,9 +3197,9 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "valuable" @@ -3010,6 +3469,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -3020,6 +3488,16 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index f282507..52f541a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,21 +15,22 @@ exclude = [".github"] [dependencies] tokio = { version = "1.36.0", features = ["rt", "rt-multi-thread", "macros"] } -# alloy is still yet stable, important to pin the revision -alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" } -alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" } -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3", features = [ +alloy-primitives = { version = "0.7.6" } +alloy = { version = "0.1.1", features = [ + "rpc", + "rpc-types", + "rpc-client", + "network", + "providers", + "eips", + "transports", + "transport-http", + "consensus", "k256", ] } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "52d16d3" } -alloy-primitives = "0.6.4" url = "2.5.0" reqwest = "0.11.26" -alloy-rlp = "0.3.4" +alloy-rlp = { version = "0.3.5" } eth_trie = "0.4.0" ethereum-types = "0.14.1" clap = { version = "4.5.4", features = ["derive"] } diff --git a/src/bin/cli.rs b/src/bin/cli.rs index 0af4083..3a8787f 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -72,6 +72,7 @@ async fn main() -> Result<(), Error> { } async fn generate_tx_proof(tx_hash: &str, rpc_url: &str) -> Result<(), Error> { + let rpc_url = url::Url::parse(rpc_url).expect("Invalid URL"); let mut txs_mpt_handler = TxsMptHandler::new(rpc_url)?; let tx_hash = B256::from_hex(tx_hash).unwrap(); txs_mpt_handler.build_tx_tree_from_tx_hash(tx_hash).await?; @@ -86,6 +87,7 @@ async fn generate_tx_proof(tx_hash: &str, rpc_url: &str) -> Result<(), Error> { } async fn generate_receipt_proof(tx_hash: &str, rpc_url: &str) -> Result<(), Error> { + let rpc_url = url::Url::parse(rpc_url).expect("Invalid URL"); let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(rpc_url)?; let tx_hash = B256::from_hex(tx_hash).unwrap(); tx_receipts_mpt_handler diff --git a/src/lib.rs b/src/lib.rs index a661cd0..6725952 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -use alloy_transport::{RpcError, TransportErrorKind}; +use alloy::transports::{RpcError, TransportErrorKind}; use eth_trie::TrieError; mod rpc; @@ -10,6 +10,7 @@ pub mod tx_trie; #[derive(Debug)] pub enum Error { Trie(TrieError), + Eip(alloy::eips::eip2718::Eip2718Error), Rlp(alloy_rlp::Error), RPC(RpcError), TxNotFound, diff --git a/src/rpc.rs b/src/rpc.rs index df1ca2c..a94e441 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -1,22 +1,19 @@ use crate::Error; -use alloy_network::Ethereum; -use alloy_primitives::B256; -use alloy_provider::{Provider, ProviderBuilder, RootProvider}; -use alloy_rpc_client::RpcClient; -use alloy_rpc_types::{BlockTransactions, Transaction, TransactionReceipt}; -use alloy_transport::{RpcError, TransportErrorKind}; -use alloy_transport_http::Http; -use reqwest::Client; +use alloy::network::Ethereum; +use alloy::primitives::B256; +use alloy::providers::{Provider, RootProvider}; + +use alloy::rpc::types::{BlockTransactions, Transaction, TransactionReceipt}; +use alloy::transports::http::{Client, Http}; +use alloy::transports::{RpcError, TransportErrorKind}; pub(crate) struct RpcProvider { - provider: RootProvider>, + provider: RootProvider, Ethereum>, } impl RpcProvider { - pub(crate) fn new(url: &str) -> Self { - let http = Http::::new(url.to_string().parse().unwrap()); - let provider = ProviderBuilder::<_, Ethereum>::new() - .provider(RootProvider::new(RpcClient::new(http, true))); + pub(crate) fn new(rpc_url: url::Url) -> Self { + let provider = RootProvider::new_http(rpc_url); Self { provider } } @@ -26,7 +23,10 @@ impl RpcProvider { ) -> Result<(Vec, B256), Error> { let block = self .provider - .get_block(block_number.into(), true) + .get_block( + block_number.into(), + alloy::rpc::types::BlockTransactionsKind::Full, + ) .await? .ok_or_else(|| Error::BlockNotFound)?; @@ -44,7 +44,10 @@ impl RpcProvider { ) -> Result<(Vec, B256), Error> { let block = self .provider - .get_block(block_number.into(), true) + .get_block( + block_number.into(), + alloy::rpc::types::BlockTransactionsKind::Full, + ) .await? .ok_or_else(|| Error::BlockNotFound)?; @@ -58,10 +61,14 @@ impl RpcProvider { } pub(crate) async fn get_tx_index_by_hash(&self, tx_hash: B256) -> Result { - let tx = self.provider.get_transaction_by_hash(tx_hash).await?; + let tx = self + .provider + .get_transaction_by_hash(tx_hash) + .await? + .expect("tx not found"); let index: u64 = match tx.transaction_index { - Some(index) => index.try_into().map_err(|_| Error::TxNotFound)?, + Some(index) => index, None => return Err(Error::TxNotFound), }; @@ -69,10 +76,14 @@ impl RpcProvider { } pub(crate) async fn get_tx_block_height(&self, tx_hash: B256) -> Result { - let tx = self.provider.get_transaction_by_hash(tx_hash).await?; + let tx = self + .provider + .get_transaction_by_hash(tx_hash) + .await? + .expect("tx not found"); let height: u64 = match tx.block_number { - Some(height) => height.try_into().map_err(|_| Error::TxNotFound)?, + Some(height) => height, None => return Err(Error::TxNotFound), }; diff --git a/src/tx.rs b/src/tx.rs index 0e4abba..d888557 100644 --- a/src/tx.rs +++ b/src/tx.rs @@ -1,14 +1,14 @@ use crate::{Error, Field}; -use alloy_consensus::{ +use alloy::consensus::{ SignableTransaction, TxEip1559, TxEip2930, TxEip4844, TxEnvelope, TxLegacy, TxType, }; -use alloy_consensus::{Transaction as ConsensusTransaction, TxEip4844Variant}; -use alloy_eips::eip2718::Decodable2718; -use alloy_eips::eip2930::AccessList; -use alloy_eips::eip2930::AccessListItem; -use alloy_network::eip2718::Encodable2718; -use alloy_primitives::{ChainId, FixedBytes, Parity, Signature, TxKind, U256, U64}; -use alloy_rpc_types::Transaction; +use alloy::consensus::{Transaction as ConsensusTransaction, TxEip4844Variant}; +use alloy::eips::eip2718::Decodable2718; +use alloy::eips::eip2930::AccessList; +use alloy::eips::eip2930::AccessListItem; +use alloy::network::eip2718::Encodable2718; +use alloy::primitives::{ChainId, FixedBytes, Parity, Signature, TxKind, U256}; +use alloy::rpc::types::Transaction; #[derive(Debug, Clone)] pub struct ConsensusTx(pub TxEnvelope); @@ -19,7 +19,7 @@ impl ConsensusTx { } pub fn rlp_decode(mut data: &[u8]) -> Result { - let tx = TxEnvelope::decode_2718(&mut data).map_err(Error::Rlp)?; + let tx = TxEnvelope::decode_2718(&mut data).map_err(Error::Eip)?; Ok(ConsensusTx(tx)) } @@ -29,24 +29,27 @@ impl ConsensusTx { TxEnvelope::Eip2930(tx) => tx.tx().nonce(), TxEnvelope::Eip1559(tx) => tx.tx().nonce(), TxEnvelope::Eip4844(tx) => tx.tx().nonce(), + _ => todo!(), } } - pub fn gas_limit(&self) -> u64 { + pub fn gas_limit(&self) -> u128 { match &self.0 { TxEnvelope::Legacy(tx) => tx.tx().gas_limit(), TxEnvelope::Eip2930(tx) => tx.tx().gas_limit(), TxEnvelope::Eip1559(tx) => tx.tx().gas_limit(), TxEnvelope::Eip4844(tx) => tx.tx().gas_limit(), + _ => todo!(), } } - pub fn gas_price(&self) -> Option { + pub fn gas_price(&self) -> Option { match &self.0 { TxEnvelope::Legacy(tx) => tx.tx().gas_price(), TxEnvelope::Eip2930(tx) => tx.tx().gas_price(), TxEnvelope::Eip1559(tx) => tx.tx().gas_price(), TxEnvelope::Eip4844(tx) => tx.tx().gas_price(), + _ => todo!(), } } @@ -56,6 +59,7 @@ impl ConsensusTx { TxEnvelope::Eip2930(tx) => tx.tx().to(), TxEnvelope::Eip1559(tx) => tx.tx().to(), TxEnvelope::Eip4844(tx) => tx.tx().to(), + _ => todo!(), } } @@ -65,6 +69,7 @@ impl ConsensusTx { TxEnvelope::Eip2930(tx) => tx.tx().value(), TxEnvelope::Eip1559(tx) => tx.tx().value(), TxEnvelope::Eip4844(tx) => tx.tx().value(), + _ => todo!(), } } @@ -74,6 +79,7 @@ impl ConsensusTx { TxEnvelope::Eip2930(tx) => tx.tx().input(), TxEnvelope::Eip1559(tx) => tx.tx().input(), TxEnvelope::Eip4844(tx) => tx.tx().input(), + _ => todo!(), } } @@ -83,6 +89,7 @@ impl ConsensusTx { TxEnvelope::Eip2930(tx) => tx.signature().v().to_u64(), TxEnvelope::Eip1559(tx) => tx.signature().v().to_u64(), TxEnvelope::Eip4844(tx) => tx.signature().v().to_u64(), + _ => todo!(), } } @@ -92,6 +99,7 @@ impl ConsensusTx { TxEnvelope::Eip2930(tx) => tx.signature().r(), TxEnvelope::Eip1559(tx) => tx.signature().r(), TxEnvelope::Eip4844(tx) => tx.signature().r(), + _ => todo!(), } } @@ -101,15 +109,17 @@ impl ConsensusTx { TxEnvelope::Eip2930(tx) => tx.signature().s(), TxEnvelope::Eip1559(tx) => tx.signature().s(), TxEnvelope::Eip4844(tx) => tx.signature().s(), + _ => todo!(), } } - pub fn sender(&self) -> Result { + pub fn sender(&self) -> Result { match &self.0 { TxEnvelope::Legacy(tx) => tx.recover_signer(), TxEnvelope::Eip2930(tx) => tx.recover_signer(), TxEnvelope::Eip1559(tx) => tx.recover_signer(), TxEnvelope::Eip4844(tx) => tx.recover_signer(), + _ => todo!(), } } @@ -119,6 +129,7 @@ impl ConsensusTx { TxEnvelope::Eip2930(tx) => tx.tx().chain_id(), TxEnvelope::Eip1559(tx) => tx.tx().chain_id(), TxEnvelope::Eip4844(tx) => tx.tx().chain_id(), + _ => todo!(), } } @@ -131,6 +142,7 @@ impl ConsensusTx { TxEip4844Variant::TxEip4844(tx) => Some(tx.access_list.clone()), TxEip4844Variant::TxEip4844WithSidecar(tx) => Some(tx.tx().access_list.clone()), }, + _ => todo!(), } } @@ -143,6 +155,7 @@ impl ConsensusTx { TxEip4844Variant::TxEip4844(tx) => Some(tx.max_fee_per_gas), TxEip4844Variant::TxEip4844WithSidecar(tx) => Some(tx.tx().max_fee_per_gas), }, + _ => todo!(), } } @@ -157,6 +170,7 @@ impl ConsensusTx { Some(tx.tx().max_priority_fee_per_gas) } }, + _ => todo!(), } } @@ -171,6 +185,7 @@ impl ConsensusTx { Some(tx.tx().blob_versioned_hashes.clone()) } }, + _ => todo!(), } } @@ -183,6 +198,7 @@ impl ConsensusTx { TxEip4844Variant::TxEip4844(tx) => Some(tx.max_fee_per_blob_gas), TxEip4844Variant::TxEip4844WithSidecar(tx) => Some(tx.tx().max_fee_per_blob_gas), }, + _ => todo!(), } } } @@ -194,26 +210,15 @@ impl TryFrom for ConsensusTx { type Error = Error; fn try_from(tx: RpcTx) -> Result { let chain_id = tx.chain_id(); - let nonce: u64 = - tx.0.nonce - .try_into() - .map_err(|_| Error::ConversionError(Field::Nonce))?; - let gas_limit: u64 = - tx.0.gas - .try_into() - .map_err(|_| Error::ConversionError(Field::GasLimit))?; - let to = tx.to(); + let nonce: u64 = tx.0.nonce; + let gas_limit: u128 = tx.0.gas; + let value = tx.0.value; let input = tx.0.input.clone(); match &tx.version()? { TxType::Legacy => { - let gas_price: u128 = if let Some(gas_price) = tx.0.gas_price { - gas_price - .try_into() - .map_err(|_| Error::ConversionError(Field::GasPrice))? - } else { - 0 - }; + let to = tx.to(); + let gas_price: u128 = tx.0.gas_price.unwrap_or_default(); let res = TxLegacy { chain_id, @@ -227,13 +232,8 @@ impl TryFrom for ConsensusTx { Ok(ConsensusTx(res.into_signed(tx.signature()?).into())) } TxType::Eip2930 => { - let gas_price: u128 = if let Some(gas_price) = tx.0.gas_price { - gas_price - .try_into() - .map_err(|_| Error::ConversionError(Field::GasPrice))? - } else { - 0 - }; + let to = tx.to(); + let gas_price: u128 = tx.0.gas_price.unwrap_or_default(); let res = TxEip2930 { chain_id: chain_id.unwrap(), @@ -248,6 +248,7 @@ impl TryFrom for ConsensusTx { Ok(ConsensusTx(res.into_signed(tx.signature()?).into())) } TxType::Eip1559 => { + let to = tx.to(); let max_fee_per_gas = tx.max_fee_per_gas()?; let max_priority_fee_per_gas = tx.max_priority_fee_per_gas()?; let res = TxEip1559 { @@ -264,6 +265,15 @@ impl TryFrom for ConsensusTx { Ok(ConsensusTx(res.into_signed(tx.signature()?).into())) } TxType::Eip4844 => { + let to = match tx.to() { + TxKind::Call(to) => to, + TxKind::Create => return Err(Error::InvalidTxVersion), + }; + let blob_versioned_hashes = tx + .clone() + .0 + .blob_versioned_hashes + .ok_or(Error::ConversionError(Field::Input))?; let max_fee_per_gas = tx.max_fee_per_gas()?; let max_priority_fee_per_gas = tx.max_priority_fee_per_gas()?; let max_fee_per_blob_gas = tx.max_fee_per_blob_gas()?; @@ -279,7 +289,7 @@ impl TryFrom for ConsensusTx { max_fee_per_gas, max_priority_fee_per_gas, max_fee_per_blob_gas, - blob_versioned_hashes: tx.0.blob_versioned_hashes.clone(), + blob_versioned_hashes, }; Ok(ConsensusTx(res.into_signed(tx.signature()?).into())) } @@ -289,55 +299,46 @@ impl TryFrom for ConsensusTx { impl RpcTx { fn chain_id(&self) -> Option { - self.0 - .chain_id - .as_ref() - .map(|chain_id| chain_id.try_into().unwrap()) + self.0.chain_id } fn to(&self) -> TxKind { - match &self.0.to { - Some(to) => TxKind::Call(*to), + match self.0.to { + Some(to) => TxKind::Call(to), None => TxKind::Create, } } fn version(&self) -> Result { - match &self.0.transaction_type { - Some(tx_type) if tx_type == &U64::from(0) => Ok(TxType::Legacy), - Some(tx_type) if tx_type == &U64::from(1) => Ok(TxType::Eip2930), - Some(tx_type) if tx_type == &U64::from(2) => Ok(TxType::Eip1559), - Some(tx_type) if tx_type == &U64::from(3) => Ok(TxType::Eip4844), + match self.0.transaction_type { + Some(0) => Ok(TxType::Legacy), + Some(1) => Ok(TxType::Eip2930), + Some(2) => Ok(TxType::Eip1559), + Some(3) => Ok(TxType::Eip4844), None => Ok(TxType::Legacy), _ => Err(Error::InvalidTxVersion), } } fn max_fee_per_gas(&self) -> Result { - if let Some(value) = &self.0.max_fee_per_gas { - Ok(value - .try_into() - .map_err(|_| Error::ConversionError(Field::MaxFeePerGas))?) + if let Some(value) = self.0.max_fee_per_gas { + Ok(value) } else { Ok(0) } } fn max_priority_fee_per_gas(&self) -> Result { - if let Some(value) = &self.0.max_priority_fee_per_gas { - Ok(value - .try_into() - .map_err(|_| Error::ConversionError(Field::MaxPriorityFeePerGas))?) + if let Some(value) = self.0.max_priority_fee_per_gas { + Ok(value) } else { Ok(0) } } fn max_fee_per_blob_gas(&self) -> Result { - if let Some(value) = &self.0.max_fee_per_blob_gas { - Ok(value - .try_into() - .map_err(|_| Error::ConversionError(Field::MaxFeePerBlobGas))?) + if let Some(value) = self.0.max_fee_per_blob_gas { + Ok(value) } else { Ok(0) } @@ -365,13 +366,7 @@ impl RpcTx { fn access_list(&self) -> Result { if let Some(al) = self.0.access_list.clone() { - let mut target_list_items: Vec<_> = vec![]; - for item in al { - target_list_items.push(AccessListItem { - address: item.address, - storage_keys: item.storage_keys, - }); - } + let target_list_items: Vec = Vec::::from(al); Ok(AccessList(target_list_items)) } else { Err(Error::ConversionError(Field::AccessList)) diff --git a/src/tx_receipt.rs b/src/tx_receipt.rs index c393c55..4fe6d5d 100644 --- a/src/tx_receipt.rs +++ b/src/tx_receipt.rs @@ -1,11 +1,11 @@ use crate::Error; -use alloy_consensus::{Receipt, ReceiptWithBloom}; -use alloy_consensus::{ReceiptEnvelope, TxType}; -use alloy_eips::eip2718::Decodable2718; -use alloy_network::eip2718::Encodable2718; -use alloy_primitives::U64; -use alloy_primitives::{Bloom, Log, LogData, U8}; -use alloy_rpc_types::{Log as RpcLog, TransactionReceipt}; +use alloy::consensus::{Eip658Value, Receipt, ReceiptWithBloom, TxReceipt}; +use alloy::consensus::{ReceiptEnvelope, TxType}; +use alloy::eips::eip2718::Decodable2718; +use alloy::network::eip2718::Encodable2718; + +use alloy::primitives::{Bloom, Log, LogData}; +use alloy::rpc::types::{Log as RpcLog, TransactionReceipt}; #[derive(Debug, Clone)] pub struct ConsensusTxReceipt(pub ReceiptEnvelope); @@ -16,25 +16,27 @@ impl ConsensusTxReceipt { } pub fn rlp_decode(mut data: &[u8]) -> Result { - let envelope = ReceiptEnvelope::decode_2718(&mut data).map_err(Error::Rlp)?; + let envelope = ReceiptEnvelope::decode_2718(&mut data).map_err(Error::Eip)?; Ok(ConsensusTxReceipt(envelope)) } - pub fn success(&self) -> bool { + pub fn status(&self) -> &Eip658Value { match &self.0 { - ReceiptEnvelope::Legacy(receipt) => receipt.receipt.success, - ReceiptEnvelope::Eip2930(receipt) => receipt.receipt.success, - ReceiptEnvelope::Eip1559(receipt) => receipt.receipt.success, - ReceiptEnvelope::Eip4844(receipt) => receipt.receipt.success, + ReceiptEnvelope::Legacy(receipt) => receipt.receipt.status_or_post_state(), + ReceiptEnvelope::Eip2930(receipt) => receipt.receipt.status_or_post_state(), + ReceiptEnvelope::Eip1559(receipt) => receipt.receipt.status_or_post_state(), + ReceiptEnvelope::Eip4844(receipt) => receipt.receipt.status_or_post_state(), + _ => todo!(), } } - pub fn cumulative_gas_used(&self) -> u64 { + pub fn cumulative_gas_used(&self) -> u128 { match &self.0 { ReceiptEnvelope::Legacy(receipt) => receipt.receipt.cumulative_gas_used, ReceiptEnvelope::Eip2930(receipt) => receipt.receipt.cumulative_gas_used, ReceiptEnvelope::Eip1559(receipt) => receipt.receipt.cumulative_gas_used, ReceiptEnvelope::Eip4844(receipt) => receipt.receipt.cumulative_gas_used, + _ => todo!(), } } @@ -44,15 +46,17 @@ impl ConsensusTxReceipt { ReceiptEnvelope::Eip2930(receipt) => receipt.receipt.logs.clone(), ReceiptEnvelope::Eip1559(receipt) => receipt.receipt.logs.clone(), ReceiptEnvelope::Eip4844(receipt) => receipt.receipt.logs.clone(), + _ => todo!(), } } pub fn bloom(&self) -> Bloom { match &self.0 { - ReceiptEnvelope::Legacy(receipt) => receipt.bloom, - ReceiptEnvelope::Eip2930(receipt) => receipt.bloom, - ReceiptEnvelope::Eip1559(receipt) => receipt.bloom, - ReceiptEnvelope::Eip4844(receipt) => receipt.bloom, + ReceiptEnvelope::Legacy(receipt) => receipt.bloom(), + ReceiptEnvelope::Eip2930(receipt) => receipt.bloom(), + ReceiptEnvelope::Eip1559(receipt) => receipt.bloom(), + ReceiptEnvelope::Eip4844(receipt) => receipt.bloom(), + _ => todo!(), } } } @@ -67,44 +71,44 @@ impl TryFrom for ConsensusTxReceipt { TxType::Legacy => { let res = ReceiptEnvelope::Legacy(ReceiptWithBloom { receipt: Receipt { - success: tx.success(), + status: Eip658Value::from(tx.status()), cumulative_gas_used: tx.cumulative_gas_used(), logs: tx.logs(), }, - bloom: tx.bloom(), + logs_bloom: tx.bloom(), }); Ok(ConsensusTxReceipt(res)) } TxType::Eip2930 => { let res = ReceiptEnvelope::Eip2930(ReceiptWithBloom { receipt: Receipt { - success: tx.success(), + status: Eip658Value::from(tx.status()), cumulative_gas_used: tx.cumulative_gas_used(), logs: tx.logs(), }, - bloom: tx.bloom(), + logs_bloom: tx.bloom(), }); Ok(ConsensusTxReceipt(res)) } TxType::Eip1559 => { let res = ReceiptEnvelope::Eip1559(ReceiptWithBloom { receipt: Receipt { - success: tx.success(), + status: Eip658Value::from(tx.status()), cumulative_gas_used: tx.cumulative_gas_used(), logs: tx.logs(), }, - bloom: tx.bloom(), + logs_bloom: tx.bloom(), }); Ok(ConsensusTxReceipt(res)) } TxType::Eip4844 => { let res = ReceiptEnvelope::Eip4844(ReceiptWithBloom { receipt: Receipt { - success: tx.success(), + status: Eip658Value::from(tx.status()), cumulative_gas_used: tx.cumulative_gas_used(), logs: tx.logs(), }, - bloom: tx.bloom(), + logs_bloom: tx.bloom(), }); Ok(ConsensusTxReceipt(res)) } @@ -114,46 +118,28 @@ impl TryFrom for ConsensusTxReceipt { impl RpcTxReceipt { fn version(&self) -> Result { - match &self.0.transaction_type { - // Legacy - tx_type if tx_type == &U8::from(0) => Ok(TxType::Legacy), - // EIP-2930 - tx_type if tx_type == &U8::from(1) => Ok(TxType::Eip2930), - // EIP-1559 - tx_type if tx_type == &U8::from(2) => Ok(TxType::Eip1559), - // EIP-4844 - tx_type if tx_type == &U8::from(3) => Ok(TxType::Eip4844), - _ => Err(Error::InvalidTxVersion), - } + Ok(self.0.transaction_type()) } - fn success(&self) -> bool { - match &self.0.status_code { - Some(status) => status == &U64::from(1), - None => false, - } + fn status(&self) -> bool { + self.0.status() } - fn cumulative_gas_used(&self) -> u64 { - self.0.cumulative_gas_used.try_into().unwrap() + fn cumulative_gas_used(&self) -> u128 { + self.0.inner.cumulative_gas_used() } - fn logs(&self) -> Vec> { + fn logs(&self) -> Vec> { let mut logs = Vec::new(); - for log in &self.0.logs { + for log in self.0.inner.logs() { let rpc_log: RpcLog = log.clone(); - let log_data = LogData::try_from(rpc_log).unwrap(); - let result = Log { - address: log.address, - data: log_data, - }; + let result = rpc_log.inner; logs.push(result); } - logs } fn bloom(&self) -> Bloom { - self.0.logs_bloom + self.0.inner.bloom() } } diff --git a/src/tx_receipt_trie.rs b/src/tx_receipt_trie.rs index 4d3fe4d..c756f2e 100644 --- a/src/tx_receipt_trie.rs +++ b/src/tx_receipt_trie.rs @@ -1,9 +1,10 @@ use std::sync::Arc; -use alloy_network::eip2718::Encodable2718; -use alloy_primitives::{B256, U256}; +use alloy::network::eip2718::Encodable2718; +use alloy::primitives::{B256, U256}; use eth_trie::{EthTrie, MemoryDB, Trie}; use ethereum_types::H256; +use url::Url; use crate::{ rpc::RpcProvider, @@ -33,7 +34,7 @@ impl TxReceiptsMptHandler { /// Creates a new [`TxReceiptsMptHandler`] with a given RPC provider URL. /// /// This does not initialize the trie yet. - pub fn new(url: &str) -> Result { + pub fn new(url: Url) -> Result { let provider = RpcProvider::new(url); Ok(Self { provider, @@ -95,7 +96,6 @@ impl TxReceiptsMptHandler { let rlp = tx.0.encoded_2718(); trie.insert(key.as_slice(), rlp.as_slice())?; } - if trie.root_hash()?.as_bytes() != expected_root.as_slice() { return Err(Error::UnexpectedRoot); } @@ -158,8 +158,8 @@ impl TxReceiptsMptHandler { #[cfg(test)] mod tests { use super::*; - use alloy_primitives::hex; - use alloy_primitives::B256; + use alloy::primitives::hex; + use alloy::primitives::B256; const MAINNET_RPC_URL: &str = "https://mainnet.infura.io/v3/720000a7936b45c79d0868f70478e2e9"; @@ -171,11 +171,12 @@ mod tests { #[tokio::test] async fn test_tx_receipt_byzantium() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); let target_tx_hash = B256::from(hex!( "1fcb1196d8a3bff0bcf13309d2d2bb1a23ae1ac13f5674c801be0ff9254d5ab5" )); - let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(url).unwrap(); tx_receipts_mpt_handler .build_tx_receipts_tree_from_block(4370000) .await @@ -193,11 +194,12 @@ mod tests { #[tokio::test] async fn test_tx_receipt_2930() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); let target_tx_hash = B256::from(hex!( "aa40dd75b18f375df1ae9a7f7de217fa3bc49b94db3c4da7b3974130990aefef" )); - let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(url).unwrap(); tx_receipts_mpt_handler .build_tx_receipts_tree_from_block(12244000) .await @@ -215,11 +217,12 @@ mod tests { #[tokio::test] async fn test_tx_receipt_1559() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); let target_tx_hash = B256::from(hex!( "2055b7e01304f87f9412cd44758cd248bc2da2dab95c97026064ffb084711735" )); - let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(url).unwrap(); tx_receipts_mpt_handler .build_tx_receipts_tree_from_block(12965000) .await @@ -237,12 +240,13 @@ mod tests { #[tokio::test] async fn test_tx_receipt_4844() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); // 4844 transaction let target_tx_hash = B256::from(hex!( "9c1fbda4f649ac806ab0faefbe94e1a60282eb374ead6aa01bac042f52b28a8c" )); - let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut tx_receipts_mpt_handler = TxReceiptsMptHandler::new(url).unwrap(); tx_receipts_mpt_handler .build_tx_receipts_tree_from_block(19426589) .await diff --git a/src/tx_trie.rs b/src/tx_trie.rs index f241f14..edbdb9a 100644 --- a/src/tx_trie.rs +++ b/src/tx_trie.rs @@ -1,9 +1,10 @@ use std::sync::Arc; -use alloy_network::eip2718::Encodable2718; -use alloy_primitives::{B256, U256}; +use alloy::network::eip2718::Encodable2718; +use alloy::primitives::{B256, U256}; use eth_trie::{EthTrie, MemoryDB, Trie as _}; use ethereum_types::H256; +use url::Url; use crate::{ rpc::RpcProvider, @@ -33,7 +34,7 @@ impl TxsMptHandler { /// Creates a new [`TxsMptHandler`] with a given RPC provider URL. /// /// This does not initialize the trie yet. - pub fn new(url: &str) -> Result { + pub fn new(url: Url) -> Result { let provider = RpcProvider::new(url); Ok(Self { provider, @@ -152,8 +153,8 @@ impl TxsMptHandler { #[cfg(test)] mod tests { use super::*; - use alloy_primitives::hex; - use alloy_primitives::B256; + use alloy::primitives::hex; + use alloy::primitives::B256; const MAINNET_RPC_URL: &str = "https://mainnet.infura.io/v3/720000a7936b45c79d0868f70478e2e9"; @@ -166,11 +167,12 @@ mod tests { #[tokio::test] async fn test_tx_mpt_frontier() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); let target_tx_hash = B256::from(hex!( "5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060" )); - let mut txs_mpt_handler = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler = TxsMptHandler::new(url).unwrap(); txs_mpt_handler .build_tx_tree_from_block(46147) @@ -183,7 +185,8 @@ mod tests { .verify_proof(tx_index, proof.clone()) .unwrap(); - let mut txs_mpt_handler2 = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let url = Url::parse(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler2 = TxsMptHandler::new(url).unwrap(); txs_mpt_handler2 .build_tx_tree_from_tx_hash(target_tx_hash) @@ -198,11 +201,12 @@ mod tests { #[tokio::test] async fn test_tx_mpt_byzantium() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); let target_tx_hash = B256::from(hex!( "1fcb1196d8a3bff0bcf13309d2d2bb1a23ae1ac13f5674c801be0ff9254d5ab5" )); - let mut txs_mpt_handler = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler = TxsMptHandler::new(url).unwrap(); txs_mpt_handler .build_tx_tree_from_block(4370000) @@ -215,7 +219,8 @@ mod tests { .verify_proof(tx_index, proof.clone()) .unwrap(); - let mut txs_mpt_handler2 = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let url = Url::parse(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler2 = TxsMptHandler::new(url).unwrap(); txs_mpt_handler2 .build_tx_tree_from_tx_hash(target_tx_hash) @@ -230,11 +235,12 @@ mod tests { #[tokio::test] async fn test_tx_mpt_2930() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); let target_tx_hash = B256::from(hex!( "aa40dd75b18f375df1ae9a7f7de217fa3bc49b94db3c4da7b3974130990aefef" )); - let mut txs_mpt_handler = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler = TxsMptHandler::new(url).unwrap(); txs_mpt_handler .build_tx_tree_from_block(12244000) @@ -247,7 +253,8 @@ mod tests { .verify_proof(tx_index, proof.clone()) .unwrap(); - let mut txs_mpt_handler2 = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let url = Url::parse(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler2 = TxsMptHandler::new(url).unwrap(); txs_mpt_handler2 .build_tx_tree_from_tx_hash(target_tx_hash) @@ -262,11 +269,12 @@ mod tests { #[tokio::test] async fn test_tx_mpt_1559() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); let target_tx_hash = B256::from(hex!( "2055b7e01304f87f9412cd44758cd248bc2da2dab95c97026064ffb084711735" )); - let mut txs_mpt_handler = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler = TxsMptHandler::new(url).unwrap(); txs_mpt_handler .build_tx_tree_from_block(12965000) @@ -279,7 +287,8 @@ mod tests { .verify_proof(tx_index, proof.clone()) .unwrap(); - let mut txs_mpt_handler2 = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let url = Url::parse(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler2 = TxsMptHandler::new(url).unwrap(); txs_mpt_handler2 .build_tx_tree_from_tx_hash(target_tx_hash) @@ -294,12 +303,13 @@ mod tests { #[tokio::test] async fn test_tx_mpt_4844() { + let url = Url::parse(MAINNET_RPC_URL).unwrap(); // 4844 transaction let target_tx_hash = B256::from(hex!( "9c1fbda4f649ac806ab0faefbe94e1a60282eb374ead6aa01bac042f52b28a8c" )); - let mut txs_mpt_handler = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler = TxsMptHandler::new(url).unwrap(); txs_mpt_handler .build_tx_tree_from_block(19426589) @@ -312,7 +322,8 @@ mod tests { .verify_proof(tx_index, proof.clone()) .unwrap(); - let mut txs_mpt_handler2 = TxsMptHandler::new(MAINNET_RPC_URL).unwrap(); + let url = Url::parse(MAINNET_RPC_URL).unwrap(); + let mut txs_mpt_handler2 = TxsMptHandler::new(url).unwrap(); txs_mpt_handler2 .build_tx_tree_from_tx_hash(target_tx_hash)