v2

package
v2.8.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GasAfterPaymentCalculation is the gas used after computing the payment
	GasAfterPaymentCalculation = 21000 +
		100 + 5000 +
		2*2100 + 20000 -
		4800 +
		6685 // Positive static costs of argument encoding etc. note that it varies by +/- x*12 for every x bytes of non-zero data in the proof.

	// BatchFulfillmentIterationGasCost is the cost of a single iteration of the batch coordinator's
	// loop. This is used to determine the gas allowance for a batch fulfillment call.
	BatchFulfillmentIterationGasCost = 52_000
)
View Source
const GasProofVerification uint32 = 200_000

GasProofVerification is an upper limit on the gas used for verifying the VRF proof on-chain. It can be used to estimate the amount of LINK or native needed to fulfill a request.

Variables

This section is empty.

Functions

func EstimateFeeJuels

func EstimateFeeJuels(callbackGasLimit uint32, maxGasPriceWei, weiPerUnitLink *big.Int) (*big.Int, error)

EstimateFeeJuels estimates the amount of link needed to fulfill a request given the callback gas limit, the gas price, and the wei per unit link. An error is returned if the wei per unit link provided is zero.

func EstimateFeeWei

func EstimateFeeWei(callbackGasLimit uint32, maxGasPriceWei *big.Int) (*big.Int, error)

EstimateFeeWei estimates the amount of wei needed to fulfill a request

func New

func New(
	cfg vrfcommon.Config,
	feeCfg vrfcommon.FeeConfig,
	l logger.Logger,
	chain legacyevm.Chain,
	chainID *big.Int,
	q pg.Q,
	coordinator CoordinatorV2_X,
	batchCoordinator batch_vrf_coordinator_v2.BatchVRFCoordinatorV2Interface,
	vrfOwner vrf_owner.VRFOwnerInterface,
	aggregator *aggregator_v3_interface.AggregatorV3Interface,
	pipelineRunner pipeline.Runner,
	gethks keystore.Eth,
	job job.Job,
	reqAdded func(),
	inflightCache vrfcommon.InflightCache,
	fulfillmentDeduper *vrfcommon.LogDeduper,
) job.ServiceCtx

func ToV2Proofs

func ToV2Proofs(proofs []VRFProof) []vrf_coordinator_v2.VRFProof

Types

type Config

type Config interface {
	MinimumRequestConfirmations() uint16
	MaxGasLimit() uint32
	GasAfterPaymentCalculation() uint32
	StalenessSeconds() uint32
}

func NewV2Config

func NewV2Config(config vrf_coordinator_v2.GetConfig) Config

func NewV2_5Config added in v2.6.0

func NewV2_5Config(config vrf_coordinator_v2_5.SConfig) Config

type CoordinatorV2_X

