Skip to content

Commit

Permalink
Merge branch 'master' into stylus_recursive_test
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacolvin0 authored May 13, 2024
2 parents 3b925be + 42d5105 commit f04470d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 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
11 changes: 9 additions & 2 deletions util/headerreader/blob_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/url"
"os"
"path"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -188,8 +189,14 @@ const trailingCharsOfResponse = 25

func (b *BlobClient) blobSidecars(ctx context.Context, slot uint64, versionedHashes []common.Hash) ([]kzg4844.Blob, error) {
rawData, err := beaconRequest[json.RawMessage](b, ctx, fmt.Sprintf("/eth/v1/beacon/blob_sidecars/%d", slot))
if err != nil {
return nil, fmt.Errorf("error calling beacon client in blobSidecars: %w", err)
if err != nil || len(rawData) == 0 {
// blobs are pruned after 4096 epochs (1 epoch = 32 slots), we determine if the requested slot were to be pruned by a non-archive endpoint
roughAgeOfSlot := uint64(time.Now().Unix()) - (b.genesisTime + slot*b.secondsPerSlot)
if roughAgeOfSlot > b.secondsPerSlot*32*4096 {
return nil, fmt.Errorf("beacon client in blobSidecars got error or empty response fetching older blobs in slot: %d, an archive endpoint is required, please refer to https://docs.arbitrum.io/run-arbitrum-node/l1-ethereum-beacon-chain-rpc-providers, err: %w", slot, err)
} else {
return nil, fmt.Errorf("beacon client in blobSidecars got error or empty response fetching non-expired blobs in slot: %d, if using a prysm endpoint, try --enable-experimental-backfill flag, err: %w", slot, err)
}
}
var response []blobResponseItem
if err := json.Unmarshal(rawData, &response); err != nil {
Expand Down

0 comments on commit f04470d

Please sign in to comment.