Skip to content

Commit 62e28ad

Browse files
authored
fix: remove hardfork restriction on eth_getLogs (#5087)
1 parent bdf3971 commit 62e28ad

File tree

4 files changed

+62
-9
lines changed

4 files changed

+62
-9
lines changed

.changeset/friendly-steaks-travel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nomicfoundation/edr": patch
3+
---
4+
5+
Fixed eth_getLogs RPC request for pre-Merge hardforks

crates/edr_eth/src/remote/filter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub enum OneOrMore<T> {
1616
}
1717

1818
/// for specifying the inputs to `eth_newFilter` and `eth_getLogs`
19-
#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
19+
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
2020
#[serde(rename_all = "camelCase")]
2121
pub struct LogFilterOptions {
2222
/// beginning of a range of blocks

crates/edr_provider/src/requests/eth/filter.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use edr_eth::{
66
filter::{FilteredEvents, LogFilterOptions, LogOutput, OneOrMore, SubscriptionType},
77
BlockSpec, BlockTag, Eip1898BlockSpec,
88
},
9-
SpecId, U256,
9+
U256,
1010
};
1111
use edr_evm::HashSet;
1212

@@ -41,13 +41,6 @@ pub fn handle_get_logs_request<LoggerErrorT: Debug>(
4141
validate_post_merge_block_tags(data.spec_id(), to_block)?;
4242
}
4343

44-
if data.spec_id() < SpecId::MERGE {
45-
return Err(ProviderError::InvalidInput(
46-
"eth_getLogs is disabled. It only works with the Berlin hardfork or a later one."
47-
.into(),
48-
));
49-
}
50-
5144
let filter = validate_filter_criteria::<true, LoggerErrorT>(data, filter_options)?;
5245
data.logs(filter)
5346
.map(|logs| logs.iter().map(LogOutput::from).collect())
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
use edr_eth::{
2+
remote::{filter::LogFilterOptions, BlockSpec},
3+
transaction::EthTransactionRequest,
4+
AccountInfo, Address, SpecId,
5+
};
6+
use edr_evm::KECCAK_EMPTY;
7+
use edr_provider::{
8+
test_utils::{create_test_config_with_fork, one_ether},
9+
MethodInvocation, NoopLogger, Provider, ProviderRequest,
10+
};
11+
use tokio::runtime;
12+
13+
#[tokio::test(flavor = "multi_thread")]
14+
async fn issue_361() -> anyhow::Result<()> {
15+
let logger = Box::new(NoopLogger);
16+
let subscriber = Box::new(|_event| {});
17+
18+
let mut config = create_test_config_with_fork(None);
19+
config.hardfork = SpecId::MUIR_GLACIER;
20+
21+
let impersonated_account = Address::random();
22+
config.genesis_accounts.insert(
23+
impersonated_account,
24+
AccountInfo {
25+
balance: one_ether(),
26+
nonce: 0,
27+
code: None,
28+
code_hash: KECCAK_EMPTY,
29+
},
30+
);
31+
32+
let provider = Provider::new(runtime::Handle::current(), logger, subscriber, config)?;
33+
34+
provider.handle_request(ProviderRequest::Single(
35+
MethodInvocation::ImpersonateAccount(impersonated_account.into()),
36+
))?;
37+
38+
provider.handle_request(ProviderRequest::Single(MethodInvocation::SendTransaction(
39+
EthTransactionRequest {
40+
from: impersonated_account,
41+
to: Some(Address::random()),
42+
..EthTransactionRequest::default()
43+
},
44+
)))?;
45+
46+
provider.handle_request(ProviderRequest::Single(MethodInvocation::GetLogs(
47+
LogFilterOptions {
48+
from_block: Some(BlockSpec::Number(0)),
49+
to_block: Some(BlockSpec::latest()),
50+
..LogFilterOptions::default()
51+
},
52+
)))?;
53+
54+
Ok(())
55+
}

0 commit comments

Comments
 (0)