Documentation ¶
Overview ¶
The blockhash store package provides a service that stores blockhashes such that they are available for on-chain proofs beyond the EVM 256 block limit.
Index ¶
- Variables
- func DecreasingBlockRange(start, end *big.Int) (ret []*big.Int, err error)
- func GetSearchWindow(latestBlock, waitBlocks, lookbackBlocks int) (uint64, uint64)
- func GetUnfulfilledBlocksAndRequests(ctx context.Context, lggr logger.Logger, coordinator Coordinator, ...) (map[uint64]map[string]struct{}, error)
- func LimitReqIDs(reqs map[string]struct{}, maxLength int) []string
- func SendingKeys(fromAddresses []ethkey.EIP55Address) []common.Address
- func ValidatedSpec(tomlString string) (job.Job, error)
- type BHS
- type BatchBlockhashStore
- type BulletproofBHS
- func (c *BulletproofBHS) IsStored(ctx context.Context, blockNum uint64) (bool, error)
- func (c *BulletproofBHS) IsTrusted() bool
- func (c *BulletproofBHS) Store(ctx context.Context, blockNum uint64) error
- func (c *BulletproofBHS) StoreEarliest(ctx context.Context) error
- func (c *BulletproofBHS) StoreTrusted(ctx context.Context, blockNums []uint64, blockhashes []common.Hash, ...) error
- type Coordinator
- type Delegate
- func (d *Delegate) AfterJobCreated(spec job.Job)
- func (d *Delegate) BeforeJobCreated(spec job.Job)
- func (d *Delegate) BeforeJobDeleted(spec job.Job)
- func (d *Delegate) JobType() job.Type
- func (d *Delegate) OnDeleteJob(spec job.Job, q pg.Queryer) error
- func (d *Delegate) ServicesForSpec(jb job.Job) ([]job.ServiceCtx, error)
- type Event
- type Feeder
- type MultiCoordinator
- type TestBHS
- func (t *TestBHS) IsStored(_ context.Context, blockNum uint64) (bool, error)
- func (t *TestBHS) IsTrusted() bool
- func (t *TestBHS) Store(_ context.Context, blockNum uint64) error
- func (t *TestBHS) StoreEarliest(ctx context.Context) error
- func (t *TestBHS) StoreTrusted(ctx context.Context, blockNums []uint64, blockhashes []common.Hash, ...) error
- type TestBatchBHS
- type TestBlockHeaderProvider
- type TestCoordinator
- type Timer
- type V2Coordinator
Constants ¶
This section is empty.
Variables ¶
var EmptyAddress = utils.ZeroAddress.Hex()
Functions ¶
func DecreasingBlockRange ¶
DecreasingBlockRange creates a contiguous block range starting with block `start` (inclusive) and ending at block `end` (inclusive).
func GetSearchWindow ¶
GetSearchWindow returns the search window (fromBlock, toBlock) given the latest block number, wait blocks and lookback blocks
func LimitReqIDs ¶
LimitReqIDs converts a set of request IDs to a slice limited to maxLength.
func SendingKeys ¶
func SendingKeys(fromAddresses []ethkey.EIP55Address) []common.Address
SendingKeys returns a list of sending keys (common.Address) given EIP55 addresses
Types ¶
type BHS ¶
type BHS interface { // Store the hash associated with blockNum. Store(ctx context.Context, blockNum uint64) error // IsStored checks whether the hash associated with blockNum is already stored. IsStored(ctx context.Context, blockNum uint64) (bool, error) // StoreEarliest stores the earliest possible blockhash (i.e. block.number - 256) StoreEarliest(ctx context.Context) error IsTrusted() bool StoreTrusted(ctx context.Context, blockNums []uint64, blockhashes []common.Hash, recentBlock uint64, recentBlockhash common.Hash) error }
BHS defines an interface for interacting with a BlockhashStore contract.
type BatchBlockhashStore ¶
type BatchBlockhashStore struct {
// contains filtered or unexported fields
}
func NewBatchBHS ¶
func NewBatchBHS( config batchBHSConfig, fromAddresses []ethkey.EIP55Address, txm txmgr.TxManager, batchbhs batch_blockhash_store.BatchBlockhashStoreInterface, chainID *big.Int, gethks keystore.Eth, lggr logger.Logger, ) (*BatchBlockhashStore, error)
func (*BatchBlockhashStore) GetBlockhashes ¶
type BulletproofBHS ¶
type BulletproofBHS struct {
// contains filtered or unexported fields
}
BulletproofBHS is an implementation of BHS that writes "store" transactions to a bulletproof transaction manager, and reads BlockhashStore state from the contract.
func NewBulletproofBHS ¶
func NewBulletproofBHS( config bpBHSConfig, dbConfig bpBHSDatabaseConfig, fromAddresses []ethkey.EIP55Address, txm txmgr.TxManager, bhs blockhash_store.BlockhashStoreInterface, trustedBHS *trusted_blockhash_store.TrustedBlockhashStore, chainID *big.Int, gethks keystore.Eth, ) (*BulletproofBHS, error)
NewBulletproofBHS creates a new instance with the given transaction manager and blockhash store.
func (*BulletproofBHS) IsTrusted ¶
func (c *BulletproofBHS) IsTrusted() bool
func (*BulletproofBHS) Store ¶
func (c *BulletproofBHS) Store(ctx context.Context, blockNum uint64) error
Store satisfies the BHS interface.
func (*BulletproofBHS) StoreEarliest ¶
func (c *BulletproofBHS) StoreEarliest(ctx context.Context) error
type Coordinator ¶
type Coordinator interface { // Requests fetches VRF requests that occurred within the specified blocks. Requests(ctx context.Context, fromBlock uint64, toBlock uint64) ([]Event, error) // Fulfillments fetches VRF fulfillments that occurred since the specified block. Fulfillments(ctx context.Context, fromBlock uint64) ([]Event, error) }
Coordinator defines an interface for fetching request and fulfillment metadata from a VRF coordinator.
func NewMultiCoordinator ¶
func NewMultiCoordinator(coordinators ...Coordinator) Coordinator
NewMultiCoordinator creates a new Coordinator that combines the results of the given coordinators.
type Delegate ¶
type Delegate struct {
// contains filtered or unexported fields
}
Delegate creates BlockhashStore feeder jobs.
func NewDelegate ¶
func NewDelegate( logger logger.Logger, legacyChains legacyevm.LegacyChainContainer, ks keystore.Eth, ) *Delegate
NewDelegate creates a new Delegate.
func (*Delegate) AfterJobCreated ¶
AfterJobCreated satisfies the job.Delegate interface.
func (*Delegate) BeforeJobCreated ¶
AfterJobCreated satisfies the job.Delegate interface.
func (*Delegate) BeforeJobDeleted ¶
AfterJobCreated satisfies the job.Delegate interface.
func (*Delegate) OnDeleteJob ¶
OnDeleteJob satisfies the job.Delegate interface.
func (*Delegate) ServicesForSpec ¶
ServicesForSpec satisfies the job.Delegate interface.
type Event ¶
type Event struct { // ID of the relevant VRF request. For a VRF V1 request, this will an encoded 32 byte array. // For VRF V2, it will be an integer in string form. ID string // Block that the request or fulfillment was included in. Block uint64 }
Event contains metadata about a VRF randomness request or fulfillment.
type Feeder ¶
type Feeder struct {
// contains filtered or unexported fields
}
Feeder checks recent VRF coordinator events and stores any blockhashes for blocks within waitBlocks and lookbackBlocks that have unfulfilled requests.
func NewFeeder ¶
func NewFeeder( logger logger.Logger, coordinator Coordinator, bhs BHS, lp logpoller.LogPoller, trustedBHSBatchSize int32, waitBlocks int, lookbackBlocks int, heartbeatPeriod time.Duration, latestBlock func(ctx context.Context) (uint64, error), ) *Feeder
NewFeeder creates a new Feeder instance.
type MultiCoordinator ¶
type MultiCoordinator []Coordinator
MultiCoordinator combines the data from multiple coordinators.
func (MultiCoordinator) Fulfillments ¶
Fulfillments satisfies the Coordinator interface.
type TestBHS ¶
type TestBHS struct { Stored []uint64 StoredEarliest bool // errorsStore defines which block numbers should return errors on Store. ErrorsStore []uint64 // errorsIsStored defines which block numbers should return errors on IsStored. ErrorsIsStored []uint64 }
type TestBatchBHS ¶
type TestBatchBHS struct { Stored []uint64 GetBlockhashesCallCounter uint16 StoreVerifyHeaderCallCounter uint16 GetBlockhashesError error StoreVerifyHeadersError error }
func (*TestBatchBHS) GetBlockhashes ¶
type TestBlockHeaderProvider ¶
type TestBlockHeaderProvider struct { }
func (*TestBlockHeaderProvider) RlpHeadersBatch ¶
type TestCoordinator ¶
func (*TestCoordinator) Addresses ¶
func (t *TestCoordinator) Addresses() []common.Address
func (*TestCoordinator) Fulfillments ¶
type V2Coordinator ¶
type V2Coordinator struct {
// contains filtered or unexported fields
}
V2Coordinator fetches request and fulfillment logs from a VRF V2 coordinator contract.
func NewV2Coordinator ¶
func NewV2Coordinator(c v2.VRFCoordinatorV2Interface, lp logpoller.LogPoller) (*V2Coordinator, error)
NewV2Coordinator creates a new V2Coordinator from the given contract.
func (*V2Coordinator) Fulfillments ¶
Fulfillments satisfies the Coordinator interface.