refactor: rename L1FeeEnabled to FeeVaultEnabled (#281)

rename `L1FeeEnabled` to `FeeVaultEnabled`
This commit is contained in:
HAOYUatHZ 2023-04-19 22:41:38 +08:00 committed by GitHub
parent f71fc6794a
commit 11ff7a0648
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 13 additions and 13 deletions

View file

@ -236,7 +236,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
cacheConfig.SnapshotLimit = 0 cacheConfig.SnapshotLimit = 0
} }
if chainConfig.Scroll.L1FeeEnabled() { if chainConfig.Scroll.FeeVaultEnabled() {
log.Warn("Using fee vault address", "FeeVaultAddress", *chainConfig.Scroll.FeeVaultAddress) log.Warn("Using fee vault address", "FeeVaultAddress", *chainConfig.Scroll.FeeVaultAddress)
} }

View file

@ -166,7 +166,7 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b
// NewStateTransition initialises and returns a new state transition object. // NewStateTransition initialises and returns a new state transition object.
func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition { func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition {
l1Fee := new(big.Int) l1Fee := new(big.Int)
if evm.ChainConfig().Scroll.L1FeeEnabled() { if evm.ChainConfig().Scroll.FeeVaultEnabled() {
l1Fee, _ = fees.CalculateL1MsgFee(msg, evm.StateDB) l1Fee, _ = fees.CalculateL1MsgFee(msg, evm.StateDB)
} }
@ -207,7 +207,7 @@ func (st *StateTransition) buyGas() error {
mgval := new(big.Int).SetUint64(st.msg.Gas()) mgval := new(big.Int).SetUint64(st.msg.Gas())
mgval = mgval.Mul(mgval, st.gasPrice) 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 // always add l1fee, because all tx are L2-to-L1 ATM
log.Debug("Adding L1 fee", "l1_fee", st.l1Fee) log.Debug("Adding L1 fee", "l1_fee", st.l1Fee)
mgval = mgval.Add(mgval, st.l1Fee) mgval = mgval.Add(mgval, st.l1Fee)
@ -218,7 +218,7 @@ func (st *StateTransition) buyGas() error {
balanceCheck = new(big.Int).SetUint64(st.msg.Gas()) balanceCheck = new(big.Int).SetUint64(st.msg.Gas())
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap) balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap)
balanceCheck.Add(balanceCheck, st.value) 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 // always add l1fee, because all tx are L2-to-L1 ATM
balanceCheck.Add(balanceCheck, st.l1Fee) balanceCheck.Add(balanceCheck, st.l1Fee)
} }
@ -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 // 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 // codepath. Add the L1 fee to the L2 fee for the total fee that is sent
// to the sequencer. // to the sequencer.

View file

@ -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. // the sender is marked as local previously, treat it as the local transaction.
isLocal := local || pool.locals.containsTx(tx) 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 { if err := fees.VerifyFee(pool.signer, tx, pool.currentState); err != nil {
log.Trace("Discarding insufficient l1fee transaction", "hash", hash, "err", err) log.Trace("Discarding insufficient l1fee transaction", "hash", hash, "err", err)
invalidTxMeter.Mark(1) invalidTxMeter.Mark(1)

View file

@ -535,7 +535,7 @@ func (evm *EVM) ChainConfig() *params.ChainConfig { return evm.chainConfig }
// FeeRecipient returns the environment's transaction fee recipient address. // FeeRecipient returns the environment's transaction fee recipient address.
func (evm *EVM) FeeRecipient() common.Address { func (evm *EVM) FeeRecipient() common.Address {
if evm.ChainConfig().Scroll.L1FeeEnabled() { if evm.ChainConfig().Scroll.FeeVaultEnabled() {
return *evm.chainConfig.Scroll.FeeVaultAddress return *evm.chainConfig.Scroll.FeeVaultAddress
} else { } else {
return evm.Context.Coinbase return evm.Context.Coinbase

View file

@ -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}) 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 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) l1Fee, err := fees.CalculateL1MsgFee(message, vmenv.StateDB)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -98,7 +98,7 @@ func (api *API) createTraceEnv(ctx context.Context, config *TraceConfig, block *
// get coinbase // get coinbase
var coinbase common.Address var coinbase common.Address
if api.backend.ChainConfig().Scroll.L1FeeEnabled() { if api.backend.ChainConfig().Scroll.FeeVaultEnabled() {
coinbase = *api.backend.ChainConfig().Scroll.FeeVaultAddress coinbase = *api.backend.ChainConfig().Scroll.FeeVaultAddress
} else { } else {
coinbase, err = api.backend.Engine().Author(block.Header()) coinbase, err = api.backend.Engine().Author(block.Header())

View file

@ -181,7 +181,7 @@ func checkStructLogs(t *testing.T, expect []*txTraceResult, actual []*types.Exec
func checkCoinbase(t *testing.T, b *testBackend, wrapper *types.AccountWrapper) { func checkCoinbase(t *testing.T, b *testBackend, wrapper *types.AccountWrapper) {
var coinbase common.Address var coinbase common.Address
if b.chainConfig.Scroll.L1FeeEnabled() { if b.chainConfig.Scroll.FeeVaultEnabled() {
coinbase = *b.chainConfig.Scroll.FeeVaultAddress coinbase = *b.chainConfig.Scroll.FeeVaultAddress
} else { } else {
header, err := b.HeaderByNumber(context.Background(), 1) header, err := b.HeaderByNumber(context.Background(), 1)

View file

@ -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) { 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 return big.NewInt(0), nil
} }

View file

@ -405,7 +405,7 @@ func (pool *TxPool) add(ctx context.Context, tx *types.Transaction) error {
return fmt.Errorf("Known transaction (%x)", hash[:4]) 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 { if err := fees.VerifyFee(pool.signer, tx, pool.currentState(ctx)); err != nil {
return err return err
} }

View file

@ -445,7 +445,7 @@ func (s ScrollConfig) BaseFeeEnabled() bool {
return s.EnableEIP2718 && s.EnableEIP1559 return s.EnableEIP2718 && s.EnableEIP1559
} }
func (s ScrollConfig) L1FeeEnabled() bool { func (s ScrollConfig) FeeVaultEnabled() bool {
return s.FeeVaultAddress != nil return s.FeeVaultAddress != nil
} }