vrf

package
v2.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 47 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 needed to fulfill a request.

Variables

View Source
var (
	ErrKeyNotSet = errors.New("key not set")
)

Functions

func CheckFromAddressMaxGasPrices

func CheckFromAddressMaxGasPrices(jb job.Job, cfg Config) (err error)

CheckFromAddressMaxGasPrices checks if the provided gas price in the job spec gas lane parameter matches what is set for the provided from addresses. If they don't match, this is a configuration error. An error is returned with all the keys that do not match the provided gas lane price.

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 VRF spec's fromAddresses field does not exist in the keystore.

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 FromAddressMaxGasPricesAllEqual

func FromAddressMaxGasPricesAllEqual(jb job.Job, cfg Config) (allEqual bool)

FromAddressMaxGasPricesAllEqual returns true if and only if all the specified from addresses in the fromAddresses field of the VRF v2 job have the same key-specific max gas price.

func GetStartingResponseCountsV1

func GetStartingResponseCountsV1(q pg.Q, l logger.Logger, chainID uint64, evmFinalityDepth uint32) map[[32]byte]uint64

func GetStartingResponseCountsV2

func GetStartingResponseCountsV2(
	q pg.Q,
	l logger.Logger,
	chainID uint64,
	evmFinalityDepth uint32,
) map[string]uint64
func MaybeSubtractReservedLink(q pg.Q, startBalance *big.Int, chainID, subID uint64) (*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 VRFRandomnessRequestLogTopic

func VRFRandomnessRequestLogTopic() common.Hash

VRFRandomnessRequestLogTopic returns the signature of the RandomnessRequest log emitted by the VRFCoordinator contract

func ValidatedVRFSpec

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

Types

type Config

type Config interface {
	EvmFinalityDepth() uint32
	EvmGasLimitDefault() uint32
	EvmGasLimitVRFJobType() *uint32
	KeySpecificMaxGasPriceWei(addr common.Address) *assets.Wei
	MinIncomingConfirmations() uint32
}

type Delegate

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

func NewDelegate

func NewDelegate(
	db *sqlx.DB,
	ks keystore.Master,
	pr pipeline.Runner,
	porm pipeline.ORM,
	chainSet evm.ChainSet,
	lggr logger.Logger,
	cfg pg.QConfig,
	mailMon *utils.MailboxMonitor) *Delegate

func (*Delegate) AfterJobCreated

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

func (*Delegate) BeforeJobCreated

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

func (*Delegate) BeforeJobDeleted

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

func (*Delegate) JobType

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

func (*Delegate) OnDeleteJob

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

func (*Delegate) ServicesForSpec

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

ServicesForSpec satisfies the job.Delegate interface.

type GethKeyStore

type GethKeyStore interface {
	GetRoundRobinAddress(chainID *big.Int, addresses ...common.Address) (common.Address, error)
}

type RandomnessRequestLog

type RandomnessRequestLog struct {
	KeyHash   common.Hash
	Seed      *big.Int // uint256
	JobID     common.Hash
	Sender    common.Address
	Fee       *assets.Link // uint256
	RequestID common.Hash
	Raw       RawRandomnessRequestLog
}

RandomnessRequestLog contains the data for a RandomnessRequest log, represented as compatible golang types.

func ParseRandomnessRequestLog

func ParseRandomnessRequestLog(log types.Log) (*RandomnessRequestLog, error)

ParseRandomnessRequestLog returns the RandomnessRequestLog corresponding to the raw logData

func RawRandomnessRequestLogToRandomnessRequestLog

func RawRandomnessRequestLogToRandomnessRequestLog(
	l *RawRandomnessRequestLog) *RandomnessRequestLog

func (*RandomnessRequestLog) ComputedRequestID

func (l *RandomnessRequestLog) ComputedRequestID() common.Hash

func (*RandomnessRequestLog) Equal

Equal(ol) is true iff l is the same log as ol, and both represent valid RandomnessRequest logs.

func (*RandomnessRequestLog) RawData

func (l *RandomnessRequestLog) RawData() ([]byte, error)

RawData returns the raw bytes corresponding to l in a solidity log

This serialization does not include the JobID, because that's an indexed field.

type RawRandomnessRequestLog

RawRandomnessRequestLog is used to parse a RandomnessRequest log into types go-ethereum knows about.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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