client

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 26 Imported by: 1

Documentation

Overview

Package client provides a common interface for eth-based clients used with chain It defines the minimum necessary methods to create a chain and implements a rate limiter and metrics around client usage- useful for monitoring and debugging.

Index

Constants

View Source
const ConcurrencyGaugeMetricName = "request_concurrency"

ConcurrencyGaugeMetricName is the name of the metric which gauges request concurrency.

View Source
const RequestCountMetricName = "request_count_total"

RequestCountMetricName is the name of the metric which counts requests.

Variables

View Source
var (
	// BSCChainConfig bsc mainnet config.
	BSCChainConfig = &params.ChainConfig{
		ChainID:             big.NewInt(56),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// ChapelChainConfig bsc testnet config.
	ChapelChainConfig = &params.ChainConfig{
		ChainID:             big.NewInt(97),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// RialtoChainConfig rial config.
	RialtoChainConfig = &params.ChainConfig{
		ChainID:             big.NewInt(1417),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// SimulatedConfig is the simulated config backend.
	SimulatedConfig = params.AllEthashProtocolChanges

	// MaticMumbaiConfig is the matic config.
	MaticMumbaiConfig = &params.ChainConfig{
		ChainID:             big.NewInt(80001),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// MaticMainnetConfig is the matic mainnet config.
	MaticMainnetConfig = &params.ChainConfig{
		ChainID:             big.NewInt(137),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// AvalancheMainnetChainConfig is the configuration for Avalanche Main Network
	// TODO: this and other avalanche configs should be imported directly from https://github.com/ava-labs/coreth/blob/master/params/config.go
	AvalancheMainnetChainConfig = &params.ChainConfig{
		ChainID:             big.NewInt(43114),
		HomesteadBlock:      big.NewInt(0),
		DAOForkBlock:        big.NewInt(0),
		DAOForkSupport:      true,
		EIP150Block:         big.NewInt(0),
		EIP150Hash:          ethCommon.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		BerlinBlock:         big.NewInt(0),
	}

	// AvalancheLocalChainConfig is the configuration for the Avalanche Local Network.
	AvalancheLocalChainConfig = &params.ChainConfig{
		ChainID:             big.NewInt(43112),
		HomesteadBlock:      big.NewInt(0),
		DAOForkBlock:        big.NewInt(0),
		DAOForkSupport:      true,
		EIP150Block:         big.NewInt(0),
		EIP150Hash:          ethCommon.HexToHash("0x2086799aeebeae135c246c65021c82b4e15a2c451340993aacfd2751886514f0"),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		BerlinBlock:         big.NewInt(0),
	}

	// ArbitrumMainnetConfig is the arbitrum mainnet config.
	ArbitrumMainnetConfig = &params.ChainConfig{
		ChainID:             big.NewInt(42161),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// FtmMainnetConfig contains the fantom mainnet config.
	FtmMainnetConfig = &params.ChainConfig{
		ChainID:             big.NewInt(250),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// HarmonyConfig contains the chain config for harmony
	// note: this is shard 0 only
	HarmonyConfig = &params.ChainConfig{
		ChainID:             big.NewInt(1666600000),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// BobaConfig contains the chain config for boba.
	BobaConfig = &params.ChainConfig{
		ChainID:             big.NewInt(288),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// MoonBeamConfig contains the configuration for moonriver.
	MoonBeamConfig = &params.ChainConfig{
		ChainID:             big.NewInt(1284),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// MoonRiverConfig contains the configuration for moonriver.
	MoonRiverConfig = &params.ChainConfig{
		ChainID:             big.NewInt(1285),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// OptimisticEthereum contains the configuration for optimism.
	OptimisticEthereum = &params.ChainConfig{
		ChainID:             big.NewInt(10),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// AuroraMainnet contains the configuration for aurora.
	AuroraMainnet = &params.ChainConfig{
		ChainID:             big.NewInt(1313161554),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// CronosMainnet is the cronos mainnet chain config.
	CronosMainnet = &params.ChainConfig{
		ChainID:             big.NewInt(25),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// MetisMainnet is the metis mainnet config.
	MetisMainnet = &params.ChainConfig{
		ChainID:             big.NewInt(1088),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         nil,
	}

	// DFKMainnet is the dfk mainnet contract.
	DFKMainnet = &params.ChainConfig{
		ChainID:             big.NewInt(53935),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         big.NewInt(0),
	}

	// DFKTestnet is the dfk testnet config.
	DFKTestnet = &params.ChainConfig{
		ChainID:             big.NewInt(335),
		HomesteadBlock:      big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
		LondonBlock:         big.NewInt(0),
	}
)

Functions

func ConfigFromID

func ConfigFromID(id *big.Int) *params.ChainConfig

ConfigFromID gets the chain config from the id.

func UsesLondon

func UsesLondon(config *params.ChainConfig, currentBlock uint64) bool

UsesLondon termines whether or not a chain uses london.

Types

type Config

type Config struct {
	// RPCUrl is the rpc websocket url to use
	// note: this is called 'WSUrl' for historical reasons and will be updated in a future version
	RPCUrl []string `toml:"WSUrl"`

	// ChainID - name of the current chain
	ChainID int `toml:"ChainID"`

	// Type is the chain type
	Type string `toml:"Type"`

	// RequiredConfirmations is the number of confirmations required until
	// a block is considered "finalized"
	RequiredConfirmations uint `toml:"Confirmations"`

	// BridgeAddress is the address of the bridge on the chain
	BridgeAddress string `toml:"BridgeAddress"`

	// StartHeight is the start height for a given contract. This is a workaround for https://github.com/synapsecns/synapse-contracts/issues/20
	// where in the start height is always returned as 0. This can be removed after version 6 of the contracts
	StartHeight uint64 `toml:"StartHeight"`

	*rate.LimiterConfig
}

Config contains the configuration needed to connect to the chain.

func (*Config) GetEthBridgeAddress

func (c *Config) GetEthBridgeAddress() ethCommon.Address

GetEthBridgeAddress gets the bridge address cast to a ethCommon.address.

func (*Config) SetEthBridgeAddress

func (c *Config) SetEthBridgeAddress(bridgeAddress ethCommon.Address)

SetEthBridgeAddress mutates the config to set a bridge address.

type EVMClient

type EVMClient interface {
	// ContractBackend defines the methods needed to work with contracts on a read-write basis.
	// this is used for deploying an interacting with contracts
	bind.ContractBackend
	// ChainReader ethereum.ChainReader for getting transactions
	ethereum.ChainReader
	// TransactionReader is used for reading txes by hash
	ethereum.TransactionReader
	// ChainStateReader gets the chain state reader
	ethereum.ChainStateReader
	// ChainID gets the chain id from the rpc server
	ChainID(ctx context.Context) (*big.Int, error)
	// ChainConfig gets the chain config
	ChainConfig() *params.ChainConfig
	// CallContext is used for manual overrides
	CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
	// BatchCallContext is used for manual overrides
	BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
	// BlockNumber gets the latest block number
	BlockNumber(ctx context.Context) (uint64, error)
}

EVMClient is the chain client. It defines everything necessary to create a Chain.

func NewClient

func NewClient(ctx context.Context, wsURL string) (EVMClient, error)

NewClient creates a client from a websocket url.

type LifecycleClient

type LifecycleClient struct {
	Permitter
	// contains filtered or unexported fields
}

LifecycleClient is an evm client that acquires a permit upon request start and releases after the request. this logic can be implemented however the caller needs.

func NewLifecycleClient

func NewLifecycleClient(client EVMClient, chainID *big.Int, permitter Permitter, requestTimeout time.Duration) LifecycleClient

NewLifecycleClient creates a new lifecyle client from an underlying client and a permitter. requestTimeout is the maximum amount of time to wait for any request. This does not include the acquirePermit/releasePermit time.

func (LifecycleClient) BalanceAt

func (m LifecycleClient) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (balance *big.Int, err error)

BalanceAt calls BalanceAt on the underlying client nolint: wrapcheck

func (LifecycleClient) BatchCallContext

func (m LifecycleClient) BatchCallContext(ctx context.Context, b []rpc.BatchElem) error

BatchCallContext calls BatchCallContext on the underlying client. Note: this will bypass the rate-limiter. nolint: wrapcheck

func (LifecycleClient) BlockByHash

func (m LifecycleClient) BlockByHash(ctx context.Context, hash common.Hash) (block *types.Block, err error)

BlockByHash calls BlockByHash on the underlying client nolint: wrapcheck

func (LifecycleClient) BlockByNumber

func (m LifecycleClient) BlockByNumber(ctx context.Context, number *big.Int) (block *types.Block, err error)

BlockByNumber calls BlockByNumber on the underlying client nolint: wrapcheck

func (LifecycleClient) BlockNumber

func (m LifecycleClient) BlockNumber(ctx context.Context) (_ uint64, err error)

BlockNumber gets the latest block number nolint: wrapcheck

func (LifecycleClient) CallContext

func (m LifecycleClient) CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) (err error)

CallContext calls CallContext on the underlying client. Note: this will bypass the rate-limiter. nolint: wrapcheck

func (LifecycleClient) CallContract

func (m LifecycleClient) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) (contractResponse []byte, err error)

CallContract calls contract on the underlying client nolint: wrapcheck

func (LifecycleClient) ChainConfig

func (m LifecycleClient) ChainConfig() *params.ChainConfig

ChainConfig calls ChainConfig on the underlying client nolint: wrapcheck

func (LifecycleClient) ChainID

func (m LifecycleClient) ChainID(ctx context.Context) (chainID *big.Int, err error)

ChainID calls ChainID on the underlying client. This also sets chainID for chainconfig if needed nolint: wrapcheck

func (LifecycleClient) CodeAt

func (m LifecycleClient) CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) (codeAt []byte, err error)

CodeAt calls CodeAt on the underlying client nolint: wrapcheck

func (LifecycleClient) EstimateGas

func (m LifecycleClient) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)

EstimateGas calls EstimateGas on the underlying client nolint: wrapcheck

func (LifecycleClient) FilterLogs

func (m LifecycleClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery) (logs []types.Log, err error)

FilterLogs calls FilterLogs on the underlying client nolint: wrapcheck

func (LifecycleClient) HeaderByHash

func (m LifecycleClient) HeaderByHash(ctx context.Context, hash common.Hash) (header *types.Header, err error)

HeaderByHash calls HeaderByHash on the underlying client nolint: wrapcheck

func (LifecycleClient) HeaderByNumber

func (m LifecycleClient) HeaderByNumber(ctx context.Context, number *big.Int) (header *types.Header, err error)

HeaderByNumber calls HeaderByNumber on the underlying client nolint: wrapcheck

func (LifecycleClient) NonceAt

func (m LifecycleClient) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (nonce uint64, err error)

NonceAt calls NonceAt on the underlying client nolint: wrapcheck

func (LifecycleClient) PendingCodeAt

func (m LifecycleClient) PendingCodeAt(ctx context.Context, account common.Address) (codeResponse []byte, err error)

PendingCodeAt calls PendingCodeAt on the underlying client nolint: wrapcheck

func (LifecycleClient) PendingNonceAt

func (m LifecycleClient) PendingNonceAt(ctx context.Context, account common.Address) (pendingNonce uint64, err error)

PendingNonceAt calls PendingNonceAt on the underlying client nolint: wrapcheck

func (LifecycleClient) SendTransaction

func (m LifecycleClient) SendTransaction(ctx context.Context, tx *types.Transaction) (err error)

SendTransaction calls SendTransaction on the underlying client nolint: wrapcheck

func (LifecycleClient) StorageAt

func (m LifecycleClient) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) (storage []byte, err error)

StorageAt calls StorageAt on the underlying client nolint: wrapcheck

func (LifecycleClient) SubscribeFilterLogs

func (m LifecycleClient) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (sub ethereum.Subscription, err error)

SubscribeFilterLogs calls SubscribeFilterLogs on the underlying client nolint: wrapcheck

func (LifecycleClient) SubscribeNewHead

func (m LifecycleClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (sub ethereum.Subscription, err error)

SubscribeNewHead calls SubscribeNewHead on the underlying client nolint: wrapcheck

func (LifecycleClient) SuggestGasPrice

func (m LifecycleClient) SuggestGasPrice(ctx context.Context) (gasPrice *big.Int, err error)

SuggestGasPrice calls SuggestGasPrice on the underlying client nolint: wrapcheck

func (LifecycleClient) SuggestGasTipCap

func (m LifecycleClient) SuggestGasTipCap(ctx context.Context) (tip *big.Int, err error)

SuggestGasTipCap gets the suggested gas tip for a chain. nolint: wrapcheck

func (LifecycleClient) TransactionByHash

func (m LifecycleClient) TransactionByHash(ctx context.Context, txHash common.Hash) (tx *types.Transaction, isPending bool, err error)

TransactionByHash calls TransactionByHash on the underlying client nolint: wrapcheck

func (LifecycleClient) TransactionCount

func (m LifecycleClient) TransactionCount(ctx context.Context, blockHash common.Hash) (txCount uint, err error)

TransactionCount calls TransactionCount on the underlying client nolint: wrapcheck

func (LifecycleClient) TransactionInBlock

func (m LifecycleClient) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (tx *types.Transaction, err error)

TransactionInBlock calls TransactionInBlock on the underlying client nolint: wrapcheck

func (LifecycleClient) TransactionReceipt

func (m LifecycleClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (receipt *types.Receipt, err error)

TransactionReceipt calls TransactionReceipt on the underlying client nolint: wrapcheck

type MeteredEVMClient

type MeteredEVMClient interface {
	EVMClient
	metrics.Instrumentable
	// RequestCount gets the request count from the metered evm client
	RequestCount() int64
	// ConcurrencyCount gets the request concurrency on the meterd client
	ConcurrencyCount() int32
	// ClientID is a unique identifier for the client.
	//
	// note: this is not guaranteed to be unique - it's set by the caller.
	ClientID() string
	// AttemptReconnect attempts to reconnect
	// TODO: replace with https://github.com/ethereum/go-ethereum/issues/22266
	AttemptReconnect() bool
}

MeteredEVMClient is a metered client that exposes a counter metric for evm requests sent through the client.

func NewMeteredClient

func NewMeteredClient(client EVMClient, chainID *big.Int, clientID string, config *keepRate.LimiterConfig) MeteredEVMClient

NewMeteredClient wraps an evm client in a keepRate limiter and creates a metric handler with some standard metrics. It also implements a ChainConfig() method to get the chainconfig for a given chain by id. This will return nil if no chain config is found.

type Permitter

type Permitter interface {
	AcquirePermit(ctx context.Context) (err error)
	// ReleasePermit releases a permit
	ReleasePermit()
}

Permitter handles permit acquires/releases for a lifecycle client. this is useful for implementing generic pre/post request logic on different kinds of clients that conform to the evm client.

type PoolClient

type PoolClient interface {
	// MeteredEVMClient is the primary client. This is swapped among clients based on liveliness
	MeteredEVMClient
	// Watcher is the watcher interface. We expose it from here since this is the most reliable client
	// it is kept ina  separate call to allow metrics to be independently assessed
	Watcher() watcher.BlockHeightWatcher
	// Instrumentable allows a user to collect metrics against pool client
	metrics.Instrumentable
}

PoolClient is a type of client that allows fallbacks to multiple rpc endpoints.

in the initial version, functionality is quite simple. Each node creates a block height watcher and the height relative to other rpcs is used to determine if this node is in the live or dead pool. A "leader" is picked from the live pool and this is used to satisfy all calls to the pool client. For this reason this client also acts as a proxy to block height wathcher.

In the case where no live client can be found, a dead client is returned. Note: subscriptions using an old client will not automatically switch over- the new client is only used on new method calls. Right now, *all* rpc servers used by a node operator are trusted (and we expect users to run them themselves). In the future it might make sense to have users verify against all live clients or use smart rate limiting.

func NewPoolClient

func NewPoolClient(ctx context.Context, chainID uint64, clients []MeteredEVMClient) (PoolClient, error)

NewPoolClient creates a new pool client from a list of metered evm clients. only errors if no clients are passed in.

func NewPoolClientFromURLs

func NewPoolClientFromURLs(ctx context.Context, chainID uint64, rpcURLs []string) (PoolClient, error)

NewPoolClientFromURLs creates a new pool client from a list of rpc url.

it differs from NewPoolClient in that it can be used even if not all rpc urls are up at start time.

Directories

Path Synopsis
Package near contains workaround for the aurora rpc
Package near contains workaround for the aurora rpc

Jump to

Keyboard shortcuts

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