From 3c8e04f16b142ab4a0bcfb7f192d7d237e9d0c07 Mon Sep 17 00:00:00 2001 From: ClaytonNorthey92 Date: Wed, 19 Feb 2025 11:30:00 -0500 Subject: [PATCH] use next keystone state root --- op-node/node/bvm_api_helper.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/op-node/node/bvm_api_helper.go b/op-node/node/bvm_api_helper.go index 0baace6a1132..33682d41ff85 100644 --- a/op-node/node/bvm_api_helper.go +++ b/op-node/node/bvm_api_helper.go @@ -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) ([]hemi.L2BTCFinality, error) { nextKeystoneHeight, err := getKeystoneProvidingFinality(blockNum) if err != nil { return nil, err @@ -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[:], } @@ -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) }