Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename L1FeeEnabled to FeeVaultEnabled #281

Merged
merged 2 commits into from Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/blockchain.go
Expand Up @@ -236,7 +236,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
cacheConfig.SnapshotLimit = 0
}

if chainConfig.Scroll.L1FeeEnabled() {
if chainConfig.Scroll.FeeVaultEnabled() {
log.Warn("Using fee vault address", "FeeVaultAddress", *chainConfig.Scroll.FeeVaultAddress)
}

Expand Down
8 changes: 4 additions & 4 deletions core/state_transition.go
Expand Up @@ -166,7 +166,7 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b
// NewStateTransition initialises and returns a new state transition object.
func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition {
l1Fee := new(big.Int)
if evm.ChainConfig().Scroll.L1FeeEnabled() {
if evm.ChainConfig().Scroll.FeeVaultEnabled() {
l1Fee, _ = fees.CalculateL1MsgFee(msg, evm.StateDB)
}

Expand Down Expand Up @@ -207,7 +207,7 @@ func (st *StateTransition) buyGas() error {
mgval := new(big.Int).SetUint64(st.msg.Gas())
mgval = mgval.Mul(mgval, st.gasPrice)

if st.evm.ChainConfig().Scroll.L1FeeEnabled() {
if st.evm.ChainConfig().Scroll.FeeVaultEnabled() {
// always add l1fee, because all tx are L2-to-L1 ATM
log.Debug("Adding L1 fee", "l1_fee", st.l1Fee)
mgval = mgval.Add(mgval, st.l1Fee)
Expand All @@ -218,7 +218,7 @@ func (st *StateTransition) buyGas() error {
balanceCheck = new(big.Int).SetUint64(st.msg.Gas())
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap)
balanceCheck.Add(balanceCheck, st.value)
if st.evm.ChainConfig().Scroll.L1FeeEnabled() {
if st.evm.ChainConfig().Scroll.FeeVaultEnabled() {
// always add l1fee, because all tx are L2-to-L1 ATM
balanceCheck.Add(balanceCheck, st.l1Fee)
}
Expand Down Expand Up @@ -370,7 +370,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}
}

if st.evm.ChainConfig().Scroll.L1FeeEnabled() {
if st.evm.ChainConfig().Scroll.FeeVaultEnabled() {
// The L2 Fee is the same as the fee that is charged in the normal geth
// codepath. Add the L1 fee to the L2 fee for the total fee that is sent
// to the sequencer.
Expand Down
2 changes: 1 addition & 1 deletion core/tx_pool.go
Expand Up @@ -682,7 +682,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
// the sender is marked as local previously, treat it as the local transaction.
isLocal := local || pool.locals.containsTx(tx)

if pool.chainconfig.Scroll.L1FeeEnabled() {
if pool.chainconfig.Scroll.FeeVaultEnabled() {
if err := fees.VerifyFee(pool.signer, tx, pool.currentState); err != nil {
log.Trace("Discarding insufficient l1fee transaction", "hash", hash, "err", err)
invalidTxMeter.Mark(1)
Expand Down
2 changes: 1 addition & 1 deletion core/vm/evm.go
Expand Up @@ -535,7 +535,7 @@ func (evm *EVM) ChainConfig() *params.ChainConfig { return evm.chainConfig }

// FeeRecipient returns the environment's transaction fee recipient address.
func (evm *EVM) FeeRecipient() common.Address {
if evm.ChainConfig().Scroll.L1FeeEnabled() {
if evm.ChainConfig().Scroll.FeeVaultEnabled() {
return *evm.chainConfig.Scroll.FeeVaultAddress
} else {
return evm.Context.Coinbase
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/api.go
Expand Up @@ -900,7 +900,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex
vmenv := vm.NewEVM(vmctx, txContext, statedb, api.backend.ChainConfig(), vm.Config{Debug: true, Tracer: tracer, NoBaseFee: true})

// If gasPrice is 0, make sure that the account has sufficient balance to cover `l1Fee`.
if api.backend.ChainConfig().Scroll.L1FeeEnabled() && message.GasPrice().Cmp(big.NewInt(0)) == 0 {
if api.backend.ChainConfig().Scroll.FeeVaultEnabled() && message.GasPrice().Cmp(big.NewInt(0)) == 0 {
l1Fee, err := fees.CalculateL1MsgFee(message, vmenv.StateDB)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/api_blocktrace.go
Expand Up @@ -98,7 +98,7 @@ func (api *API) createTraceEnv(ctx context.Context, config *TraceConfig, block *

// get coinbase
var coinbase common.Address
if api.backend.ChainConfig().Scroll.L1FeeEnabled() {
if api.backend.ChainConfig().Scroll.FeeVaultEnabled() {
coinbase = *api.backend.ChainConfig().Scroll.FeeVaultAddress
} else {
coinbase, err = api.backend.Engine().Author(block.Header())
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/api_blocktrace_test.go
Expand Up @@ -181,7 +181,7 @@ func checkStructLogs(t *testing.T, expect []*txTraceResult, actual []*types.Exec

func checkCoinbase(t *testing.T, b *testBackend, wrapper *types.AccountWrapper) {
var coinbase common.Address
if b.chainConfig.Scroll.L1FeeEnabled() {
if b.chainConfig.Scroll.FeeVaultEnabled() {
coinbase = *b.chainConfig.Scroll.FeeVaultAddress
} else {
header, err := b.HeaderByNumber(context.Background(), 1)
Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/api.go
Expand Up @@ -908,7 +908,7 @@ func newRPCBalance(balance *big.Int) **hexutil.Big {
}

func CalculateL1MsgFee(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, timeout time.Duration, globalGasCap uint64, config *params.ChainConfig) (*big.Int, error) {
if !config.Scroll.L1FeeEnabled() {
if !config.Scroll.FeeVaultEnabled() {
return big.NewInt(0), nil
}

Expand Down
2 changes: 1 addition & 1 deletion light/txpool.go
Expand Up @@ -405,7 +405,7 @@ func (pool *TxPool) add(ctx context.Context, tx *types.Transaction) error {
return fmt.Errorf("Known transaction (%x)", hash[:4])
}

if pool.config.Scroll.L1FeeEnabled() {
if pool.config.Scroll.FeeVaultEnabled() {
if err := fees.VerifyFee(pool.signer, tx, pool.currentState(ctx)); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion params/config.go
Expand Up @@ -445,7 +445,7 @@ func (s ScrollConfig) BaseFeeEnabled() bool {
return s.EnableEIP2718 && s.EnableEIP1559
}

func (s ScrollConfig) L1FeeEnabled() bool {
func (s ScrollConfig) FeeVaultEnabled() bool {
return s.FeeVaultAddress != nil
}

Expand Down