Documentation
¶
Overview ¶
Ticket queue/retry policy ported from go-livepeer/pm/queue.go and pm/sendermonitor.go at 0ff08af1bb4cb268f428d619cc968b5eaee0d093, by Yondon Fu, Nico Vergauwen and Rafal Leszko. MIT notice in LICENSE.
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.
Recovery adapters for the go-livepeer port at 0ff08af1bb4cb268f428d619cc968b5eaee0d093. These bridge node's durable store and finalized settlement to the upstream nonce/send/wait/replace lifecycle.
Index ¶
- Variables
- func ManifestFromSegment(header string) (string, error)
- func ProcessRedemptions(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, key *eth.Key, ...) []error
- func ReconcileSubmitted(ctx context.Context, store *RedeemerDB, chain ReceiptReader) []error
- func RedeemPending(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, key *eth.Key, ...) []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)
- func StartRedemptionRecovery(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, key *eth.Key, ...) 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) 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 RedemptionOptions
- 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, key *eth.Key, chainID *big.Int) []error
func ReconcileSubmitted ¶
func ReconcileSubmitted(ctx context.Context, store *RedeemerDB, chain ReceiptReader) []error
ReconcileSubmitted checks every retained identity, including old retry groups. A finalized success wins over sibling failures; failed attempts alone cannot release liability while another signed identity might still redeem the ticket.
func RedeemPending ¶
func RedeemPending(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, key *eth.Key, chainID *big.Int, snapshot eth.ChainSnapshot) []error
RedeemPending adapts handleBlockEvent and redeemWinningTicket to node snapshots. Inclusion/replacement waits run on the service manager, never on this heartbeat.
func RetryRedemption ¶
func RetryRedemption(ctx context.Context, store *RedeemerDB, contracts *eth.Contracts, hash ethcommon.Hash) error
RetryRedemption preserves the existing explicit identical-byte retry command. Historical identities are inspectable, but cannot replace a newer active job.
func StartRedemptionRecovery ¶ added in v1.0.6
func StartRedemptionRecovery(ctx context.Context, store *RedeemerDB, chain eth.PaymentChain, key *eth.Key, options RedemptionOptions) error
StartRedemptionRecovery binds long inclusion waits to the service lifetime, independently of the bounded heartbeat contexts used to schedule tickets.
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"`
RedeemerTxTimeout time.Duration `default:"5m" descr:"Inclusion timeout for each redemption transaction attempt"`
RedeemerMaxTxReplacements int `default:"1" min:"0" descr:"Maximum fee replacements per redemption attempt"`
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"`
}
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) 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 restores only acknowledged sends, following upstream backend's Update-after-send rule. A rejected/prepared identity must not create a gap.
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 RedemptionOptions ¶ added in v1.0.6
type RedemptionStatus ¶
type RedemptionStatus struct {
Hash string `json:"hash,omitempty"`
Phase string `json:"phase"`
Error string `json:"error,omitempty"`
}
RedemptionStatus excludes recipient randomness, signatures and signed 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)