Skip to content

Commit

Permalink
fix: ToBlock argument in L1 getLogs is inclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Dec 17, 2024
1 parent df3c51b commit 5140327
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
34 changes: 19 additions & 15 deletions yarn-project/archiver/src/archiver/data_retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ export async function retrieveBlocksFromRollup(
if (searchStartBlock > searchEndBlock) {
break;
}
const l2BlockProposedLogs = await rollup.getEvents.L2BlockProposed(
{},
{
fromBlock: searchStartBlock,
toBlock: searchEndBlock + 1n,
},
);
const l2BlockProposedLogs = (
await rollup.getEvents.L2BlockProposed(
{},
{
fromBlock: searchStartBlock,
toBlock: searchEndBlock,
},
)
).filter(log => log.blockNumber! >= searchStartBlock && log.blockNumber! <= searchEndBlock);

if (l2BlockProposedLogs.length === 0) {
break;
Expand Down Expand Up @@ -218,13 +220,15 @@ export async function retrieveL1ToL2Messages(
break;
}

const messageSentLogs = await inbox.getEvents.MessageSent(
{},
{
fromBlock: searchStartBlock,
toBlock: searchEndBlock + 1n,
},
);
const messageSentLogs = (
await inbox.getEvents.MessageSent(
{},
{
fromBlock: searchStartBlock,
toBlock: searchEndBlock,
},
)
).filter(log => log.blockNumber! >= searchStartBlock && log.blockNumber! <= searchEndBlock);

if (messageSentLogs.length === 0) {
break;
Expand All @@ -251,7 +255,7 @@ export async function retrieveL2ProofVerifiedEvents(
const logs = await publicClient.getLogs({
address: rollupAddress.toString(),
fromBlock: searchStartBlock,
toBlock: searchEndBlock ? searchEndBlock + 1n : undefined,
toBlock: searchEndBlock ? searchEndBlock : undefined,
strict: true,
event: getAbiItem({ abi: RollupAbi, name: 'L2ProofVerified' }),
});
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli/src/cmds/l1/prover_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async function getL2BlockEvents(
name: 'L2BlockProposed',
}),
fromBlock: blockNum,
toBlock: end + 1n, // the toBlock argument in getLogs is exclusive
toBlock: end,
});

events.push(...newEvents);
Expand Down

0 comments on commit 5140327

Please sign in to comment.