state

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VMTypeAlphabet   = "ALPHABET"
	VMTypeCannon     = "CANNON"      // Corresponds to the currently released Cannon StateVersion. See: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go
	VMTypeCannonNext = "CANNON-NEXT" // Corresponds to the next in-development Cannon StateVersion. See: https://github.com/ethereum-optimism/optimism/blob/4c05241bc534ae5837007c32995fc62f3dd059b6/cannon/mipsevm/versions/version.go
)

Variables

View Source
var ErrEip1559ZeroValue = fmt.Errorf("eip1559 param is set to zero value")
View Source
var ErrFeeVaultZeroAddress = fmt.Errorf("chain has a fee vault set to zero address")
View Source
var ErrGasLimitZeroValue = fmt.Errorf("chain has a gas limit set to zero value")
View Source
var ErrIncompatibleValue = fmt.Errorf("chain contains incompatible config value")
View Source
var ErrL1ContractsLocatorUndefined = errors.New("L1ContractsLocator undefined")
View Source
var ErrL2ContractsLocatorUndefined = errors.New("L2ContractsLocator undefined")
View Source
var ErrNonStandardValue = fmt.Errorf("chain contains non-standard config value")

Functions

func CombineDeployConfig

func CombineDeployConfig(intent *Intent, chainIntent *ChainIntent, state *State, chainState *ChainState) (genesis.DeployConfig, error)

func GetStandardSuperchainRoles added in v1.12.1

func GetStandardSuperchainRoles(l1ChainId uint64) (*addresses.SuperchainRoles, error)

Types

type AdditionalDisputeGame added in v1.11.0

type AdditionalDisputeGame struct {
	ChainProofParams
	VMType                       VMType
	UseCustomOracle              bool
	OracleMinProposalSize        uint64
	OracleChallengePeriodSeconds uint64
	MakeRespected                bool
}

type AdditionalDisputeGameState added in v1.11.0

type AdditionalDisputeGameState struct {
	GameType      uint32
	GameAddress   common.Address
	VMAddress     common.Address
	OracleAddress common.Address
	VMType        VMType
}

type Base64Bytes

type Base64Bytes []byte

func (Base64Bytes) MarshalJSON

func (b Base64Bytes) MarshalJSON() ([]byte, error)

func (*Base64Bytes) UnmarshalJSON

func (b *Base64Bytes) UnmarshalJSON(data []byte) error

type ChainIntent

type ChainIntent struct {
	ID                         common.Hash               `json:"id" toml:"id"`
	BaseFeeVaultRecipient      common.Address            `json:"baseFeeVaultRecipient" toml:"baseFeeVaultRecipient"`
	L1FeeVaultRecipient        common.Address            `json:"l1FeeVaultRecipient" toml:"l1FeeVaultRecipient"`
	SequencerFeeVaultRecipient common.Address            `json:"sequencerFeeVaultRecipient" toml:"sequencerFeeVaultRecipient"`
	Eip1559DenominatorCanyon   uint64                    `json:"eip1559DenominatorCanyon" toml:"eip1559DenominatorCanyon"`
	Eip1559Denominator         uint64                    `json:"eip1559Denominator" toml:"eip1559Denominator"`
	Eip1559Elasticity          uint64                    `json:"eip1559Elasticity" toml:"eip1559Elasticity"`
	GasLimit                   uint64                    `json:"gasLimit" toml:"gasLimit"`
	Roles                      ChainRoles                `json:"roles" toml:"roles"`
	DeployOverrides            map[string]any            `json:"deployOverrides" toml:"deployOverrides"`
	DangerousAltDAConfig       genesis.AltDADeployConfig `json:"dangerousAltDAConfig,omitempty" toml:"dangerousAltDAConfig,omitempty"`
	AdditionalDisputeGames     []AdditionalDisputeGame   `json:"dangerousAdditionalDisputeGames" toml:"dangerousAdditionalDisputeGames,omitempty"`
	OperatorFeeScalar          uint32                    `json:"operatorFeeScalar,omitempty" toml:"operatorFeeScalar,omitempty"`
	OperatorFeeConstant        uint64                    `json:"operatorFeeConstant,omitempty" toml:"operatorFeeConstant,omitempty"`
	L1StartBlockHash           *common.Hash              `json:"l1StartBlockHash,omitempty" toml:"l1StartBlockHash,omitempty"`
	MinBaseFee                 uint64                    `json:"minBaseFee,omitempty" toml:"minBaseFee,omitempty"`
	DAFootprintGasScalar       uint16                    `json:"daFootprintGasScalar,omitempty" toml:"daFootprintGasScalar,omitempty"`

	// Optional. For development purposes only. Only enabled if the operation mode targets a genesis-file output.
	L2DevGenesisParams *L2DevGenesisParams `json:"l2DevGenesisParams,omitempty" toml:"l2DevGenesisParams,omitempty"`
}

