v2

package
v2.4.1-scale-20230817 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 44 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

	V2ReservedLinkQuery = `` /* 257-byte string literal not displayed */

	V2PlusReservedLinkQuery = `` /* 269-byte string literal not displayed */

	V2PlusReservedEthQuery = `` /* 267-byte string literal not displayed */

	CouldNotDetermineIfLogConsumedMsg = "Could not determine if log was already consumed"
)
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 MaybeSubtractReservedEth

func MaybeSubtractReservedEth(q pg.Q, startBalance *big.Int, chainID uint64, subID *big.Int, vrfVersion vrfcommon.Version) (*big.Int, error)

MaybeSubtractReservedEth figures out how much ether is reserved for other VRF requests that have not been fully confirmed yet on-chain, and subtracts that from the given startBalance, and returns that value if there are no errors.

func MaybeSubtractReservedLink(q pg.Q, startBalance *big.Int, chainID uint64, subID *big.Int, vrfVersion vrfcommon.Version) (*big.Int, error)

MaybeSubtractReservedLink figures out how much LINK is reserved for other VRF requests that have not been fully confirmed yet on-chain, and subtracts that from the given startBalance, and returns that value if there are no errors.

func New

func New(
	cfg vrfcommon.Config,
	feeCfg vrfcommon.FeeConfig,
	l logger.Logger,
	ethClient evmclient.Client,
	chainID *big.Int,
	logBroadcaster log.Broadcaster,
	q pg.Q,
	coordinator CoordinatorV2_X,
	batchCoordinator batch_vrf_coordinator_v2.BatchVRFCoordinatorV2Interface,
	vrfOwner vrf_owner.VRFOwnerInterface,
	aggregator *aggregator_v3_interface.AggregatorV3Interface,
	txm txmgr.TxManager,
	pipelineRunner pipeline.Runner,
	gethks keystore.Eth,
	job job.Job,
	mailMon *utils.MailboxMonitor,
	reqLogs *utils.Mailbox[log.Broadcast],
	reqAdded func(),
	respCount map[string]uint64,
	headBroadcaster httypes.HeadBroadcasterRegistry,
	deduper *vrfcommon.LogDeduper,
) job.ServiceCtx

func ToV2PlusProofs

func ToV2PlusProofs(proofs []VRFProof) []vrf_coordinator_v2plus.VRFProof

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 NewV2PlusConfig

func NewV2PlusConfig(config vrf_coordinator_v2plus.SConfig) Config

type CoordinatorV2_X

type CoordinatorV2_X interface {
	Address() common.Address
	ParseRandomWordsRequested(log types.Log) (RandomWordsRequested, 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)
	FundSubscriptionWithEth(opts *bind.TransactOpts, subID *big.Int, amount *big.Int) (*types.Transaction, error)
}

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

type RandomWordsFulfilled

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

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 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
	EthBalance() *big.Int
	Owner() common.Address
	Consumers() []common.Address
	Version() vrfcommon.Version
}

type SubscriptionCreated

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

type VRFProof

type VRFProof struct {
	VRFVersion vrfcommon.Version
	V2         vrf_coordinator_v2.VRFProof
	V2Plus     vrf_coordinator_v2plus.VRFProof
}

func FromV2PlusProof

func FromV2PlusProof(proof vrf_coordinator_v2plus.VRFProof) VRFProof

func FromV2Proof

func FromV2Proof(proof vrf_coordinator_v2.VRFProof) VRFProof

Jump to

Keyboard shortcuts

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