type CoordinatorV2_X interface {
	Address() common.Address
	ParseRandomWordsRequested(log types.Log) (RandomWordsRequested, error)
	ParseRandomWordsFulfilled(log types.Log) (RandomWordsFulfilled, error)
	RequestRandomWords(opts *bind.TransactOpts, keyHash [32]byte, subID *big.Int, requestConfirmations uint16, callbackGasLimit uint32, numWords uint32, payInEth bool) (*types.Transaction, error)
	AddConsumer(opts *bind.TransactOpts, subID *big.Int, consumer common.Address) (*types.Transaction, error)
	CreateSubscription(opts *bind.TransactOpts) (*types.Transaction, error)
	GetSubscription(opts *bind.CallOpts, subID *big.Int) (Subscription, error)
	GetConfig(opts *bind.CallOpts) (Config, error)
	ParseLog(log types.Log) (generated.AbigenLog, error)
	OracleWithdraw(opts *bind.TransactOpts, recipient common.Address, amount *big.Int) (*types.Transaction, error)
	LogsWithTopics(keyHash common.Hash) map[common.Hash][][]log.Topic
	Version() vrfcommon.Version
	RegisterProvingKey(opts *bind.TransactOpts, oracle common.Address, publicProvingKey [2]*big.Int) (*types.Transaction, error)
	FilterSubscriptionCreated(opts *bind.FilterOpts, subID []*big.Int) (SubscriptionCreatedIterator, error)
	FilterRandomWordsRequested(opts *bind.FilterOpts, keyHash [][32]byte, subID []*big.Int, sender []common.Address) (RandomWordsRequestedIterator, error)
	FilterRandomWordsFulfilled(opts *bind.FilterOpts, requestID []*big.Int, subID []*big.Int) (RandomWordsFulfilledIterator, error)
	TransferOwnership(opts *bind.TransactOpts, to common.Address) (*types.Transaction, error)
	RemoveConsumer(opts *bind.TransactOpts, subID *big.Int, consumer common.Address) (*types.Transaction, error)
	CancelSubscription(opts *bind.TransactOpts, subID *big.Int, to common.Address) (*types.Transaction, error)
	GetCommitment(opts *bind.CallOpts, requestID *big.Int) ([32]byte, error)
	Migrate(opts *bind.TransactOpts, subID *big.Int, newCoordinator common.Address) (*types.Transaction, error)
	FundSubscriptionWithNative(opts *bind.TransactOpts, subID *big.Int, amount *big.Int) (*types.Transaction, error)
	// RandomWordsRequestedTopic returns the log topic of the RandomWordsRequested log
	RandomWordsRequestedTopic() common.Hash
	// RandomWordsFulfilledTopic returns the log topic of the RandomWordsFulfilled log
	RandomWordsFulfilledTopic() common.Hash
}

CoordinatorV2_X is an interface that allows us to use the same code for both the V2 and V2Plus coordinators.

func NewCoordinatorV2_5 added in v2.6.0

type RandomWordsFulfilled

type RandomWordsFulfilled interface {
	RequestID() *big.Int
	Success() bool
	SubID() *big.Int
	Payment() *big.Int
	Raw() types.Log
}

type RandomWordsFulfilledIterator

type RandomWordsFulfilledIterator interface {
	Next() bool
	Error() error
	Close() error
	Event() RandomWordsFulfilled
}

type RandomWordsRequested

type RandomWordsRequested interface {
	Raw() types.Log
	NumWords() uint32
	SubID() *big.Int
	MinimumRequestConfirmations() uint16
	KeyHash() [32]byte
	RequestID() *big.Int
	PreSeed() *big.Int
	Sender() common.Address
	CallbackGasLimit() uint32
	NativePayment() bool
}

type RandomWordsRequestedIterator

type RandomWordsRequestedIterator interface {
	Next() bool
	Error() error
	Close() error
	Event() RandomWordsRequested
}

type RequestCommitment

func NewRequestCommitment

func NewRequestCommitment(val any) RequestCommitment

func (*RequestCommitment) BlockNum

func (r *RequestCommitment) BlockNum() uint64

func (*RequestCommitment) CallbackGasLimit

func (r *RequestCommitment) CallbackGasLimit() uint32

func (*RequestCommitment) Get

func (r *RequestCommitment) Get() any

func (*RequestCommitment) NativePayment

func (r *RequestCommitment) NativePayment() bool

func (*RequestCommitment) NumWords

func (r *RequestCommitment) NumWords() uint32

func (*RequestCommitment) Sender

func (r *RequestCommitment) Sender() common.Address

func (*RequestCommitment) SubID

func (r *RequestCommitment) SubID() *big.Int

type Subscription

type Subscription interface {
	Balance() *big.Int
	NativeBalance() *big.Int
	Owner() common.Address
	Consumers() []common.Address
	Version() vrfcommon.Version
}

func NewV2_5Subscription added in v2.6.0

func NewV2_5Subscription(event vrf_coordinator_v2_5.GetSubscription) Subscription

type SubscriptionCreated

type SubscriptionCreated interface {
	Owner() common.Address
	SubID() *big.Int
}

type SubscriptionCreatedIterator

type SubscriptionCreatedIterator interface {
	Next() bool
	Error() error
	Close() error
	Event() SubscriptionCreated
}

Jump to

Keyboard shortcuts

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