genesis

package
v0.0.0-...-eb934a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDeployConfig     = errors.New("invalid deploy config")
	ErrInvalidImmutablesConfig = errors.New("invalid immutables config")
)
View Source
var (

	// bigL2PredeployNamespace represents the predeploy namespace as a big.Int
	BigL2PredeployNamespace = new(big.Int).SetBytes(l2PredeployNamespace.Bytes())

	// implementationSlot represents the EIP 1967 implementation storage slot
	ImplementationSlot = common.HexToHash("0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc")
	// implementationSlot represents the EIP 1967 admin storage slot
	AdminSlot = common.HexToHash("0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103")
)
View Source
var BedrockTransitionBlockExtraData = []byte("BEDROCK")

BedrockTransitionBlockExtraData represents the default extra data for the bedrock transition block.

View Source
var DevAccounts = []common.Address{
	common.HexToAddress("0x14dC79964da2C08b23698B3D3cc7Ca32193d9955"),
	common.HexToAddress("0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65"),
	common.HexToAddress("0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec"),
	common.HexToAddress("0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f"),
	common.HexToAddress("0x2546BcD3c84621e976D8185a91A922aE77ECEc30"),
	common.HexToAddress("0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"),
	common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8"),
	common.HexToAddress("0x71bE63f3384f5fb98995898A86B02Fb2426c5788"),
	common.HexToAddress("0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199"),
	common.HexToAddress("0x90F79bf6EB2c4f870365E785982E1f101E93b906"),
	common.HexToAddress("0x976EA74026E726554dB657fA54763abd0C3a0aa9"),
	common.HexToAddress("0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc"),
	common.HexToAddress("0xBcd4042DE499D14e55001CcbB24a551F3b954096"),
	common.HexToAddress("0xFABB0ac9d68B0B445fB7357272Ff202C5651694a"),
	common.HexToAddress("0xa0Ee7A142d267C1f36714E4a8F75612F20a79720"),
	common.HexToAddress("0xbDA5747bFD65F08deb54cb465eB87D40e51B197E"),
	common.HexToAddress("0xcd3B766CCDd6AE721141F452C550Ca635964ce71"),
	common.HexToAddress("0xdD2FD4581271e230360230F9337D5c0430Bf44C0"),
	common.HexToAddress("0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097"),
	common.HexToAddress("0xde3829a23df1479438622a08a116e8eb3f620bb5"),
	common.HexToAddress("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"),

	common.HexToAddress("0x71562b71999873DB5b286dF957af199Ec94617F7"),
}

DevAccounts represent the standard hardhat development accounts. These are funded if the deploy config has funding development accounts enabled.

Functions

func AddressToCodeNamespace

func AddressToCodeNamespace(addr common.Address) (common.Address, error)

AddressToCodeNamespace takes a predeploy address and computes the implementation address that the implementation should be deployed at

func BuildL1DeveloperGenesis

func BuildL1DeveloperGenesis(config *DeployConfig) (*core.Genesis, error)

BuildL1DeveloperGenesis will create a L1 genesis block after creating all of the state required for an Slice network to function.

func BuildL2Genesis

func BuildL2Genesis(config *DeployConfig, l1StartBlock *types.Block) (*core.Genesis, error)

BuildL2DeveloperGenesis will build the L2 genesis block.

func FundDevAccounts

func FundDevAccounts(db vm.StateDB)

FundDevAccounts will fund each of the development accounts.

func GetBlockFromTag

func GetBlockFromTag(chain ethereum.ChainReader, tag *rpc.BlockNumberOrHash) (*types.Block, error)

GetBlockFromTag will resolve a Block given an rpc block tag

func IsL1DevPredeploy

func IsL1DevPredeploy(addr common.Address) bool

func IsL2DevPredeploy

func IsL2DevPredeploy(addr common.Address) bool

func NewL1Genesis

func NewL1Genesis(config *DeployConfig) (*core.Genesis, error)

NewL1Genesis will create a new L1 genesis config

func NewL2Genesis

func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, error)

NewL2Genesis will create a new L2 genesis

func NewL2ImmutableConfig

func NewL2ImmutableConfig(config *DeployConfig, block *types.Block) (immutables.ImmutableConfig, error)

NewL2ImmutableConfig will create an ImmutableConfig given an instance of a DeployConfig and a block.

func NewL2StorageConfig

func NewL2StorageConfig(config *DeployConfig, block *types.Block) (state.StorageConfig, error)

NewL2StorageConfig will create a StorageConfig given an instance of a Hardhat and a DeployConfig.

func SetL1Proxies

func SetL1Proxies(db vm.StateDB, proxyAdminAddr common.Address) error

SetL1Proxies will set each of the proxies in the state. It requires a Proxy and ProxyAdmin deployment present so that the Proxy bytecode can be set in state and the ProxyAdmin can be set as the admin of the Proxy.

func SetPrecompileBalances

func SetPrecompileBalances(db vm.StateDB)

SetPrecompileBalances will set a single wei at each precompile address. This is an optimization to make calling them cheaper. This should only be used for devnets.

