celo-org / celo-org/developer-tooling
[CLI] Introduce ability to limit block number fetched by get logs in epoch switching
- Dominant language
- TypeScript
- Stars
- 44
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
Currently epoch switching is querying all blocks within given epochs for events (getLogs).
Public forno api limits them to 1000. It would be amazing to have configurable block limit for querying.
Potential solution in `EpochManager.ts`:
```ts
// Public RPC nodes cap eth_getLogs to a 1000-block range; an unprocessed epoch
// can span a full day of blocks, so page the GroupProcessed query.
private static readonly GETLOGS_RANGE = 1000
private getGroupProcessedEvents = async (fromBlock: number): Promise => {
const latest = Number(await this.client.getBlockNumber())
const events: EventLog[] = []
for (let start = fromBlock; start <= latest; start += EpochManagerWrapper.GETLOGS_RANGE) {
const toBlock = Math.min(start + EpochManagerWrapper.GETLOGS_RANGE - 1, latest)
events.push(...(await this.getPastEvents('GroupProcessed', { fromBlock: start, toBlock })))
}
return events
}
// replace the call:
const fromBlock = (await this.getFirstBlockAtEpoch(await this.getCurrentEpochNumber())) + 1
const groupProcessedEvents = await this.getGroupProcessedEvents(fromBlock)
```
Contributor guide
Research direction
Start in EpochManager.ts and trace the epoch-switching getLogs call for GroupProcessed events. Verify the behavior against the public RPC 1000-block limit, then ensure the query range is configurable and events across the full epoch are fetched. Done means no request exceeds the configured block range while epoch switching still collects all matching events.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100