-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
Description
NOTE: This is a bit tricky one as the last finalised block depends on the finality gadget implementation.
One solution could be respecting the finalisation status of Ethereum, i.e, as we currently do
// QueryLatestFinalizedBlock returns the finalized L2 block from a RPC call
// TODO: return the BTC finalized L2 block, it is tricky b/c it's not recorded anywhere so we can
// use some exponential strategy to search
func (cc *RollupBSNController) QueryLatestFinalizedBlock(ctx context.Context) (types.BlockDescription, error) {
l2Block, err := cc.ethClient.HeaderByNumber(ctx, big.NewInt(ethrpc.FinalizedBlockNumber.Int64()))
if err != nil {
return nil, err
}
if l2Block.Number.Uint64() == 0 {
return nil, nil
}
return types.NewBlockInfo(l2Block.Number.Uint64(), l2Block.Hash().Bytes(), false), nil
}
Here cc.ethClient.HeaderByNumber(ctx, big.NewInt(ethrpc.FinalizedBlockNumber.Int64()))
is querying the last finalised block where "finalised" means the L2 block is in a L1 block that is finalised in Ethereum. This is stronger notion than BTC staking finality.
For this issue, we need to examine whether this is good enough. If yes, we need to revise the docstring. If no, we need to have a new design and implement accordingly.