orchestrator

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 46 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Winning-ticket store operations follow livepeer/go-livepeer/common/db.go, by Elad Mallel and Nico Vergauwen (404d24a9455cd0997af1be6d18faa998702cce69). The redemption recovery schema and transaction state are implemented here.

Index

Constants

This section is empty.

Variables

View Source
var ErrFixedAlreadyCharged = errors.New("fixed-price session already charged")
View Source
var ErrInsufficientBalance = errors.New("insufficient payment balance")
View Source
var ErrInvalidPayment = errors.New("invalid payment")
View Source
var ErrMissingChallenge = errors.New("payment challenge not found")

Functions

func ManifestFromSegment

func ManifestFromSegment(header string) (string, error)

func ProcessRedemptions

func ProcessRedemptions(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, redeemer *eth.Key, chainID *big.Int) []error

func ReconcileSubmitted

func ReconcileSubmitted(ctx context.Context, store *RedeemerDB, chain ReceiptReader) []error

ReconcileSubmitted checks receipts once per background tick. It never broadcasts, so a pending or uncertain transaction cannot be sent twice.

func RedeemPending

func RedeemPending(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, redeemer *eth.Key, chainID *big.Int, snapshot eth.ChainSnapshot) []error

RedeemPending only reveals randomness once the parameter acceptance window has ended. Preparation failures leave tickets queued; signed identities are durable before broadcasting. Call from one bounded worker per store. The expiry rule follows Nico Vergauwen's go-livepeer/pm/queue.go; L1-clock handling follows Rafał Leszko's 4b6ede31f040a084ff9e55bd798a0d6fffee1e1b.

func RetryRedemption

func RetryRedemption(ctx context.Context, store *RedeemerDB, contracts *eth.Contracts, hash ethcommon.Hash) error

RetryRedemption is an explicit operator action after an uncertain broadcast. It can only send the identical stored transaction, preserving its nonce/hash.

func Root

func Root(out, errOut io.Writer) *cobra.Command

func Serve

func Serve(parent context.Context, p Params, logOut io.Writer) (result error)

Types

type Challenge

type Challenge struct {
	PaymentParams string `json:"payment_params"`
	Orchestrator  string `json:"orchestrator"`
	ManifestID    string `json:"manifest_id"`
	PaymentURL    string `json:"payment_url"`
}

type Params

type Params struct {
	ConfigFile string `` /* 151-byte string literal not displayed */
	nodeconfig.Settings
	Account              *ethcommon.Address `descr:"Keystore account address"`
	OrchestratorAddress  *ethcommon.Address `descr:"Registered orchestrator address receiving ticket payments; defaults to the keystore account"`
	ETHUSDFeed           *ethcommon.Address `name:"eth-usd-feed" descr:"ETH/USD oracle address, alternative to a fixed wei-per-usd rate"`
	PriceMaxAge          time.Duration      `default:"2h" descr:"Maximum age of the oracle observation"`
	Listen               netip.AddrPort     `default:"127.0.0.1:8935" descr:"Public HTTP listener"`
	MetricsListen        netip.AddrPort     `default:"127.0.0.1:8936" descr:"Loopback metrics listener"`
	ServiceURL           boa.Text[*url.URL] `optional:"true" descr:"Public orchestrator base URL; defaults to http://listen"`
	RunnerServiceURL     boa.Text[*url.URL] `optional:"true" descr:"Runner-facing base URL for callbacks and trickle; defaults to service-url"`
	ProxyURLTemplate     string             `optional:"true" descr:"Generated proxy URL with {proxy} in a hostname label or final path segment"`
	BootstrapSecret      string             `secret:"true" optional:"true" descr:"Dynamic runner bootstrap credential"`
	BootstrapSecretFile  string             `basepath:"source" secretfor:"BootstrapSecret" descr:"File containing runner bootstrap credential"`
	RunnerConfig         string             `basepath:"source" optional:"true" file:"true" descr:"Static runner TOML path"`
	RedeemerDB           string             `optional:"true" file:"optional"`
	KeystoreFile         string             `basepath:"source" optional:"true" descr:"Encrypted geth redemption account JSON file"`
	KeystorePassword     *string            `secret:"true" optional:"true" descr:"Keystore decryption password"`
	KeystorePasswordFile string             `basepath:"source" secretfor:"KeystorePassword" descr:"Owner-only file containing the exact keystore password bytes"`
	RPCURL               *url.URL           `name:"rpc-url" secret:"true" optional:"true"`
	RPCURLFile           string             `basepath:"source" name:"rpc-url-file" secretfor:"RPCURL"`
	ChainID              *uint64            `min:"1"`
	RedeemerMaxFeePerGas *uint256.Int       `descr:"Optional maximum redemption fee in wei per gas"`
	Controller           *ethcommon.Address `name:"controller-address"`
	WeiPerUSD            *big.Rat
	TicketFaceValue      *uint256.Int
	TicketWinProb        *uint256.Int
	RunnerGrants         []string      `optional:"true" descr:"Private runner IP[:port] or CIDR grants"`
	SessionProxyGrants   []string      `optional:"true" descr:"Private session proxy IP[:port] or CIDR grants"`
	HealthGrants         []string      `optional:"true" descr:"Private static runner health IP[:port] or CIDR grants"`
	HeartbeatInterval    time.Duration `default:"5s" descr:"Runner heartbeat interval"`
	HeartbeatTTL         time.Duration `default:"30s" descr:"Runner heartbeat expiry"`
	PrintConfig          bool          `optional:"true" boa:"noconfig,noenv" descr:"Print audited redacted TOML configuration"`
}

