Skip to content

Commit

Permalink
Merge pull request ethereum#106 from OffchainLabs/remove-tips
Browse files Browse the repository at this point in the history
Remove tips
  • Loading branch information
PlasmaPower authored Jun 14, 2022
2 parents df56736 + 53740c7 commit 819647b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
10 changes: 3 additions & 7 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
// 6. caller has enough balance to cover asset transfer for **topmost** call

// Arbitrum: drop support for tips from upgrade 2 onward
if st.evm.ProcessingHook.DropTip() && st.gasPrice.Cmp(st.evm.Context.BaseFee) > 0 {
if st.gasPrice.Cmp(st.evm.Context.BaseFee) > 0 {
st.gasPrice = st.evm.Context.BaseFee
st.gasTipCap = common.Big0
}
Expand All @@ -328,8 +328,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}
st.gas -= gas

tipRecipient, err := st.evm.ProcessingHook.GasChargingHook(&st.gas)
if err != nil {
if err := st.evm.ProcessingHook.GasChargingHook(&st.gas); err != nil {
return nil, err
}

Expand Down Expand Up @@ -365,10 +364,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
if london {
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
}
if tipRecipient == nil {
tipRecipient = &st.evm.Context.Coinbase
}
st.state.AddBalance(*tipRecipient, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip))
st.state.AddBalance(st.evm.Context.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip))

st.evm.ProcessingHook.EndTxHook(st.gas, vmerr == nil)

Expand Down
3 changes: 1 addition & 2 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ type Transaction struct {
time time.Time // Time first seen locally (spam avoidance)

// Arbitrum cache
PosterCost *big.Int
PosterIsReimbursable bool
PosterCost *big.Int

// caches
hash atomic.Value
Expand Down
11 changes: 3 additions & 8 deletions core/vm/evm_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (evm *EVM) DecrementDepth() {

type TxProcessingHook interface {
StartTxHook() (bool, uint64, error, []byte) // return 4-tuple rather than *struct to avoid an import cycle
GasChargingHook(gasRemaining *uint64) (*common.Address, error)
GasChargingHook(gasRemaining *uint64) error
PushCaller(addr common.Address)
PopCaller()
ForceRefundGas() uint64
Expand All @@ -46,7 +46,6 @@ type TxProcessingHook interface {
L1BlockNumber(blockCtx BlockContext) (uint64, error)
L1BlockHash(blockCtx BlockContext, l1BlocKNumber uint64) (common.Hash, error)
FillReceiptInfo(receipt *types.Receipt)
DropTip() bool
}

type DefaultTxProcessor struct{}
Expand All @@ -55,8 +54,8 @@ func (p DefaultTxProcessor) StartTxHook() (bool, uint64, error, []byte) {
return false, 0, nil, nil
}

func (p DefaultTxProcessor) GasChargingHook(gasRemaining *uint64) (*common.Address, error) {
return nil, nil
func (p DefaultTxProcessor) GasChargingHook(gasRemaining *uint64) error {
return nil
}

func (p DefaultTxProcessor) PushCaller(addr common.Address) {}
Expand Down Expand Up @@ -87,7 +86,3 @@ func (p DefaultTxProcessor) L1BlockHash(blockCtx BlockContext, l1BlocKNumber uin
}

func (p DefaultTxProcessor) FillReceiptInfo(*types.Receipt) {}

func (p DefaultTxProcessor) DropTip() bool {
return false
}

0 comments on commit 819647b

Please sign in to comment.