Skip to content

BlockNumberToTimestamp duplication and inconsistencies #33

@lucasmt

Description

@lucasmt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions