Skip to content
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

feat(taiko-client): preconfirmations taiko client support contracts #17745

Merged
Changes from 3 commits
Commits
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
50 changes: 41 additions & 9 deletions packages/taiko-client/driver/chain_syncer/blob/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,48 @@ func (s *Syncer) onBlockProposed(
return fmt.Errorf("failed to fetch original TaikoL1.proposeBlock transaction: %w", err)
}

// Decode transactions list.
var txListFetcher txlistFetcher.TxListFetcher
if event.Meta.BlobUsed {
txListFetcher = txlistFetcher.NewBlobTxListFetcher(s.rpc.L1Beacon, s.blobDatasource)
} else {
txListFetcher = new(txlistFetcher.CalldataFetcher)
}
txListBytes, err := txListFetcher.Fetch(ctx, tx, &event.Meta)
// first see if we have a CalldataTxList event in the same transaction
// Get the transaction receipt
receipt, err := s.rpc.L1.TransactionReceipt(ctx, tx.Hash())
if err != nil {
return fmt.Errorf("failed to fetch tx list: %w", err)
return fmt.Errorf("failed to get transaction receipt: %w", err)
}

var txListBytes []byte
calldataTxListFound := false

// Iterate through the receipt logs
for _, vLog := range receipt.Logs {
// Use the generated binding's method to parse the log
calldataEvent, err := s.rpc.TaikoL1.ParseCalldataTxList(*vLog)
if err == nil {
log.Info("CalldataTxList event found", "blockID", calldataEvent.BlockId.String())
if calldataEvent.BlockId.Cmp(event.BlockId) != 0 {
log.Warn("CalldataTxList event blockID doesnt match",
"wantBlockID", event.BlockId.String(),
"eventBlockID", calldataEvent.BlockId.String(),
)
continue
}
txListBytes = calldataEvent.TxList
calldataTxListFound = true
break
}
}

if !calldataTxListFound {
// Decode transactions list.
var txListFetcher txlistFetcher.TxListFetcher
if event.Meta.BlobUsed {
txListFetcher = txlistFetcher.NewBlobTxListFetcher(s.rpc.L1Beacon, s.blobDatasource)
} else {
txListFetcher = new(txlistFetcher.CalldataFetcher)
}

txListBytes, err = txListFetcher.Fetch(ctx, tx, &event.Meta)
if err != nil {
return fmt.Errorf("failed to fetch tx list: %w", err)
}
}

// Decompress the transactions list and try to insert a new head block to L2 EE.
Expand Down
Loading