From 13c31a6b245a9a79bc11e1cbf8ec18de9657d719 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Thu, 30 May 2024 16:47:44 -0500 Subject: [PATCH 1/2] Allow lowering of basefee to 0 if vm runs with NoBaseFee flag and 0 gas price --- core/vm/evm.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index 13fea79f57..0d73e4e451 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -84,6 +84,7 @@ type BlockContext struct { // Arbitrum information ArbOSVersion uint64 + BaseFeeCopy *big.Int // Copy of BaseFee to be used in arbitrum's geth hooks and precompiles when BaseFee is lowered to 0 when vm runs with NoBaseFee flag and 0 gas price. Is nil when BaseFee isn't lowered to 0 } // TxContext provides the EVM with information about a transaction. @@ -141,8 +142,8 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig // gas prices were specified, lower the basefee to 0 to avoid breaking EVM // invariants (basefee < feecap) if config.NoBaseFee { - // Currently we don't set block context's BaseFee to zero, since nitro uses this field - if txCtx.GasPrice.BitLen() == 0 && !chainConfig.IsArbitrum() { + if txCtx.GasPrice.BitLen() == 0 { + blockCtx.BaseFeeCopy = new(big.Int).Set(blockCtx.BaseFee) blockCtx.BaseFee = new(big.Int) } if txCtx.BlobFeeCap != nil && txCtx.BlobFeeCap.BitLen() == 0 { From 2d84bba914e8111afedf491697c221d26e4430f6 Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Fri, 14 Jun 2024 14:47:10 -0500 Subject: [PATCH 2/2] code refactor --- core/vm/evm.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index 0d73e4e451..c530a0ef0e 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -83,8 +83,8 @@ type BlockContext struct { Random *common.Hash // Provides information for PREVRANDAO // Arbitrum information - ArbOSVersion uint64 - BaseFeeCopy *big.Int // Copy of BaseFee to be used in arbitrum's geth hooks and precompiles when BaseFee is lowered to 0 when vm runs with NoBaseFee flag and 0 gas price. Is nil when BaseFee isn't lowered to 0 + ArbOSVersion uint64 + BaseFeeInBlock *big.Int // Copy of BaseFee to be used in arbitrum's geth hooks and precompiles when BaseFee is lowered to 0 when vm runs with NoBaseFee flag and 0 gas price. Is nil when BaseFee isn't lowered to 0 } // TxContext provides the EVM with information about a transaction. @@ -143,7 +143,7 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig // invariants (basefee < feecap) if config.NoBaseFee { if txCtx.GasPrice.BitLen() == 0 { - blockCtx.BaseFeeCopy = new(big.Int).Set(blockCtx.BaseFee) + blockCtx.BaseFeeInBlock = new(big.Int).Set(blockCtx.BaseFee) blockCtx.BaseFee = new(big.Int) } if txCtx.BlobFeeCap != nil && txCtx.BlobFeeCap.BitLen() == 0 {