func (*ChainIntent) Check

func (c *ChainIntent) Check() error

type ChainProofParams added in v1.11.0

type ChainProofParams struct {
	DisputeGameType                         uint32      `json:"respectedGameType" toml:"respectedGameType"`
	DisputeAbsolutePrestate                 common.Hash `json:"faultGameAbsolutePrestate" toml:"faultGameAbsolutePrestate"`
	DisputeMaxGameDepth                     uint64      `json:"faultGameMaxDepth" toml:"faultGameMaxDepth"`
	DisputeSplitDepth                       uint64      `json:"faultGameSplitDepth" toml:"faultGameSplitDepth"`
	DisputeClockExtension                   uint64      `json:"faultGameClockExtension" toml:"faultGameClockExtension"`
	DisputeMaxClockDuration                 uint64      `json:"faultGameMaxClockDuration" toml:"faultGameMaxClockDuration"`
	DangerouslyAllowCustomDisputeParameters bool        `json:"dangerouslyAllowCustomDisputeParameters" toml:"dangerouslyAllowCustomDisputeParameters"`
}

type ChainRoles

type ChainRoles struct {
	L1ProxyAdminOwner common.Address `json:"l1ProxyAdminOwner" toml:"l1ProxyAdminOwner"`
	L2ProxyAdminOwner common.Address `json:"l2ProxyAdminOwner" toml:"l2ProxyAdminOwner"`
	SystemConfigOwner common.Address `json:"systemConfigOwner" toml:"systemConfigOwner"`
	UnsafeBlockSigner common.Address `json:"unsafeBlockSigner" toml:"unsafeBlockSigner"`
	Batcher           common.Address `json:"batcher" toml:"batcher"`
	Proposer          common.Address `json:"proposer" toml:"proposer"`
	Challenger        common.Address `json:"challenger" toml:"challenger"`
}

type ChainState

type ChainState struct {
	ID common.Hash `json:"id"`

	addresses.OpChainContracts

	AdditionalDisputeGames []AdditionalDisputeGameState `json:"additionalDisputeGames"`

	Allocs *GzipData[foundry.ForgeAllocs] `json:"allocs"`

	StartBlock *L1BlockRefJSON `json:"startBlock"`
}

type GzipData

type GzipData[T any] struct {
	Data *T
}

func (*GzipData[T]) MarshalJSON

func (g *GzipData[T]) MarshalJSON() ([]byte, error)

func (*GzipData[T]) UnmarshalJSON

func (g *GzipData[T]) UnmarshalJSON(b []byte) error

type Intent

type Intent struct {
	ConfigType            IntentType                 `json:"configType" toml:"configType"`
	L1ChainID             uint64                     `json:"l1ChainID" toml:"l1ChainID"`
	OPCMAddress           *common.Address            `json:"opcmAddress" toml:"opcmAddress"`
	SuperchainConfigProxy *common.Address            `json:"superchainConfigProxy" toml:"superchainConfigProxy"`
	SuperchainRoles       *addresses.SuperchainRoles `json:"superchainRoles" toml:"superchainRoles,omitempty"`
	FundDevAccounts       bool                       `json:"fundDevAccounts" toml:"fundDevAccounts"`
	L1ContractsLocator    *artifacts.Locator         `json:"l1ContractsLocator" toml:"l1ContractsLocator"`
	L2ContractsLocator    *artifacts.Locator         `json:"l2ContractsLocator" toml:"l2ContractsLocator"`
	Chains                []*ChainIntent             `json:"chains" toml:"chains"`
	GlobalDeployOverrides map[string]any             `json:"globalDeployOverrides" toml:"globalDeployOverrides"`

	// L1DevGenesisParams is optional. This may be used to customize the L1 genesis when
	// the deployer output is directed to produce a L1 genesis state for development.
	L1DevGenesisParams *L1DevGenesisParams `json:"l1DevGenesisParams"`
}

