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 ¶
- Variables
- func ManifestFromSegment(header string) (string, error)
- func ProcessRedemptions(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, ...) []error
- func ReconcileSubmitted(ctx context.Context, store *RedeemerDB, chain ReceiptReader) []error
- func RedeemPending(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, ...) []error
- func RetryRedemption(ctx context.Context, store *RedeemerDB, contracts *eth.Contracts, ...) error
- func Root(out, errOut io.Writer) *cobra.Command
- func Serve(parent context.Context, p Params, logOut io.Writer) (result error)
- type Challenge
- type Params
- type PaymentEngine
- func (e *PaymentEngine) Balance(manifest string) (*big.Rat, error)
- func (e *PaymentEngine) ChallengeForManifest(runner, manifest, service string) (Challenge, error)
- func (e *PaymentEngine) ChallengeInfo(manifest string) (wire.OrchestratorInfo, error)
- func (e *PaymentEngine) ChallengePrice(runner, manifest string) (int64, string, error)
- func (e *PaymentEngine) Charge(ctx context.Context, manifest string, now time.Time) error
- func (e *PaymentEngine) MakeChallenge(ctx context.Context, runner, manifest string, payer ethcommon.Address, ...) (Challenge, error)
- func (e *PaymentEngine) PruneControlState(ctx context.Context) error
- func (e *PaymentEngine) Receive(ctx context.Context, runner, manifest, paymentHeader, segmentHeader string) (ethcommon.Address, *big.Rat, error)
- func (e *PaymentEngine) RefreshChallenge(ctx context.Context, manifest string, payer ethcommon.Address, service string) (Challenge, error)
- type ReceiptReader
- type RedeemerDB
- func (s *RedeemerDB) Close() error
- func (s *RedeemerDB) ConfirmRedemption(sig []byte) error
- func (s *RedeemerDB) FailRedemption(sig []byte) error
- func (s *RedeemerDB) PendingPayers() ([]ethcommon.Address, error)
- func (s *RedeemerDB) Redemptions() ([]RedemptionStatus, error)
- func (s *RedeemerDB) RemoveWinningTicket(t *pm.SignedTicket) error
- func (s *RedeemerDB) SavedNonceFloor(ctx context.Context, address ethcommon.Address) (uint64, error)
- func (s *RedeemerDB) SelectEarliestWinningTicket(payer ethcommon.Address, minCreationRound int64) (*pm.SignedTicket, error)
- func (s *RedeemerDB) StoreWinningTicket(t *pm.SignedTicket) error
- func (s *RedeemerDB) SubmittedRedemptions() ([]SubmittedRedemption, error)
- func (s *RedeemerDB) WinningTicketCount(payer ethcommon.Address, minCreationRound int64) (int, error)
- type RedemptionStatus
- type Registry
- func (r *Registry) AddStatic(config StaticRunner) error
- func (r *Registry) CheckStaticHealth(ctx context.Context, client *http.Client)
- func (r *Registry) Close()
- func (r *Registry) Counts() (runners, sessions int)
- func (r *Registry) Discovery() []discoveryEntry
- func (r *Registry) Expire()
- func (r *Registry) Heartbeat(req heartbeatRequest, auth string) (heartbeatResponse, int, error)
- func (r *Registry) ModeForRunner(id string) (string, int, error)
- func (r *Registry) PaidSessions() []string
- func (r *Registry) PriceForRunner(id string) (priceInfo, int, error)
- func (r *Registry) PriceForSession(id, sid string) (priceInfo, int, error)
- func (r *Registry) ReleaseBySession(sid string)
- func (r *Registry) Reserve(id string) (string, string, string, int, error)
- func (r *Registry) ReserveWithID(id, requestedID string) (string, string, string, int, error)
- func (r *Registry) SetWeiPerUSD(rate *big.Rat)
- func (r *Registry) String() string
- func (r *Registry) Unregister(id, auth string) (int, error)
- type Server
- type StaticRunner
- type SubmittedRedemption
Constants ¶
This section is empty.
Variables ¶
var ErrFixedAlreadyCharged = errors.New("fixed-price session already charged")
var ErrInsufficientBalance = errors.New("insufficient payment balance")
var ErrInvalidPayment = errors.New("invalid payment")
var ErrMissingChallenge = errors.New("payment challenge not found")
Functions ¶
func ManifestFromSegment ¶
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.
Types ¶
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] grants"`
SessionProxyGrants []string `optional:"true" descr:"Private session proxy IP[:port] grants"`
HealthGrants []string `optional:"true" descr:"Private static runner health IP[:port] 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"`
}
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) 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) 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.
type ReceiptReader ¶
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 ¶
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 (*Registry) AddStatic ¶
func (r *Registry) AddStatic(config StaticRunner) error
func (*Registry) CheckStaticHealth ¶
func (*Registry) PaidSessions ¶
func (*Registry) PriceForRunner ¶
func (*Registry) PriceForSession ¶
func (*Registry) ReleaseBySession ¶
func (*Registry) ReserveWithID ¶
func (*Registry) SetWeiPerUSD ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ChargePaidSessions ¶
func (*Server) SetPayment ¶
func (s *Server) SetPayment(engine *PaymentEngine)