Types

type DeployConfig

type DeployConfig struct {
	L1StartingBlockTag *MarshalableRPCBlockNumberOrHash `json:"l1StartingBlockTag"`
	L1ChainID          uint64                           `json:"l1ChainID"`
	L2ChainID          uint64                           `json:"l2ChainID"`
	L2BlockTime        uint64                           `json:"l2BlockTime"`

	FinalizationPeriodSeconds uint64         `json:"finalizationPeriodSeconds"`
	MaxSequencerDrift         uint64         `json:"maxSequencerDrift"`
	SequencerWindowSize       uint64         `json:"sequencerWindowSize"`
	ChannelTimeout            uint64         `json:"channelTimeout"`
	P2PSequencerAddress       common.Address `json:"p2pSequencerAddress"`
	BatchInboxAddress         common.Address `json:"batchInboxAddress"`
	BatchSenderAddress        common.Address `json:"batchSenderAddress"`

	L2OutputOracleSubmissionInterval uint64         `json:"l2OutputOracleSubmissionInterval"`
	L2OutputOracleStartingTimestamp  int            `json:"l2OutputOracleStartingTimestamp"`
	L2OutputOracleProposer           common.Address `json:"l2OutputOracleProposer"`
	L2OutputOracleChallenger         common.Address `json:"l2OutputOracleChallenger"`

	L1BlockTime                 uint64         `json:"l1BlockTime"`
	L1GenesisBlockTimestamp     hexutil.Uint64 `json:"l1GenesisBlockTimestamp"`
	L1GenesisBlockNonce         hexutil.Uint64 `json:"l1GenesisBlockNonce"`
	CliqueSignerAddress         common.Address `json:"cliqueSignerAddress"` // proof of stake genesis if left zeroed.
	L1GenesisBlockGasLimit      hexutil.Uint64 `json:"l1GenesisBlockGasLimit"`
	L1GenesisBlockDifficulty    *hexutil.Big   `json:"l1GenesisBlockDifficulty"`
	L1GenesisBlockMixHash       common.Hash    `json:"l1GenesisBlockMixHash"`
	L1GenesisBlockCoinbase      common.Address `json:"l1GenesisBlockCoinbase"`
	L1GenesisBlockNumber        hexutil.Uint64 `json:"l1GenesisBlockNumber"`
	L1GenesisBlockGasUsed       hexutil.Uint64 `json:"l1GenesisBlockGasUsed"`
	L1GenesisBlockParentHash    common.Hash    `json:"l1GenesisBlockParentHash"`
	L1GenesisBlockBaseFeePerGas *hexutil.Big   `json:"l1GenesisBlockBaseFeePerGas"`

	L2GenesisBlockNonce         hexutil.Uint64 `json:"l2GenesisBlockNonce"`
	L2GenesisBlockGasLimit      hexutil.Uint64 `json:"l2GenesisBlockGasLimit"`
	L2GenesisBlockDifficulty    *hexutil.Big   `json:"l2GenesisBlockDifficulty"`
	L2GenesisBlockMixHash       common.Hash    `json:"l2GenesisBlockMixHash"`
	L2GenesisBlockNumber        hexutil.Uint64 `json:"l2GenesisBlockNumber"`
	L2GenesisBlockGasUsed       hexutil.Uint64 `json:"l2GenesisBlockGasUsed"`
	L2GenesisBlockParentHash    common.Hash    `json:"l2GenesisBlockParentHash"`
	L2GenesisBlockBaseFeePerGas *hexutil.Big   `json:"l2GenesisBlockBaseFeePerGas"`

	// Seconds after genesis block that Regolith hard fork activates. 0 to activate at genesis. Nil to disable regolith
	L2GenesisRegolithTimeOffset *hexutil.Uint64 `json:"l2GenesisRegolithTimeOffset,omitempty"`

	// Configurable extradata. Will default to []byte("BEDROCK") if left unspecified.
	L2GenesisBlockExtraData []byte `json:"l2GenesisBlockExtraData"`

	// Owner of the ProxyAdmin predeploy
	ProxyAdminOwner common.Address `json:"proxyAdminOwner"`
	// Owner of the system on L1
	FinalSystemOwner common.Address `json:"finalSystemOwner"`
	// GUARDIAN account in the SlicePortal
	PortalGuardian common.Address `json:"portalGuardian"`
	// L1 recipient of fees accumulated in the BaseFeeVault
	BaseFeeVaultRecipient common.Address `json:"baseFeeVaultRecipient"`
	// L1 recipient of fees accumulated in the L1FeeVault
	L1FeeVaultRecipient common.Address `json:"l1FeeVaultRecipient"`
	// L1 recipient of fees accumulated in the SequencerFeeVault
	SequencerFeeVaultRecipient common.Address `json:"sequencerFeeVaultRecipient"`
	// Minimum withdrawal amount for the BaseFeeVault
	BaseFeeVaultMinimumWithdrawalAmount *hexutil.Big `json:"baseFeeVaultMinimumWithdrawalAmount"`
	// Minimum withdrawal amount for the L1FeeVault
	L1FeeVaultMinimumWithdrawalAmount *hexutil.Big `json:"l1FeeVaultMinimumWithdrawalAmount"`
	// Minimum withdrawal amount for the SequencerFeeVault
	SequencerFeeVaultMinimumWithdrawalAmount *hexutil.Big `json:"sequencerFeeVaultMinimumWithdrawalAmount"`
	// Withdrawal network for the BaseFeeVault
	BaseFeeVaultWithdrawalNetwork uint8 `json:"baseFeeVaultWithdrawalNetwork"`
	// Withdrawal network for the L1FeeVault
	L1FeeVaultWithdrawalNetwork uint8 `json:"l1FeeVaultWithdrawalNetwork"`
	// Withdrawal network for the SequencerFeeVault
	SequencerFeeVaultWithdrawalNetwork uint8 `json:"sequencerFeeVaultWithdrawalNetwork"`
	// L1StandardBridge proxy address on L1
	L1StandardBridgeProxy common.Address `json:"l1StandardBridgeProxy"`
	// L1CrossDomainMessenger proxy address on L1
	L1CrossDomainMessengerProxy common.Address `json:"l1CrossDomainMessengerProxy"`
	// L1ERC721Bridge proxy address on L1
	L1ERC721BridgeProxy common.Address `json:"l1ERC721BridgeProxy"`
	// SystemConfig proxy address on L1
	SystemConfigProxy common.Address `json:"systemConfigProxy"`
	// SlicePortal proxy address on L1
	SlicePortalProxy common.Address `json:"slicePortalProxy"`
	// The initial value of the gas overhead
	GasPriceOracleOverhead uint64 `json:"gasPriceOracleOverhead"`
	// The initial value of the gas scalar
	GasPriceOracleScalar uint64 `json:"gasPriceOracleScalar"`
	// Whether or not include governance token predeploy
	EnableGovernance bool `json:"enableGovernance"`
	// The ERC20 symbol of the GovernanceToken
	GovernanceTokenSymbol string `json:"governanceTokenSymbol"`
	// The ERC20 name of the GovernanceToken
	GovernanceTokenName string `json:"governanceTokenName"`
	// The owner of the GovernanceToken
	GovernanceTokenOwner common.Address `json:"governanceTokenOwner"`

	DeploymentWaitConfirmations int `json:"deploymentWaitConfirmations"`

	EIP1559Elasticity  uint64 `json:"eip1559Elasticity"`
	EIP1559Denominator uint64 `json:"eip1559Denominator"`

	FundDevAccounts bool `json:"fundDevAccounts"`
}

