rpc

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnvilContainer

type AnvilContainer struct {
	testcontainers.Container
	URL string
}

func StartAnvil

func StartAnvil(params []string) (*AnvilContainer, error)

type CurrentBlockResponse

type CurrentBlockResponse struct {
	Result string `json:"result"`
}

type GethContainer

type GethContainer struct {
	testcontainers.Container
	URL string
}

type RPCClient

type RPCClient struct {
	URL string
	// contains filtered or unexported fields
}

RPCClient is an RPC client for various node simulators API Reference https://book.getfoundry.sh/reference/anvil/

func New

func New(url string, headers http.Header) *RPCClient

New creates new RPC client that can be used with Geth or Anvil this is a high level wrapper for common calls we use

func (*RPCClient) AnvilAutoImpersonate

func (m *RPCClient) AnvilAutoImpersonate(b bool) error

AnvilAutoImpersonate sets auto impersonification to true or false

func (*RPCClient) AnvilDropTransaction

func (m *RPCClient) AnvilDropTransaction(params []interface{}) error

AnvilDropTransaction removes transaction from tx pool API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilMine

func (m *RPCClient) AnvilMine(params []interface{}) error

AnvilMine calls "evm_mine", mines one or more blocks, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetAutoMine

func (m *RPCClient) AnvilSetAutoMine(flag bool) error

AnvilSetAutoMine calls "evm_setAutomine", turns automatic mining on, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetBlockGasLimit

func (m *RPCClient) AnvilSetBlockGasLimit(params []interface{}) error

AnvilSetBlockGasLimit sets next block gas limit API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetMinGasPrice

func (m *RPCClient) AnvilSetMinGasPrice(params []interface{}) error

AnvilSetMinGasPrice sets min gas price (pre-EIP-1559 anvil is required) API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetNextBlockBaseFeePerGas

func (m *RPCClient) AnvilSetNextBlockBaseFeePerGas(params []interface{}) error

AnvilSetNextBlockBaseFeePerGas sets next block base fee per gas value API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilSetStorageAt

func (m *RPCClient) AnvilSetStorageAt(params []interface{}) error

AnvilSetStorageAt sets storage at address API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) AnvilTxPoolStatus

func (m *RPCClient) AnvilTxPoolStatus(params []interface{}) (*TxStatusResponse, error)

AnvilTxPoolStatus calls "txpool_status", returns txpool status, see the reference on RPCClient API Reference https://book.getfoundry.sh/reference/anvil/

func (*RPCClient) BlockNumber

func (m *RPCClient) BlockNumber() (int64, error)

Call "eth_blockNumber" to get the current block number

func (*RPCClient) GethSetHead

func (m *RPCClient) GethSetHead(blocksBack int) error

func (*RPCClient) ModulateBaseFeeOverDuration

func (m *RPCClient) ModulateBaseFeeOverDuration(lggr zerolog.Logger, startingBaseFee int64, percentage float64, duration time.Duration, spike bool) error

ModulateBaseFeeOverDuration will cause the gas price to rise or drop to a certain percentage of the starting gas price over the duration specified. Minimum duration is 1 s if spike is true, the gas price will rise to the target price if spike is false, the gas price will drop to the target price

type RemoteAnvilMiner

type RemoteAnvilMiner struct {
	Client *RPCClient
	// contains filtered or unexported fields
}

RemoteAnvilMiner is a remote miner for Anvil node Allows to control blocks emission more precisely to mimic real networks workload

func NewRemoteAnvilMiner

func NewRemoteAnvilMiner(url string, headers http.Header) *RemoteAnvilMiner

NewRemoteAnvilMiner creates a new remote miner client

func (*RemoteAnvilMiner) MineBatch

func (m *RemoteAnvilMiner) MineBatch(capacity int64, checkInterval time.Duration, sendInterval time.Duration)

MineBatch checks the pending transactions in the pool, if threshold is reached mines the block and repeat the process

func (*RemoteAnvilMiner) MinePeriodically

func (m *RemoteAnvilMiner) MinePeriodically(interval time.Duration)

MinePeriodically mines blocks with a specified interval should be used when Anvil mining is off

func (*RemoteAnvilMiner) Stop

func (m *RemoteAnvilMiner) Stop()

Stop stops the miner

type TxStatusResponse

type TxStatusResponse struct {
	Result struct {
		Pending string `json:"pending"`
	} `json:"result"`
}

TxStatusResponse common RPC response body

Jump to

Keyboard shortcuts

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