keeper

package
v0.0.0-...-beefb37 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package keeper prepares recipes and owns their process-local execution lifecycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePlanComposition

func ValidatePlanComposition(calldata []byte, providers []Provider, outputs [][]provider.Output) error

ValidatePlanComposition checks receipt attribution against immutable call data.

func ValidateRecipeComposition

func ValidateRecipeComposition(recipe recipes.Recipe, tree *recipes.Tree, requirements []RecipeRequirements) error

ValidateRecipeComposition checks pure authenticated target ownership before any provider resolution or HTTP. Immutable calldata is checked again later.

Types

type Backend

type Backend interface {
	CallContract(context.Context, ethereum.CallMsg, *big.Int) ([]byte, error)
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
	HeaderByHash(context.Context, common.Hash) (*types.Header, error)
	FilterLogs(context.Context, ethereum.FilterQuery) ([]types.Log, error)
}

type Config

type Config struct {
	Name, Executor, Account, RecipeHash, Tree string
	Interval                                  time.Duration
}

Config identifies one committed executor and its scheduling policy. Name must be nonempty and unique within a Keeper.

type ExecutionPlan

type ExecutionPlan struct {
	To       common.Address   `json:"to"`
	Sender   common.Address   `json:"sender,omitempty"`
	Members  []PlanMember     `json:"members"`
	Failures map[string]error `json:"-"`
}

func (ExecutionPlan) Transaction

func (b ExecutionPlan) Transaction() (common.Address, []byte, error)

Transaction encodes a direct, AccessManager-forwarded or delegated call.

type Keeper

type Keeper struct {
	Sender           Sender
	Planner          Planning
	Strategies       []Strategy
	Mode             string
	OperationTimeout time.Duration
	Log              logr.Logger
	Observe          func(strategy, outcome string)
	// contains filtered or unexported fields
}

Keeper is driven explicitly by the host. It never writes state or starts workers. Configuration is fixed for its lifetime; use one Keeper per sender.

func (*Keeper) Pending

func (k *Keeper) Pending() bool

Pending reports process-owned transaction or external settlement work.

func (*Keeper) Tick

func (k *Keeper) Tick(ctx context.Context) error

type PermissionSource

type PermissionSource interface {
	PermissionTree(context.Context, *big.Int, recipes.Snapshot) ([]byte, error)
}

PermissionSource supplies encoded artifacts; the SDK validates every leaf and proof itself. Errors must omit credentials, URLs and remote payloads. It is called only during preparation; pending RAM tasks retain their identity.

type Plan

type Plan struct {
	Snapshot provider.Snapshot   `json:"snapshot"`
	Recipe   recipes.Snapshot    `json:"recipe"`
	Calldata hexutil.Bytes       `json:"calldata"`
	Leaves   []common.Hash       `json:"leaves"`
	Outputs  [][]provider.Output `json:"outputs"`
	Results  map[uint]string     `json:"results,omitempty"`
}

type PlanMember

type PlanMember struct {
	Name string `json:"name"`
	Plan Plan   `json:"plan"`
}

type Planner

type Planner struct {
	PermissionSource PermissionSource
	Chain            Backend
	ChainID          *big.Int
	Caller           common.Address
	Sender           common.Address // Zero uses Caller; otherwise route through its AccessManager.
	Confirmations    uint64
	MaxGas           uint64 // Zero uses the conservative 16,777,216 gas budget.
	RecipeCache      *recipes.RecipeCache
}

func (*Planner) ConfirmedSnapshot

func (p *Planner) ConfirmedSnapshot(ctx context.Context, original provider.Snapshot) (provider.Snapshot, error)

func (*Planner) Prepare

func (p *Planner) Prepare(ctx context.Context, strategy Strategy) (Plan, error)

func (*Planner) PrepareExecution

func (p *Planner) PrepareExecution(ctx context.Context, strategies []Strategy) (ExecutionPlan, error)

PrepareExecution authenticates candidates together and validates one selected envelope. Independent reads batch across executors; EVM effects retain order.

func (*Planner) VerifyConfirmedSnapshot

func (p *Planner) VerifyConfirmedSnapshot(ctx context.Context, snapshot provider.Snapshot) error

VerifyConfirmedSnapshot checks provider reads still refer to a canonical block with the configured number of descendants before their progress is committed.

type Planning

type Planning interface {
	PrepareExecution(context.Context, []Strategy) (ExecutionPlan, error)
	ConfirmedSnapshot(context.Context, provider.Snapshot) (provider.Snapshot, error)
	VerifyConfirmedSnapshot(context.Context, provider.Snapshot) error
}

type Provider

type Provider interface {
	RecipeRequirements(provider.Snapshot, recipes.Recipe, *recipes.Tree) (RecipeRequirements, error)
	PrepareRecipe(context.Context, provider.Snapshot, recipes.Recipe, *recipes.Tree, map[uint]*big.Int) ([]provider.Output, error)
}

Provider derives its configuration from authenticated program bytes. The SDK invokes this only after validating the active root, chain and account. Inputs, results, recipe bytes and permissions are copied for each invocation. Each output supplies one execution's runtime data and an optional RAM task.

type RecipeRequirements

type RecipeRequirements struct {
	Values           []recipes.Value
	Inputs           []uint
	Actions          []string
	ExclusiveTargets map[string]common.Address
}

RecipeRequirements declares authorized input ownership and the numerical expressions needed before obtaining external runtime data. This method is pure: every provider is checked before any quote or reward HTTP request.

type Sender

type Sender interface {
	Submit(context.Context, transaction.ExecutionRequest) error
	Poll(context.Context) (*transaction.ExecutionResult, error)
	Busy() bool
}

Sender owns at most one transaction and returns canonical execution evidence. Submit errors may leave Busy true: ambiguous submission retains ownership.

type Strategy

type Strategy struct {
	Config    Config
	Providers []Provider
}

Jump to

Keyboard shortcuts

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