devnetwork

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: AGPL-3.0 Imports: 30 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 (*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 added in v0.11.0

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) 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 {
	Start()
	Stop()
	NumNodes() int
	GetClient(i int) ethadapter.EthClient
	ObscuroSetupData() *params.L1SetupData
}

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
}

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