Skip to content

Commit

Permalink
Merge pull request ethereum#128 from OffchainLabs/gas-price-op
Browse files Browse the repository at this point in the history
Add hook for gasprice opcode
  • Loading branch information
PlasmaPower authored Jul 14, 2022
2 parents 173f323 + 3ad5274 commit 0f7dd4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions core/vm/evm_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package vm

import (
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
Expand Down Expand Up @@ -45,6 +47,7 @@ type TxProcessingHook interface {
ScheduledTxes() types.Transactions
L1BlockNumber(blockCtx BlockContext) (uint64, error)
L1BlockHash(blockCtx BlockContext, l1BlocKNumber uint64) (common.Hash, error)
GasPriceOp(evm *EVM) *big.Int
FillReceiptInfo(receipt *types.Receipt)
}

Expand Down Expand Up @@ -85,4 +88,8 @@ func (p DefaultTxProcessor) L1BlockHash(blockCtx BlockContext, l1BlocKNumber uin
return blockCtx.GetHash(l1BlocKNumber), nil
}

func (p DefaultTxProcessor) GasPriceOp(evm *EVM) *big.Int {
return evm.GasPrice
}

func (p DefaultTxProcessor) FillReceiptInfo(*types.Receipt) {}
6 changes: 5 additions & 1 deletion core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,11 @@ func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
}

func opGasprice(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
v, _ := uint256.FromBig(interpreter.evm.GasPrice)

// Arbitrum: provide an opportunity to remove the tip from the gas price
gasPrice := interpreter.evm.ProcessingHook.GasPriceOp(interpreter.evm)

v, _ := uint256.FromBig(gasPrice)
scope.Stack.push(v)
return nil, nil
}
Expand Down

0 comments on commit 0f7dd4b

Please sign in to comment.