fix: prevent logs for unseen blocks (#192)

This commit is contained in:
Noah Citron 2023-02-08 18:12:41 -05:00 committed by GitHub
parent 1b1a540340
commit 4066828387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -291,7 +291,22 @@ impl<R: ExecutionRpc> ExecutionClient<R> {
filter: &Filter,
payloads: &BTreeMap<u64, ExecutionPayload>,
) -> Result<Vec<Log>> {
let logs = self.rpc.get_logs(filter).await?;
let filter = filter.clone();
// avoid fetching logs for a block helios hasn't seen yet
let filter = if filter.get_to_block().is_none() && filter.get_block_hash().is_none() {
let block = *payloads.last_key_value().unwrap().0;
let filter = filter.to_block(block);
if filter.get_from_block().is_none() {
filter.from_block(block)
} else {
filter
}
} else {
filter
};
let logs = self.rpc.get_logs(&filter).await?;
if logs.len() > MAX_SUPPORTED_LOGS_NUMBER {
return Err(
ExecutionError::TooManyLogsToProve(logs.len(), MAX_SUPPORTED_LOGS_NUMBER).into(),