netconf

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package netconf provides the configuration of an Omni network, an instance of the Omni cross chain protocol.

Index

Constants

View Source
const (
	StratFinalized = FinalizationStrat("finalized")
	StratLatest    = FinalizationStrat("latest")
	StratSafe      = FinalizationStrat("safe")
)

Variables

This section is empty.

Functions

func BindFlag

func BindFlag(flags *pflag.FlagSet, network *ID)

BindFlag binds the network identifier flag.

func ChainNamer added in v0.1.4

func ChainNamer(network ID) func(uint64) string

func ConsensusChainIDStr2Uint64 added in v0.1.2

func ConsensusChainIDStr2Uint64(id string) (uint64, error)

ConsensusChainIDStr2Uint64 parses the uint suffix from the provided a consensus chain ID string.

func IsAny added in v0.1.4

func IsAny(id ID, targets ...ID) bool

IsAny returns true if the `ID` matches any of the provided targets.

func IsOmniConsensus added in v0.1.4

func IsOmniConsensus(network ID, chainID uint64) bool

IsOmniConsensus returns true if provided chainID is the omni consensus chain for the network.

func IsOmniExecution added in v0.1.4

func IsOmniExecution(network ID, chainID uint64) bool

IsOmniExecution returns true if provided chainID is the omni execution chain for the network.

func MetadataByID added in v0.1.4

func MetadataByID(network ID, chainID uint64) evmchain.Metadata

Types

type Chain

type Chain struct {
	ID   uint64 // Chain ID asa per https://chainlist.org
	Name string // Chain name as per https://chainlist.org
	// RPCURL            string            // RPC URL of the chain
	PortalAddress     common.Address    // Address of the omni portal contract on the chain
	DeployHeight      uint64            // Height that the portal contracts were deployed
	BlockPeriod       time.Duration     // Block period of the chain
	FinalizationStrat FinalizationStrat // Finalization strategy of the chain
}

Chain defines the configuration of an execution chain that supports the Omni cross chain protocol. This is most supported Rollup EVMs, but also the Omni EVM, and the Omni Consensus chain.

func (Chain) ConfLevels added in v0.1.8

func (c Chain) ConfLevels() []xchain.ConfLevel

ConfLevels returns the uniq set of confirmation levels supported by the chain. This is inferred from the supported shards.

func (Chain) Shards added in v0.1.8

func (c Chain) Shards() []uint64

Shards returns the supported shards for the chain. TODO(corver): Store these in XRegistry, currently it is inferred from the FinalizationStrat.

type Deployment added in v0.1.3

type Deployment struct {
	ChainID      uint64
	Address      common.Address
	DeployHeight uint64
}

type FinalizationStrat

type FinalizationStrat string

FinalizationStrat defines the finalization strategy of a chain. This is mostly ethclient.HeadFinalized, but some chains may not support it, like zkEVM chains which would need a much more involved strategy.

func (FinalizationStrat) ConfLevel added in v0.1.8

func (h FinalizationStrat) ConfLevel() xchain.ConfLevel

ConfLevel returns the confirmation level of the finalization strategy. TODO(corver): Replace FinalizationStrat with ConfLevel completely.

func (FinalizationStrat) String added in v0.1.4

func (h FinalizationStrat) String() string

func (FinalizationStrat) Verify

func (h FinalizationStrat) Verify() error

type ID added in v0.1.2

type ID string

ID is a network identifier.

const (
	// Simnet is a simulated network for very simple testing of individual binaries.
	// It is a single binary with mocked clients (no networking).
	Simnet ID = "simnet" // Single binary with mocked clients (no network)

	// Devnet is the most basic single-machine deployment of the Omni cross chain protocol.
	// It uses docker compose to setup a network with multi containers.
	// E.g. 2 geth nodes, 4 halo validators, a relayer, and 2 anvil rollups.
	Devnet ID = "devnet"

	// Staging is the Omni team's internal staging network, similar to a internal testnet.
	// It connects to real public rollup testnets (e.g. Arbitrum testnet).
	// It is deployed to GCP using terraform.
	// E.g. 1 Erigon, 1 Geth, 4 halo validators, 2 halo sentries, 1 relayer.
	Staging ID = "staging"

	// Testnet is the Omni public testnet.
	Testnet ID = "testnet"

	// Mainnet is the Omni public mainnet.
	Mainnet ID = "mainnet"
)

func All added in v0.1.5

func All() []ID

All returns all the supported network IDs.

func (ID) IsEphemeral added in v0.1.2

func (i ID) IsEphemeral() bool

IsEphemeral returns true if the network is short-lived, therefore ephemeral.

