superchain

package module
v0.0.0-...-3f08c3f Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 20 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Addresses = map[uint64]*AddressList{}
View Source
var GenesisSystemConfigs = map[uint64]*GenesisSystemConfig{}
View Source
var Implementations = map[string]ContractImplementations{}

Implementations maps superchain name to contract implementations

View Source
var OPChains = map[uint64]*ChainConfig{}
View Source
var SuperchainSemver map[string]ContractVersions

SuperchainSemver maps superchain name to a contract name : approved semver version structure.

View Source
var Superchains = map[string]*Superchain{}

Functions

func LoadContractBytecode

func LoadContractBytecode(codeHash Hash) ([]byte, error)

func MustBeValidSuperchainLevel

func MustBeValidSuperchainLevel(chainConfig ChainConfig)

Types

type Address

type Address [20]byte

func HexToAddress

func HexToAddress(s string) Address

func (Address) MarshalText

func (b Address) MarshalText() ([]byte, error)

func (Address) String

func (b Address) String() string

func (*Address) UnmarshalText

func (b *Address) UnmarshalText(text []byte) error

type AddressList

type AddressList struct {
	AddressManager                    Address `json:"AddressManager"`
	L1CrossDomainMessengerProxy       Address `json:"L1CrossDomainMessengerProxy"`
	L1ERC721BridgeProxy               Address `json:"L1ERC721BridgeProxy"`
	L1StandardBridgeProxy             Address `json:"L1StandardBridgeProxy"`
	L2OutputOracleProxy               Address `json:"L2OutputOracleProxy"`
	OptimismMintableERC20FactoryProxy Address `json:"OptimismMintableERC20FactoryProxy"`
	OptimismPortalProxy               Address `json:"OptimismPortalProxy"`
	SystemConfigProxy                 Address `json:"SystemConfigProxy"`
	ProxyAdmin                        Address `json:"ProxyAdmin"`
}

AddressList represents the set of network specific contracts for a given network.

func (AddressList) AddressFor

func (a AddressList) AddressFor(contractName string) (Address, error)

AddressFor returns a nonzero address for the supplied contract name, if it has been specified (and an error otherwise). Useful for slicing into the struct using a string.

type AddressSet

type AddressSet map[string]Address

AddressSet represents a set of addresses for a given contract. They are keyed by the semantic version.

func (AddressSet) Get

func (a AddressSet) Get(key string) Address

Get will handle getting semantic versions from the set in the case where the semver string is not prefixed with a "v" as well as if it does have a "v" prefix.

func (AddressSet) Versions

func (a AddressSet) Versions() []string

Versions will return the list of semantic versions for a contract. It handles the case where the versions are not prefixed with a "v".

type BlockID

type BlockID struct {
	Hash   Hash   `yaml:"hash"`
	Number uint64 `yaml:"number"`
}

type ChainConfig

type ChainConfig struct {
	Name         string `yaml:"name"`
	ChainID      uint64 `yaml:"chain_id"`
	PublicRPC    string `yaml:"public_rpc"`
	SequencerRPC string `yaml:"sequencer_rpc"`
	Explorer     string `yaml:"explorer"`

	SuperchainLevel SuperchainLevel `yaml:"superchain_level"`

	BatchInboxAddr Address `yaml:"batch_inbox_addr"`

	Genesis ChainGenesis `yaml:"genesis"`

	// Superchain is a simple string to identify the superchain.
	// This is implied by directory structure, and not encoded in the config file itself.
	Superchain string `yaml:"-"`
	// Chain is a simple string to identify the chain, within its superchain context.
	// This matches the resource filename, it is not encoded in the config file itself.
	Chain string `yaml:"-"`

	// Hardfork Configuration Overrides
	HardForkConfiguration `yaml:",inline"`

	// Optional feature
	Plasma *PlasmaConfig `yaml:"plasma,omitempty"`
}

func (*ChainConfig) EnhanceYAML

func (c *ChainConfig) EnhanceYAML(ctx context.Context, node *yaml.Node) error

EnhanceYAML creates a customized yaml string from a RollupConfig. After completion, the *yaml.Node pointer can be used with a yaml encoder to write the custom format to file

func (*ChainConfig) IsEcotone

func (c *ChainConfig) IsEcotone() bool

IsEcotone returns true if the EcotoneTime for this chain in the past.

func (*ChainConfig) SetDefaultHardforkTimestampsToNil

func (c *ChainConfig) SetDefaultHardforkTimestampsToNil(s *SuperchainConfig)

SetDefaultHardforkTimestampsToNil sets each hardfork timestamp to nil (to remove the override) if the timestamp matches the superchain default

type ChainGenesis