func (Params) Validate

func (p Params) Validate() error

type PaymentEngine

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

PaymentEngine owns process-local payment challenges and session accounting. Winning tickets and redemption state are durable in the orchestrator redeemer.

func NewPaymentEngine

func NewPaymentEngine(store *RedeemerDB, chain pm.PaymentChain, recipient ethcommon.Address, faceValue, winProb *big.Int) (*PaymentEngine, error)

func (*PaymentEngine) Balance

func (e *PaymentEngine) Balance(manifest string) (*big.Rat, error)

func (*PaymentEngine) ChallengeForManifest

func (e *PaymentEngine) ChallengeForManifest(runner, manifest, service string) (Challenge, error)

func (*PaymentEngine) ChallengeInfo

func (e *PaymentEngine) ChallengeInfo(manifest string) (wire.OrchestratorInfo, error)

func (*PaymentEngine) ChallengePrice

func (e *PaymentEngine) ChallengePrice(runner, manifest string) (int64, string, error)

ChallengePrice returns the agreed quote for a pending reservation, scoped to its runner. Updating the runner/feed must not change a previously issued quote.

func (*PaymentEngine) Charge

func (e *PaymentEngine) Charge(ctx context.Context, manifest string, now time.Time) error

func (*PaymentEngine) MakeChallenge

func (e *PaymentEngine) MakeChallenge(ctx context.Context, runner, manifest string, payer ethcommon.Address, price int64, unit, service string) (Challenge, error)

MakeChallenge returns a Python/Go runner compatible 402 body. Ticket parameters are authenticated by the recipient HMAC.

func (*PaymentEngine) PruneControlState

func (e *PaymentEngine) PruneControlState(ctx context.Context) error

PruneControlState bounds process-local session and nonce state. Winning tickets and uncertain broadcasts remain durable for redemption/recovery.

func (*PaymentEngine) Receive

func (e *PaymentEngine) Receive(ctx context.Context, runner, manifest, paymentHeader, segmentHeader string) (ethcommon.Address, *big.Rat, error)

func (*PaymentEngine) RefreshChallenge

func (e *PaymentEngine) RefreshChallenge(ctx context.Context, manifest string, payer ethcommon.Address, service string) (Challenge, error)

type ReceiptReader

type ReceiptReader interface {
	Receipt(context.Context, ethcommon.Hash) (confirmed, reverted bool, err error)
}

type RedeemerDB

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

RedeemerDB owns the orchestrator redeemer's durable winning-ticket queue, redemption lifecycle, and chain activity observations.

func OpenRedeemerDB

func OpenRedeemerDB(path string) (*RedeemerDB, error)

func (*RedeemerDB) Close

func (s *RedeemerDB) Close() error

func (*RedeemerDB) ConfirmRedemption

func (s *RedeemerDB) ConfirmRedemption(sig []byte) error

func (*RedeemerDB) FailRedemption

func (s *RedeemerDB) FailRedemption(sig []byte) error

func (*RedeemerDB) PendingPayers

