l1

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TooManyRetries = errors.New("too many retries")
)

Functions

func LimitRPC

func LimitRPC(c client.RPC, concurrentRequests int) client.RPC

LimitRPC limits concurrent RPC requests (excluding subscriptions) to a given number by wrapping the client with a semaphore.

Types

type HeaderInfo

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

func (*HeaderInfo) BaseFee

func (info *HeaderInfo) BaseFee() *big.Int

func (*HeaderInfo) BlockRef

func (info *HeaderInfo) BlockRef() eth.L1BlockRef

func (*HeaderInfo) Hash

func (info *HeaderInfo) Hash() common.Hash

func (*HeaderInfo) ID

func (info *HeaderInfo) ID() eth.BlockID

func (*HeaderInfo) MixDigest

func (info *HeaderInfo) MixDigest() common.Hash

func (*HeaderInfo) NumberU64

func (info *HeaderInfo) NumberU64() uint64

func (*HeaderInfo) ParentHash

func (info *HeaderInfo) ParentHash() common.Hash

func (*HeaderInfo) ReceiptHash

func (info *HeaderInfo) ReceiptHash() common.Hash

func (*HeaderInfo) Root

func (info *HeaderInfo) Root() common.Hash

func (*HeaderInfo) Time

func (info *HeaderInfo) Time() uint64

type Source

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

Source to retrieve L1 data from with optimized batch requests, cached results, and flag to not trust the RPC.

func NewSource

func NewSource(client client.RPC, log log.Logger, metrics caching.Metrics, config *SourceConfig) (*Source, error)

NewSource wraps a RPC with bindings to fetch L1 data, while logging errors, tracking metrics (optional), and caching.

func (*Source) Close

func (s *Source) Close()

func (*Source) Fetch

func (s *Source) Fetch(ctx context.Context, blockHash common.Hash) (eth.L1Info, types.Transactions, types.Receipts, error)

func (*Source) FetchAllTransactions

func (s *Source) FetchAllTransactions(ctx context.Context, window []eth.BlockID) ([]types.Transactions, error)

FetchAllTransactions fetches transaction lists of a window of blocks, and caches each block and the transactions

func (*Source) InfoAndTxsByHash

func (s *Source) InfoAndTxsByHash(ctx context.Context, hash common.Hash) (eth.L1Info, types.Transactions, error)

func (*Source) InfoAndTxsByNumber

func (s *Source) InfoAndTxsByNumber(ctx context.Context, number uint64) (eth.L1Info, types.Transactions, error)

func (*Source) InfoAndTxsHead

func (s *Source) InfoAndTxsHead(ctx context.Context) (eth.L1Info, types.Transactions, error)

func (*Source) InfoByHash

func (s *Source) InfoByHash(ctx context.Context, hash common.Hash) (eth.L1Info, error)

func (*Source) InfoByNumber

func (s *Source) InfoByNumber(ctx context.Context, number uint64) (eth.L1Info, error)

func (*Source) InfoHead

func (s *Source) InfoHead(ctx context.Context) (eth.L1Info, error)

func (*Source) L1BlockRefByHash

func (s *Source) L1BlockRefByHash(ctx context.Context, hash common.Hash) (eth.L1BlockRef, error)

func (*Source) L1BlockRefByNumber

func (s *Source) L1BlockRefByNumber(ctx context.Context, l1Num uint64) (eth.L1BlockRef, error)

func (*Source) L1HeadBlockRef

func (s *Source) L1HeadBlockRef(ctx context.Context) (eth.L1BlockRef, error)

func (*Source) L1Range

func (s *Source) L1Range(ctx context.Context, begin eth.BlockID, max uint64) ([]eth.BlockID, error)

L1Range returns a range of L1 block beginning just after begin, up to max blocks. This batch-requests all blocks by number in the range at once, and then verifies the consistency

func (*Source) SubscribeNewHead

func (s *Source) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)

SubscribeNewHead subscribes to notifications about the current blockchain head on the given channel.

type SourceConfig

type SourceConfig struct {
	// batching parameters
	MaxParallelBatching int
	MaxBatchRetry       int
	MaxRequestsPerBatch int

	// limit concurrent requests, applies to the source as a whole
	MaxConcurrentRequests int

	// Number of blocks worth of receipts to cache
	ReceiptsCacheSize int
	// Number of blocks worth of transactions to cache
	TransactionsCacheSize int
	// Number of block headers to cache
	HeadersCacheSize int

	// If the RPC is untrusted, then we should not use cached information from responses,
	// and instead verify against the block-hash.
	// Of real L1 blocks no deposits can be missed/faked, no batches can be missed/faked,
	// only the wrong L1 blocks can be retrieved.
	TrustRPC bool
}

func DefaultConfig

func DefaultConfig(config *rollup.Config, trustRPC bool) *SourceConfig

func (*SourceConfig) Check

func (c *SourceConfig) Check() error

Jump to

Keyboard shortcuts

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