blockheaderfeeder

package
v2.3.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

The block header feeder package enables automated lookback and blockhash filling beyond the EVM 256 block lookback window to catch missed block hashes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFromAddressesExist

func CheckFromAddressesExist(jb job.Job, gethks keystore.Eth) (err error)

CheckFromAddressesExist returns an error if and only if one of the addresses in the BlockHeaderFeeder spec's fromAddresses field does not exist in the keystore.

func ValidatedSpec

func ValidatedSpec(tomlString string) (job.Job, error)

ValidatedSpec validates and converts the given toml string to a job.Job.

Types

type BatchBHS

type BatchBHS interface {
	// GetBlockhashes returns blockhashes for given blockNumbers
	GetBlockhashes(ctx context.Context, blockNumbers []*big.Int) ([][32]byte, error)

	// StoreVerifyHeader stores blockhashes on-chain by using block headers
	StoreVerifyHeader(ctx context.Context, blockNumbers []*big.Int, blockHeaders [][]byte, fromAddress common.Address) error
}

BatchBHS defines an interface for interacting with a BatchBlockhashStore contract.

type BlockHeaderFeeder

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

BlockHeaderFeeder checks recent VRF coordinator events and stores any blockhashes for blocks within waitBlocks and lookbackBlocks that have unfulfilled requests.

func NewBlockHeaderFeeder

func NewBlockHeaderFeeder(
	logger logger.Logger,
	coordinator blockhashstore.Coordinator,
	bhs blockhashstore.BHS,
	batchBHS BatchBHS,
	blockHeaderProvider BlockHeaderProvider,
	waitBlocks int,
	lookbackBlocks int,
	latestBlock func(ctx context.Context) (uint64, error),
	gethks keystore.Eth,
	getBlockhashesBatchSize uint16,
	storeBlockhashesBatchSize uint16,
	fromAddresses []ethkey.EIP55Address,
	chainID *big.Int,
) *BlockHeaderFeeder

NewBlockHeaderFeeder creates a new BlockHeaderFeeder instance.

func (*BlockHeaderFeeder) Run

func (f *BlockHeaderFeeder) Run(ctx context.Context) error

Run the feeder.

type BlockHeaderProvider

type BlockHeaderProvider interface {
	RlpHeadersBatch(ctx context.Context, blockRange []*big.Int) ([][]byte, error)
}

type Client

type Client interface {
	BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
}

type Delegate

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

func NewDelegate

func NewDelegate(
	logger logger.Logger,
	chains evm.ChainSet,
	ks keystore.Eth,
) *Delegate

func (*Delegate) AfterJobCreated

func (d *Delegate) AfterJobCreated(spec job.Job)

AfterJobCreated satisfies the job.Delegate interface.

func (*Delegate) BeforeJobCreated

func (d *Delegate) BeforeJobCreated(spec job.Job)

func (*Delegate) BeforeJobDeleted

func (d *Delegate) BeforeJobDeleted(spec job.Job)

BeforeJobDeleted satisfies the job.Delegate interface.

func (*Delegate) JobType

func (d *Delegate) JobType() job.Type

JobType satisfies the job.Delegate interface.

func (*Delegate) OnDeleteJob

func (d *Delegate) OnDeleteJob(spec job.Job, q pg.Queryer) error

OnDeleteJob satisfies the job.Delegate interface.

func (*Delegate) ServicesForSpec

func (d *Delegate) ServicesForSpec(jb job.Job) ([]job.ServiceCtx, error)

ServicesForSpec satisfies the job.Delegate interface.

type GethBlockHeaderProvider

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

func NewGethBlockHeaderProvider

func NewGethBlockHeaderProvider(client Client) *GethBlockHeaderProvider

func (*GethBlockHeaderProvider) RlpHeadersBatch

func (p *GethBlockHeaderProvider) RlpHeadersBatch(ctx context.Context, blockRange []*big.Int) ([][]byte, error)

RlpHeadersBatch retrieves RLP-encoded block headers this function is not supported for Avax because Avalanche block header format is different from go-ethereum types.Header. validation for invalid chain ID is done upstream in blockheaderfeeder.validate.go

Jump to

Keyboard shortcuts

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