func NewIntent added in v1.11.0

func NewIntent(configType IntentType, l1ChainId uint64, l2ChainIds []common.Hash) (intent Intent, err error)

func NewIntentCustom added in v1.11.0

func NewIntentCustom(l1ChainId uint64, l2ChainIds []common.Hash) (Intent, error)

Sets all Intent fields to their zero value with the expectation that the user will populate the values before running 'apply'

func NewIntentStandard added in v1.11.0

func NewIntentStandard(l1ChainId uint64, l2ChainIds []common.Hash) (Intent, error)

func NewIntentStandardOverrides added in v1.11.0

func NewIntentStandardOverrides(l1ChainId uint64, l2ChainIds []common.Hash) (Intent, error)

func (*Intent) Chain

func (c *Intent) Chain(id common.Hash) (*ChainIntent, error)

func (*Intent) Check

func (c *Intent) Check() error

func (*Intent) L1ChainIDBig

func (c *Intent) L1ChainIDBig() *big.Int

func (*Intent) WriteToFile

func (c *Intent) WriteToFile(path string) error

type IntentType added in v1.11.2

type IntentType string
const (
	IntentTypeStandard          IntentType = "standard"
	IntentTypeCustom            IntentType = "custom"
	IntentTypeStandardOverrides IntentType = "standard-overrides"
)

type L1BlockRefJSON added in v1.12.2

type L1BlockRefJSON struct {
	Hash       common.Hash    `json:"hash"`
	ParentHash common.Hash    `json:"parentHash"`
	Number     hexutil.Uint64 `json:"number"`
	Time       hexutil.Uint64 `json:"timestamp"`
}

func BlockRefJsonFromBlockRef added in v1.12.2

func BlockRefJsonFromBlockRef(br *eth.BlockRef) *L1BlockRefJSON

func BlockRefJsonFromHeader added in v1.12.2

func BlockRefJsonFromHeader(h *types.Header) *L1BlockRefJSON

func (*L1BlockRefJSON) ToBlockRef added in v1.12.2

func (b *L1BlockRefJSON) ToBlockRef() *eth.BlockRef

type L1DevGenesisBlockParams added in v1.13.1

type L1DevGenesisBlockParams struct {
	// Warning: the genesis timestamp will default to time.Now().
	Timestamp uint64 `json:"timestamp"`
	// Gas limit, uses default if 0
	GasLimit uint64 `json:"gasLimit"`
	// Optional. Dencun is always active in L1 dev genesis, so 0 is used as-is if not modified.
	// This may be used to start the chain with high blob fees.
	ExcessBlobGas uint64 `json:"excessBlobGas"`
}

type L1DevGenesisParams added in v1.13.1

type L1DevGenesisParams struct {
	// BlockParams is the set of genesis-block parameters to use.
	BlockParams L1DevGenesisBlockParams `json:"blockParams" toml:"blockParams"`

	// PragueTimeOffset configures Prague (aka Pectra) to be activated at the given time after L1 dev genesis time.
	PragueTimeOffset *uint64 `json:"pragueTimeOffset" toml:"pragueTimeOffset"`

	// OsakaTimeOffset configures Osaka (the EL changes in the Fusaka Ethereum fork) to be
	// activated at the given time after L1 dev genesis time.
	OsakaTimeOffset *uint64 `json:"osakaTimeOffset" toml:"osakaTimeOffset"`

	// BPO1TimeOffset configures the BPO1 fork to be activated at the given time after L1 dev
	// genesis time.
	BPO1TimeOffset *uint64 `json:"bpo1TimeOffset" toml:"bpo1TimeOffset"`

	BlobSchedule *params.BlobScheduleConfig `json:"blobSchedule"`

	// Prefund is a map of addresses to balances (in wei), to prefund in the L1 dev genesis state.
	// This is independent of the "Prefund" functionality that may fund a default 20 test accounts.
	Prefund map[common.Address]*hexutil.U256 `json:"prefund" toml:"prefund"`
}

type L2DevGenesisParams added in v1.13.1

type L2DevGenesisParams struct {
	// Prefund is a map of addresses to balances (in wei), to prefund in the L2 dev genesis state.
	// This is independent of the "Prefund" functionality that may fund a default 20 test accounts.
	Prefund map[common.Address]*hexutil.U256 `json:"prefund" toml:"prefund"`
}