type ChainGenesis struct {
	L1           BlockID      `yaml:"l1"`
	L2           BlockID      `yaml:"l2"`
	L2Time       uint64       `json:"l2_time" yaml:"l2_time"`
	ExtraData    *HexBytes    `yaml:"extra_data,omitempty"`
	SystemConfig SystemConfig `json:"system_config" yaml:"-"`
}

type ContractImplementations

type ContractImplementations struct {
	L1CrossDomainMessenger       AddressSet `yaml:"l1_cross_domain_messenger"`
	L1ERC721Bridge               AddressSet `yaml:"l1_erc721_bridge"`
	L1StandardBridge             AddressSet `yaml:"l1_standard_bridge"`
	L2OutputOracle               AddressSet `yaml:"l2_output_oracle"`
	OptimismMintableERC20Factory AddressSet `yaml:"optimism_mintable_erc20_factory"`
	OptimismPortal               AddressSet `yaml:"optimism_portal"`
	SystemConfig                 AddressSet `yaml:"system_config"`
}

ContractImplementations represent a set of contract implementations on a given network. The key in the map represents the semantic version of the contract and the value is the address that the contract is deployed to.

func (ContractImplementations) Copy

Copy will return a shallow copy of the ContractImplementations.

func (ContractImplementations) Merge

Merge will combine two ContractImplementations into one. Any conflicting keys will be overwritten by the arguments. It assumes that nonce of the struct fields are nil.

func (ContractImplementations) Resolve

Resolve will return a set of addresses that resolve a given semantic version set.

type ContractVersions

type ContractVersions struct {
	L1CrossDomainMessenger       string `yaml:"l1_cross_domain_messenger"`
	L1ERC721Bridge               string `yaml:"l1_erc721_bridge"`
	L1StandardBridge             string `yaml:"l1_standard_bridge"`
	L2OutputOracle               string `yaml:"l2_output_oracle"`
	OptimismMintableERC20Factory string `yaml:"optimism_mintable_erc20_factory"`
	OptimismPortal               string `yaml:"optimism_portal"`
	SystemConfig                 string `yaml:"system_config"`
	// Superchain-wide contracts:
	ProtocolVersions string `yaml:"protocol_versions"`
	SuperchainConfig string `yaml:"superchain_config,omitempty"`
}

ContractVersions represents the desired semantic version of the contracts in the superchain. This currently only supports L1 contracts but could represent L2 predeploys in the future.

func (ContractVersions) Check

func (c ContractVersions) Check(allowEmptyVersions bool) error

Check will sanity check the validity of the semantic version strings in the ContractVersions struct. If allowEmptyVersions is true, empty version errors will be ignored.

func (ContractVersions) VersionFor

func (c ContractVersions) VersionFor(contractName string) (string, error)

VersionFor returns the version for the supplied contract name, if it exits (and an error otherwise). Useful for slicing into the struct using a string.

type Genesis

type Genesis struct {
	// Block properties
	Nonce         uint64  `json:"nonce"`
	Timestamp     uint64  `json:"timestamp"`
	ExtraData     []byte  `json:"extraData"`
	GasLimit      uint64  `json:"gasLimit"`
	Difficulty    *HexBig `json:"difficulty"`
	Mixhash       Hash    `json:"mixHash"`
	Coinbase      Address `json:"coinbase"`
	Number        uint64  `json:"number"`
	GasUsed       uint64  `json:"gasUsed"`
	ParentHash    Hash    `json:"parentHash"`
	BaseFee       *HexBig `json:"baseFeePerGas"`
	ExcessBlobGas *uint64 `json:"excessBlobGas"` // EIP-4844
	BlobGasUsed   *uint64 `json:"blobGasUsed"`   // EIP-4844
	// State data
	Alloc map[Address]GenesisAccount `json:"alloc"`
	// StateHash substitutes for a full embedded state allocation,
	// for instantiating states with the genesis block only, to be state-synced before operation.
	// Archive nodes should use a full external genesis.json or datadir.
	StateHash *Hash `json:"stateHash,omitempty"`
}

func LoadGenesis

func LoadGenesis(chainID uint64) (*Genesis, error)

type GenesisAccount

type GenesisAccount struct {
	CodeHash Hash          `json:"codeHash,omitempty"` // code hash only, to reduce overhead of duplicate bytecode
	Storage  map[Hash]Hash `json:"storage,omitempty"`
	Balance  *HexBig       `json:"balance,omitempty"`
	Nonce    uint64        `json:"nonce,omitempty"`
}

type GenesisData

type GenesisData struct {
	L1     GenesisLayer `json:"l1" yaml:"l1"`
	L2     GenesisLayer `json:"l2" yaml:"l2"`
	L2Time int          `json:"l2_time" yaml:"l2_time"`
}

type GenesisLayer

