state

package
v1.16.13 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 31 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 (
	ErrL1ContractsLocatorUndefined = errors.New("L1ContractsLocator undefined")
	ErrL2ContractsLocatorUndefined = errors.New("L2ContractsLocator undefined")
	ErrPAOMustBeSpecified          = errors.New("l1ProxyAdminOwner and l2ProxyAdminOwner must be specified in intent.toml - they are not set by default")
)
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 ErrNonStandardValue = fmt.Errorf("chain contains non-standard config value")
View Source
var ErrRevenueShareZeroAddress = fmt.Errorf("chain has enabled revenue share but recipient is set to zero address")

Functions

func CombineDeployConfig

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

func GetStandardSuperchainRoles

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

Types

type AdditionalDisputeGame

type AdditionalDisputeGame struct {
	ChainProofParams
	VMType        VMType
	MakeRespected bool
}

type AdditionalDisputeGameState

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"`
	OperatorFeeVaultRecipient  common.Address            `json:"operatorFeeVaultRecipient" toml:"operatorFeeVaultRecipient"`
	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"`
	UseRevenueShare            bool                      `json:"useRevenueShare,omitempty" toml:"useRevenueShare,omitempty"`
	ChainFeesRecipient         common.Address            `json:"chainFeesRecipient,omitempty" toml:"chainFeesRecipient,omitempty"`
	MinBaseFee                 uint64                    `json:"minBaseFee,omitempty" toml:"minBaseFee,omitempty"`
	DAFootprintGasScalar       uint16                    `json:"daFootprintGasScalar,omitempty" toml:"daFootprintGasScalar,omitempty"`
	CustomGasToken             CustomGasToken            `json:"customGasToken" toml:"customGasToken"`

	// 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

func (*ChainIntent) GetInitialLiquidity

func (c *ChainIntent) GetInitialLiquidity() *big.Int

GetInitialLiquidity returns the native asset liquidity amount for the chain. If not set and custom gas token is enabled, returns type(uint248).max as the default. Otherwise returns zero.

func (*ChainIntent) GetLiquidityControllerOwner

func (c *ChainIntent) GetLiquidityControllerOwner() common.Address

GetLiquidityControllerOwner returns the owner of the LiquidityController. If not set in CustomGasToken config, defaults to L2ProxyAdminOwner.

func (*ChainIntent) IsCustomGasTokenEnabled

func (c *ChainIntent) IsCustomGasTokenEnabled() bool

IsCustomGasTokenEnabled returns true if custom gas token is enabled. It's enabled when both Name and Symbol are provided.

type ChainProofParams

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 CustomGasToken

type CustomGasToken struct {
	Name                     string         `json:"name,omitempty" toml:"name,omitempty"`
	Symbol                   string         `json:"symbol,omitempty" toml:"symbol,omitempty"`
	InitialLiquidity         *hexutil.Big   `json:"initialLiquidity" toml:"initialLiquidity"`
	LiquidityControllerOwner common.Address `json:"liquidityControllerOwner" toml:"liquidityControllerOwner"`
}

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"`
	OpDeployerVersion     string                     `json:"opDeployerVersion" toml:"opDeployerVersion"`
	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"`
	UseInterop            bool                       `json:"useInterop" toml:"useInterop"`

	// 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

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

func NewIntentCustom

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

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

func NewIntentStandardOverrides

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

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

type L1BlockRefJSON

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

func BlockRefJsonFromBlockRef(br *eth.BlockRef) *L1BlockRefJSON

func BlockRefJsonFromHeader

func BlockRefJsonFromHeader(h *types.Header) *L1BlockRefJSON

func (*L1BlockRefJSON) ToBlockRef

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

type L1DevGenesisBlockParams

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

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"`

	// BPO2TimeOffset configures the BPO2 fork to be activated at the given time after L1 dev
	// genesis time.
	BPO2TimeOffset *uint64 `json:"bpo2TimeOffset" toml:"bpo2TimeOffset"`

	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

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"`

	// OpDeployerVersion is the version of op-deployer that was used to create the state
	OpDeployerVersion string `json:"opDeployerVersion"`

	// 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

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

type VMType string

func (VMType) MipsVersion

func (v VMType) MipsVersion() uint64

Jump to

Keyboard shortcuts

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