From f20818784e484a1baeaced440c95af36696e0f6a Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 15 Jan 2024 20:24:14 +0100 Subject: [PATCH] fix: handle all payload errors (#6805) --- Cargo.lock | 36 ++++++++++++++-------------- crates/anvil/src/eth/backend/fork.rs | 8 ++++--- crates/common/src/provider/tower.rs | 11 +++++---- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecafc175ce6f..26b733975040 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-eips", "alloy-network", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-primitives", "serde", @@ -156,7 +156,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "alloy-providers" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-network", "alloy-primitives", @@ -214,7 +214,7 @@ dependencies = [ [[package]] name = "alloy-pubsub" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "alloy-primitives", @@ -252,7 +252,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -269,7 +269,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -335,7 +335,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "base64 0.21.7", @@ -351,7 +351,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "alloy-transport-ipc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-json-rpc", "alloy-pubsub", @@ -382,7 +382,7 @@ dependencies = [ [[package]] name = "alloy-transport-ws" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" dependencies = [ "alloy-pubsub", "alloy-transport", @@ -3732,9 +3732,9 @@ dependencies = [ [[package]] name = "gix-trace" -version = "0.1.7" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b202d766a7fefc596e2cc6a89cda8ad8ad733aed82da635ac120691112a9b1" +checksum = "e8e1127ede0475b58f4fe9c0aaa0d9bb0bad2af90bbd93ccd307c8632b863d89" [[package]] name = "gix-utils" @@ -7943,9 +7943,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "vergen" -version = "8.2.9" +version = "8.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03c7b513a7d40506d5a07f186a298821cc9ec2cc22088a3593f7b612a66659f6" +checksum = "6cf9c2670809c4840d4648fc7daa396551d7d88966f9ba93821b81a5c0c2d3f5" dependencies = [ "anyhow", "git2", @@ -8555,4 +8555,4 @@ dependencies = [ [[patch.unused]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy#c5e9371f1c00e7fd700e28bf2e95fc5e671d93c4" +source = "git+https://github.com/alloy-rs/alloy#19bed90f9bd8b5f70dc799fd318dc0b7d7a25429" diff --git a/crates/anvil/src/eth/backend/fork.rs b/crates/anvil/src/eth/backend/fork.rs index 34a67fcf1a0d..857d241cce53 100644 --- a/crates/anvil/src/eth/backend/fork.rs +++ b/crates/anvil/src/eth/backend/fork.rs @@ -434,10 +434,12 @@ impl ClientFork { if self.predates_fork_inclusive(number) { let receipts = self.provider().get_block_receipts(BlockNumber::Number(number)).await?; - let mut storage = self.storage_write(); - storage.block_receipts.insert(number, receipts.clone()); + if let Some(receipts) = receipts.clone() { + let mut storage = self.storage_write(); + storage.block_receipts.insert(number, receipts); + } - return Ok(Some(receipts)); + return Ok(receipts); } Ok(None) diff --git a/crates/common/src/provider/tower.rs b/crates/common/src/provider/tower.rs index 5e08b836c991..632d8b29951d 100644 --- a/crates/common/src/provider/tower.rs +++ b/crates/common/src/provider/tower.rs @@ -108,13 +108,16 @@ impl Service for RetryBackoffService { match fut { Ok(res) => { - this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); - return Ok(res) + if let Some(e) = res.as_error() { + err = TransportError::ErrorResp(e.clone()) + } else { + this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); + return Ok(res) + } } Err(e) => err = e, } - let err = TransportError::from(err); let should_retry = this.policy.should_retry(&err); if should_retry { rate_limit_retry_number += 1; @@ -159,7 +162,7 @@ impl Service for RetryBackoffService { } this.requests_enqueued.fetch_sub(1, Ordering::SeqCst); - return Err(TransportErrorKind::custom_str("Max retries exceeded")) + return Err(err) } } })