From df0dd50e52d7c4196553d070c5dda67467fb6dac Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 22 Mar 2024 09:23:50 -0500 Subject: [PATCH 1/3] Fix MaxFeeBidMultipleBips to respect rbf minimums --- arbnode/dataposter/data_poster.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index c26e7ab3b6..11e810f7f2 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -583,13 +583,8 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u blobGasUsed := params.BlobTxBlobGasPerBlob * numBlobs currentBlobCost := arbmath.BigMulByUint(currentBlobFee, blobGasUsed) currentNonBlobCost := arbmath.BigMulByUint(currentNonBlobFee, gasLimit) - currentTotalCost := arbmath.BigAdd(currentBlobCost, currentNonBlobCost) - if config.MaxFeeBidMultipleBips > 0 { - targetMaxCost = arbmath.BigMin(targetMaxCost, arbmath.BigMulByBips(currentTotalCost, config.MaxFeeBidMultipleBips)) - } - newBlobFeeCap := arbmath.BigMul(targetMaxCost, currentBlobFee) - newBlobFeeCap.Div(newBlobFeeCap, currentTotalCost) + newBlobFeeCap.Div(newBlobFeeCap, arbmath.BigAdd(currentBlobCost, currentNonBlobCost)) if lastTx != nil && lastTx.BlobGasFeeCap() != nil { newBlobFeeCap = arbmath.BigMax(newBlobFeeCap, arbmath.BigMulByBips(lastTx.BlobGasFeeCap(), minRbfIncrease)) } @@ -606,6 +601,18 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u newBlobFeeCap = arbmath.BigDivByUint(newBlobCost, blobGasUsed) } + // Limit the fee caps to be no greater than max(MaxFeeBidMultipleBips, minRbf) + maxNonBlobFee := arbmath.BigMulByBips(currentNonBlobFee, config.MaxFeeBidMultipleBips) + if lastTx != nil { + maxNonBlobFee = arbmath.BigMax(maxNonBlobFee, arbmath.BigMulByBips(lastTx.GasFeeCap(), minRbfIncrease)) + } + maxBlobFee := arbmath.BigMulByBips(currentBlobFee, config.MaxFeeBidMultipleBips) + if lastTx != nil && lastTx.BlobGasFeeCap() != nil { + maxBlobFee = arbmath.BigMax(maxBlobFee, arbmath.BigMulByBips(lastTx.BlobGasFeeCap(), minRbfIncrease)) + } + newBaseFeeCap = arbmath.BigMin(newBaseFeeCap, maxNonBlobFee) + newBlobFeeCap = arbmath.BigMin(newBlobFeeCap, maxBlobFee) + if arbmath.BigGreaterThan(newTipCap, newBaseFeeCap) { log.Info( "reducing new tip cap to new basefee cap", From c38a0eea44be9deecdb1bfcab8b5b989da4fada7 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 22 Mar 2024 09:33:24 -0500 Subject: [PATCH 2/3] Fix MaxFeeBidMultipleBips == 0 --- arbnode/dataposter/data_poster.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index 11e810f7f2..298cfd548a 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -601,17 +601,19 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u newBlobFeeCap = arbmath.BigDivByUint(newBlobCost, blobGasUsed) } - // Limit the fee caps to be no greater than max(MaxFeeBidMultipleBips, minRbf) - maxNonBlobFee := arbmath.BigMulByBips(currentNonBlobFee, config.MaxFeeBidMultipleBips) - if lastTx != nil { - maxNonBlobFee = arbmath.BigMax(maxNonBlobFee, arbmath.BigMulByBips(lastTx.GasFeeCap(), minRbfIncrease)) - } - maxBlobFee := arbmath.BigMulByBips(currentBlobFee, config.MaxFeeBidMultipleBips) - if lastTx != nil && lastTx.BlobGasFeeCap() != nil { - maxBlobFee = arbmath.BigMax(maxBlobFee, arbmath.BigMulByBips(lastTx.BlobGasFeeCap(), minRbfIncrease)) + if config.MaxFeeBidMultipleBips > 0 { + // Limit the fee caps to be no greater than max(MaxFeeBidMultipleBips, minRbf) + maxNonBlobFee := arbmath.BigMulByBips(currentNonBlobFee, config.MaxFeeBidMultipleBips) + if lastTx != nil { + maxNonBlobFee = arbmath.BigMax(maxNonBlobFee, arbmath.BigMulByBips(lastTx.GasFeeCap(), minRbfIncrease)) + } + maxBlobFee := arbmath.BigMulByBips(currentBlobFee, config.MaxFeeBidMultipleBips) + if lastTx != nil && lastTx.BlobGasFeeCap() != nil { + maxBlobFee = arbmath.BigMax(maxBlobFee, arbmath.BigMulByBips(lastTx.BlobGasFeeCap(), minRbfIncrease)) + } + newBaseFeeCap = arbmath.BigMin(newBaseFeeCap, maxNonBlobFee) + newBlobFeeCap = arbmath.BigMin(newBlobFeeCap, maxBlobFee) } - newBaseFeeCap = arbmath.BigMin(newBaseFeeCap, maxNonBlobFee) - newBlobFeeCap = arbmath.BigMin(newBlobFeeCap, maxBlobFee) if arbmath.BigGreaterThan(newTipCap, newBaseFeeCap) { log.Info( From 6bd27214527d94ce81948ba4d699748b40124182 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 22 Mar 2024 11:56:54 -0500 Subject: [PATCH 3/3] Add backtrace to help debug flaky relay test --- broadcaster/broadcaster.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/broadcaster/broadcaster.go b/broadcaster/broadcaster.go index ed3088ca2e..242b8f9eeb 100644 --- a/broadcaster/broadcaster.go +++ b/broadcaster/broadcaster.go @@ -7,6 +7,7 @@ import ( "context" "errors" "net" + "runtime/debug" "github.com/gobwas/ws" @@ -60,7 +61,7 @@ func (b *Broadcaster) NewBroadcastFeedMessage(message arbostypes.MessageWithMeta func (b *Broadcaster) BroadcastSingle(msg arbostypes.MessageWithMetadata, seq arbutil.MessageIndex) (err error) { defer func() { if r := recover(); r != nil { - log.Error("recovered error in BroadcastSingle", "recover", r) + log.Error("recovered error in BroadcastSingle", "recover", r, "backtrace", string(debug.Stack())) err = errors.New("panic in BroadcastSingle") } }() @@ -84,7 +85,7 @@ func (b *Broadcaster) BroadcastSingleFeedMessage(bfm *m.BroadcastFeedMessage) { func (b *Broadcaster) BroadcastMessages(messages []arbostypes.MessageWithMetadata, seq arbutil.MessageIndex) (err error) { defer func() { if r := recover(); r != nil { - log.Error("recovered error in BroadcastMessages", "recover", r) + log.Error("recovered error in BroadcastMessages", "recover", r, "backtrace", string(debug.Stack())) err = errors.New("panic in BroadcastMessages") } }()