func (s *RedeemerDB) PendingPayers() ([]ethcommon.Address, error)

func (*RedeemerDB) Redemptions

func (s *RedeemerDB) Redemptions() ([]RedemptionStatus, error)

func (*RedeemerDB) RemoveWinningTicket

func (s *RedeemerDB) RemoveWinningTicket(t *pm.SignedTicket) error

func (*RedeemerDB) SavedNonceFloor

func (s *RedeemerDB) SavedNonceFloor(ctx context.Context, address ethcommon.Address) (uint64, error)

SavedNonceFloor reserves every signed identity across process restarts, including confirmed/reverted attempts that an RPC may omit from pending.

func (*RedeemerDB) SelectEarliestWinningTicket

func (s *RedeemerDB) SelectEarliestWinningTicket(payer ethcommon.Address, minCreationRound int64) (*pm.SignedTicket, error)

func (*RedeemerDB) StoreWinningTicket

func (s *RedeemerDB) StoreWinningTicket(t *pm.SignedTicket) error

func (*RedeemerDB) SubmittedRedemptions

func (s *RedeemerDB) SubmittedRedemptions() ([]SubmittedRedemption, error)

func (*RedeemerDB) WinningTicketCount

func (s *RedeemerDB) WinningTicketCount(payer ethcommon.Address, minCreationRound int64) (int, error)

type RedemptionStatus

type RedemptionStatus struct {
	Hash  string `json:"hash,omitempty"`
	Phase string `json:"phase"`
	Error string `json:"error,omitempty"`
}

RedemptionStatus is safe to display: it excludes recipient randomness, signatures, and signed transaction bytes.

type Registry

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

func NewRegistry

func NewRegistry(secret, service string, interval, ttl time.Duration) *Registry

func (*Registry) AddStatic

func (r *Registry) AddStatic(config StaticRunner) error

func (*Registry) CheckStaticHealth

func (r *Registry) CheckStaticHealth(ctx context.Context, client *http.Client)

func (*Registry) Close

func (r *Registry) Close()

func (*Registry) Counts

func (r *Registry) Counts() (runners, sessions int)

func (*Registry) Discovery

func (r *Registry) Discovery() []discoveryEntry

func (*Registry) Expire

func (r *Registry) Expire()

func (*Registry) Heartbeat

func (r *Registry) Heartbeat(req heartbeatRequest, auth string) (heartbeatResponse, int, error)

func (*Registry) ModeForRunner

func (r *Registry) ModeForRunner(id string) (string, int, error)

func (*Registry) PaidSessions

func (r *Registry) PaidSessions() []string

func (*Registry) PriceForRunner

func (r *Registry) PriceForRunner(id string) (priceInfo, int, error)

func (*Registry) PriceForSession

func (r *Registry) PriceForSession(id, sid string) (priceInfo, int, error)

func (*Registry) ReleaseBySession

func (r *Registry) ReleaseBySession(sid string)

func (*Registry) Reserve

func (r *Registry) Reserve(id string) (string, string, string, int, error)

func (*Registry) ReserveWithID

func (r *Registry) ReserveWithID(id, requestedID string) (string, string, string, int, error)

func (*Registry) SetWeiPerUSD

func (r *Registry) SetWeiPerUSD(rate *big.Rat)

func (*Registry) String

func (r *Registry) String() string

func (*Registry) Unregister

func (r *Registry) Unregister(id, auth string) (int, error)

type Server

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

func NewServer

func NewServer(registry *Registry, runnerPolicy, proxyPolicy destination.Policy, logger *slog.Logger) *Server

func (*Server) ChargePaidSessions

func (s *Server) ChargePaidSessions(ctx context.Context)

func (*Server) Close

func (s *Server) Close()

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) SetPayment

func (s *Server) SetPayment(engine *PaymentEngine)

func (*Server) String

func (s *Server) String() string

type StaticRunner

type StaticRunner struct {
	ID         string
	Proxy      bool
	RunnerURL  string
	Version    string
	Metadata   string
	GPU        *runnerGPU
	App        string
	Mode       string
	Status     string
	Capacity   int
	HealthURL  string
	HealthCode int
	PriceInfo  priceInfo
}

type SubmittedRedemption

type SubmittedRedemption struct {
	Signature []byte
	Hash      ethcommon.Hash
}

Jump to

Keyboard shortcuts

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