type GenesisLayer struct {
	Hash   string `json:"hash" yaml:"hash"`
	Number int    `json:"number" yaml:"number"`
}

type GenesisSystemConfig

type GenesisSystemConfig struct {
	BatcherAddr Address `json:"batcherAddr"`
	Overhead    Hash    `json:"overhead"`
	Scalar      Hash    `json:"scalar"`
	GasLimit    uint64  `json:"gasLimit"`
}

type HardForkConfiguration

type HardForkConfiguration struct {
	CanyonTime  *uint64 `json:"canyon_time,omitempty" yaml:"canyon_time,omitempty"`
	DeltaTime   *uint64 `json:"delta_time,omitempty" yaml:"delta_time,omitempty"`
	EcotoneTime *uint64 `json:"ecotone_time,omitempty" yaml:"ecotone_time,omitempty"`
	FjordTime   *uint64 `json:"fjord_time,omitempty" yaml:"fjord_time,omitempty"`
}

type Hash

type Hash [32]byte

func (Hash) MarshalText

func (b Hash) MarshalText() ([]byte, error)

func (Hash) String

func (b Hash) String() string

func (*Hash) UnmarshalText

func (b *Hash) UnmarshalText(text []byte) error

type HexBig

type HexBig big.Int

func (HexBig) MarshalText

func (b HexBig) MarshalText() ([]byte, error)

func (HexBig) String

func (b HexBig) String() string

func (*HexBig) UnmarshalText

func (b *HexBig) UnmarshalText(text []byte) error

type HexBytes

type HexBytes []byte

func (HexBytes) MarshalText

func (b HexBytes) MarshalText() ([]byte, error)

func (HexBytes) String

func (b HexBytes) String() string

func (*HexBytes) UnmarshalText

func (b *HexBytes) UnmarshalText(text []byte) error

type ImplementationList

type ImplementationList struct {
	L1CrossDomainMessenger       VersionedContract `json:"L1CrossDomainMessenger"`
	L1ERC721Bridge               VersionedContract `json:"L1ERC721Bridge"`
	L1StandardBridge             VersionedContract `json:"L1StandardBridge"`
	L2OutputOracle               VersionedContract `json:"L2OutputOracle"`
	OptimismMintableERC20Factory VersionedContract `json:"OptimismMintableERC20Factory"`
	OptimismPortal               VersionedContract `json:"OptimismPortal"`
	SystemConfig                 VersionedContract `json:"SystemConfig"`
}

ImplementationList represents the set of implementation contracts to be used together for a network.

type PlasmaConfig

type PlasmaConfig struct {
	DAChallengeAddress *Address `json:"da_challenge_contract_address" yaml:"-"`
	// DA challenge window value set on the DAC contract. Used in plasma mode
	// to compute when a commitment can no longer be challenged.
	DAChallengeWindow *uint64 `json:"da_challenge_window" yaml:"da_challenge_window"`
	// DA resolve window value set on the DAC contract. Used in plasma mode
	// to compute when a challenge expires and trigger a reorg if needed.
	DAResolveWindow *uint64 `json:"da_resolve_window" yaml:"da_resolve_window"`
}

type Superchain

type Superchain struct {
	Config SuperchainConfig

	// Chains that are part of this superchain
	ChainIDs []uint64

	// Superchain identifier, without capitalization or display changes.
	Superchain string
}

type SuperchainConfig

type SuperchainConfig struct {
	Name string           `yaml:"name"`
	L1   SuperchainL1Info `yaml:"l1"`

	ProtocolVersionsAddr *Address `yaml:"protocol_versions_addr,omitempty"`
	SuperchainConfigAddr *Address `yaml:"superchain_config_addr,omitempty"`
	// contains filtered or unexported fields
}

type SuperchainL1Info

type SuperchainL1Info struct {
	ChainID   uint64 `yaml:"chain_id"`
	PublicRPC string `yaml:"public_rpc"`
	Explorer  string `yaml:"explorer"`
}

type SuperchainLevel

type SuperchainLevel uint
const (
	Standard SuperchainLevel = 2
	Frontier SuperchainLevel = 1
)

type SystemConfig

type SystemConfig struct {
	BatcherAddr       string `json:"batcherAddr"`
	Overhead          string `json:"overhead"`
	Scalar            string `json:"scalar"`
	GasLimit          uint64 `json:"gasLimit"`
	BaseFeeScalar     uint64 `json:"baseFeeScalar"`
	BlobBaseFeeScalar uint64 `json:"blobBaseFeeScalar"`
}

type VersionedContract

type VersionedContract struct {
	Version string  `json:"version"`
	Address Address `json:"address"`
}

VersionedContract represents a contract that has a semantic version.

Jump to

Keyboard shortcuts

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