Documentation
¶
Index ¶
- Constants
- Variables
- func NewORM(db *gorm.DB) *orm
- func ValidatedFluxMonitorSpec(config *coreorm.Config, ts string) (job.Job, error)
- type Config
- type ContractSubmitter
- type Delegate
- type DeviationChecker
- type DeviationThresholds
- type Flags
- type FluxAggregatorContractSubmitter
- type FluxMonitor
- func (fm *FluxMonitor) Close() error
- func (fm *FluxMonitor) HandleLog(broadcast log.Broadcast)
- func (fm *FluxMonitor) IsV2Job() bool
- func (fm *FluxMonitor) JobID() models.JobID
- func (fm *FluxMonitor) JobIDV2() int32
- func (fm *FluxMonitor) OnConnect()
- func (fm *FluxMonitor) OnDisconnect()
- func (fm *FluxMonitor) SetOracleAddress() error
- func (fm *FluxMonitor) Start() error
- type FluxMonitorRoundStatsV2
- type IdleTimer
- type KeyStore
- type KeyStoreInterface
- type ORM
- type PaymentChecker
- type PipelineRun
- type PollTicker
- type SubmissionChecker
Constants ¶
const ( PriorityFlagChangedLog uint = 0 PriorityNewRoundLog uint = 1 PriorityAnswerUpdatedLog uint = 2 )
const MinFundedRounds int64 = 3
MinFundedRounds defines the minimum number of rounds that needs to be paid to oracles on a contract
Variables ¶
var ( // ErrNotEligible defines when the round is not eligible for submission ErrNotEligible = errors.New("not eligible to submit") // ErrUnderfunded defines when the aggregator does not have sufficient funds ErrUnderfunded = errors.New("aggregator is underfunded") // ErrPaymentTooLow defines when the round payment is too low ErrPaymentTooLow = errors.New("round payment amount < minimum contract payment") )
var FluxAggregatorABI = eth.MustGetABI(flux_aggregator_wrapper.FluxAggregatorABI)
FluxAggregatorABI initializes the Flux Aggregator ABI
Functions ¶
Types ¶
type Config ¶ added in v0.10.3
type Config struct {
DefaultHTTPTimeout time.Duration
FlagsContractAddress string
MinContractPayment *assets.Link
EthGasLimit uint64
MaxUnconfirmedTransactions uint64
}
Config defines the Flux Monitor configuration.
func (*Config) MinimumPollingInterval ¶ added in v0.10.3
MinimumPollingInterval returns the minimum duration between polling ticks
type ContractSubmitter ¶ added in v0.10.3
ContractSubmitter defines an interface to submit an eth tx.
type Delegate ¶ added in v0.9.10
type Delegate struct {
// contains filtered or unexported fields
}
Delegate represents a Flux Monitor delegate
func NewDelegate ¶ added in v0.9.10
func NewDelegate( store *corestore.Store, jobORM job.ORM, pipelineORM pipeline.ORM, pipelineRunner pipeline.Runner, db *gorm.DB, ethClient eth.Client, logBroadcaster log.Broadcaster, cfg Config, ) *Delegate
NewDelegate constructs a new delegate
type DeviationChecker ¶ added in v0.10.3
type DeviationChecker struct {
Thresholds DeviationThresholds
}
DeviationChecker checks the deviation of the next answer against the current answer.
func NewDeviationChecker ¶ added in v0.10.3
func NewDeviationChecker(rel, abs float64) *DeviationChecker
NewDeviationChecker constructs a new deviation checker with thresholds.
func NewZeroDeviationChecker ¶ added in v0.10.3
func NewZeroDeviationChecker() *DeviationChecker
NewZeroDeviationChecker constructs a new deviation checker with 0 as thresholds.
func (*DeviationChecker) OutsideDeviation ¶ added in v0.10.3
func (c *DeviationChecker) OutsideDeviation(curAnswer, nextAnswer decimal.Decimal) bool
OutsideDeviation checks whether the next price is outside the threshold. If both thresholds are zero (default value), always returns true.
type DeviationThresholds ¶ added in v0.10.3
type DeviationThresholds struct {
Rel float64 // Relative change required, i.e. |new-old|/|old| >= Rel
Abs float64 // Absolute change required, i.e. |new-old| >= Abs
}
DeviationThresholds carries parameters used by the threshold-trigger logic
type Flags ¶ added in v0.10.3
type Flags struct {
flags_wrapper.FlagsInterface
}
Flags wraps the a contract
func (*Flags) Contract ¶ added in v0.10.3
func (f *Flags) Contract() flags_wrapper.FlagsInterface
Contract returns the flags contract
func (*Flags) ContractExists ¶ added in v0.10.3
ContractExists returns whether a flag contract exists
type FluxAggregatorContractSubmitter ¶ added in v0.10.3
type FluxAggregatorContractSubmitter struct {
flux_aggregator_wrapper.FluxAggregatorInterface
// contains filtered or unexported fields
}
FluxAggregatorContractSubmitter submits the polled answer in an eth tx.
func NewFluxAggregatorContractSubmitter ¶ added in v0.10.3
func NewFluxAggregatorContractSubmitter( contract flux_aggregator_wrapper.FluxAggregatorInterface, orm ORM, keyStore KeyStoreInterface, gasLimit uint64, maxUnconfirmedTransactions uint64, ) *FluxAggregatorContractSubmitter
NewFluxAggregatorContractSubmitter constructs a new NewFluxAggregatorContractSubmitter
type FluxMonitor ¶ added in v0.10.3
type FluxMonitor struct {
// contains filtered or unexported fields
}
FluxMonitor polls external price adapters via HTTP to check for price swings.
func NewFluxMonitor ¶ added in v0.10.3
func NewFluxMonitor( jobID int32, pipelineRun PipelineRun, orm ORM, jobORM job.ORM, pipelineORM pipeline.ORM, keyStore KeyStoreInterface, pollTicker *PollTicker, idleTimer *IdleTimer, paymentChecker *PaymentChecker, contractAddress common.Address, contractSubmitter ContractSubmitter, deviationChecker *DeviationChecker, submissionChecker *SubmissionChecker, flags Flags, fluxAggregator flux_aggregator_wrapper.FluxAggregatorInterface, logBroadcaster log.Broadcaster, precision int32, readyForLogs func(), fmLogger *logger.Logger, ) (*FluxMonitor, error)
NewFluxMonitor returns a new instance of PollingDeviationChecker.
func NewFromJobSpec ¶ added in v0.10.3
func NewFromJobSpec( jobSpec job.Job, orm ORM, jobORM job.ORM, pipelineORM pipeline.ORM, keyStore KeyStoreInterface, ethClient eth.Client, logBroadcaster log.Broadcaster, pipelineRunner pipeline.Runner, cfg Config, ) (*FluxMonitor, error)
NewFromJobSpec constructs an instance of FluxMonitor with sane defaults and validation.
func (*FluxMonitor) Close ¶ added in v0.10.3
func (fm *FluxMonitor) Close() error
Close implements the job.Service interface. It stops this instance from polling, cleaning up resources.
func (*FluxMonitor) HandleLog ¶ added in v0.10.3
func (fm *FluxMonitor) HandleLog(broadcast log.Broadcast)
HandleLog processes the contract logs
func (*FluxMonitor) IsV2Job ¶ added in v0.10.3
func (fm *FluxMonitor) IsV2Job() bool
IsV2Job implements the listener.Listener interface.
Returns true as this is a v2 job
func (*FluxMonitor) JobID ¶ added in v0.10.3
func (fm *FluxMonitor) JobID() models.JobID
JobID implements the listener.Listener interface.
Since we don't have a v1 ID, we return a new v1 job id to satisfy the interface. This should not cause a problem as the log broadcaster will check if it is a v2 job before attempting to use this job id
func (*FluxMonitor) JobIDV2 ¶ added in v0.10.3
func (fm *FluxMonitor) JobIDV2() int32
JobIDV2 implements the listener.Listener interface.
Returns the v2 job id
func (*FluxMonitor) OnConnect ¶ added in v0.10.3
func (fm *FluxMonitor) OnConnect()
OnConnect sets the poller as connected
func (*FluxMonitor) OnDisconnect ¶ added in v0.10.3
func (fm *FluxMonitor) OnDisconnect()
OnDisconnect sets the poller as disconnected
func (*FluxMonitor) SetOracleAddress ¶ added in v0.10.3
func (fm *FluxMonitor) SetOracleAddress() error
SetOracleAddress sets the oracle address which matches the node's keys. If none match, it uses the first available key
func (*FluxMonitor) Start ¶ added in v0.10.3
func (fm *FluxMonitor) Start() error
Start implements the job.Service interface. It begins the CSP consumer in a single goroutine to poll the price adapters and listen to NewRound events.
type FluxMonitorRoundStatsV2 ¶ added in v0.10.3
type FluxMonitorRoundStatsV2 struct {
ID uint64 `gorm:"primary key;not null;auto_increment"`
PipelineRunID null.Int64 `gorm:"default:null"`
Aggregator common.Address `gorm:"not null"`
RoundID uint32 `gorm:"not null"`
NumNewRoundLogs uint64 `gorm:"not null;default 0"`
NumSubmissions uint64 `gorm:"not null;default 0"`
}
FluxMonitorRoundStatsV2 defines the stats for a round
type IdleTimer ¶ added in v0.10.3
type IdleTimer struct {
// contains filtered or unexported fields
}
IdleTimer defines a ResettableTimer which can be disabled
func NewIdleTimer ¶ added in v0.10.3
NewIdleTimer constructs a new IdleTimer
func (*IdleTimer) IsDisabled ¶ added in v0.10.3
IsDisabled determines if the timer is disabled
type KeyStore ¶ added in v0.10.3
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore implements KeyStoreInterface
func NewKeyStore ¶ added in v0.10.3
NewKeyStore initializes a new keystore
type KeyStoreInterface ¶ added in v0.10.3
type KeyStoreInterface interface {
Accounts() []accounts.Account
GetRoundRobinAddress() (common.Address, error)
}
KeyStoreInterface defines an interface to interact with the keystore
type ORM ¶ added in v0.10.3
type ORM interface {
MostRecentFluxMonitorRoundID(aggregator common.Address) (uint32, error)
DeleteFluxMonitorRoundsBackThrough(aggregator common.Address, roundID uint32) error
FindOrCreateFluxMonitorRoundStats(aggregator common.Address, roundID uint32) (FluxMonitorRoundStatsV2, error)
UpdateFluxMonitorRoundStats(aggregator common.Address, roundID uint32, runID int64) error
CreateEthTransaction(fromAddress, toAddress common.Address, payload []byte, gasLimit uint64, maxUnconfirmedTransactions uint64) error
}
ORM defines an interface for database commands related to Flux Monitor v2
type PaymentChecker ¶ added in v0.10.3
type PaymentChecker struct {
// The minimum amount for a payment set in the ENV Var
MinContractPayment *assets.Link
// The minimum amount for a payment set in the job
MinJobPayment *assets.Link
}
PaymentChecker provides helper functions to check whether payments are valid
func NewPaymentChecker ¶ added in v0.10.3
func NewPaymentChecker(minContractPayment, minJobPayment *assets.Link) *PaymentChecker
NewPaymentChecker constructs a new payment checker
func (*PaymentChecker) SufficientFunds ¶ added in v0.10.3
func (c *PaymentChecker) SufficientFunds(availableFunds *big.Int, paymentAmount *big.Int, oracleCount uint8) bool
SufficientFunds checks if the contract has sufficient funding to pay all the oracles on a contract for a minimum number of rounds, based on the payment amount in the contract
func (*PaymentChecker) SufficientPayment ¶ added in v0.10.3
func (c *PaymentChecker) SufficientPayment(payment *big.Int) bool
SufficientPayment checks if the available payment is enough to submit an answer. It compares the payment amount on chain with the min payment amount listed in the job / ENV var.
type PipelineRun ¶ added in v0.10.3
type PipelineRun struct {
// contains filtered or unexported fields
}
PipelineRun wraps a the pipeline to execute a single pipeline run
func NewPipelineRun ¶ added in v0.10.3
func NewPipelineRun( runner pipeline.Runner, spec pipeline.Spec, jobID int32, logger logger.Logger, ) PipelineRun
NewPipelineRun constructs a new PipelineRun
type PollTicker ¶ added in v0.10.3
type PollTicker struct {
// contains filtered or unexported fields
}
PollTicker defines a PausableTicker which can be disabled
func NewPollTicker ¶ added in v0.10.3
func NewPollTicker(interval time.Duration, disabled bool) *PollTicker
NewPollTicker constructs a new PollTicker
func (*PollTicker) Interval ¶ added in v0.10.3
func (t *PollTicker) Interval() time.Duration
Interval gets the ticker interval
func (*PollTicker) IsDisabled ¶ added in v0.10.3
func (t *PollTicker) IsDisabled() bool
IsDisabled determines if the picker is disabled
func (*PollTicker) IsEnabled ¶ added in v0.10.3
func (t *PollTicker) IsEnabled() bool
IsEnabled determines if the picker is enabled
func (*PollTicker) Resume ¶ added in v0.10.3
func (t *PollTicker) Resume()
Resume resumes the ticker if it is enabled
func (*PollTicker) Stop ¶ added in v0.10.3
func (t *PollTicker) Stop()
Stop stops the ticker permanently
func (*PollTicker) Ticks ¶ added in v0.10.3
func (t *PollTicker) Ticks() <-chan time.Time
Ticks ticks on a given interval
type SubmissionChecker ¶ added in v0.10.3
SubmissionChecker checks whether an answer is inside the allowable range.
func NewSubmissionChecker ¶ added in v0.10.3
NewSubmissionChecker initializes a new SubmissionChecker