ocr2

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2025 License: MIT Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfigProvider

func NewConfigProvider(chainID *big.Int, contractAddress address.Address, readerClient reader.Reader, cfg Config, lggr logger.Logger) (*configProvider, error)

func NewContractCache

func NewContractCache(cfg Config, reader ContractReader, lggr logger.Logger) *contractCache

func NewMedianProvider

func NewMedianProvider(
	ctx context.Context,
	cfg Config,
	medianContract median.MedianContract,
	configProvider *configProvider,
	contractAddress address.Address,
	senderAddress address.Address,
	txm *txm.TronTxm,
	lggr logger.Logger,
) *medianProvider

func NewOCRContractTransmitter

func NewOCRContractTransmitter(
	ctx context.Context,
	transmissionsCache TransmissionsCache,
	contractAddress address.Address,
	senderAddress address.Address,
	txm *txm.TronTxm,
	lggr logger.Logger,
) *contractTransmitter

func NewPluginProvider

func NewPluginProvider(
	chainReader types.ContractReader,
	codec types.Codec,
	contractTransmitter ocrtypes.ContractTransmitter,
	configProvider types.ConfigProvider,
	lggr logger.Logger,
) *pluginProvider

func NewTransmissionsCache

func NewTransmissionsCache(cfg Config, reader median.MedianContract, lggr logger.Logger) *transmissionsCache

Types

type BillingDetails

type BillingDetails struct {
	ObservationPaymentGJuels  uint32
	TransmissionPaymentGJuels uint32
}

type Config

type Config interface {
	OCR2CachePollPeriod() time.Duration
	OCR2CacheTTL() time.Duration
}

type ContractConfig

type ContractConfig struct {
	Config      types.ContractConfig
	ConfigBlock uint64
}

type ContractConfigDetails

type ContractConfigDetails struct {
	Block  uint64
	Digest types.ConfigDigest
}

type ContractReader

type ContractReader interface {
	types.ContractConfigTracker
	median.MedianContract
}

ContractReader implements both the median.MedianContract and ocrtypes.ContractConfigTracker interfaces

func NewContractReader

func NewContractReader(address address.Address, reader OCR2Reader, lggr logger.Logger) ContractReader

type ContractTransmitter

type ContractTransmitter interface {
	services.Service
	ocrtypes.ContractTransmitter
}

type FeedsTransmissionsCache

type FeedsTransmissionsCache interface {
	TransmissionsCache
	LatestRoundRequested(ctx context.Context, lookback time.Duration) (types.ConfigDigest, uint32, uint8, error)
}

type NewTransmissionEvent

type NewTransmissionEvent struct {
	RoundId         uint32 //nolint:revive
	LatestAnswer    *big.Int
	Transmitter     *address.Address
	LatestTimestamp time.Time
	Observers       []uint8
	ObservationsLen uint32
	Observations    []*big.Int
	JuelsPerFeeCoin *big.Int
	GasPrice        *big.Int
	ConfigDigest    types.ConfigDigest
	Epoch           uint32
	Round           uint8
	Reimbursement   *big.Int
}

type OCR2Reader

type OCR2Reader interface {
	LatestConfigDetails(context.Context, tronaddress.Address) (ContractConfigDetails, error)
	LatestTransmissionDetails(context.Context, tronaddress.Address) (TransmissionDetails, error)
	LatestRoundData(context.Context, tronaddress.Address) (RoundData, error)
	LinkAvailableForPayment(context.Context, tronaddress.Address) (*big.Int, error)
	ConfigFromEventAt(context.Context, tronaddress.Address, uint64) (ContractConfig, error)
	// NewTransmissionsFromEventsAt(context.Context, tronaddress.Address, uint64) ([]NewTransmissionEvent, error) // is this needed?
	BillingDetails(context.Context, tronaddress.Address) (BillingDetails, error)

	BaseReader() reader.Reader
}

type OCR2ReaderClient

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

func NewOCR2Reader

func NewOCR2Reader(reader reader.Reader, lggr logger.Logger) *OCR2ReaderClient

func (*OCR2ReaderClient) BaseReader

func (c *OCR2ReaderClient) BaseReader() reader.Reader

func (*OCR2ReaderClient) BillingDetails

func (c *OCR2ReaderClient) BillingDetails(ctx context.Context, address tronaddress.Address) (BillingDetails, error)

func (*OCR2ReaderClient) ConfigFromEventAt

func (c *OCR2ReaderClient) ConfigFromEventAt(ctx context.Context, address tronaddress.Address, blockNum uint64) (ContractConfig, error)

func (*OCR2ReaderClient) LatestConfigDetails

func (c *OCR2ReaderClient) LatestConfigDetails(ctx context.Context, address tronaddress.Address) (ContractConfigDetails, error)

func (*OCR2ReaderClient) LatestRoundData

func (c *OCR2ReaderClient) LatestRoundData(ctx context.Context, address tronaddress.Address) (RoundData, error)

func (*OCR2ReaderClient) LatestTransmissionDetails

func (c *OCR2ReaderClient) LatestTransmissionDetails(ctx context.Context, address tronaddress.Address) (TransmissionDetails, error)

func (*OCR2ReaderClient) LinkAvailableForPayment

func (c *OCR2ReaderClient) LinkAvailableForPayment(ctx context.Context, address tronaddress.Address) (*big.Int, error)

type RoundData

type RoundData struct {
	RoundID   uint32
	Answer    *big.Int
	StartedAt time.Time
	UpdatedAt time.Time
}

type TRONOffchainConfigDigester

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

TRON offchain config digester.

This is different from the EVM config digester because we store TRON format addresses as transmitters, and because EVM expects the chain id to fit in a uint64: https://github.com/smartcontractkit/libocr/blob/063ceef8c42eeadbe94221e55b8892690d36099a/offchainreporting2plus/chains/evmutil/config_digest.go#L28

although the calculation onchain using `block.chainid` is a uint256: https://github.com/smartcontractkit/libocr/blob/063ceef8c42eeadbe94221e55b8892690d36099a/contract2/OCR2Abstract.sol#L72

`block.chainid` in the TVM, depending on config, can be the entire genesis block id, or the last 4 bytes. for the former, it does not fit in a uint64.

func NewOffchainConfigDigester

func NewOffchainConfigDigester(lggr logger.Logger, chainID *big.Int, contractAddress ethcommon.Address) (*TRONOffchainConfigDigester, error)

func (*TRONOffchainConfigDigester) ConfigDigest

func (*TRONOffchainConfigDigester) ConfigDigestPrefix

type Tracker

type Tracker interface {
	Start() error
	Close() error
	// contains filtered or unexported methods
}

type TransmissionDetails

type TransmissionDetails struct {
	Digest          types.ConfigDigest
	Epoch           uint32
	Round           uint8
	LatestAnswer    *big.Int
	LatestTimestamp time.Time
}

type TransmissionsCache

type TransmissionsCache interface {
	LatestTransmissionDetails(ctx context.Context) (types.ConfigDigest, uint32, uint8, *big.Int, time.Time, error)
}

Jump to

Keyboard shortcuts

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