Skip to content

Commit

Permalink
feat(taiko-client): include ParentMetaHash for proposing Ontake blo…
Browse files Browse the repository at this point in the history
…cks for better revert protection
  • Loading branch information
davidtaikocha committed Feb 19, 2025
1 parent d351788 commit 3505a2a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
21 changes: 18 additions & 3 deletions packages/taiko-client/proposer/transaction_builder/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,33 @@ func (b *BlobTransactionBuilder) BuildOntake(
if err := blob.FromData(txListBytesArray[i]); err != nil {
return nil, err
}

blobs = append(blobs, blob)

encodedParams, err := encoding.EncodeBlockParamsOntake(&encoding.BlockParamsV2{
params := &encoding.BlockParamsV2{
Coinbase: b.l2SuggestedFeeRecipient,
ParentMetaHash: [32]byte{},
AnchorBlockId: 0,
Timestamp: 0,
BlobTxListOffset: 0,
BlobTxListLength: uint32(len(txListBytesArray[i])),
BlobIndex: uint8(i),
})
}

if i == 0 && b.revertProtectionEnabled {
_, slotB, err := b.rpc.GetProtocolStateVariablesOntake(nil)
if err != nil {
return nil, err
}

blockInfo, err := b.rpc.GetL2BlockInfoV2(ctx, new(big.Int).SetUint64(slotB.NumBlocks-1))
if err != nil {
return nil, err
}

params.ParentMetaHash = blockInfo.MetaHash
}

encodedParams, err := encoding.EncodeBlockParamsOntake(params)
if err != nil {
return nil, err
}
Expand Down
22 changes: 19 additions & 3 deletions packages/taiko-client/proposer/transaction_builder/calldata.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,29 @@ func (b *CalldataTransactionBuilder) BuildOntake(
encodedParamsArray [][]byte
)

for range txListBytesArray {
encodedParams, err := encoding.EncodeBlockParamsOntake(&encoding.BlockParamsV2{
for i := range txListBytesArray {
params := &encoding.BlockParamsV2{
Coinbase: b.l2SuggestedFeeRecipient,
ParentMetaHash: [32]byte{},
AnchorBlockId: 0,
Timestamp: 0,
})
}

if i == 0 && b.revertProtectionEnabled {
_, slotB, err := b.rpc.GetProtocolStateVariablesOntake(nil)
if err != nil {
return nil, err
}

blockInfo, err := b.rpc.GetL2BlockInfoV2(ctx, new(big.Int).SetUint64(slotB.NumBlocks-1))
if err != nil {
return nil, err
}

params.ParentMetaHash = blockInfo.MetaHash
}

encodedParams, err := encoding.EncodeBlockParamsOntake(params)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 3505a2a

Please sign in to comment.