Skip to content

Integer undeflow in calculateStartingBlock #37

@tothtamas28

Description

@tothtamas28

In calculateStartingBlock, backfillTimestamp underflows if c.startTimestamp < uint64(backfillDuration.Seconds()).

https://github.com/ethereum-optimism/optimism/blob/be00aaa2cc3c8bea80e916d17c30a2b5d8d87696/op-interop-filter/filter/logsdb_chain_ingester.go#L337-L340

Both fields are set directly from arguments of NewLogsDBChainIngester:

https://github.com/ethereum-optimism/optimism/blob/be00aaa2cc3c8bea80e916d17c30a2b5d8d87696/op-interop-filter/filter/logsdb_chain_ingester.go#L79-L80

https://github.com/ethereum-optimism/optimism/blob/be00aaa2cc3c8bea80e916d17c30a2b5d8d87696/op-interop-filter/filter/logsdb_chain_ingester.go#L123-L124

In service.go, startTimestamp is set from the current system time, whereas backfillDuration comes from the Config.

https://github.com/ethereum-optimism/optimism/blob/45c7305a2045aa40dc5f881d771b97fc70394a2b/op-interop-filter/filter/service.go#L157-L162

https://github.com/ethereum-optimism/optimism/blob/45c7305a2045aa40dc5f881d771b97fc70394a2b/op-interop-filter/filter/service.go#L199-L200

Recommendation

Enforce startTimestamp >= uint64(backfillDuration.Seconds()) in either NewLogsDBChainIngester or calculateStartingBlock, or log the underflow and start ingestion from the genesis block as a fallback.

Status

Fixed in ethereum-optimism@e7b34fe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions