client

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 22 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),
		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),
		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"`

	*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 deprecated

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
	// PendingStateReader handles pending state calls
	ethereum.PendingStateReader
	// ChainSyncReader tracks state head
	ethereum.ChainSyncReader
	// PendingContractCaller tracks pending contract calls
	ethereum.PendingContractCaller
	// FeeHistory gets the fee history for a given block
	FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)
	// NetworkID returns the network ID (also known as the chain ID) for this chain.
	NetworkID(ctx context.Context) (*big.Int, error)
	// ChainID gets the chain id from the rpc server
	ChainID(ctx context.Context) (*big.Int, error)
	// 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)
	// BatchContext uses w3 as a helper method for batch calls
	// Deprecated: use BatchCallContext and stop using chain/client
	BatchContext(ctx context.Context, calls ...w3types.Caller) error
	// Web3Version gets the web3 version
	Web3Version(ctx context.Context) (version string, err error)
}

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

Deprecated: use ethergo/client

func NewClient

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

NewClient creates a client from a url.

func NewClientFromChainID added in v0.0.20

func NewClientFromChainID(ctx context.Context, url string, chainID *big.Int) (EVMClient, error)

NewClientFromChainID creates a new client from a chain id.

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

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.

func (LifecycleClient) BatchContext added in v0.0.20

func (m LifecycleClient) BatchContext(ctx context.Context, calls ...w3types.Caller) error

BatchContext calls BatchContext on the underlying client

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

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

func (LifecycleClient) BlockNumber

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

BlockNumber gets the latest block number

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.

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

func (LifecycleClient) ChainConfig

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

ChainConfig calls ChainConfig on the underlying client

func (LifecycleClient) ChainID

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

ChainID calls ChainID on the underlying client.

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

func (LifecycleClient) EstimateGas

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

EstimateGas calls EstimateGas on the underlying client

func (LifecycleClient) FeeHistory added in v0.0.21

func (m LifecycleClient) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)

FeeHistory calls FeeHistory on the underlying client

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

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

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

func (LifecycleClient) NetworkID added in v0.0.21

func (m LifecycleClient) NetworkID(ctx context.Context) (id *big.Int, err error)

NetworkID calls NetworkID on the underlying client

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

func (LifecycleClient) PendingBalanceAt added in v0.0.21

func (m LifecycleClient) PendingBalanceAt(ctx context.Context, account common.Address) (pendingBalance *big.Int, err error)

PendingBalanceAt calls PendingBalanceAt on the underlying client

func (LifecycleClient) PendingCallContract added in v0.0.21

func (m LifecycleClient) PendingCallContract(ctx context.Context, call ethereum.CallMsg) (contractResponse []byte, err error)

PendingCallContract calls contract on the underlying client

func (LifecycleClient) PendingCodeAt

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

PendingCodeAt calls PendingCodeAt on the underlying client

func (LifecycleClient) PendingNonceAt

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

PendingNonceAt calls PendingNonceAt on the underlying client

func (LifecycleClient) PendingStorageAt added in v0.0.21

func (m LifecycleClient) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) (pendingStorage []byte, err error)

PendingStorageAt calls PendingStorageAt on the underlying client

func (LifecycleClient) PendingTransactionCount added in v0.0.21

func (m LifecycleClient) PendingTransactionCount(ctx context.Context) (count uint, err error)

PendingTransactionCount calls PendingTransactionCount on the underlying client

func (LifecycleClient) SendTransaction

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

SendTransaction calls SendTransaction on the underlying client

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

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

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

func (LifecycleClient) SuggestGasPrice

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

SuggestGasPrice calls SuggestGasPrice on the underlying client

func (LifecycleClient) SuggestGasTipCap

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

SuggestGasTipCap gets the suggested gas tip for a chain.

func (LifecycleClient) SyncProgress added in v0.0.21

func (m LifecycleClient) SyncProgress(ctx context.Context) (syncProgress *ethereum.SyncProgress, err error)

SyncProgress calls SyncProgress on the underlying client

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

func (LifecycleClient) TransactionCount

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

TransactionCount calls TransactionCount on the underlying client

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

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

func (LifecycleClient) Web3Version added in v0.7.0

func (m LifecycleClient) Web3Version(ctx context.Context) (version string, err error)

Web3Version calls Web3Version on the underlying client

type LimiterConfig added in v0.1.22

type LimiterConfig struct {
	// RequestsPerSecondLimit sets the maximum average number of requests
	// per second. It's important to note that in short periods of time
	// the actual average may exceed this limit slightly.
	RequestsPerSecondLimit int

	// ConcurrencyLimit sets the maximum number of concurrent requests which
	// can be executed against the target at the same time.
	ConcurrencyLimit int

	// AcquirePermitTimeout determines how long a request can wait trying
	// to acquire a permit from the rate limiter.
	AcquirePermitTimeout time.Duration
}

LimiterConfig represents the configuration of the rate limiter. copied from https://github.com/keep-network/keep-common/blob/v1.7.0/pkg/rate/limiter.go#L19

type MeteredEVMClient

type MeteredEVMClient interface {
	EVMClient
	// 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 *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.

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