Skip to content

feat(taiko-client): introduce payloadQueue for P2P gossip messages #19195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Apr 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7059f16
feat(taiko-client): introduce `payloadQueue` for P2P gossip messages
davidtaikocha Apr 2, 2025
05f855d
feat: more methods
davidtaikocha Apr 2, 2025
c29f276
feat: more methods
davidtaikocha Apr 2, 2025
03654d1
build docker image
mask-pp Apr 2, 2025
954cd9a
build docker image
mask-pp Apr 2, 2025
1d49a30
Merge branch 'main' into p2p-payloadQueue
mask-pp Apr 2, 2025
139faa5
feat: more changes
davidtaikocha Apr 2, 2025
58e0260
feat: more changes
davidtaikocha Apr 2, 2025
32c29f5
Update packages/taiko-client/driver/chain_syncer/blob/blocks_inserter…
davidtaikocha Apr 2, 2025
6d362dd
chore: more comments
davidtaikocha Apr 2, 2025
5c8ea0c
feat: add ValidateExecutionPayload
davidtaikocha Apr 2, 2025
451cb30
chore: update ci
davidtaikocha Apr 2, 2025
15bd193
build
cyberhorsey Apr 2, 2025
1404fe0
log
cyberhorsey Apr 2, 2025
aac8c89
rm build
cyberhorsey Apr 2, 2025
62655a2
feat: try RLP decoding
davidtaikocha Apr 3, 2025
a169228
Revert "feat: try RLP decoding"
davidtaikocha Apr 3, 2025
9705881
feat: add more tx list checks in ValidateExecutionPayload
davidtaikocha Apr 3, 2025
404bfa2
rm blobsize check, can be spread over multiple blobs
cyberhorsey Apr 3, 2025
c1cdc05
can be 6 blobs
cyberhorsey Apr 3, 2025
6fe780d
Merge branch 'main' into p2p-payloadQueue
cyberhorsey Apr 3, 2025
fa30d74
bump opt
cyberhorsey Apr 3, 2025
b501836
Merge branch 'p2p-payloadQueue' of github.com:taikoxyz/taiko-mono int…
cyberhorsey Apr 3, 2025
bd80fd0
chore: go mod tidy
davidtaikocha Apr 4, 2025
b75ae3d
fix: fix ci issue
davidtaikocha Apr 4, 2025
d494418
fix: fix lint errors
davidtaikocha Apr 4, 2025
76f579b
Merge branch 'main' into p2p-payloadQueue
davidtaikocha Apr 4, 2025
adaa23f
feat: use const
davidtaikocha Apr 4, 2025
0c1bc6d
Merge branch 'main' into p2p-payloadQueue
davidtaikocha Apr 4, 2025
342d29c
Merge branch 'main' into p2p-payloadQueue
cyberhorsey Apr 4, 2025
a23be5d
add the block hash to the log
cyberhorsey Apr 4, 2025
a9ea045
lint
cyberhorsey Apr 4, 2025
73d89f7
Update packages/taiko-client/driver/preconf_blocks/server.go
cyberhorsey Apr 5, 2025
2f9d81e
check parent hash as well, log if its not found
cyberhorsey Apr 5, 2025
0385f5b
dont check parent
cyberhorsey Apr 5, 2025
02202f9
Merge branch 'main' into p2p-payloadQueue
davidtaikocha Apr 7, 2025
e13cd75
Merge branch 'main' into p2p-payloadQueue
davidtaikocha Apr 8, 2025
8ea05c4
feat(taiko-client): improve `ImportChildBlocksFromCache` and increase…
davidtaikocha Apr 13, 2025
f4d2f92
chore: update ci
davidtaikocha Apr 13, 2025
e3cfaa3
Merge branch 'main' into p2p-payloadQueue
davidtaikocha Apr 13, 2025
9bd9780
feat: update maxTrackedPayloads back to 768
davidtaikocha Apr 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/taiko-client/bindings/encoding/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ func TransitionContestedEventToV2(
}
}

