Skip to content

Commit

Permalink
Merge branch 'master' into consensus_exec_split_l1gas
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahee authored Jun 26, 2024
2 parents 060da16 + d906798 commit d9a5572
Show file tree
Hide file tree
Showing 8 changed files with 664 additions and 28 deletions.
17 changes: 17 additions & 0 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ var (
blobGasLimitGauge = metrics.NewRegisteredGauge("arb/batchposter/blobgas/limit", nil)
suggestedTipCapGauge = metrics.NewRegisteredGauge("arb/batchposter/suggestedtipcap", nil)

batchPosterEstimatedBatchBacklogGauge = metrics.NewRegisteredGauge("arb/batchposter/estimated_batch_backlog", nil)

batchPosterDALastSuccessfulActionGauge = metrics.NewRegisteredGauge("arb/batchPoster/action/da_last_success", nil)
batchPosterDASuccessCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/da_success", nil)
batchPosterDAFailureCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/da_failure", nil)

batchPosterFailureCounter = metrics.NewRegisteredCounter("arb/batchPoster/action/failure", nil)

usableBytesInBlob = big.NewInt(int64(len(kzg4844.Blob{}) * 31 / 32))
blobTxBlobGasPerBlob = big.NewInt(params.BlobTxBlobGasPerBlob)
)
Expand Down Expand Up @@ -1239,6 +1247,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
// don't post anything for now
return false, nil
}

sequencerMsg, err := b.building.segments.CloseAndGetBytes()
if err != nil {
return false, err
Expand All @@ -1256,15 +1265,21 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)

gotNonce, gotMeta, err := b.dataPoster.GetNextNonceAndMeta(ctx)
if err != nil {
batchPosterDAFailureCounter.Inc(1)
return false, err
}
if nonce != gotNonce || !bytes.Equal(batchPositionBytes, gotMeta) {
batchPosterDAFailureCounter.Inc(1)
return false, fmt.Errorf("%w: nonce changed from %d to %d while creating batch", storage.ErrStorageRace, nonce, gotNonce)
}
sequencerMsg, err = b.dapWriter.Store(ctx, sequencerMsg, uint64(time.Now().Add(config.DASRetentionPeriod).Unix()), []byte{}, config.DisableDapFallbackStoreDataOnChain)
if err != nil {
batchPosterDAFailureCounter.Inc(1)
return false, err
}

batchPosterDASuccessCounter.Inc(1)
batchPosterDALastSuccessfulActionGauge.Update(time.Now().Unix())
}

