From 8b8f26b4a9329f4bd21ba417beff4235e386a712 Mon Sep 17 00:00:00 2001 From: 0xaatif <169152398+0xaatif@users.noreply.github.com> Date: Sat, 31 Aug 2024 14:59:21 +0100 Subject: [PATCH] chore: update alloy (#573) * mark: 0xaatif/update-alloy * chore: alloy 0.1.0 -> alloy 0.3.0 * chore: alloy git -> crates.io --- Cargo.lock | 161 +++++++++++++++------ Cargo.toml | 3 +- trace_decoder/tests/trace_decoder_tests.rs | 2 +- zero_bin/common/src/provider.rs | 18 +-- zero_bin/rpc/src/lib.rs | 15 +- zero_bin/rpc/src/native/state.rs | 5 +- 6 files changed, 132 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 472554ab5..11feda934 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,18 +58,19 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eadd758805fe353ea8a520da4531efb9739382312c354d3e90b7a16353b0315" dependencies = [ "alloy-consensus", "alloy-core", + "alloy-eips", "alloy-json-rpc", "alloy-provider", "alloy-rpc-client", "alloy-rpc-types", "alloy-transport", "alloy-transport-http", - "reqwest", ] [[package]] @@ -84,8 +85,9 @@ dependencies = [ [[package]] name = "alloy-consensus" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7198a527b4c4762cb88d54bcaeb0428f4298b72552c9c8ec4af614b4a4990c59" dependencies = [ "alloy-eips", "alloy-primitives", @@ -97,19 +99,44 @@ dependencies = [ [[package]] name = "alloy-core" -version = "0.7.7" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e6dbb79f4e3285cc87f50c0d4be9a3a812643623b2e3558d425b41cbd795ceb" +dependencies = [ + "alloy-primitives", + "alloy-rlp", +] + +[[package]] +name = "alloy-eip2930" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0069cf0642457f87a01a014f6dc29d5d893cd4fd8fddf0c3cdfad1bb3ebafc41" +dependencies = [ + "alloy-primitives", + "alloy-rlp", + "serde", +] + +[[package]] +name = "alloy-eip7702" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "529fc6310dc1126c8de51c376cbc59c79c7f662bd742be7dc67055d5421a81b4" +checksum = "37d319bb544ca6caeab58c39cea8921c55d924d4f68f2c60f24f914673f9a74a" dependencies = [ "alloy-primitives", "alloy-rlp", + "serde", ] [[package]] name = "alloy-eips" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "159eab0e4e15b88571f55673af37314f4b8f17630dc1b393c3d70f2128a1d494" dependencies = [ + "alloy-eip2930", + "alloy-eip7702", "alloy-primitives", "alloy-rlp", "alloy-serde", @@ -121,10 +148,12 @@ dependencies = [ [[package]] name = "alloy-json-rpc" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7733446dd531f8eb877331fea02f6c40bdbb47444a17dc3464bf75319cc073a" dependencies = [ "alloy-primitives", + "alloy-sol-types", "serde", "serde_json", "thiserror", @@ -133,12 +162,14 @@ dependencies = [ [[package]] name = "alloy-network" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b80851d1697fc4fa2827998e3ee010a3d1fc59c7d25e87070840169fcf465832" dependencies = [ "alloy-consensus", "alloy-eips", "alloy-json-rpc", + "alloy-network-primitives", "alloy-primitives", "alloy-rpc-types-eth", "alloy-serde", @@ -150,11 +181,22 @@ dependencies = [ "thiserror", ] +[[package]] +name = "alloy-network-primitives" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76a2336889f3d0624b18213239d27f4f34eb476eb35bef22f6a8cc24e0c0078" +dependencies = [ + "alloy-primitives", + "alloy-serde", + "serde", +] + [[package]] name = "alloy-primitives" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccb3ead547f4532bc8af961649942f0b9c16ee9226e26caa3f38420651cc0bf4" +checksum = "a767e59c86900dd7c3ce3ecef04f3ace5ac9631ee150beb8b7d22f7fa3bbb2d7" dependencies = [ "alloy-rlp", "bytes", @@ -174,14 +216,16 @@ dependencies = [ [[package]] name = "alloy-provider" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d2a195caa6707f5ce13905794865765afc6d9ea92c3a56e3a973c168d703bc" dependencies = [ "alloy-chains", "alloy-consensus", "alloy-eips", "alloy-json-rpc", "alloy-network", + "alloy-network-primitives", "alloy-primitives", "alloy-rpc-client", "alloy-rpc-types-eth", @@ -191,7 +235,7 @@ dependencies = [ "async-stream", "async-trait", "auto_impl", - "dashmap", + "dashmap 6.0.1", "futures", "futures-utils-wasm", "lru", @@ -199,6 +243,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "thiserror", "tokio", "tracing", "url", @@ -228,8 +273,9 @@ dependencies = [ [[package]] name = "alloy-rpc-client" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed31cdba2b23d71c555505b06674f8e7459496abfd7f4875d268434ef5a99ee6" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -248,21 +294,25 @@ dependencies = [ [[package]] name = "alloy-rpc-types" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d758f65aa648491c6358335c578de45cd7de6fdf2877c3cef61f2c9bebea21" dependencies = [ "alloy-rpc-types-eth", "alloy-rpc-types-trace", "alloy-serde", + "serde", ] [[package]] name = "alloy-rpc-types-eth" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ba05d6ee4db0d89113294a614137940f79abfc2c40a9a3bee2995660358776" dependencies = [ "alloy-consensus", "alloy-eips", + "alloy-network-primitives", "alloy-primitives", "alloy-rlp", "alloy-serde", @@ -275,20 +325,23 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd2af822ed58f2b6dd7cfccf88bf69f42c9a8cbf4663316227646a8a3e5a591f" dependencies = [ "alloy-primitives", "alloy-rpc-types-eth", "alloy-serde", "serde", "serde_json", + "thiserror", ] [[package]] name = "alloy-serde" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfd260ede54f0b53761fdd04133acc10ae70427f66a69aa9590529bbd066cd58" dependencies = [ "alloy-primitives", "serde", @@ -297,8 +350,9 @@ dependencies = [ [[package]] name = "alloy-signer" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5193ee6b370b89db154d7dc40c6a8e6ce11213865baaf2b418a9f2006be762" dependencies = [ "alloy-primitives", "async-trait", @@ -310,9 +364,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b40397ddcdcc266f59f959770f601ce1280e699a91fc1862f29cef91707cd09" +checksum = "183bcfc0f3291d9c41a3774172ee582fb2ce6eb6569085471d8f225de7bb86fc" dependencies = [ "alloy-sol-macro-expander", "alloy-sol-macro-input", @@ -324,9 +378,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-expander" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "867a5469d61480fea08c7333ffeca52d5b621f5ca2e44f271b117ec1fc9a0525" +checksum = "71c4d842beb7a6686d04125603bc57614d5ed78bf95e4753274db3db4ba95214" dependencies = [ "alloy-sol-macro-input", "const-hex", @@ -342,9 +396,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e482dc33a32b6fadbc0f599adea520bd3aaa585c141a80b404d0a3e3fa72528" +checksum = "1306e8d3c9e6e6ecf7a39ffaf7291e73a5f655a2defd366ee92c2efebcdf7fee" dependencies = [ "const-hex", "dunce", @@ -357,9 +411,9 @@ dependencies = [ [[package]] name = "alloy-sol-types" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91ca40fa20793ae9c3841b83e74569d1cc9af29a2f5237314fd3452d51e38c7" +checksum = "577e262966e92112edbd15b1b2c0947cc434d6e8311df96d3329793fe8047da9" dependencies = [ "alloy-primitives", "alloy-sol-macro", @@ -368,8 +422,9 @@ dependencies = [ [[package]] name = "alloy-transport" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "454220c714857cf68af87d788d1f0638ad8766268b94f6a49fed96cbc2ab382c" dependencies = [ "alloy-json-rpc", "base64", @@ -380,13 +435,15 @@ dependencies = [ "thiserror", "tokio", "tower", + "tracing", "url", ] [[package]] name = "alloy-transport-http" -version = "0.1.1" -source = "git+https://github.com/alloy-rs/alloy?tag=v0.1.1#f04a704ac5be9cb21b4b1f6c35f925607f1aa939" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "377f2353d7fea03a2dba6b9ffbb7d610402c040dd5700d1fae8b9ec2673eed9b" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -1549,6 +1606,20 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "dashmap" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "data-encoding" version = "2.6.0" @@ -3231,7 +3302,7 @@ dependencies = [ "clap", "crossbeam", "crossbeam-skiplist", - "dashmap", + "dashmap 5.5.3", "dotenvy", "futures", "lapin", @@ -4683,9 +4754,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c837dc8852cb7074e46b444afb81783140dab12c58867b49fb3898fbafedf7ea" +checksum = "284c41c2919303438fcf8dede4036fd1e82d4fc0fbb2b279bd2a1442c909ca92" dependencies = [ "paste", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index cd48fcca2..008257556 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ categories = ["cryptography::cryptocurrencies"] [workspace.dependencies] __compat_primitive_types = { version = "0.12.2", package = "primitive-types" } -alloy = { git = "https://github.com/alloy-rs/alloy", tag = 'v0.1.1', default-features = false, features = [ +alloy = { version = '0.3.0', default-features = false, features = [ "consensus", "reqwest", "json-rpc", @@ -139,4 +139,3 @@ trybuild = "1.0" [workspace.lints.clippy] too_long_first_doc_paragraph = "allow" - diff --git a/trace_decoder/tests/trace_decoder_tests.rs b/trace_decoder/tests/trace_decoder_tests.rs index 63cd4dd37..6db98749f 100644 --- a/trace_decoder/tests/trace_decoder_tests.rs +++ b/trace_decoder/tests/trace_decoder_tests.rs @@ -137,7 +137,7 @@ fn verify_generation_inputs( // Block hash check assert_eq!( last_generation_input.block_hashes.cur_hash.as_bytes(), - &header.hash.unwrap().to_vec() + &header.hash.to_vec() ); // Previous block hash check assert_eq!( diff --git a/zero_bin/common/src/provider.rs b/zero_bin/common/src/provider.rs index cb1472dbd..876cb270c 100644 --- a/zero_bin/common/src/provider.rs +++ b/zero_bin/common/src/provider.rs @@ -105,15 +105,15 @@ where .await? .context(format!("target block {:?} does not exist", id))?; - if let Some(block_num) = block.header.number { - self.blocks_by_number - .lock() - .await - .put(block_num, block.clone()); - if let Some(hash) = block.header.hash { - self.blocks_by_hash.lock().await.put(hash, block_num); - } - } + self.blocks_by_number + .lock() + .await + .put(block.header.number, block.clone()); + self.blocks_by_hash + .lock() + .await + .put(block.header.hash, block.header.number); + Ok(block) } } diff --git a/zero_bin/rpc/src/lib.rs b/zero_bin/rpc/src/lib.rs index 10bcb0fad..c27015df6 100644 --- a/zero_bin/rpc/src/lib.rs +++ b/zero_bin/rpc/src/lib.rs @@ -111,7 +111,7 @@ where .context("couldn't get block")?; anyhow::Ok([ (block.header.hash, Some(block_num)), - (Some(block.header.parent_hash), previous_block_number), + (block.header.parent_hash, previous_block_number), ]) } }), @@ -128,7 +128,7 @@ where .skip(odd_offset as usize) .take(PREVIOUS_HASHES_COUNT) .for_each(|(hash, block_num)| { - if let (Some(hash), Some(block_num)) = (hash, block_num) { + if let (hash, Some(block_num)) = (hash, block_num) { // Most recent previous block hash is expected at the end of the array prev_hashes [PREVIOUS_HASHES_COUNT - (target_block_number - block_num as u64) as usize] = @@ -215,10 +215,7 @@ where let target_block = cached_provider .get_block(target_block_id, BlockTransactionsKind::Hashes) .await?; - let target_block_number = target_block - .header - .number - .context("target block is missing field `number`")?; + let target_block_number = target_block.header.number; let chain_id = cached_provider.get_provider().await?.get_chain_id().await?; let prev_hashes = fetch_previous_block_hashes(cached_provider, target_block_number).await?; @@ -261,11 +258,7 @@ where }, b_hashes: BlockHashes { prev_hashes: prev_hashes.map(|it| it.compat()).into(), - cur_hash: target_block - .header - .hash - .context("target block is missing field `hash`")? - .compat(), + cur_hash: target_block.header.hash.compat(), }, withdrawals: target_block .withdrawals diff --git a/zero_bin/rpc/src/native/state.rs b/zero_bin/rpc/src/native/state.rs index f988e9788..b46eabc9d 100644 --- a/zero_bin/rpc/src/native/state.rs +++ b/zero_bin/rpc/src/native/state.rs @@ -31,10 +31,7 @@ where { let state_access = process_states_access(txn_infos, &block)?; - let block_number = block - .header - .number - .context("Block number not returned with block")?; + let block_number = block.header.number; let prev_state_root = cached_provider .get_block((block_number - 1).into(), BlockTransactionsKind::Hashes) .await?