Documentation ¶
Index ¶
- Constants
- Variables
- func CheckStateTransition(prev RequestState, next RequestState) error
- func NewFunctionsConnectorHandler(pluginConfig *config.PluginConfig, signerKey *ecdsa.PrivateKey, ...) (*functionsConnectorHandler, error)
- func NewFunctionsListener(job job.Job, client client.Client, contractAddressHex string, ...) *functionsListener
- type AggregationMethod
- type BridgeAccessor
- type DONHostedSecrets
- type ErrType
- type ExternalAdapterClient
- type FunctionsListener
- type HeartbeatResponse
- type ORM
- type OffchainRequest
- type OffchainResponse
- type OffchainTransmitter
- type Request
- type RequestData
- type RequestFlags
- type RequestID
- type RequestState
- type SignedRequestData
Constants ¶
const ( DefaultPruneMaxStoredRequests uint32 = 20_000 DefaultPruneCheckFrequencySec uint32 = 60 * 10 DefaultPruneBatchSize uint32 = 500 // Used in place of OnchainMetadata for all offchain requests. OffchainRequestMarker string = "OFFCHAIN_REQUEST" FlagCBORMaxSize uint32 = 1 FlagSecretsMaxSize uint32 = 2 )
const ( LocationInline = 0 LocationRemote = 1 LocationDONHosted = 2 LanguageJavaScript = 0 RequestStatePending = 1 RequestStateComplete = 2 RequestStateInternalError = 3 )
const HeartbeatCacheSize = 1000
const RequestIDLength int = 32
Variables ¶
var ErrDuplicateRequestID = errors.New("Functions ORM: duplicate request ID")
Functions ¶
func CheckStateTransition ¶
func CheckStateTransition(prev RequestState, next RequestState) error
* +-----------+ * +----+IN_PROGRESS+----------------+ * | +-----+-----+ | * | | | * | v v * | +------------+ +---------+ * | |RESULT_READY+---------->|TIMED_OUT| * | +------+-----+ +---------+ * | | ^ * | v | * | +---------+ | * +---->|FINALIZED|-----------------+ * +---------+ * * \ / * | * v * +---------+ * |CONFIRMED| * +---------+
func NewFunctionsConnectorHandler ¶ added in v2.3.0
func NewFunctionsConnectorHandler(pluginConfig *config.PluginConfig, signerKey *ecdsa.PrivateKey, storage s4.Storage, allowlist fallow.OnchainAllowlist, rateLimiter *hc.RateLimiter, subscriptions fsub.OnchainSubscriptions, listener FunctionsListener, offchainTransmitter OffchainTransmitter, lggr logger.Logger) (*functionsConnectorHandler, error)
func NewFunctionsListener ¶
func NewFunctionsListener( job job.Job, client client.Client, contractAddressHex string, bridgeAccessor BridgeAccessor, pluginORM ORM, pluginConfig config.PluginConfig, s4Storage s4.Storage, lggr logger.Logger, urlsMonEndpoint commontypes.MonitoringEndpoint, decryptor threshold.Decryptor, logPollerWrapper evmrelayTypes.LogPollerWrapper, ) *functionsListener
Types ¶
type AggregationMethod ¶ added in v2.4.0
type AggregationMethod int8
type BridgeAccessor ¶ added in v2.3.0
type BridgeAccessor interface {
NewExternalAdapterClient(context.Context) (ExternalAdapterClient, error)
}
func NewBridgeAccessor ¶ added in v2.3.0
type DONHostedSecrets ¶ added in v2.4.0
type ExternalAdapterClient ¶ added in v2.3.0
type ExternalAdapterClient interface { RunComputation( ctx context.Context, requestId string, jobName string, subscriptionOwner string, subscriptionId uint64, flags RequestFlags, nodeProvidedSecrets string, requestData *RequestData, ) (userResult, userError []byte, domains []string, err error) FetchEncryptedSecrets(ctx context.Context, encryptedSecretsUrls []byte, requestId string, jobName string) (encryptedSecrets, userError []byte, err error) }
ExternalAdapterClient supports two endpoints:
- Request (aka "lambda") for executing Functions requests via RunComputation()
- Secrets (aka "fetcher") for fetching offchain secrets via FetchEncryptedSecrets()
Both endpoints share the same response format. All methods are thread-safe.
func NewExternalAdapterClient ¶ added in v2.3.0
type FunctionsListener ¶
type FunctionsListener interface { job.ServiceCtx HandleOffchainRequest(ctx context.Context, request *OffchainRequest) error }
type HeartbeatResponse ¶ added in v2.8.0
type HeartbeatResponse struct { Status int `json:"status"` InternalError string `json:"internalError,omitempty"` ReceivedTs uint64 `json:"receivedTs"` CompletedTs uint64 `json:"completedTs"` Response *OffchainResponse `json:"response,omitempty"` }
type ORM ¶
type ORM interface { CreateRequest(ctx context.Context, request *Request) error SetResult(ctx context.Context, requestID RequestID, computationResult []byte, readyAt time.Time) error SetError(ctx context.Context, requestID RequestID, errorType ErrType, computationError []byte, readyAt time.Time, readyForProcessing bool) error SetFinalized(ctx context.Context, requestID RequestID, reportedResult []byte, reportedError []byte) error SetConfirmed(ctx context.Context, requestID RequestID) error TimeoutExpiredResults(ctx context.Context, cutoff time.Time, limit uint32) ([]RequestID, error) FindOldestEntriesByState(ctx context.Context, state RequestState, limit uint32) ([]Request, error) FindById(ctx context.Context, requestID RequestID) (*Request, error) PruneOldestRequests(ctx context.Context, maxRequestsInDB uint32, batchSize uint32) (total uint32, pruned uint32, err error) }
type OffchainRequest ¶ added in v2.8.0
type OffchainResponse ¶ added in v2.8.0
type OffchainResponse struct { RequestId []byte `json:"requestId"` Result []byte `json:"result,omitempty"` Error []byte `json:"error,omitempty"` }
NOTE: to be extended with raw report and signatures when needed
type OffchainTransmitter ¶ added in v2.8.0
type OffchainTransmitter interface { TransmitReport(ctx context.Context, report *OffchainResponse) error ReportChannel() chan *OffchainResponse }
Simple wrapper around a channel to transmit offchain reports between OCR plugin and Gateway connector
func NewOffchainTransmitter ¶ added in v2.8.0
func NewOffchainTransmitter(chanSize uint32) OffchainTransmitter
type Request ¶
type Request struct { RequestID RequestID ReceivedAt time.Time RequestTxHash *common.Hash State RequestState ResultReadyAt *time.Time Result []byte ErrorType *ErrType Error []byte TransmittedResult []byte TransmittedError []byte Flags []byte AggregationMethod *AggregationMethod CallbackGasLimit *uint32 CoordinatorContractAddress *common.Address OnchainMetadata []byte ProcessingMetadata []byte }
type RequestData ¶ added in v2.3.0
type RequestData struct { Source string `json:"source" cbor:"source"` Language int `json:"language" cbor:"language"` CodeLocation int `json:"codeLocation" cbor:"codeLocation"` Secrets []byte `json:"secrets,omitempty" cbor:"secrets"` SecretsLocation int `json:"secretsLocation" cbor:"secretsLocation"` Args []string `json:"args,omitempty" cbor:"args"` BytesArgs [][]byte `json:"bytesArgs,omitempty" cbor:"bytesArgs"` }
type RequestFlags ¶ added in v2.5.0
type RequestFlags [32]byte
type RequestID ¶
type RequestID [RequestIDLength]byte
func InternalId ¶ added in v2.8.0
internal request ID is a hash of (sender, requestID)
type RequestState ¶
type RequestState int8
const ( // IN_PROGRESS is the initial state of a request, set right after receiving it in an on-chain event. IN_PROGRESS RequestState = iota // RESULT_READY means that computation has finished executing (with either success or user error). // OCR2 reporting includes only requests in RESULT_READY state (for Query and Observation phases). RESULT_READY // TIMED_OUT request has been waiting to get confirmed on chain for too long. // It won't be included in OCR2 reporting rounds any more. TIMED_OUT // FINALIZED request is a part of a report produced by OCR2 and has now entered the transmission protocol // (i.e. passed through ShouldAcceptFinalizedReport()). FINALIZED // CONFIRMED state indicates that we received an on-chain confirmation event // (with or without this node's participation in an earlier OCR round). // We can transition here at any time (full fan-in) and cannot transition out (empty fan-out). // This is a desired and expected final state for every request. CONFIRMED )
func (RequestState) String ¶
func (s RequestState) String() string