Skip to content

Commit

Permalink
parent meta hash for the GetL2TxLists
Browse files Browse the repository at this point in the history
  • Loading branch information
mskrzypkows committed Jul 2, 2024
1 parent 8f3ed88 commit 085fd74
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
16 changes: 13 additions & 3 deletions packages/taiko-client/proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ type Args struct {
}

type RPCReplyL2TxLists struct {
TxLists []types.Transactions
TxListBytes [][]byte
TxLists []types.Transactions
TxListBytes [][]byte
ParentMetaHash common.Hash
}

type CustomResponse struct {
Expand All @@ -198,7 +199,13 @@ func (p *RPC) GetL2TxLists(_ *http.Request, _ *Args, reply *RPCReplyL2TxLists) e
if len(txLists) == 1 {
log.Info("Single L2 txList", "txList", txLists[0])
}
*reply = RPCReplyL2TxLists{TxLists: txLists, TxListBytes: compressedTxLists}

parentMetaHash, err := builder.GetParentMetaHash(p.proposer.ctx, p.proposer.rpc)
if err != nil {
return err
}

*reply = RPCReplyL2TxLists{TxLists: txLists, TxListBytes: compressedTxLists, ParentMetaHash: parentMetaHash}
return nil
}

Expand Down Expand Up @@ -452,6 +459,9 @@ func (p *Proposer) ProposeOpForTakingL2Blocks(ctx context.Context) ([]types.Tran
}

compressedTxLists := [][]byte{}
if err != nil {
return nil, nil, fmt.Errorf("failed to get parent meta hash: %w", err)
}

//TODO adjust the Max value
for _, txs := range txLists[:utils.Min(p.MaxProposedTxListsPerEpoch, uint64(len(txLists)))] {
Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/proposer/transaction_builder/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (b *BlobTransactionBuilder) Build(
// If the current proposer wants to include the parent meta hash, then fetch it from the protocol.
var parentMetaHash = [32]byte{}
if includeParentMetaHash {
if parentMetaHash, err = getParentMetaHash(ctx, b.rpc); err != nil {
if parentMetaHash, err = GetParentMetaHash(ctx, b.rpc); err != nil {
return nil, err
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (b *CalldataTransactionBuilder) Build(
// If the current proposer wants to include the parent meta hash, then fetch it from the protocol.
var parentMetaHash = [32]byte{}
if includeParentMetaHash {
if parentMetaHash, err = getParentMetaHash(ctx, b.rpc); err != nil {
if parentMetaHash, err = GetParentMetaHash(ctx, b.rpc); err != nil {
return nil, err
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/taiko-client/proposer/transaction_builder/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
)

// getParentMetaHash returns the meta hash of the parent block of the latest proposed block in protocol.
func getParentMetaHash(ctx context.Context, rpc *rpc.Client) (common.Hash, error) {
// GetParentMetaHash returns the meta hash of the parent block of the latest proposed block in protocol.
func GetParentMetaHash(ctx context.Context, rpc *rpc.Client) (common.Hash, error) {
state, err := rpc.TaikoL1.State(&bind.CallOpts{Context: ctx})
if err != nil {
return common.Hash{}, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *TransactionBuilderTestSuite) SetupTest() {
}

func (s *TransactionBuilderTestSuite) TestGetParentMetaHash() {
metahash, err := getParentMetaHash(context.Background(), s.RPCClient)
metahash, err := GetParentMetaHash(context.Background(), s.RPCClient)
s.Nil(err)
s.NotEmpty(metahash)
}
Expand Down

0 comments on commit 085fd74

Please sign in to comment.