types

package
v0.11.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ModeValidator defines a validator node.
	// It's validator key has staked tokens and it actively participates in consensus and is subject to rewards and penalties.
	// It must always be online, otherwise it will get stashed/jailed.
	// [genesis_validator_set=true,pruning=default,consensus=default,special_p2p=false].
	// Note technically a validator node is also a "full node".
	ModeValidator = e2e.ModeValidator

	// ModeArchive defines an archive node.
	// It stores all historical blocks and state, it doesn't delete anything ever. It will require TBs of disk.
	// [genesis_validator_set=false,pruning=none,consensus=default,special_p2p=false].
	// Note technically an archive node is also a "full node".
	ModeArchive Mode = "archive"

	// ModeSeed defines a seed node. It must have a long-lived p2p pubkey and address (encoded in repo).
	// It acts as notice board for external nodes to learn about the network and connect to publicly available nodes.
	// It crawls the network regularly, making it available to new nodes.
	// [genesis_validator_set=false,pruning=default,consensus=default,special_p2p=true].
	// Note technically a seed node is also a "full node".
	ModeSeed = e2e.ModeSeed

	// ModeFull defines a full node. A full node a normal node without a special role.
	// [genesis_validator_set=false,pruning=default,consensus=default,special_p2p=false].
	ModeFull = e2e.ModeFull

	// ModeLight defines a light node. This isn't used yet.
	// [genesis_validator_set=false,pruning=no_data,consensus=light,special_p2p=false]
	// Only light nodes are not also full nodes.
	ModeLight = e2e.ModeLight
)

Variables

This section is empty.

Functions

func PublicRPCByName

func PublicRPCByName(name string) string

PublicRPCByName returns the public chain RPC address by name.

Types

type AnvilChain

type AnvilChain struct {
	Chain       EVMChain // For netconf
	InternalIP  net.IP   // For docker container IP
	ProxyPort   uint32   // For binding
	InternalRPC string   // For JSON-RPC queries from halo/relayer
	ExternalRPC string   // For JSON-RPC queries from e2e app.
	ForkRPC     string   // JSON-RPC to fork from
	LoadState   string   // File path to load anvil state from
}

AnvilChain represents an anvil chain instance in a omni network.

type ContractName

type ContractName string
const (
	ContractPortal ContractName = "portal"
)

type DeployInfo

type DeployInfo struct {
	Address common.Address
	Height  uint64
}

DeployInfo contains the address and deploy height of a deployed contract.

type DeployInfos

type DeployInfos map[uint64]map[ContractName]DeployInfo

DeployInfos contains the addresses of deployed xdapps and contracts by chainID.

Note that ContractPortal is duplicated both here and in netconf.Chain. That is because netconf is used by halo and relayer and other production apps.

This DeployInfos is similar to netconf, but it is only used by e2e deployment and tests. As soon as any production app needs to use any of these addresses, they should be moved to netconf. TODO(corver): Remove since this is stored in on-chain PortalRegistry.

func LoadDeployInfos

func LoadDeployInfos(file string) (DeployInfos, error)

func (DeployInfos) Addr

func (i DeployInfos) Addr(chainID uint64, contract ContractName) (common.Address, bool)

func (DeployInfos) Save

func (i DeployInfos) Save(file string) error

func (DeployInfos) Set

func (i DeployInfos) Set(chainID uint64, contract ContractName, addr common.Address, height uint64)

type EVMChain

type EVMChain struct {
	evmchain.Metadata
	Shards   []xchain.ShardID
	IsPublic bool
}

EVMChain represents a EVM chain in a omni network.

func AnvilChainsByNames

func AnvilChainsByNames(names []string) ([]EVMChain, error)

AnvilChainsByNames returns the Anvil evm chain definitions by names.

func OmniEVMByNetwork

func OmniEVMByNetwork(network netconf.ID) EVMChain

OmniEVMByNetwork returns the Omni evm chain definition by netconf network.

func PublicChainByName

func PublicChainByName(name string) (EVMChain, error)

PublicChainByName returns the public chain definition by name.

func (EVMChain) AttestInterval

func (c EVMChain) AttestInterval(network netconf.ID) uint64

AttestInterval returns the a constant interval for which attestations are always required, even if empty..

func (EVMChain) ShardsUint64

func (c EVMChain) ShardsUint64() []uint64

type InfraProvider

type InfraProvider interface {
	infra.Provider

	// Upgrade copies dynamic config and files to VMs and restarts services.
	// This assumes that important files are long-lived/deterministic (e.g. private keys).
	// It notably doesn't copy newly generated genesis files.
	// Note that all services on matching VMs are upgraded.
	Upgrade(ctx context.Context, cfg ServiceConfig) error

	// Clean deletes all containers, networks, and data on disk.
	Clean(ctx context.Context) error

	// Restart restarts the services that match the given config.
	// I.e., docker-compose up/down.
	// Note that all services on matching VMs are restarted.
	Restart(ctx context.Context, cfg ServiceConfig) error
}