prevMessageCount := batchPosition.MessageCount
Expand Down Expand Up @@ -1372,6 +1387,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
messagesPerBatch = 1
}
backlog := uint64(unpostedMessages) / messagesPerBatch
batchPosterEstimatedBatchBacklogGauge.Update(int64(backlog))
if backlog > 10 {
logLevel := log.Warn
if recentlyHitL1Bounds {
Expand Down Expand Up @@ -1484,6 +1500,7 @@ func (b *BatchPoster) Start(ctxIn context.Context) {
logLevel = normalGasEstimationFailedEphemeralErrorHandler.LogLevel(err, logLevel)
logLevel = accumulatorNotFoundEphemeralErrorHandler.LogLevel(err, logLevel)
logLevel("error posting batch", "err", err)
batchPosterFailureCounter.Inc(1)
return b.config().ErrorDelay
} else if posted {
return 0
Expand Down
32 changes: 15 additions & 17 deletions arbos/tx_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,10 @@ func (p *TxProcessor) StartTxHook() (endTxNow bool, gasUsed uint64, err error, r
}

balance := statedb.GetBalance(tx.From)
// evm.Context.BaseFee is already lowered to 0 when vm runs with NoBaseFee flag and 0 gas price
effectiveBaseFee := evm.Context.BaseFee
usergas := p.msg.GasLimit

if !p.msg.TxRunMode.ExecutedOnChain() && p.msg.GasFeeCap.BitLen() == 0 {
// In gas estimation or eth_call mode, we permit a zero gas fee cap.
// This matches behavior with normal tx gas estimation and eth_call.
effectiveBaseFee = common.Big0
}

maxGasCost := arbmath.BigMulByUint(tx.GasFeeCap, usergas)
maxFeePerGasTooLow := arbmath.BigLessThan(tx.GasFeeCap, effectiveBaseFee)
if arbmath.BigLessThan(balance.ToBig(), maxGasCost) || usergas < params.TxGas || maxFeePerGasTooLow {
Expand Down Expand Up @@ -433,7 +428,12 @@ func (p *TxProcessor) GasChargingHook(gasRemaining *uint64) (common.Address, err

var gasNeededToStartEVM uint64
tipReceipient, _ := p.state.NetworkFeeAccount()
basefee := p.evm.Context.BaseFee
var basefee *big.Int
if p.evm.Context.BaseFeeInBlock != nil {
basefee = p.evm.Context.BaseFeeInBlock
} else {
basefee = p.evm.Context.BaseFee
}

var poster common.Address
if !p.msg.TxRunMode.ExecutedOnChain() {
Expand Down Expand Up @@ -594,7 +594,12 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {
return
}

basefee := p.evm.Context.BaseFee
var basefee *big.Int
if p.evm.Context.BaseFeeInBlock != nil {
basefee = p.evm.Context.BaseFeeInBlock
} else {
basefee = p.evm.Context.BaseFee
}
totalCost := arbmath.BigMul(basefee, arbmath.UintToBig(gasUsed)) // total cost = price of gas * gas burnt
computeCost := arbmath.BigSub(totalCost, p.PosterFee) // total cost = network's compute + poster's L1 costs
if computeCost.Sign() < 0 {
Expand Down Expand Up @@ -656,15 +661,10 @@ func (p *TxProcessor) EndTxHook(gasLeft uint64, success bool) {
func (p *TxProcessor) ScheduledTxes() types.Transactions {
scheduled := types.Transactions{}
time := p.evm.Context.Time
// p.evm.Context.BaseFee is already lowered to 0 when vm runs with NoBaseFee flag and 0 gas price
effectiveBaseFee := p.evm.Context.BaseFee
chainID := p.evm.ChainConfig().ChainID

if !p.msg.TxRunMode.ExecutedOnChain() && p.msg.GasFeeCap.BitLen() == 0 {
// In gas estimation or eth_call mode, we permit a zero gas fee cap.
// This matches behavior with normal tx gas estimation and eth_call.
effectiveBaseFee = common.Big0
}

logs := p.evm.StateDB.GetCurrentTxLogs()
for _, log := range logs {
if log.Address != ArbRetryableTxAddress || log.Topics[0] != RedeemScheduledEventID {
Expand Down Expand Up @@ -738,10 +738,8 @@ func (p *TxProcessor) GetPaidGasPrice() *big.Int {
gasPrice := p.evm.GasPrice
version := p.state.ArbOSVersion()
if version != 9 {
// p.evm.Context.BaseFee is already lowered to 0 when vm runs with NoBaseFee flag and 0 gas price
gasPrice = p.evm.Context.BaseFee
if !p.msg.TxRunMode.ExecutedOnChain() && p.msg.GasFeeCap.Sign() == 0 {
gasPrice = common.Big0
}
}
return gasPrice
}
Expand Down
43 changes: 39 additions & 4 deletions cmd/util/confighelpers/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,49 @@ func applyOverrideOverrides(f *flag.FlagSet, k *koanf.Koanf) error {
return nil
}

var envvarsToSplitOnComma map[string]any = map[string]any{
"auth.api": struct{}{},
"auth.origins": struct{}{},
"chain.info-files": struct{}{},
"conf.file": struct{}{},
"execution.secondary-forwarding-target": struct{}{},
"graphql.corsdomain": struct{}{},
"graphql.vhosts": struct{}{},
"http.api": struct{}{},
"http.corsdomain": struct{}{},
"http.vhosts": struct{}{},
"node.data-availability.rest-aggregator.urls": struct{}{},
"node.feed.input.secondary-url": struct{}{},
"node.feed.input.url": struct{}{},
"node.feed.input.verify.allowed-addresses": struct{}{},
"node.seq-coordinator.signer.ecdsa.allowed-addresses": struct{}{},
"p2p.bootnodes": struct{}{},
"p2p.bootnodes-v5": struct{}{},
"validation.api-auth": struct{}{},
"validation.arbitrator.redis-validation-server-config.module-roots": struct{}{},
"validation.wasm.allowed-wasm-module-roots": struct{}{},
"ws.api": struct{}{},
"ws.origins": struct{}{},
}

func loadEnvironmentVariables(k *koanf.Koanf) error {
envPrefix := k.String("conf.env-prefix")
if len(envPrefix) != 0 {
return k.Load(env.Provider(envPrefix+"_", ".", func(s string) string {
return k.Load(env.ProviderWithValue(envPrefix+"_", ".", func(key string, v string) (string, interface{}) {
// FOO__BAR -> foo-bar to handle dash in config names
s = strings.ReplaceAll(strings.ToLower(
strings.TrimPrefix(s, envPrefix+"_")), "__", "-")
return strings.ReplaceAll(s, "_", ".")
key = strings.ReplaceAll(strings.ToLower(
strings.TrimPrefix(key, envPrefix+"_")), "__", "-")
key = strings.ReplaceAll(key, "_", ".")

if _, found := envvarsToSplitOnComma[key]; found {
// If there are commas in the value, split the value into a slice.
if strings.Contains(v, ",") {
return key, strings.Split(v, ",")

}
}

return key, v
}), nil)
}

Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
Submodule go-ethereum updated 1 files
+4 −3 core/vm/evm.go
28 changes: 24 additions & 4 deletions precompiles/ArbGasInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ func (con ArbGasInfo) GetPricesInWeiWithAggregator(
if err != nil {
return nil, nil, nil, nil, nil, nil, err
}
l2GasPrice := evm.Context.BaseFee
var l2GasPrice *big.Int
if evm.Context.BaseFeeInBlock != nil {
l2GasPrice = evm.Context.BaseFeeInBlock
} else {
l2GasPrice = evm.Context.BaseFee
}

// aggregators compress calldata, so we must estimate accordingly
weiForL1Calldata := arbmath.BigMulByUint(l1GasPrice, params.TxDataNonZeroGasEIP2028)
Expand Down Expand Up @@ -69,7 +74,12 @@ func (con ArbGasInfo) _preVersion4_GetPricesInWeiWithAggregator(
if err != nil {
return nil, nil, nil, nil, nil, nil, err
}
l2GasPrice := evm.Context.BaseFee
var l2GasPrice *big.Int
if evm.Context.BaseFeeInBlock != nil {
l2GasPrice = evm.Context.BaseFeeInBlock
} else {
l2GasPrice = evm.Context.BaseFee
}

// aggregators compress calldata, so we must estimate accordingly
weiForL1Calldata := arbmath.BigMulByUint(l1GasPrice, params.TxDataNonZeroGasEIP2028)
Expand Down Expand Up @@ -101,7 +111,12 @@ func (con ArbGasInfo) GetPricesInArbGasWithAggregator(c ctx, evm mech, aggregato
if err != nil {
return nil, nil, nil, err
}
l2GasPrice := evm.Context.BaseFee
var l2GasPrice *big.Int
if evm.Context.BaseFeeInBlock != nil {
l2GasPrice = evm.Context.BaseFeeInBlock
} else {
l2GasPrice = evm.Context.BaseFee
}

// aggregators compress calldata, so we must estimate accordingly
weiForL1Calldata := arbmath.BigMulByUint(l1GasPrice, params.TxDataNonZeroGasEIP2028)
Expand All @@ -121,7 +136,12 @@ func (con ArbGasInfo) _preVersion4_GetPricesInArbGasWithAggregator(c ctx, evm me
if err != nil {
return nil, nil, nil, err
}
l2GasPrice := evm.Context.BaseFee
var l2GasPrice *big.Int
if evm.Context.BaseFeeInBlock != nil {
l2GasPrice = evm.Context.BaseFeeInBlock
} else {
l2GasPrice = evm.Context.BaseFee
}

// aggregators compress calldata, so we must estimate accordingly
weiForL1Calldata := arbmath.BigMulByUint(l1GasPrice, params.TxDataNonZeroGasEIP2028)
Expand Down
Loading

0 comments on commit d9a5572

Please sign in to comment.