Skip to content

Commit

Permalink
Merge pull request #9 from hemilabs/clayton/stateroot
Browse files Browse the repository at this point in the history
use next keystone state root
  • Loading branch information
ClaytonNorthey92 authored Feb 19, 2025
2 parents 4ab38c7 + 75380eb commit 6eccf20
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions op-node/node/bvm_api_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func getTipHeight(ctx context.Context, driver driverClient) (uint64, error) {
return syncStatus.UnsafeL2.Number, nil
}

func getBTCFinalityForBlockNum(ctx context.Context, blockNum uint64, stateRoot []byte, driver driverClient, bssClient client.BssClient) ([]hemi.L2BTCFinality, error) {
func getBTCFinalityForBlockNum(ctx context.Context, blockNum uint64, driver driverClient, bssClient client.BssClient, l2Client l2EthClient) ([]hemi.L2BTCFinality, error) {
nextKeystoneHeight, err := getKeystoneProvidingFinality(blockNum)
if err != nil {
return nil, err
Expand Down Expand Up @@ -61,13 +61,20 @@ func getBTCFinalityForBlockNum(ctx context.Context, blockNum uint64, stateRoot [
prevKeystoneHash = [32]byte(prevKeystone.Hash[:])
}

block, err := l2Client.InfoByHash(ctx, nextKeystone.Hash)
if err != nil {
return nil, err
}

stateRoot := block.Root()

l2Keystone := &hemi.L2Keystone{
Version: 0x01,
L1BlockNumber: uint32(nextKeystone.L1Origin.Number),
L2BlockNumber: uint32(nextKeystone.Number),
ParentEPHash: nextKeystone.ParentHash[:],
PrevKeystoneEPHash: prevKeystoneHash[:],
StateRoot: stateRoot,
StateRoot: stateRoot[:],
EPHash: nextKeystone.Hash[:],
}

Expand Down Expand Up @@ -97,7 +104,5 @@ func getBTCFinalityForBlockHash(ctx context.Context, blockHash common.Hash, l2Cl
"%d is %x", blockHash, blockNum, blockNum, blockHash)
}

stateRoot := block.Root()

return getBTCFinalityForBlockNum(ctx, blockNum, stateRoot[:], driver, bssClient)
return getBTCFinalityForBlockNum(ctx, blockNum, driver, bssClient, l2Client)
}

0 comments on commit 6eccf20

Please sign in to comment.