// BlockVerifiedEventToV2 converts a *ontakeBindings.OntakeClients.TaikoL1ClientBlockVerified to *ontakeBindings.OntakeClients.TaikoL1ClientBlockVerifiedV2.
// BlockVerifiedEventToV2 converts a *ontakeBindings.OntakeClients.TaikoL1ClientBlockVerified
// to *ontakeBindings.OntakeClients.TaikoL1ClientBlockVerifiedV2.
func BlockVerifiedEventToV2(e *ontakeBindings.TaikoL1ClientBlockVerified) *ontakeBindings.TaikoL1ClientBlockVerifiedV2 {
return &ontakeBindings.TaikoL1ClientBlockVerifiedV2{
BlockId: e.BlockId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ func assembleCreateExecutionPayloadMetaPacaya(
}, anchorTx, nil
}

// updateL1OriginForBatch updates the each block's L1 origin in the given batch.
func updateL1OriginForBatch(
ctx context.Context,
rpc *rpc.Client,
Expand All @@ -466,26 +465,32 @@ func updateL1OriginForBatch(

for i := 0; i < len(meta.GetBlocks()); i++ {
g.Go(func() error {
blockID := new(big.Int).SetUint64(meta.GetLastBlockID() - uint64(i))
blockID := new(big.Int).SetUint64(meta.GetLastBlockID() - uint64(len(meta.GetBlocks())-1-i))

header, err := rpc.L2.HeaderByNumber(ctx, blockID)
if err != nil {
return fmt.Errorf("failed to get block by number %d: %w", blockID, err)
}

l1Origin := &rawdb.L1Origin{
BlockID: blockID,
L2BlockHash: header.Hash(),
L1BlockHeight: meta.GetRawBlockHeight(),
L1BlockHash: meta.GetRawBlockHash(),
}
// Update the l1Origin and headL1Origin cursor for that preconfirmed block.

if _, err := rpc.L2Engine.UpdateL1Origin(ctx, l1Origin); err != nil {
return fmt.Errorf("failed to update L1 origin: %w", err)
}

// If this is the most recent block, update the HeadL1Origin.
if i == len(meta.GetBlocks())-1 {
log.Info("Update head L1 origin", "blockID", blockID, "l1Origin", l1Origin)
if _, err := rpc.L2Engine.SetHeadL1Origin(ctx, l1Origin.BlockID); err != nil {
return fmt.Errorf("failed to write head L1 origin: %w", err)
}
}

return nil
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,24 @@ func (i *BlocksInserterPacaya) InsertBlocks(

log.Debug("Payload data", "hash", lastPayloadData.BlockHash, "txs", len(lastPayloadData.Transactions))

// Wait till the corresponding L2 header to be existed in the L2 EE.
if _, err := i.rpc.WaitL2Header(ctx, new(big.Int).SetUint64(lastPayloadData.Number)); err != nil {
return fmt.Errorf("failed to wait for L2 header (%d): %w", lastPayloadData.Number, err)
}

log.Info(
"🔗 New L2 block inserted",
"blockID", lastPayloadData.Number,
"hash", lastPayloadData.BlockHash,
"coinbase", lastPayloadData.FeeRecipient.Hex(),
"transactions", len(lastPayloadData.Transactions),
"timestamp", lastPayloadData.Timestamp,
"baseFee", utils.WeiToGWei(lastPayloadData.BaseFeePerGas),
"withdrawals", len(lastPayloadData.Withdrawals),
"batchID", meta.GetBatchID(),
"gasLimit", lastPayloadData.GasLimit,
"gasUsed", lastPayloadData.GasUsed,
"parentHash", lastPayloadData.ParentHash,
"indexInBatch", j,
)

Expand All @@ -213,14 +222,31 @@ func (i *BlocksInserterPacaya) InsertBlocks(
return nil
}

// InsertPreconfBlockFromExecutionPayload inserts a preconf block from the given execution payload.
func (i *BlocksInserterPacaya) InsertPreconfBlockFromExecutionPayload(
// InsertPreconfBlocksFromExecutionPayloads inserts preconf blocks from the given execution payloads.
func (i *BlocksInserterPacaya) InsertPreconfBlocksFromExecutionPayloads(
ctx context.Context,
executableData *eth.ExecutionPayload,
) (*types.Header, error) {
executionPayloads []*eth.ExecutionPayload,
) ([]*types.Header, error) {
i.mutex.Lock()
defer i.mutex.Unlock()

headers := make([]*types.Header, len(executionPayloads))
for j, executableData := range executionPayloads {
header, err := i.insertPreconfBlockFromExecutionPayload(ctx, executableData)
if err != nil {
return nil, fmt.Errorf("failed to insert preconf block: %w", err)
}
headers[j] = header
}

return headers, nil
}

// insertPreconfBlockFromExecutionPayload the inner method to insert a preconf block from the given execution payload.
func (i *BlocksInserterPacaya) insertPreconfBlockFromExecutionPayload(
ctx context.Context,
executableData *eth.ExecutionPayload,
) (*types.Header, error) {
// Ensure the preconfirmation block number is greater than the current head L1 origin block ID.
headL1Origin, err := i.rpc.L2.HeadL1Origin(ctx)
if err != nil && err.Error() != ethereum.NotFound.Error() {
Expand All @@ -231,7 +257,7 @@ func (i *BlocksInserterPacaya) InsertPreconfBlockFromExecutionPayload(
if headL1Origin != nil {
if uint64(executableData.BlockNumber) <= headL1Origin.BlockID.Uint64() {
return nil, fmt.Errorf(
"preconfirmation block number (%d) is less than or equal to the current head L1 origin block ID (%d)",
"preconfirmation block ID (%d) is less than or equal to the current head L1 origin block ID (%d)",
executableData.BlockNumber,
headL1Origin.BlockID,
)
Expand All @@ -242,6 +268,11 @@ func (i *BlocksInserterPacaya) InsertPreconfBlockFromExecutionPayload(
return nil, fmt.Errorf("no transactions data in the payload")
}

// Decompress the transactions list.
if executableData.Transactions[0], err = utils.DecompressPacaya(executableData.Transactions[0]); err != nil {
return nil, fmt.Errorf("failed to decompress transactions list bytes: %w", err)
}

var u256BaseFee = uint256.Int(executableData.BaseFeePerGas)
payload, err := createExecutionPayloadsAndSetHead(
ctx,
Expand Down
8 changes: 1 addition & 7 deletions packages/taiko-client/driver/chain_syncer/chain_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ func New(
go tracker.Track(ctx)

beaconSyncer := beaconsync.NewSyncer(ctx, rpc, state, tracker)
blobSyncer, err := blob.NewSyncer(
ctx,
rpc,
state,
tracker,
blobServerEndpoint,
)
blobSyncer, err := blob.NewSyncer(ctx, rpc, state, tracker, blobServerEndpoint)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions packages/taiko-client/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (d *Driver) InitFromConfig(ctx context.Context, cfg *Config) (err error) {
if d.preconfBlockServer, err = preconfBlocks.New(
d.PreconfBlockServerCORSOrigins,
d.PreconfBlockServerJWTSecret,
d.TaikoL2Address,
d.l2ChainSyncer.BlobSyncer().BlocksInserterPacaya(),
d.rpc,
); err != nil {
Expand Down
Loading
Loading