devnetwork

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemDevNetwork

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

InMemDevNetwork is a local dev network (L1 and L2) - the obscuro nodes are in-memory in a single go process, the L1 nodes are a docker geth network

It can play the role of node operators and network admins to reproduce complex scenarios around nodes joining/leaving/failing.

It also implements networktest.NetworkConnector to allow us to run the same NetworkTests against it that we can run against Testnets.

func DefaultDevNetwork

func DefaultDevNetwork() *InMemDevNetwork

DefaultDevNetwork provides an off-the-shelf default config for a sim network

func LiveL1DevNetwork

func LiveL1DevNetwork(seqWallet wallet.Wallet, validatorWallets []wallet.Wallet, rpcURLs []string) *InMemDevNetwork

LiveL1DevNetwork provides a local obscuro network running on a live L1 Caller should provide a wallet per node and ideally an RPC URL per node (may not be necessary but can avoid conflicts, e.g. Infura seems to require an API key per connection)

func (*InMemDevNetwork) AllocateFaucetFunds

func (s *InMemDevNetwork) AllocateFaucetFunds(ctx context.Context, account gethcommon.Address) error

func (*InMemDevNetwork) ChainID

func (s *InMemDevNetwork) ChainID() int64

func (*InMemDevNetwork) CleanUp

func (s *InMemDevNetwork) CleanUp()

func (*InMemDevNetwork) DeployL1StandardContracts

func (s *InMemDevNetwork) DeployL1StandardContracts()

func (*InMemDevNetwork) FaucetWallet

func (s *InMemDevNetwork) FaucetWallet() wallet.Wallet

func (*InMemDevNetwork) GetL1Client

func (s *InMemDevNetwork) GetL1Client() (ethadapter.EthClient, error)

GetL1Client returns the first client we have for our local L1 network todo (@matt) - this allows tests some basic L1 verification but in future this will need support more manipulation of L1 nodes,

(to allow us to simulate various scenarios where L1 is unavailable, under attack, etc.)

func (*InMemDevNetwork) GetMCOwnerWallet

func (s *InMemDevNetwork) GetMCOwnerWallet() (wallet.Wallet, error)

func (*InMemDevNetwork) GetSequencerNode

func (s *InMemDevNetwork) GetSequencerNode() networktest.NodeOperator

func (*InMemDevNetwork) GetValidatorNode

func (s *InMemDevNetwork) GetValidatorNode(i int) networktest.NodeOperator

func (*InMemDevNetwork) NumValidators

func (s *InMemDevNetwork) NumValidators() int

func (*InMemDevNetwork) SequencerRPCAddress

func (s *InMemDevNetwork) SequencerRPCAddress() string

func (*InMemDevNetwork) Start

func (s *InMemDevNetwork) Start()

func (*InMemDevNetwork) ValidatorRPCAddress

func (s *InMemDevNetwork) ValidatorRPCAddress(idx int) string

type InMemNodeOperator

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

InMemNodeOperator represents an Obscuro node playing a role in a DevSimulation

Anything a node operator could do, that we need to simulate belongs here, for example: * start/stop/reset the host/enclave components of the node * provide convenient access to RPC clients for the node * it might even provide access to things like the database files for the node if needed

Note: InMemNodeOperator will panic when things go wrong, we want to fail fast in sims and avoid verbose error handling in usage

func NewInMemNodeOperator

func NewInMemNodeOperator(operatorIdx int, config ObscuroConfig, nodeType common.NodeType, l1Data *params.L1SetupData,
	l1Client ethadapter.EthClient, l1Wallet wallet.Wallet, logger gethlog.Logger,
) *InMemNodeOperator

func (*InMemNodeOperator) HostRPCAddress

func (n *InMemNodeOperator) HostRPCAddress() string

func (*InMemNodeOperator) Start

func (n *InMemNodeOperator) Start() error

func (*InMemNodeOperator) StartEnclave

func (n *InMemNodeOperator) StartEnclave() error

StartEnclave starts the enclave process in

func (*InMemNodeOperator) StartHost

func (n *InMemNodeOperator) StartHost() error

StartHost starts the host process in a new thread

func (*InMemNodeOperator) Stop

func (n *InMemNodeOperator) Stop() error

func (*InMemNodeOperator) StopEnclave

func (n *InMemNodeOperator) StopEnclave() error

func (*InMemNodeOperator) StopHost

func (n *InMemNodeOperator) StopHost() error

type L1Config

type L1Config struct {
	PortStart          int
	WebsocketPortStart int
	NumNodes           int
	AvgBlockDuration   time.Duration
}

L1Config tells network admin how to setup the L1 network

type L1Network

type L1Network interface {
	Prepare() // ensure L1 connectivity (start nodes if required)
	CleanUp() // shut down  nodes if required, clean up connections
	NumNodes() int
	GetClient(i int) ethadapter.EthClient
}

L1Network represents the L1Network being used for the devnetwork (it could be a local geth docker network, a local in-memory network or even a live public L1) todo (@matt) - refactor to use the same NodeOperator approach as the L2?

func NewGethNetwork

func NewGethNetwork(networkWallets *params.SimWallets, l1Config *L1Config) L1Network

type ObscuroConfig

type ObscuroConfig struct {
	PortStart         int
	InitNumValidators int
	BatchInterval     time.Duration
	RollupInterval    time.Duration
	L1BlockTime       time.Duration
	SequencerID       common.Address
}

ObscuroConfig tells the L2 node operators how to configure the nodes

Jump to

Keyboard shortcuts

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