DeployConfig represents the deployment configuration for Slice

func NewDeployConfig

func NewDeployConfig(path string) (*DeployConfig, error)

NewDeployConfig reads a config file given a path on the filesystem.

func NewDeployConfigWithNetwork

func NewDeployConfigWithNetwork(network, path string) (*DeployConfig, error)

NewDeployConfigWithNetwork takes a path to a deploy config directory and the network name. The config file in the deploy config directory must match the network name and be a JSON file.

func (*DeployConfig) Check

func (d *DeployConfig) Check() error

Check will ensure that the config is sane and return an error when it is not

func (*DeployConfig) GetDeployedAddresses

func (d *DeployConfig) GetDeployedAddresses(hh *hardhat.Hardhat) error

GetDeployedAddresses will get the deployed addresses of deployed L1 contracts required for the L2 genesis creation. Legacy systems use the `Proxy__` prefix while modern systems use the `Proxy` suffix. First check for the legacy deployments so that this works with upgrading a system.

func (*DeployConfig) InitDeveloperDeployedAddresses

func (d *DeployConfig) InitDeveloperDeployedAddresses() error

InitDeveloperDeployedAddresses will set the dev addresses on the DeployConfig

func (*DeployConfig) RegolithTime

func (d *DeployConfig) RegolithTime(genesisTime uint64) *uint64

func (*DeployConfig) RollupConfig

func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHash common.Hash, l2GenesisBlockNumber uint64) (*rollup.Config, error)

RollupConfig converts a DeployConfig to a rollup.Config

type MarshalableRPCBlockNumberOrHash

type MarshalableRPCBlockNumberOrHash rpc.BlockNumberOrHash

func (*MarshalableRPCBlockNumberOrHash) Hash

Hash wraps the rpc.BlockNumberOrHash Hash method.

func (*MarshalableRPCBlockNumberOrHash) MarshalJSON

func (m *MarshalableRPCBlockNumberOrHash) MarshalJSON() ([]byte, error)

func (*MarshalableRPCBlockNumberOrHash) Number

Number wraps the rpc.BlockNumberOrHash Number method.

func (*MarshalableRPCBlockNumberOrHash) String

String wraps the rpc.BlockNumberOrHash String method.

func (*MarshalableRPCBlockNumberOrHash) UnmarshalJSON

func (m *MarshalableRPCBlockNumberOrHash) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL