@@ -324,16 +324,14 @@ func (p *Proposer) sendTxListByBlobTx(ctx context.Context, txListBytes []byte) (
324
324
return tx , nil
325
325
}
326
326
327
- // sendProposeBlockTx tries to send a TaikoL1.proposeBlock transaction.
328
- func (p * Proposer ) sendProposeBlockTx (
327
+ func (p * Proposer ) sendProposeBlockTxWithBlobHash (
329
328
ctx context.Context ,
330
329
blobHash common.Hash ,
331
330
nonce * uint64 ,
332
331
assignment * encoding.ProverAssignment ,
333
332
assignedProver common.Address ,
334
333
maxFee * big.Int ,
335
- isReplacement bool ,
336
- ) (* types.Transaction , error ) {
334
+ isReplacement bool ) (* types.Transaction , error ) {
337
335
// Propose the transactions list
338
336
opts , err := getTxOpts (ctx , p .rpc .L1 , p .L1ProposerPrivKey , p .rpc .L1ChainID , maxFee )
339
337
if err != nil {
@@ -415,6 +413,96 @@ func (p *Proposer) sendProposeBlockTx(
415
413
return proposeTx , nil
416
414
}
417
415
416
+ // sendProposeBlockTx tries to send a TaikoL1.proposeBlock transaction.
417
+ func (p * Proposer ) sendProposeBlockTx (
418
+ ctx context.Context ,
419
+ txListBytes []byte ,
420
+ nonce * uint64 ,
421
+ assignment * encoding.ProverAssignment ,
422
+ assignedProver common.Address ,
423
+ maxFee * big.Int ,
424
+ isReplacement bool ,
425
+ ) (* types.Transaction , error ) {
426
+ // Propose the transactions list
427
+ opts , err := getTxOpts (ctx , p .rpc .L1 , p .L1ProposerPrivKey , p .rpc .L1ChainID , maxFee )
428
+ if err != nil {
429
+ return nil , err
430
+ }
431
+ if nonce != nil {
432
+ opts .Nonce = new (big.Int ).SetUint64 (* nonce )
433
+ }
434
+ opts .GasLimit = p .ProposeBlockTxGasLimit
435
+ if isReplacement {
436
+ if opts , err = rpc .IncreaseGasTipCap (
437
+ ctx ,
438
+ p .rpc ,
439
+ opts ,
440
+ p .proposerAddress ,
441
+ new (big.Int ).SetUint64 (p .ProposeBlockTxReplacementMultiplier ),
442
+ p .ProposeBlockTxGasTipCap ,
443
+ ); err != nil {
444
+ return nil , err
445
+ }
446
+ }
447
+
448
+ var parentMetaHash = [32 ]byte {}
449
+ if p .IncludeParentMetaHash {
450
+ state , err := p .rpc .TaikoL1 .State (& bind.CallOpts {Context : ctx })
451
+ if err != nil {
452
+ return nil , err
453
+ }
454
+
455
+ parent , err := p .rpc .TaikoL1 .GetBlock (& bind.CallOpts {Context : ctx }, state .SlotB .NumBlocks - 1 )
456
+ if err != nil {
457
+ return nil , err
458
+ }
459
+
460
+ parentMetaHash = parent .MetaHash
461
+ }
462
+
463
+ hookCalls := make ([]encoding.HookCall , 0 )
464
+
465
+ // initially just use the AssignmentHook default.
466
+ // TODO: flag for additional hook addresses and data.
467
+ hookInputData , err := encoding .EncodeAssignmentHookInput (& encoding.AssignmentHookInput {
468
+ Assignment : assignment ,
469
+ Tip : common .Big0 , // TODO: flag for tip
470
+ })
471
+ if err != nil {
472
+ return nil , err
473
+ }
474
+
475
+ hookCalls = append (hookCalls , encoding.HookCall {
476
+ Hook : p .AssignmentHookAddress ,
477
+ Data : hookInputData ,
478
+ })
479
+
480
+ encodedParams , err := encoding .EncodeBlockParams (& encoding.BlockParams {
481
+ AssignedProver : assignedProver ,
482
+ ExtraData : rpc .StringToBytes32 (p .ExtraData ),
483
+ TxListByteOffset : common .Big0 ,
484
+ TxListByteSize : common .Big0 ,
485
+ BlobHash : [32 ]byte {},
486
+ CacheBlobForReuse : false ,
487
+ ParentMetaHash : parentMetaHash ,
488
+ HookCalls : hookCalls ,
489
+ })
490
+ if err != nil {
491
+ return nil , err
492
+ }
493
+
494
+ proposeTx , err := p .rpc .TaikoL1 .ProposeBlock (
495
+ opts ,
496
+ encodedParams ,
497
+ txListBytes ,
498
+ )
499
+ if err != nil {
500
+ return nil , encoding .TryParsingCustomError (err )
501
+ }
502
+
503
+ return proposeTx , nil
504
+ }
505
+
418
506
// ProposeTxList proposes the given transactions list to TaikoL1 smart contract.
419
507
func (p * Proposer ) ProposeTxList (
420
508
ctx context.Context ,
@@ -433,7 +521,6 @@ func (p *Proposer) ProposeTxList(
433
521
434
522
var (
435
523
isReplacement bool
436
- blobTx * types.Transaction
437
524
tx * types.Transaction
438
525
)
439
526
if err := backoff .Retry (
@@ -443,16 +530,37 @@ func (p *Proposer) ProposeTxList(
443
530
}
444
531
445
532
// Send tx list by blob tx.
446
- if blobTx == nil {
447
- blobTx , err = p .sendTxListByBlobTx (ctx , txListBytes )
533
+ if p . BlobAllowed {
534
+ blobTx , err : = p .sendTxListByBlobTx (ctx , txListBytes )
448
535
if err != nil {
449
536
return nil
450
537
}
538
+ if tx , err = p .sendProposeBlockTxWithBlobHash (
539
+ ctx ,
540
+ blobTx .BlobHashes ()[0 ],
541
+ nonce ,
542
+ assignment ,
543
+ proverAddress ,
544
+ maxFee ,
545
+ isReplacement ,
546
+ ); err != nil {
547
+ log .Warn ("Failed to send taikoL1.proposeBlock blob transaction" , "error" , encoding .TryParsingCustomError (err ))
548
+ if strings .Contains (err .Error (), core .ErrNonceTooLow .Error ()) {
549
+ return nil
550
+ }
551
+ if strings .Contains (err .Error (), txpool .ErrReplaceUnderpriced .Error ()) {
552
+ isReplacement = true
553
+ } else {
554
+ isReplacement = false
555
+ }
556
+ return err
557
+ }
558
+ return nil
451
559
}
452
560
453
561
if tx , err = p .sendProposeBlockTx (
454
562
ctx ,
455
- blobTx . BlobHashes ()[ 0 ] ,
563
+ txListBytes ,
456
564
nonce ,
457
565
assignment ,
458
566
proverAddress ,
0 commit comments