Skip to content

Commit

Permalink
Merge branch 'master' into wsMessageSizeLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-Wilson authored May 13, 2024
2 parents 725ec52 + 51189e4 commit 69a3e9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 11 additions & 3 deletions arbnode/dataposter/data_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u
targetBlobCost := arbmath.BigMulByUint(newBlobFeeCap, blobGasUsed)
targetNonBlobCost := arbmath.BigSub(targetMaxCost, targetBlobCost)
newBaseFeeCap := arbmath.BigDivByUint(targetNonBlobCost, gasLimit)
if lastTx != nil && numBlobs > 0 && arbmath.BigDivToBips(newBaseFeeCap, lastTx.GasFeeCap()) < minRbfIncrease {
if lastTx != nil && numBlobs > 0 && lastTx.GasFeeCap().Sign() > 0 && arbmath.BigDivToBips(newBaseFeeCap, lastTx.GasFeeCap()) < minRbfIncrease {
// Increase the non-blob fee cap to the minimum rbf increase
newBaseFeeCap = arbmath.BigMulByBips(lastTx.GasFeeCap(), minRbfIncrease)
newNonBlobCost := arbmath.BigMulByUint(newBaseFeeCap, gasLimit)
Expand Down Expand Up @@ -665,6 +665,14 @@ func (p *DataPoster) feeAndTipCaps(ctx context.Context, nonce uint64, gasLimit u
return lastTx.GasFeeCap(), lastTx.GasTipCap(), lastTx.BlobGasFeeCap(), nil
}

// Ensure we bid at least 1 wei to prevent division by zero
if newBaseFeeCap.Sign() == 0 {
newBaseFeeCap = big.NewInt(1)
}
if newBlobFeeCap.Sign() == 0 {
newBlobFeeCap = big.NewInt(1)
}

return newBaseFeeCap, newTipCap, newBlobFeeCap, nil
}

Expand Down Expand Up @@ -934,8 +942,8 @@ func (p *DataPoster) replaceTx(ctx context.Context, prevTx *storage.QueuedTransa
}

newTx := *prevTx
if arbmath.BigDivToBips(newFeeCap, prevTx.FullTx.GasFeeCap()) < minRbfIncrease ||
(prevTx.FullTx.BlobGasFeeCap() != nil && arbmath.BigDivToBips(newBlobFeeCap, prevTx.FullTx.BlobGasFeeCap()) < minRbfIncrease) {
if (prevTx.FullTx.GasFeeCap().Sign() > 0 && arbmath.BigDivToBips(newFeeCap, prevTx.FullTx.GasFeeCap()) < minRbfIncrease) ||
(prevTx.FullTx.BlobGasFeeCap() != nil && prevTx.FullTx.BlobGasFeeCap().Sign() > 0 && arbmath.BigDivToBips(newBlobFeeCap, prevTx.FullTx.BlobGasFeeCap()) < minRbfIncrease) {
log.Debug(
"no need to replace by fee transaction",
"nonce", prevTx.FullTx.Nonce(),
Expand Down
9 changes: 7 additions & 2 deletions staker/l1_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/offchainlabs/nitro/staker/txbuilder"
"github.com/offchainlabs/nitro/util/arbmath"
"github.com/offchainlabs/nitro/util/headerreader"
"github.com/offchainlabs/nitro/validator"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -187,12 +188,16 @@ func (v *L1Validator) resolveNextNode(ctx context.Context, info *StakerInfo, lat

func (v *L1Validator) isRequiredStakeElevated(ctx context.Context) (bool, error) {
callOpts := v.getCallOpts(ctx)
requiredStake, err := v.rollup.CurrentRequiredStake(callOpts)
baseStake, err := v.rollup.BaseStake(callOpts)
if err != nil {
return false, err
}
baseStake, err := v.rollup.BaseStake(callOpts)
requiredStake, err := v.rollup.CurrentRequiredStake(callOpts)
if err != nil {
if headerreader.ExecutionRevertedRegexp.MatchString(err.Error()) {
log.Warn("execution reverted checking if required state is elevated; assuming elevated", "err", err)
return true, nil
}
return false, err
}
return requiredStake.Cmp(baseStake) > 0, nil
Expand Down

0 comments on commit 69a3e9f

Please sign in to comment.