type InfrastructureData

type InfrastructureData struct {
	e2e.InfrastructureData

	// VMs maps the VM name to its instance data.
	// Note this differs from e2e.InfrastructureData.Instances, which maps the service names to its instance data.
	VMs map[string]e2e.InstanceData
}

InfrastructureData wraps e2e.InfrastructureData with additional omni-specific fields.

func (InfrastructureData) ServicesByInstance

func (d InfrastructureData) ServicesByInstance(data e2e.InstanceData) map[string]bool

ServicesByInstance returns the set of services associated to the instance.

type Manifest

type Manifest struct {
	e2e.Manifest

	Network netconf.ID `toml:"network"`

	// AnvilChains defines the anvil chains to deploy; mock_l1, mock_l2, etc.
	AnvilChains []string `toml:"anvil_chains"`

	// PublicChains defines the public chains to connect to; arb_sepolia, etc.
	PublicChains []string `toml:"public_chains"`

	// MultiOmniEVMs defines whether to deploy one or multiple Omni EVMs.
	MultiOmniEVMs bool `toml:"multi_omni_evms"`

	// PingPongN defines the number of ping pong messages to send. Defaults 3 if 0.
	PingPongN uint64 `toml:"pingpong_n"`

	// DeploySolve defines whether to deploy the solve contracts
	DeploySolve bool `toml:"deploy_solve"`

	// Forks maps devnet chain name to name of public chain to fork from.
	Forks map[string]string

	// Keys contains long-lived private keys (address by type) by node name.
	Keys map[string]map[key.Type]string `toml:"keys"`

	// Perturb defines additional (non-cometBFT) perturbations by service name.
	Perturb map[string][]Perturb `json:"perturb"`

	// PinnedHaloTag defines the pinned halo docker image tag.
	// This allows source code defined versions for protected networks.
	// This overrides the --omni-image-tag if non-empty.
	PinnedHaloTag string `toml:"pinned_halo_tag"`

	// PinnedMonitorTag defines the pinned monitor docker image tag.
	// This allows source code defined versions for protected networks.
	// This overrides the --omni-image-tag if non-empty.
	PinnedMonitorTag string `toml:"pinned_monitor_tag"`

	// PinnedRelayerTag defines the pinned relayer docker image tag.
	// This allows source code defined versions for protected networks.
	// This overrides the --omni-image-tag if non-empty.
	PinnedRelayerTag string `toml:"pinned_relayer_tag"`

	// NetworkUpgradeHeight defines the network upgrade height, default is genesis, negative is disabled.
	// Note that it might be scheduled at a later height.
	NetworkUpgradeHeight int64 `toml:"network_upgrade_height"`

	// FeatureFlags defines the feature flags to enable.
	FeatureFlags feature.Flags `toml:"feature_flags"`
}

func (Manifest) OmniEVMs

func (m Manifest) OmniEVMs() map[string]Mode

OmniEVMs returns a map of omni evm instances names by mode to deploy. If only a single Omni EVM is to be deployed, the name is "omni_evm". Otherwise, the names are "<node>_evm".

func (Manifest) Seeds

func (m Manifest) Seeds() map[string]bool

Seeds returns a map of seed nodes by name.

func (Manifest) Validate added in v0.11.0

func (m Manifest) Validate() error

type Mode

type Mode = e2e.Mode

Mode defines the halo consensus node mode. Nodes are in general full nodes (light nodes are not supported yet). In some cases, additional roles are defined: validator, archive, seed.

Note that the execution clients only have two modes: "default" and "archive".

e2e.Mode is extended so ModeArchive can be added transparently.

type OmniEVM

type OmniEVM struct {
	Chain        EVMChain // For netconf (all instances must have the same chain)
	InstanceName string   // For docker container name
	AdvertisedIP net.IP   // For setting up NAT on geth bootnode
	ProxyPort    uint32   // For binding
	InternalRPC  string   // For JSON-RPC queries from halo/relayer
	ExternalRPC  string   // For JSON-RPC queries from e2e app.
	IsArchive    bool     // Whether this instance is in archive mode
	JWTSecret    string   // JWT secret for authentication

	// P2P networking
	NodeKey *ecdsa.PrivateKey // Private key
	Enode   *enode.Node       // Public key
	Peers   []*enode.Node     // Peer public keys
}

OmniEVM represents a omni evm instance in a omni network. Similar to e2e.Node for halo instances.

func (OmniEVM) NodeKeyHex

func (o OmniEVM) NodeKeyHex() string

NodeKeyHex returns the hex-encoded node key. Used for geth's config.

type Perturb

type Perturb string

Perturb defines non-cometBFT perturbations of components like omni_evm.

