Skip to content

Commit

Permalink
Misc refactors while I was tracking down the previous bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Jan 23, 2024
1 parent 5cdcde1 commit 54ee5c3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
11 changes: 6 additions & 5 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ type estimateGasParams struct {
To *common.Address `json:"to"`
Data hexutil.Bytes `json:"data"`
AccessList types.AccessList `json:"accessList"`
BlobHashes []common.Hash `json:"blobVersionedHashes"`
BlobHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
}

func estimateGas(client rpc.ClientInterface, ctx context.Context, params estimateGasParams) (uint64, error) {
Expand Down Expand Up @@ -1164,12 +1164,13 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
}
log.Info(
"BatchPoster: batch sent",
"sequence nr.", batchPosition.NextSeqNum,
"sequenceNumber", batchPosition.NextSeqNum,
"from", batchPosition.MessageCount,
"to", b.building.msgCount,
"prev delayed", batchPosition.DelayedMessageCount,
"current delayed", b.building.segments.delayedMsg,
"total segments", len(b.building.segments.rawSegments),
"prevDelayed", batchPosition.DelayedMessageCount,
"currentDelayed", b.building.segments.delayedMsg,
"totalSegments", len(b.building.segments.rawSegments),
"numBlobs", len(kzgBlobs),
)
recentlyHitL1Bounds := time.Since(b.lastHitL1Bounds) < config.PollInterval*3
postedMessages := b.building.msgCount - batchPosition.MessageCount
Expand Down
19 changes: 10 additions & 9 deletions arbnode/dataposter/data_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ func (p *DataPoster) PostTransaction(ctx context.Context, dataCreatedAt time.Tim
ChainID: p.parentChainID256,
}
// reuse the code to convert gas fee and tip caps to uint256s
inner, err = updateTxDataGasCaps(inner, feeCap, tipCap, blobFeeCap)
err = updateTxDataGasCaps(inner, feeCap, tipCap, blobFeeCap)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -714,34 +714,35 @@ func (p *DataPoster) sendTx(ctx context.Context, prevTx *storage.QueuedTransacti
return p.saveTx(ctx, newTx, &newerTx)
}

func updateTxDataGasCaps(data types.TxData, newFeeCap, newTipCap, newBlobFeeCap *big.Int) (types.TxData, error) {
func updateTxDataGasCaps(data types.TxData, newFeeCap, newTipCap, newBlobFeeCap *big.Int) error {
switch data := data.(type) {
case *types.DynamicFeeTx:
data.GasFeeCap = newFeeCap
data.GasTipCap = newTipCap
return data, nil
return nil
case *types.BlobTx:
var overflow bool
data.GasFeeCap, overflow = uint256.FromBig(newFeeCap)
if overflow {
return nil, fmt.Errorf("blob tx fee cap %v exceeds uint256", newFeeCap)
return fmt.Errorf("blob tx fee cap %v exceeds uint256", newFeeCap)
}
data.GasTipCap, overflow = uint256.FromBig(newTipCap)
if overflow {
return nil, fmt.Errorf("blob tx tip cap %v exceeds uint256", newTipCap)
return fmt.Errorf("blob tx tip cap %v exceeds uint256", newTipCap)
}
data.BlobFeeCap, overflow = uint256.FromBig(newBlobFeeCap)
if overflow {
return nil, fmt.Errorf("blob tx blob fee cap %v exceeds uint256", newBlobFeeCap)
return fmt.Errorf("blob tx blob fee cap %v exceeds uint256", newBlobFeeCap)
}
return data, nil
return nil
default:
return nil, fmt.Errorf("unexpected transaction data type %T", data)
return fmt.Errorf("unexpected transaction data type %T", data)
}
}

func updateGasCaps(tx *types.Transaction, newFeeCap, newTipCap, newBlobFeeCap *big.Int) (*types.Transaction, error) {
data, err := updateTxDataGasCaps(tx.GetInner(), newFeeCap, newTipCap, newBlobFeeCap)
data := tx.GetInner()
err := updateTxDataGasCaps(data, newFeeCap, newTipCap, newBlobFeeCap)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion system_tests/batch_poster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func testBatchPosterParallel(t *testing.T, useRedis bool) {
}

lastTxHash := txs[len(txs)-1].Hash()
for i := 90; i > 0; i-- {
for i := 90; i >= 0; i-- {
builder.L1.SendWaitTestTransactions(t, []*types.Transaction{
builder.L1Info.PrepareTx("Faucet", "User", 30000, big.NewInt(1e12), nil),
})
Expand Down

0 comments on commit 54ee5c3

Please sign in to comment.