type State

type State struct {
	// Version versions the state so we can update it later.
	Version int `json:"version"`

	// Create2Salt is the salt used for CREATE2 deployments.
	Create2Salt common.Hash `json:"create2Salt"`

	// AppliedIntent contains the chain intent that was last
	// successfully applied. It is diffed against new intent
	// in order to determine what deployment steps to take.
	// This field is nil for new deployments.
	AppliedIntent *Intent `json:"appliedIntent"`

	// PrestateManifest contains the prestate generated by the op-program-svc
	PrestateManifest *prestate.PrestateManifest `json:"prestateManifest"`

	// InteropDepSet contains the interop dependency set render by the prestate SDK if interop is enabled
	InteropDepSet *depset.StaticConfigDependencySet `json:"interopDepSet,omitempty"`

	// SuperchainDeployment contains the addresses of the Superchain
	// deployment. It only contains the proxies because the implementations
	// can be looked up on chain.
	SuperchainDeployment *addresses.SuperchainContracts `json:"superchainContracts"`

	// SuperchainRoles contains the addresses of the Superchain roles.
	SuperchainRoles *addresses.SuperchainRoles `json:"superchainRoles"`

	// ImplementationsDeployment contains the addresses of the common implementation
	// contracts required for the Superchain to function.
	ImplementationsDeployment *addresses.ImplementationsContracts `json:"implementationsDeployment"`

	// Chains contains data about L2 chain deployments.
	Chains []*ChainState `json:"opChainDeployments"`

	// L1StateDump contains the complete L1 state dump of the deployment.
	L1StateDump *GzipData[foundry.ForgeAllocs] `json:"l1StateDump"`

	// L1DevGenesis contains the dev L1 genesis, and may be nil if this is not a genesis-strategy deployment.
	// Warning: the Allocs part of the genesis is not included. Instead, the stateHash attribute is set.
	// The allocs are included in L1StateDump.
	// The stateHash can be used for consistency checks and faster block-hash computation.
	L1DevGenesis *core.Genesis `json:"-"`

	// DeploymentCalldata contains the calldata of each transaction in the deployment. This is only
	// populated if apply is called with --deployment-target=calldata.
	DeploymentCalldata []broadcaster.CalldataDump
}

State contains the data needed to recreate the deployment as it progresses and once it is fully applied.

func (*State) Chain

func (s *State) Chain(id common.Hash) (*ChainState, error)

func (*State) WriteToFile

func (s *State) WriteToFile(path string) error

type SuperchainProofParams added in v1.11.0

type SuperchainProofParams struct {
	WithdrawalDelaySeconds          uint64      `json:"faultGameWithdrawalDelay" toml:"faultGameWithdrawalDelay"`
	MinProposalSizeBytes            uint64      `json:"preimageOracleMinProposalSize" toml:"preimageOracleMinProposalSize"`
	ChallengePeriodSeconds          uint64      `json:"preimageOracleChallengePeriod" toml:"preimageOracleChallengePeriod"`
	ProofMaturityDelaySeconds       uint64      `json:"proofMaturityDelaySeconds" toml:"proofMaturityDelaySeconds"`
	DisputeGameFinalityDelaySeconds uint64      `json:"disputeGameFinalityDelaySeconds" toml:"disputeGameFinalityDelaySeconds"`
	DisputeMaxGameDepth             uint64      `json:"faultGameMaxDepth" toml:"faultGameMaxDepth"`
	DisputeSplitDepth               uint64      `json:"faultGameSplitDepth" toml:"faultGameSplitDepth"`
	DisputeClockExtension           uint64      `json:"faultGameClockExtension" toml:"faultGameClockExtension"`
	DisputeMaxClockDuration         uint64      `json:"faultGameMaxClockDuration" toml:"faultGameMaxClockDuration"`
	MIPSVersion                     uint64      `json:"mipsVersion" toml:"mipsVersion"`
	DevFeatureBitmap                common.Hash `json:"devFeatureBitmap" toml:"devFeatureBitmap"`
}

type VMType added in v1.11.0

type VMType string

func (VMType) MipsVersion added in v1.13.3

func (v VMType) MipsVersion() uint64

Jump to

Keyboard shortcuts

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