• Matthew Slipper's avatar
    l2geth: Add support for system addresses · 962f36e4
    Matthew Slipper authored
    Adds support for system addresses.
    
    To deploy to a system address, the deployer must either be in the list of hardcoded addresses described in `SystemAddressDeployers`, or be specified via the `SYSTEM_ADDRESS_0_DEPLOYER`/`SYSTEM_ADDRESS_1_DEPLOYER` environment variables. The hardcoded system addresses deployers will always override those placed in the environment, so specifying the `SYSTEM_ADDRESS_*` env vars on mainnet, Kovan, or Goerli is a no-op. The env vars are available primarily for testing purposes.
    
    The contract deployment **must** be the first transaction from the deployment address - i.e., it must have nonce zero.
    
    In order to make the tests work, I had to change the integration tests chain ID to no longer conflict with Goerli. The new integration tests chain ID is `987`.
    
    Co-Authored-By: @inphi
    962f36e4
config.go 1.53 KB
package rcfg

import (
	"math/big"
	"os"

	"github.com/ethereum-optimism/optimism/l2geth/common"
)

// UsingOVM is used to enable or disable functionality necessary for the OVM.
var UsingOVM bool

var (
	// L2GasPriceSlot refers to the storage slot that the L2 gas price is stored
	// in in the OVM_GasPriceOracle predeploy
	L2GasPriceSlot = common.BigToHash(big.NewInt(1))
	// L1GasPriceSlot refers to the storage slot that the L1 gas price is stored
	// in in the OVM_GasPriceOracle predeploy
	L1GasPriceSlot = common.BigToHash(big.NewInt(2))
	// L2GasPriceOracleOwnerSlot refers to the storage slot that the owner of
	// the OVM_GasPriceOracle is stored in
	L2GasPriceOracleOwnerSlot = common.BigToHash(big.NewInt(0))
	// L2GasPriceOracleAddress is the address of the OVM_GasPriceOracle
	// predeploy
	L2GasPriceOracleAddress = common.HexToAddress("0x420000000000000000000000000000000000000F")
	// OverheadSlot refers to the storage slot in the OVM_GasPriceOracle that
	// holds the per transaction overhead. This is added to the L1 cost portion
	// of the fee
	OverheadSlot = common.BigToHash(big.NewInt(3))
	// ScalarSlot refers to the storage slot in the OVM_GasPriceOracle that
	// holds the transaction fee scalar. This value is scaled upwards by
	// the number of decimals
	ScalarSlot = common.BigToHash(big.NewInt(4))
	// DecimalsSlot refers to the storage slot in the OVM_GasPriceOracle that
	// holds the number of decimals in the fee scalar
	DecimalsSlot = common.BigToHash(big.NewInt(5))
)

func init() {
	UsingOVM = os.Getenv("USING_OVM") == "true"
}