const (
	PerturbUnknown Perturb = ""
	// PerturbRestart defines a perturbation that restarts a docker container.
	PerturbRestart Perturb = "restart"
	// PerturbStopStart defines a perturbation that stops and then starts a docker container.
	PerturbStopStart Perturb = "stopstart"
	// PerturbRollback defines a perturbation that stops a halo node, performs a rollback, then starts it again.
	PerturbRollback Perturb = "rollback"
	// PerturbUpgrade defines a perturbation that upgrades a geth node to the latest version.
	// Note that halo upgrades are handled by CometBFT perturbations.
	PerturbUpgrade Perturb = "upgrade"

	// PerturbFuzzyHeadDropBlocks defines a perturbation that enables fuzzyhead dropping xblock for a while.
	PerturbFuzzyHeadDropBlocks Perturb = "fuzzyhead_dropblocks"
	// PerturbFuzzyHeadDropMsgs defines a perturbation that enables fuzzyhead drop xmsgs for a while.
	PerturbFuzzyHeadDropMsgs Perturb = "fuzzyhead_dropmsgs"
	// PerturbFuzzyHeadAttRoot defines a perturbation that enables fuzzyhead inconsistent attestation root for a while.
	PerturbFuzzyHeadAttRoot Perturb = "fuzzyhead_attroot"
	// PerturbFuzzyHeadMoreMsgs defines a perturbation that enables fuzzyhead more/duplicate xmsgs for a while.
	PerturbFuzzyHeadMoreMsgs Perturb = "fuzzyhead_moremsgs"
)

type PublicChain

type PublicChain struct {
	// contains filtered or unexported fields
}

PublicChain represents a public chain in a omni network.

func NewPublicChain

func NewPublicChain(chain EVMChain, rpcAddresses []string) PublicChain

func (PublicChain) Chain

func (c PublicChain) Chain() EVMChain

Chain returns the EVM chain.

func (PublicChain) NextRPCAddress

func (c PublicChain) NextRPCAddress() string

NextRPCAddress returns the next RPC address in the list.

type ServiceConfig

type ServiceConfig struct {
	// Regexp to match the service names.
	Regexp string
}

func DefaultServiceConfig

func DefaultServiceConfig() ServiceConfig

func (ServiceConfig) MatchService added in v0.11.0

func (c ServiceConfig) MatchService(service string) bool

MatchService returns true if the service matches the regexp config.

type Testnet

type Testnet struct {
	*e2e.Testnet
	Manifest     Manifest
	Network      netconf.ID
	OmniEVMs     []OmniEVM
	AnvilChains  []AnvilChain
	PublicChains []PublicChain
	Perturb      map[string][]Perturb
}

Testnet wraps e2e.Omega with additional omni-specific fields.

func (Testnet) ArchiveNode

func (t Testnet) ArchiveNode() (*e2e.Node, bool)

ArchiveNode returns the last node running in ModeArchive. Note that this is different from the CometBFT Testnet.ArchiveNodes() method.

func (Testnet) BroadcastNode

func (t Testnet) BroadcastNode() *e2e.Node

BroadcastNode returns a halo node to use for RPC queries broadcasts. It prefers a validator nodes since we have an issue with mempool+p2p+startup where txs get stuck in non-validator mempool immediately after startup if not connected to peers yet. Also avoid validators that are not started immediately.

func (Testnet) BroadcastOmniEVM

func (t Testnet) BroadcastOmniEVM() OmniEVM

BroadcastOmniEVM returns a Omni EVM to use for e2e app tx broadcasts. It prefers a validator nodes since we have an issue with mempool+p2p+startup where txs get stuck in non-validator mempool immediately after startup if not connected to peers yet. Also avoid validators that are not started immediately or evms with perturbations.

func (Testnet) EVMChainByID added in v0.10.0

func (t Testnet) EVMChainByID(id uint64) (EVMChain, bool)

func (Testnet) EVMChainByName added in v0.10.0

func (t Testnet) EVMChainByName(name string) (EVMChain, bool)

func (Testnet) EVMChains added in v0.10.0

func (t Testnet) EVMChains() []EVMChain

EVMChains returns all EVM chains in the network.

func (Testnet) EthereumChain added in v0.10.0

func (t Testnet) EthereumChain() (EVMChain, bool)

func (Testnet) HasOmniEVM

func (t Testnet) HasOmniEVM() bool

func (Testnet) HasPerturbations

func (t Testnet) HasPerturbations() bool

HasPerturbations returns whether the network has any perturbations.

func (Testnet) OmniEVMChain added in v0.10.0

func (t Testnet) OmniEVMChain() (EVMChain, bool)

func (Testnet) RandomHaloAddr

func (t Testnet) RandomHaloAddr() string

RandomHaloAddr returns a random halo address for cprovider and cometBFT rpc clients. It uses the internal IP address of a random node that isn't delayed or a seed.

Jump to

Keyboard shortcuts

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