Documentation
¶
Index ¶
- Constants
- Variables
- func New(data code_data.Provider, scheduler Scheduler, ...) async.Service
- type ActionHandler
- func NewCloseEmptyAccountActionHandler(data code_data.Provider) ActionHandler
- func NewNoPrivacyTransferActionHandler(data code_data.Provider) ActionHandler
- func NewNoPrivacyWithdrawActionHandler(data code_data.Provider) ActionHandler
- func NewOpenAccountActionHandler(data code_data.Provider) ActionHandler
- type CloseEmptyAccountActionHandler
- type CloseEmptyTimelockAccountFulfillmentHandler
- func (h *CloseEmptyTimelockAccountFulfillmentHandler) CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error)
- func (h *CloseEmptyTimelockAccountFulfillmentHandler) IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error)
- func (h *CloseEmptyTimelockAccountFulfillmentHandler) MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) (*solana.Transaction, error)
- func (h *CloseEmptyTimelockAccountFulfillmentHandler) OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) (recovered bool, err error)
- func (h *CloseEmptyTimelockAccountFulfillmentHandler) OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) error
- func (h *CloseEmptyTimelockAccountFulfillmentHandler) SupportsOnDemandTransactions() bool
- type ConfigProvider
- type FulfillmentHandler
- func NewCloseEmptyTimelockAccountFulfillmentHandler(data code_data.Provider, vmIndexerClient indexerpb.IndexerClient) FulfillmentHandler
- func NewInitializeLockedTimelockAccountFulfillmentHandler(data code_data.Provider) FulfillmentHandler
- func NewNoPrivacyTransferWithAuthorityFulfillmentHandler(data code_data.Provider, vmIndexerClient indexerpb.IndexerClient) FulfillmentHandler
- func NewNoPrivacyWithdrawFulfillmentHandler(data code_data.Provider, vmIndexerClient indexerpb.IndexerClient) FulfillmentHandler
- type InitializeLockedTimelockAccountFulfillmentHandler
- func (h *InitializeLockedTimelockAccountFulfillmentHandler) CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error)
- func (h *InitializeLockedTimelockAccountFulfillmentHandler) IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error)
- func (h *InitializeLockedTimelockAccountFulfillmentHandler) MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) (*solana.Transaction, error)
- func (h *InitializeLockedTimelockAccountFulfillmentHandler) OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) (recovered bool, err error)
- func (h *InitializeLockedTimelockAccountFulfillmentHandler) OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) error
- func (h *InitializeLockedTimelockAccountFulfillmentHandler) SupportsOnDemandTransactions() bool
- type IntentHandler
- type NoPrivacyTransferActionHandler
- type NoPrivacyTransferWithAuthorityFulfillmentHandler
- func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error)
- func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error)
- func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) (*solana.Transaction, error)
- func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) (recovered bool, err error)
- func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) error
- func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) SupportsOnDemandTransactions() bool
- type NoPrivacyWithdrawActionHandler
- type NoPrivacyWithdrawFulfillmentHandler
- func (h *NoPrivacyWithdrawFulfillmentHandler) CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error)
- func (h *NoPrivacyWithdrawFulfillmentHandler) IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error)
- func (h *NoPrivacyWithdrawFulfillmentHandler) MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) (*solana.Transaction, error)
- func (h *NoPrivacyWithdrawFulfillmentHandler) OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) (recovered bool, err error)
- func (h *NoPrivacyWithdrawFulfillmentHandler) OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, ...) error
- func (h *NoPrivacyWithdrawFulfillmentHandler) SupportsOnDemandTransactions() bool
- type OpenAccountActionHandler
- type OpenAccountsIntentHandler
- type ReceivePaymentsPubliclyIntentHandler
- type Scheduler
- type SendPublicPaymentIntentHandler
Constants ¶
View Source
const ( DisableTransactionSchedulingConfigEnvName = envConfigPrefix + "DISABLE_TRANSACTION_SCHEDULING" DisableTransactionSubmissionConfigEnvName = envConfigPrefix + "DISABLE_TRANSACTION_SUBMISSION" MaxGlobalFailedFulfillmentsConfigEnvName = envConfigPrefix + "MAX_GLOBAL_FAILED_FULFILLMENTS" EnableSubsidizerChecksConfigEnvName = envConfigPrefix + "ENABLE_SUBSIDIZER_CHECKS" )
Variables ¶
View Source
var ( ErrInvalidFulfillmentSignature = errors.New("invalid fulfillment signature") ErrInvalidFulfillmentStateTransition = errors.New("invalid fulfillment state transition") ErrCouldNotGetIntentLock = errors.New("could not get intent lock") )
View Source
var (
ErrInvalidActionStateTransition = errors.New("invalid action state transition")
)
View Source
var (
ErrInvalidIntentStateTransition = errors.New("invalid intent state transition")
)
Functions ¶
func New ¶
func New(data code_data.Provider, scheduler Scheduler, vmIndexerClient indexerpb.IndexerClient, configProvider ConfigProvider) async.Service
Types ¶
type ActionHandler ¶
type ActionHandler interface { // Note: New fulfillment states are not recorded until the very end of a worker // run, which is why we need to pass it into this function. OnFulfillmentStateChange(ctx context.Context, fulfillmentRecord *fulfillment.Record, newState fulfillment.State) error }
func NewCloseEmptyAccountActionHandler ¶
func NewCloseEmptyAccountActionHandler(data code_data.Provider) ActionHandler
func NewNoPrivacyTransferActionHandler ¶
func NewNoPrivacyTransferActionHandler(data code_data.Provider) ActionHandler
func NewNoPrivacyWithdrawActionHandler ¶
func NewNoPrivacyWithdrawActionHandler(data code_data.Provider) ActionHandler
func NewOpenAccountActionHandler ¶
func NewOpenAccountActionHandler(data code_data.Provider) ActionHandler
type CloseEmptyAccountActionHandler ¶
type CloseEmptyAccountActionHandler struct {
// contains filtered or unexported fields
}
func (*CloseEmptyAccountActionHandler) OnFulfillmentStateChange ¶
func (h *CloseEmptyAccountActionHandler) OnFulfillmentStateChange(ctx context.Context, fulfillmentRecord *fulfillment.Record, newState fulfillment.State) error
type CloseEmptyTimelockAccountFulfillmentHandler ¶
type CloseEmptyTimelockAccountFulfillmentHandler struct {
// contains filtered or unexported fields
}
func (*CloseEmptyTimelockAccountFulfillmentHandler) CanSubmitToBlockchain ¶
func (h *CloseEmptyTimelockAccountFulfillmentHandler) CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error)
func (*CloseEmptyTimelockAccountFulfillmentHandler) IsRevoked ¶
func (h *CloseEmptyTimelockAccountFulfillmentHandler) IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error)
func (*CloseEmptyTimelockAccountFulfillmentHandler) MakeOnDemandTransaction ¶
func (h *CloseEmptyTimelockAccountFulfillmentHandler) MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, selectedNonce *transaction_util.SelectedNonce) (*solana.Transaction, error)
func (*CloseEmptyTimelockAccountFulfillmentHandler) OnFailure ¶
func (h *CloseEmptyTimelockAccountFulfillmentHandler) OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) (recovered bool, err error)
func (*CloseEmptyTimelockAccountFulfillmentHandler) OnSuccess ¶
func (h *CloseEmptyTimelockAccountFulfillmentHandler) OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) error
func (*CloseEmptyTimelockAccountFulfillmentHandler) SupportsOnDemandTransactions ¶
func (h *CloseEmptyTimelockAccountFulfillmentHandler) SupportsOnDemandTransactions() bool
type ConfigProvider ¶
type ConfigProvider func() *conf
ConfigProvider defines how config values are pulled
func WithEnvConfigs ¶
func WithEnvConfigs() ConfigProvider
WithEnvConfigs returns configuration pulled from environment variables
type FulfillmentHandler ¶
type FulfillmentHandler interface { // CanSubmitToBlockchain determines whether the given fulfillment can be // scheduled for submission to the blockchain. // // Implementations must consider global, account, intent, action and local // state relevant to the type of fulfillment being handled to determine if // it's safe to schedule. // // Implementations do not need to validate basic preconditions or basic // circuit breaking checks, which is performed by the contextual scheduler. CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error) // SupportsOnDemandTransactions returns whether a fulfillment type supports // on demand transaction creation // // Note: This is also being abused for an initial version of packing virtual // instructions 1:1 into a Solana transaction. A new flow/strategy will be // needed when we require more efficient packing. SupportsOnDemandTransactions() bool // MakeOnDemandTransaction constructs a transaction at the time of submission // to the blockchain. This is an optimization for the nonce pool. Implementations // should not modify the provided fulfillment record or selected nonce, but rather // use relevant fields to make the corresponding transaction. MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, selectedNonce *transaction_util.SelectedNonce) (*solana.Transaction, error) // OnSuccess is a callback function executed on a finalized transaction. OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) error // OnFailure is a callback function executed upon detecting a failed // transaction. // // In general, for automated and manual recovery, the steps should be // 1. Ensure the assigned nonce is transitioned back to available // state with the correct blockhash. // 2. Update the fulfillment record with a new transaction, plus relevant // metadata (eg. nonce, signature, etc), that does the exact same operation // The fulfillment's state should be pending, so the fulfillment worker can // begin submitting it immediately. The worker does this when recovered = true. OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) (recovered bool, err error) // IsRevoked checks whether a fulfillment in the unknown state is revoked. // It also provides a hint as to whether the nonce was used or not. When in // doubt, say no or error out and let a human decide. IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error) }
func NewCloseEmptyTimelockAccountFulfillmentHandler ¶
func NewCloseEmptyTimelockAccountFulfillmentHandler(data code_data.Provider, vmIndexerClient indexerpb.IndexerClient) FulfillmentHandler
func NewInitializeLockedTimelockAccountFulfillmentHandler ¶
func NewInitializeLockedTimelockAccountFulfillmentHandler(data code_data.Provider) FulfillmentHandler
func NewNoPrivacyTransferWithAuthorityFulfillmentHandler ¶
func NewNoPrivacyTransferWithAuthorityFulfillmentHandler(data code_data.Provider, vmIndexerClient indexerpb.IndexerClient) FulfillmentHandler
func NewNoPrivacyWithdrawFulfillmentHandler ¶
func NewNoPrivacyWithdrawFulfillmentHandler(data code_data.Provider, vmIndexerClient indexerpb.IndexerClient) FulfillmentHandler
type InitializeLockedTimelockAccountFulfillmentHandler ¶
type InitializeLockedTimelockAccountFulfillmentHandler struct {
// contains filtered or unexported fields
}
func (*InitializeLockedTimelockAccountFulfillmentHandler) CanSubmitToBlockchain ¶
func (h *InitializeLockedTimelockAccountFulfillmentHandler) CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error)
func (*InitializeLockedTimelockAccountFulfillmentHandler) IsRevoked ¶
func (h *InitializeLockedTimelockAccountFulfillmentHandler) IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error)
func (*InitializeLockedTimelockAccountFulfillmentHandler) MakeOnDemandTransaction ¶
func (h *InitializeLockedTimelockAccountFulfillmentHandler) MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, selectedNonce *transaction_util.SelectedNonce) (*solana.Transaction, error)
func (*InitializeLockedTimelockAccountFulfillmentHandler) OnFailure ¶
func (h *InitializeLockedTimelockAccountFulfillmentHandler) OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) (recovered bool, err error)
func (*InitializeLockedTimelockAccountFulfillmentHandler) OnSuccess ¶
func (h *InitializeLockedTimelockAccountFulfillmentHandler) OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) error
func (*InitializeLockedTimelockAccountFulfillmentHandler) SupportsOnDemandTransactions ¶
func (h *InitializeLockedTimelockAccountFulfillmentHandler) SupportsOnDemandTransactions() bool
type IntentHandler ¶
type IntentHandler interface { // Note: As of right now, we're restricted to checking actions, whose state is // guaranteed to be updated by the time this is called. As a result, the // intent handler should just get the records as needed since they need // a global view anyways. OnActionUpdated(ctx context.Context, intentId string) error }
func NewOpenAccountsIntentHandler ¶
func NewOpenAccountsIntentHandler(data code_data.Provider) IntentHandler
func NewReceivePaymentsPubliclyIntentHandler ¶
func NewReceivePaymentsPubliclyIntentHandler(data code_data.Provider) IntentHandler
func NewSendPublicPaymentIntentHandler ¶
func NewSendPublicPaymentIntentHandler(data code_data.Provider) IntentHandler
type NoPrivacyTransferActionHandler ¶
type NoPrivacyTransferActionHandler struct {
// contains filtered or unexported fields
}
func (*NoPrivacyTransferActionHandler) OnFulfillmentStateChange ¶
func (h *NoPrivacyTransferActionHandler) OnFulfillmentStateChange(ctx context.Context, fulfillmentRecord *fulfillment.Record, newState fulfillment.State) error
type NoPrivacyTransferWithAuthorityFulfillmentHandler ¶
type NoPrivacyTransferWithAuthorityFulfillmentHandler struct {
// contains filtered or unexported fields
}
func (*NoPrivacyTransferWithAuthorityFulfillmentHandler) CanSubmitToBlockchain ¶
func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error)
func (*NoPrivacyTransferWithAuthorityFulfillmentHandler) IsRevoked ¶
func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error)
func (*NoPrivacyTransferWithAuthorityFulfillmentHandler) MakeOnDemandTransaction ¶
func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, selectedNonce *transaction_util.SelectedNonce) (*solana.Transaction, error)
func (*NoPrivacyTransferWithAuthorityFulfillmentHandler) OnFailure ¶
func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) (recovered bool, err error)
func (*NoPrivacyTransferWithAuthorityFulfillmentHandler) OnSuccess ¶
func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) error
func (*NoPrivacyTransferWithAuthorityFulfillmentHandler) SupportsOnDemandTransactions ¶
func (h *NoPrivacyTransferWithAuthorityFulfillmentHandler) SupportsOnDemandTransactions() bool
type NoPrivacyWithdrawActionHandler ¶
type NoPrivacyWithdrawActionHandler struct {
// contains filtered or unexported fields
}
func (*NoPrivacyWithdrawActionHandler) OnFulfillmentStateChange ¶
func (h *NoPrivacyWithdrawActionHandler) OnFulfillmentStateChange(ctx context.Context, fulfillmentRecord *fulfillment.Record, newState fulfillment.State) error
type NoPrivacyWithdrawFulfillmentHandler ¶
type NoPrivacyWithdrawFulfillmentHandler struct {
// contains filtered or unexported fields
}
func (*NoPrivacyWithdrawFulfillmentHandler) CanSubmitToBlockchain ¶
func (h *NoPrivacyWithdrawFulfillmentHandler) CanSubmitToBlockchain(ctx context.Context, fulfillmentRecord *fulfillment.Record) (scheduled bool, err error)
func (*NoPrivacyWithdrawFulfillmentHandler) IsRevoked ¶
func (h *NoPrivacyWithdrawFulfillmentHandler) IsRevoked(ctx context.Context, fulfillmentRecord *fulfillment.Record) (revoked bool, nonceUsed bool, err error)
func (*NoPrivacyWithdrawFulfillmentHandler) MakeOnDemandTransaction ¶
func (h *NoPrivacyWithdrawFulfillmentHandler) MakeOnDemandTransaction(ctx context.Context, fulfillmentRecord *fulfillment.Record, selectedNonce *transaction_util.SelectedNonce) (*solana.Transaction, error)
func (*NoPrivacyWithdrawFulfillmentHandler) OnFailure ¶
func (h *NoPrivacyWithdrawFulfillmentHandler) OnFailure(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) (recovered bool, err error)
func (*NoPrivacyWithdrawFulfillmentHandler) OnSuccess ¶
func (h *NoPrivacyWithdrawFulfillmentHandler) OnSuccess(ctx context.Context, fulfillmentRecord *fulfillment.Record, txnRecord *transaction.Record) error
func (*NoPrivacyWithdrawFulfillmentHandler) SupportsOnDemandTransactions ¶
func (h *NoPrivacyWithdrawFulfillmentHandler) SupportsOnDemandTransactions() bool
type OpenAccountActionHandler ¶
type OpenAccountActionHandler struct {
// contains filtered or unexported fields
}
func (*OpenAccountActionHandler) OnFulfillmentStateChange ¶
func (h *OpenAccountActionHandler) OnFulfillmentStateChange(ctx context.Context, fulfillmentRecord *fulfillment.Record, newState fulfillment.State) error
type OpenAccountsIntentHandler ¶
type OpenAccountsIntentHandler struct {
// contains filtered or unexported fields
}
func (*OpenAccountsIntentHandler) OnActionUpdated ¶
func (h *OpenAccountsIntentHandler) OnActionUpdated(ctx context.Context, intentId string) error
type ReceivePaymentsPubliclyIntentHandler ¶
type ReceivePaymentsPubliclyIntentHandler struct {
// contains filtered or unexported fields
}
func (*ReceivePaymentsPubliclyIntentHandler) OnActionUpdated ¶
func (h *ReceivePaymentsPubliclyIntentHandler) OnActionUpdated(ctx context.Context, intentId string) error
type Scheduler ¶
type Scheduler interface { // CanSubmitToBlockchain determines whether the given fulfillment can be // scheduled for submission to the blockchain. CanSubmitToBlockchain(ctx context.Context, record *fulfillment.Record) (bool, error) }
Scheduler decides when fulfillments can be scheduled for submission to the blockchain. It does not manage the internal state of a fulfillment.
func NewContextualScheduler ¶
func NewContextualScheduler(data code_data.Provider, indexerClient indexerpb.IndexerClient, configProvider ConfigProvider) Scheduler
NewContextualScheduler returns a scheduler that utilizes the global, account, intent, action and local context of a fulfillment to determine whether scheduling submission to the blockchain should occur.
The implementations has generic handling for:
- Precondition checks
- Circuit breaker safety mechanisms
- Subisider sanity checks
The implementation defers contextualized scheduling logic to handler implementations.
The implementation makes the following assumptions:
- We have full control of user account balances via a timelock account. Otherwise, we'd require a much more complex solution for the knapsack problem (likely a wavefunction collapse implementation).
- Fulfillments that require client signatures are validated to guarantee success before being created.
type SendPublicPaymentIntentHandler ¶
type SendPublicPaymentIntentHandler struct {
// contains filtered or unexported fields
}
func (*SendPublicPaymentIntentHandler) OnActionUpdated ¶
func (h *SendPublicPaymentIntentHandler) OnActionUpdated(ctx context.Context, intentId string) error
Click to show internal directories.
Click to hide internal directories.