network

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: AGPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Localhost               = "127.0.0.1"
	EnclaveClientRPCTimeout = 5 * time.Minute
	DefaultL1RPCTimeout     = 15 * time.Second
)

Variables

This section is empty.

Functions

func CheckHostRPCServersStopped

func CheckHostRPCServersStopped(hostWSURLS []string)

CheckHostRPCServersStopped checks whether the hosts' RPC server addresses have been freed up.

func CreateAuthClients added in v0.18.0

func CreateAuthClients(clients []rpc.Client, wal wallet.Wallet) []*obsclient.AuthObsClient

func CreateEthClientConnection added in v0.17.0

func CreateEthClientConnection(id int64, port uint) ethadapter.EthClient

func DeployContract

func DeployContract(workerClient ethadapter.EthClient, w wallet.Wallet, contractBytes []byte) (*types.Receipt, error)

DeployContract returns receipt of deployment todo (@matt) - this should live somewhere else

func DeployObscuroNetworkContracts added in v0.17.0

func DeployObscuroNetworkContracts(client ethadapter.EthClient, wallets *params.SimWallets, deployERC20s bool) (*params.L1SetupData, error)

func GetNodeType added in v0.6.0

func GetNodeType(i int) common.NodeType

GetNodeType returns the type of the node based on its ID.

func SetUpGethNetwork

func SetUpGethNetwork(wallets *params.SimWallets, startPort int, nrNodes int, blockDurationSeconds int) (*params.L1SetupData, []ethadapter.EthClient, eth2network.Eth2Network)

func StartGethNetwork added in v0.17.0

func StartGethNetwork(wallets *params.SimWallets, startPort int, blockDurationSeconds int) (eth2network.Eth2Network, error)

func StopEth2Network added in v0.10.0

func StopEth2Network(clients []ethadapter.EthClient, netw eth2network.Eth2Network)

func StopObscuroNodes

func StopObscuroNodes(clients []rpc.Client)

StopObscuroNodes stops the Obscuro nodes and their RPC clients.

Types

type Network

type Network interface {
	// Create - returns the started Ethereum nodes and the started Obscuro node clients.
	// Responsible with spinning up all resources required for the test
	// Return an error in case it cannot start for an expected reason. Otherwise it panics.
	Create(params *params.SimParams, stats *stats.Stats) (*RPCHandles, error)
	TearDown()
}

Network is responsible with knowing how to manage the lifecycle of networks of Ethereum or Obscuro nodes. These networks can be composed of in-memory go-routines or of fully fledged existing nodes like Ropsten. Implementation notes: - This is a work in progress, so there is a lot of code duplication in the implementations - Once we implement a few more versions: for example using Geth, we'll revisit and create better abstractions.

func NewBasicNetworkOfInMemoryNodes

func NewBasicNetworkOfInMemoryNodes() Network

func NewNetworkInMemoryGeth

func NewNetworkInMemoryGeth(wallets *params.SimWallets) Network

func NewNetworkOfSocketNodes

func NewNetworkOfSocketNodes(wallets *params.SimWallets) Network

type RPCHandles

type RPCHandles struct {
	// an eth client per eth node in the network
	EthClients []ethadapter.EthClient

	// An Obscuro client per Obscuro node in the network.
	ObscuroClients []*obsclient.ObsClient
	// An RPC client per Obscuro node in the network (used for APIs that don't have methods on `ObsClient`.
	RPCClients []rpc.Client

	// an RPC client per node per wallet, with a viewing key set up (on the client and registered on its corresponding host enclave),
	//	to mimic user acc interaction via a wallet extension
	// map of owner addresses to RPC clients for that owner (one per L2 node)
	// todo (@matt) - simplify this with a client per node when we have clients that can support multiple wallets
	AuthObsClients map[string][]*obsclient.AuthObsClient
}

func (*RPCHandles) ObscuroWalletClient

func (n *RPCHandles) ObscuroWalletClient(walletAddress common.Address, nodeIdx int) *obsclient.AuthObsClient

ObscuroWalletClient fetches a client for a given wallet address, for a specific node

func (*RPCHandles) ObscuroWalletRndClient

func (n *RPCHandles) ObscuroWalletRndClient(wallet wallet.Wallet) *obsclient.AuthObsClient

ObscuroWalletRndClient fetches an RPC client connected to a random L2 node for a given wallet

func (*RPCHandles) RndEthClient

func (n *RPCHandles) RndEthClient() ethadapter.EthClient

Jump to

Keyboard shortcuts

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