func (ID) IsProtected added in v0.1.2

func (i ID) IsProtected() bool

IsProtected returns true if the network is long-lived, therefore protected.

func (ID) Static added in v0.1.2

func (i ID) Static() Static

Static returns the static config and data for the network.

func (ID) String added in v0.1.3

func (i ID) String() string

func (ID) Verify added in v0.1.3

func (i ID) Verify() error

func (ID) Version added in v0.1.3

func (i ID) Version() string

type Network

type Network struct {
	ID     ID      `json:"name"`   // ID of the network. e.g. "simnet", "testnet", "staging", "mainnet"
	Chains []Chain `json:"chains"` // Chains that are part of the network
}

Network defines a deployment of the Omni cross chain protocol. It spans an omni chain (both execution and consensus) and a set of supported rollup EVMs.

func AwaitOnChain added in v0.1.4

func AwaitOnChain(ctx context.Context, netID ID, portalRegistry *bindings.PortalRegistry, expected []string) (Network, error)

AwaitOnChain blocks and returns network configuration as soon as it can be loaded from the on-chain registry. It only returns an error if the context is canceled.

func (Network) Chain

func (n Network) Chain(id uint64) (Chain, bool)

Chain returns the chain config for the given ID or false if it does not exist.

func (Network) ChainIDs

func (n Network) ChainIDs() []uint64

ChainIDs returns the all chain IDs in the network. This is a convenience method.

func (Network) ChainName

func (n Network) ChainName(id uint64) string

ChainName returns the chain name for the given ID or an empty string if it does not exist.

func (Network) ChainNamesByIDs

func (n Network) ChainNamesByIDs() map[uint64]string

ChainNamesByIDs returns the all chain IDs and names in the network. This is a convenience method.

func (Network) EVMChains added in v0.1.2

func (n Network) EVMChains() []Chain

EVMChains returns all evm chains in the network. It excludes the omni consensus chain.

func (Network) EthereumChain

func (n Network) EthereumChain() (Chain, bool)

EthereumChain returns the ethereum Layer1 chain config or false if it does not exist.

func (Network) OmniConsensusChain added in v0.1.2

func (n Network) OmniConsensusChain() (Chain, bool)

OmniConsensusChain returns the Omni consensus chain config or false if it does not exist.

func (Network) OmniEVMChain added in v0.1.2

func (n Network) OmniEVMChain() (Chain, bool)

OmniEVMChain returns the Omni execution chain config or false if it does not exist.

func (Network) StreamsBetween added in v0.1.8

func (n Network) StreamsBetween(srcChainID uint64, dstChainID uint64) []xchain.StreamID

StreamsBetween returns the all streams between the provided source and destination chain.

func (Network) StreamsFrom added in v0.1.8

func (n Network) StreamsFrom(srcChainID uint64) []xchain.StreamID

StreamsFrom returns the all streams from the provided source chain.

func (Network) StreamsTo added in v0.1.8

func (n Network) StreamsTo(dstChainID uint64) []xchain.StreamID

StreamsTo returns the all streams to the provided destination chain.

func (Network) Validate

func (n Network) Validate() error

Validate returns an error if the configuration is invalid.

type Static added in v0.1.2

type Static struct {
	Version              string
	OmniExecutionChainID uint64
	AVSContractAddress   common.Address
	Portals              []Deployment
	MaxValidators        uint32
	ConsensusGenesisJSON []byte
	ConsensusSeedTXT     []byte
	ExecutionGenesisJSON []byte
	ExecutionSeedTXT     []byte
}

Static defines static config and data for a network.

func (Static) ConsensusSeeds added in v0.1.5

func (s Static) ConsensusSeeds() []string

func (Static) ExecutionSeeds added in v0.1.5

func (s Static) ExecutionSeeds() []string

func (Static) OmniConsensusChainIDStr added in v0.1.2

func (s Static) OmniConsensusChainIDStr() string

OmniConsensusChainIDStr returns the chain ID string for the Omni consensus chain. It is calculated as "omni-<OmniConsensusChainIDUint64>".

func (Static) OmniConsensusChainIDUint64 added in v0.1.2

func (s Static) OmniConsensusChainIDUint64() uint64

OmniConsensusChainIDUint64 returns the chain ID uint64 for the Omni consensus chain. It is calculated as 1_000_000 + OmniExecutionChainID.

func (Static) PortalDeployment added in v0.1.3

func (s Static) PortalDeployment(chainID uint64) (Deployment, bool)

PortalDeployment returns the portal deployment for the given chainID. If there is none, it returns an empty deployment.

Jump to

Keyboard shortcuts

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