geth

package
v1.16.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 43 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func ConnectP2P

func ConnectP2P(t *testing.T, node1 *ethclient.Client, node2 *ethclient.Client)

ConnectP2P creates a p2p peer connection between node1 and node2.

func FindBlock added in v1.7.2

func FindBlock(client *ethclient.Client,
	from, to int, timeout time.Duration,
	pred func(*types.Block) (bool, error),
) (*types.Block, error)

FindBlock finds the first block for which the predicate [pred] matches and returns it. It starts at [from] and iterates until [to], inclusively, using the provided [client]. It supports both search directions, forwards and backwards.

func InitL1

func InitL1(blockTime uint64, finalizedDistance uint64, genesis *core.Genesis, c clock.Clock, blobPoolDir string, beaconSrv Beacon, opts ...GethOption) (*GethInstance, *FakePoS, error)

func WaitForBlock

func WaitForBlock(number *big.Int, client *ethclient.Client, opts ...WaitForBlockOption) (*types.Block, error)

WaitForBlock waits for the chain to advance to the provided block number. It can be configured with two different timeout: an absolute timeout, and a no change timeout. The absolute timeout caps the maximum amount of time this method will run. The no change timeout will return an error if the block number does not change within that time window. This is useful to bail out early in the event of a stuck chain, but allow things to continue if the chain is still advancing.

This function will also retry fetch errors up to three times before returning an error in order to protect against transient network problems. This function uses polling rather than websockets.

func WaitForBlockToBeFinalized added in v1.4.2

func WaitForBlockToBeFinalized(number *big.Int, client *ethclient.Client, timeout time.Duration) (*types.Block, error)

func WaitForBlockToBeSafe added in v1.4.2

func WaitForBlockToBeSafe(number *big.Int, client *ethclient.Client, timeout time.Duration) (*types.Block, error)

func WaitForL1OriginOnL2

func WaitForL1OriginOnL2(rollupCfg *rollup.Config, l1BlockNum uint64, client *ethclient.Client, timeout time.Duration) (*types.Block, error)

func WaitForTransaction

func WaitForTransaction(hash common.Hash, client *ethclient.Client, timeout time.Duration) (*types.Receipt, error)

func WaitUntilTransactionNotFound added in v1.16.3

func WaitUntilTransactionNotFound(client *ethclient.Client, hash common.Hash, timeout time.Duration) error

WaitUntilTransactionNotFound polls TransactionByHash until the client returns ethereum.NotFound, indicating the EL has finished indexing and the transaction is definitively absent.

func WithP2P

func WithP2P() func(ethCfg *ethconfig.Config, nodeCfg *node.Config) error

Types

type Backend added in v1.14.0

type Backend interface {
	// HeaderByNumber is assumed to behave the same as go-ethereum/ethclient.Client.HeaderByNumber.
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
}

type Beacon added in v1.4.2

type Beacon interface {
	StoreBlobsBundle(slot uint64, bundle *engine.BlobsBundle) error
}

type FakePoS added in v1.13.4

type FakePoS struct {
	// contains filtered or unexported fields
}

fakePoS is a testing-only utility to attach to Geth, to build a fake proof-of-stake L1 chain with fixed block time and basic lagging safe/finalized blocks.

func NewFakePoS added in v1.14.0

func NewFakePoS(backend Backend, engineAPI EngineAPI, c clock.Clock, logger log.Logger, blockTime uint64, finalizedDistance uint64, beacon Beacon, config *params.ChainConfig) *FakePoS

func (*FakePoS) FakeBeaconBlockRoot added in v1.13.4

func (f *FakePoS) FakeBeaconBlockRoot(time uint64) common.Hash

func (*FakePoS) Start added in v1.13.4

func (f *FakePoS) Start() error

func (*FakePoS) Stop added in v1.13.4

func (f *FakePoS) Stop() error

type GethInstance added in v1.9.1

type GethInstance struct {
	Backend *eth.Ethereum
	Node    *node.Node
}

func InitL2

func InitL2(name string, genesis *core.Genesis, jwtPath string, opts ...GethOption) (*GethInstance, error)

InitL2 inits a L2 geth node.

func (*GethInstance) AuthRPC added in v1.9.1

func (gi *GethInstance) AuthRPC() endpoint.RPC

func (*GethInstance) Close added in v1.9.1

func (gi *GethInstance) Close() error

func (*GethInstance) UserRPC added in v1.9.1

func (gi *GethInstance) UserRPC() endpoint.RPC

type GethOption

type GethOption func(ethCfg *ethconfig.Config, nodeCfg *node.Config) error

func WithAuth added in v1.14.0

func WithAuth(jwtPath string) GethOption

type WaitForBlockOption added in v1.9.5

type WaitForBlockOption func(*waitForBlockOptions)

func WithAbsoluteTimeout added in v1.9.5

func WithAbsoluteTimeout(timeout time.Duration) WaitForBlockOption

func WithNoChangeTimeout added in v1.9.5

func WithNoChangeTimeout(timeout time.Duration) WaitForBlockOption

Jump to

Keyboard shortcuts

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