chain_container.go includes two functions called BlockNumberToTimestamp and blockNumberToTimestamp:
|
func (c *simpleChainContainer) BlockNumberToTimestamp(ctx context.Context, blocknum uint64) (uint64, error) { |
|
if c.vncfg == nil { |
|
return 0, fmt.Errorf("rollup config not available") |
|
} |
|
return c.vncfg.Rollup.Genesis.L2Time + (blocknum * c.vncfg.Rollup.BlockTime), nil |
|
} |
|
// blockNumberToTimestamp converts a block number to its timestamp using rollup config. |
|
func (c *simpleChainContainer) blockNumberToTimestamp(blockNum uint64) uint64 { |
|
if c.vncfg == nil { |
|
return 0 |
|
} |
|
return c.vncfg.Rollup.Genesis.L2Time + (blockNum * c.vncfg.Rollup.BlockTime) |
|
} |
- These functions are a duplication of each other, except that
blockNumberToTimestamp doesn't return an error and just returns 0 if the virtual node config is empty.
- Their calculation seems to assume that the genesis block timestamp is always 0. This is inconsistent with
c.vncfg.Rollup.TargetBlockNumber(), which subtracts cfg.Genesis.L2Time to calculate the result.
Status
Fixed in PR #19542.
chain_container.goincludes two functions calledBlockNumberToTimestampandblockNumberToTimestamp:_audits_Ethereum-optimism_optimism_interopv2/op-supernode/supernode/chain_container/chain_container.go
Lines 296 to 301 in be00aaa
_audits_Ethereum-optimism_optimism_interopv2/op-supernode/supernode/chain_container/chain_container.go
Lines 547 to 553 in be00aaa
blockNumberToTimestampdoesn't return an error and just returns 0 if the virtual node config is empty.c.vncfg.Rollup.TargetBlockNumber(), which subtractscfg.Genesis.L2Timeto calculate the result.Status
Fixed in PR #19542.