Documentation ¶
Index ¶
- Variables
- func AccountConfig(numValidators, numExternal int) *env.AccountsConfig
- func BuildConfig(accounts *env.AccountsConfig, gingerbreadBlock *big.Int) (*genesis.Config, *ethconfig.Config, error)
- func BuildSignedTransaction(client *ethclient.Client, senderKey *ecdsa.PrivateKey, ...) (*types.Transaction, error)
- func GenerateGenesis(accounts *env.AccountsConfig, gc *genesis.Config, contractsBuildPath string) (*core.Genesis, error)
- func ValueTransferTransactionWithDynamicFee(client *ethclient.Client, senderKey *ecdsa.PrivateKey, ...) (*types.Transaction, error)
- type Account
- func (a *Account) SendCelo(ctx context.Context, recipient common.Address, value int64, node *Node) (*types.Transaction, error)
- func (a *Account) SendCeloTracked(ctx context.Context, recipient common.Address, value int64, node *Node) (*types.Transaction, error)
- func (a *Account) SendCeloViaGoldToken(ctx context.Context, recipient common.Address, value int64, node *Node) (*types.Transaction, error)
- func (a *Account) SendCeloWithDynamicFee(ctx context.Context, recipient common.Address, value int64, gasFeeCap *big.Int, ...) (*types.Transaction, error)
- func (a *Account) SendValueWithDynamicFee(ctx context.Context, recipient common.Address, value int64, ...) (*types.Transaction, error)
- type BalanceWatcher
- type Balances
- type MarshalableECDSAPrivateKey
- type MarshalableNodeConfig
- type MarshalableP2PConfig
- type Network
- type Node
- func (n *Node) AddPeers(nodes ...*Node)
- func (n *Node) AwaitTransactions(ctx context.Context, txs ...*types.Transaction) error
- func (n *Node) Close() error
- func (n *Node) GossipEnodeCertificatge() error
- func (n *Node) ProcessedTxBlock(tx *types.Transaction) *types.Block
- func (n *Node) Start() error
- func (n *Node) TxFee(ctx context.Context, tx *types.Transaction) (*big.Int, error)
- type Token
- type Tracker
- func (tr *Tracker) AwaitBlock(ctx context.Context, num uint64) error
- func (tr *Tracker) AwaitTransactions(ctx context.Context, hashes []common.Hash) error
- func (tr *Tracker) GetProcessedBlock(num uint64) *types.Block
- func (tr *Tracker) GetProcessedBlockForTx(hash common.Hash) *types.Block
- func (tr *Tracker) GetProcessedTx(hash common.Hash) *types.Transaction
- func (tr *Tracker) StartTracking(client *ethclient.Client) error
- func (tr *Tracker) StopTracking() error
Constants ¶
This section is empty.
Variables ¶
var ( BaseEthConfig = ð.Config{ SyncMode: downloader.FullSync, MinSyncPeers: 1, DatabaseCache: 256, DatabaseHandles: 256, TxPool: core.DefaultTxPoolConfig, RPCEthCompatibility: true, RPCGasPriceMultiplier: big.NewInt(100), Istanbul: istanbul.Config{ Validator: true, AnnounceQueryEnodeGossipPeriod: 60, RequestTimeout: 200, TimeoutBackoffFactor: 200, MinResendRoundChangeTimeout: 200, MaxResendRoundChangeTimeout: 10000, Epoch: 20, ProposerPolicy: istanbul.ShuffledRoundRobin, DefaultLookbackWindow: 3, BlockPeriod: 0, }, Miner: miner.Config{ FeeCurrencyDefault: 0.9, }, } )
var (
ErrTrackerAlreadyStopped = errors.New("attempted to stop already stopped tracker")
)
Functions ¶
func AccountConfig ¶ added in v1.5.3
func AccountConfig(numValidators, numExternal int) *env.AccountsConfig
func BuildConfig ¶
func BuildConfig(accounts *env.AccountsConfig, gingerbreadBlock *big.Int) (*genesis.Config, *ethconfig.Config, error)
BuildConfig generates genesis and eth config instances, that can be modified before passing to NewNetwork or NewNode.
NOTE: Do not edit the Istanbul field of the returned genesis config it will be overwritten with the corresponding config from the Istanbul field of the returned eth config.
func BuildSignedTransaction ¶ added in v1.8.0
func BuildSignedTransaction( client *ethclient.Client, senderKey *ecdsa.PrivateKey, sender, recipient common.Address, nonce uint64, value *big.Int, signer types.Signer, data []byte, ) (*types.Transaction, error)
Uses the client to suggest a gas price and to estimate the gas.
func GenerateGenesis ¶ added in v1.5.3
func GenerateGenesis(accounts *env.AccountsConfig, gc *genesis.Config, contractsBuildPath string) (*core.Genesis, error)
GenerateGenesis checks that the contractsBuildPath exists and if so proceeds to generate the genesis.
func ValueTransferTransactionWithDynamicFee ¶ added in v1.5.3
func ValueTransferTransactionWithDynamicFee( client *ethclient.Client, senderKey *ecdsa.PrivateKey, sender, recipient common.Address, nonce uint64, value *big.Int, feeCurrency *common.Address, gasFeeCap *big.Int, gasTipCap *big.Int, signer types.Signer, ) (*types.Transaction, error)
ValueTransferTransactionWithDynamicFee builds a signed value transfer transaction from the sender to the recipient with the given value, nonce, gasFeeCap and gasTipCap.
Types ¶
type Account ¶ added in v1.5.3
type Account struct { Address common.Address Key *ecdsa.PrivateKey ChainConfig *params.ChainConfig Nonce *uint64 }
func Accounts ¶
func Accounts(accts []env.Account, chainConfig *params.ChainConfig) []*Account
Accounts converts a slice of env.Account objects to Account objects.
func NewAccount ¶ added in v1.5.3
func NewAccount(key *ecdsa.PrivateKey, address common.Address, chainConfig *params.ChainConfig) *Account
func (*Account) SendCelo ¶ added in v1.5.3
func (a *Account) SendCelo(ctx context.Context, recipient common.Address, value int64, node *Node) (*types.Transaction, error)
SendCelo submits a value transfer transaction via the provided Node to send celo to the recipient. The submitted transaction is returned.
func (*Account) SendCeloTracked ¶ added in v1.5.3
func (a *Account) SendCeloTracked(ctx context.Context, recipient common.Address, value int64, node *Node) (*types.Transaction, error)
SendCeloTracked functions like SendCelo but also waits for the transaction to be processed by the sending node.
func (*Account) SendCeloViaGoldToken ¶ added in v1.8.0
func (a *Account) SendCeloViaGoldToken(ctx context.Context, recipient common.Address, value int64, node *Node) (*types.Transaction, error)
SendCelo submits a transaction to `node` that invokes the equivalent of GoldToken.transfer(recipient, value), sent from the calling account. The submitted transaction is returned.
func (*Account) SendCeloWithDynamicFee ¶ added in v1.5.3
func (a *Account) SendCeloWithDynamicFee(ctx context.Context, recipient common.Address, value int64, gasFeeCap *big.Int, gasTipCap *big.Int, node *Node) (*types.Transaction, error)
SendCeloWithDynamicFee submits a value transfer transaction via the provided Node to send celo to the recipient. The submitted transaction is returned.
func (*Account) SendValueWithDynamicFee ¶ added in v1.8.0
func (a *Account) SendValueWithDynamicFee(ctx context.Context, recipient common.Address, value int64, feeCurrency *common.Address, gasFeeCap, gasTipCap *big.Int, node *Node) (*types.Transaction, error)
SendValueWithDynamicFee submits a value transfer transaction via the provided Node to send celo to the recipient. The submitted transaction is returned.
type BalanceWatcher ¶ added in v1.6.0
type BalanceWatcher struct {
// contains filtered or unexported fields
}
BalanceWatcher is a helper to watch balance changes over addresses.
func NewBalanceWatcher ¶ added in v1.6.0
func NewBalanceWatcher(client *ethclient.Client, addresses []common.Address) *BalanceWatcher
NewBalanceWatcher creates a BalanceWatcher, records initial balances of the accounts.
func (*BalanceWatcher) Current ¶ added in v1.6.0
func (w *BalanceWatcher) Current(address common.Address) *big.Int
Current returns current balance of given address.
func (*BalanceWatcher) Delta ¶ added in v1.6.0
func (w *BalanceWatcher) Delta(address common.Address) *big.Int
Delta returns difference between current and initial balance of given address for given token.
func (*BalanceWatcher) Initial ¶ added in v1.6.0
func (w *BalanceWatcher) Initial(address common.Address) *big.Int
Initial returns initial balance of given address, or nil if address is not found.
func (*BalanceWatcher) Update ¶ added in v1.6.0
func (w *BalanceWatcher) Update()
Update updates current balances in the BalanceWatcher
type MarshalableECDSAPrivateKey ¶
type MarshalableECDSAPrivateKey ecdsa.PrivateKey
func (*MarshalableECDSAPrivateKey) MarshalJSON ¶
func (k *MarshalableECDSAPrivateKey) MarshalJSON() ([]byte, error)
func (*MarshalableECDSAPrivateKey) UnmarshalJSON ¶
func (k *MarshalableECDSAPrivateKey) UnmarshalJSON(b []byte) error
type MarshalableNodeConfig ¶
type MarshalableNodeConfig struct { node.Config P2P MarshalableP2PConfig }
type MarshalableP2PConfig ¶
type MarshalableP2PConfig struct { p2p.Config PrivateKey *MarshalableECDSAPrivateKey }
type Network ¶
type Network []*Node
Network represents a network of nodes and provides functionality to easily create, start and stop a collection of nodes.
func NewNetwork ¶
func NewNetwork(accounts *env.AccountsConfig, gc *genesis.Config, ec *eth.Config) (Network, func(), error)
NewNetwork generates a network of nodes that are running and mining. For each provided validator account a corresponding node is created and each node is also assigned a developer account, there must be at least as many developer accounts provided as validator accounts. A shutdown function is also returned which will shutdown and clean up the network when called. In the case that an error is returned the shutdown function will be nil and so no attempt should be made to call it.
func (Network) AwaitBlock ¶ added in v1.5.0
AwaitBlock ensures that the entire network has processed a block with the given num.
func (Network) AwaitTransactions ¶
AwaitTransactions ensures that the entire network has processed the provided transactions.
type Node ¶
type Node struct { *node.Node Config *node.Config P2PListenAddr string Enode *enode.Node Eth *eth.Ethereum EthConfig *eth.Config WsClient *ethclient.Client Key *ecdsa.PrivateKey Address common.Address Tracker *Tracker // The transactions that this node has sent. SentTxs []*types.Transaction }
Node provides an enhanced interface to node.Node with useful additions, the *node.Node is embedded so that its api is available through Node.
func NewNode ¶
func NewNode( validatorAccount *env.Account, nc *node.Config, ec *eth.Config, genesis *core.Genesis, ) (*Node, error)
NewNode creates a new running node with the provided config.
func (*Node) AwaitTransactions ¶
AwaitTransactions awaits all the provided transactions.
func (*Node) Close ¶
Close shuts down the node and releases all resources and removes the datadir unless an error is returned, in which case there is no guarantee that all resources are released. It is assumed that this is only called after calling Start otherwise it will panic.
func (*Node) GossipEnodeCertificatge ¶ added in v1.5.3
GossipEnodeCertificatge gossips this nodes enode certificates to the rest of the network.
func (*Node) ProcessedTxBlock ¶
func (n *Node) ProcessedTxBlock(tx *types.Transaction) *types.Block
ProcessedTxBlock returns the block that the given transaction was processed in, nil will be retuned if the transaction has not been processed by this node.
type Tracker ¶ added in v1.5.0
type Tracker struct {
// contains filtered or unexported fields
}
Tracker tracks processed blocks and transactions through a subscription with an ethclient. It provides the ability to check whether blocks or transactions have been processed and to wait till those blocks or transactions have been processed.
func (*Tracker) AwaitBlock ¶ added in v1.5.0
AwaitBlock waits for a block with the given num to be processed, it will return the ctx.Err() if ctx expires before a block with that number has been processed or ErrStopped if StopTracking is called before a block with that number is processed.
func (*Tracker) AwaitTransactions ¶ added in v1.5.0
AwaitTransactions waits for the transactions listed in hashes to be processed, it will return the ctx.Err() if ctx expires before all the transactions in hashes were processed or ErrStopped if StopTracking is called before all the transactions in hashes were processed.
func (*Tracker) GetProcessedBlock ¶ added in v1.5.0
GetProcessedBlock returns processed block with the given num or nil if the tracker has not seen a processed block with that num.
func (*Tracker) GetProcessedBlockForTx ¶ added in v1.5.0
GetProcessedBlockForTx returns the block that a transaction with the given hash was processed in or nil if the tracker has not seen a processed transaction with the given hash.
func (*Tracker) GetProcessedTx ¶ added in v1.5.0
func (tr *Tracker) GetProcessedTx(hash common.Hash) *types.Transaction
GetProcessedTx returns the processed transaction with the given hash or nil if the tracker has not seen a processed transaction with the given hash.
func (*Tracker) StartTracking ¶ added in v1.5.0
StartTracking subscribes to new head events on the client and starts processing the events in a goroutine.
func (*Tracker) StopTracking ¶ added in v1.5.0
StopTracking shuts down all the goroutines in the tracker.