Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/livepeer/testdata/cli/orchestrator-help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ Flags:
--controller-address string (env: LIVEPEER_ORCHESTRATOR_CONTROLLER_ADDRESS)
-w, --wei-per-usd string (env: LIVEPEER_ORCHESTRATOR_WEI_PER_USD)
-t, --ticket-face-value string (env: LIVEPEER_ORCHESTRATOR_TICKET_FACE_VALUE)
--ticket-win-prob string (env: LIVEPEER_ORCHESTRATOR_TICKET_WIN_PROB)
--ticket-win-prob string Legacy setting accepted for compatibility (env: LIVEPEER_ORCHESTRATOR_TICKET_WIN_PROB)
--max-ticket-ev string Maximum quoted EV per ticket in wei; defaults to the stock signer limit (env: LIVEPEER_ORCHESTRATOR_MAX_TICKET_EV)
--max-batch-ev string Maximum quoted EV per payment batch in wei; defaults to the stock signer limit (env: LIVEPEER_ORCHESTRATOR_MAX_BATCH_EV)
--metered-ticket-seconds int Seconds of quoted usage per metered ticket; defaults to 3 (env: LIVEPEER_ORCHESTRATOR_METERED_TICKET_SECONDS)
--payer-deposit-multiplier int Signer deposit multiplier; defaults to 1 (env: LIVEPEER_ORCHESTRATOR_PAYER_DEPOSIT_MULTIPLIER)
--runner-grants strings Private runner IP[:port] or CIDR grants (env: LIVEPEER_ORCHESTRATOR_RUNNER_GRANTS)
--session-proxy-grants strings Private session proxy IP[:port] or CIDR grants (env: LIVEPEER_ORCHESTRATOR_SESSION_PROXY_GRANTS)
--health-grants strings Private static runner health IP[:port] or CIDR grants (env: LIVEPEER_ORCHESTRATOR_HEALTH_GRANTS)
Expand Down
14 changes: 8 additions & 6 deletions configs/orchestrator/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ HealthGrants = []
# To retain other cookies, omit "Cookie" from ExcludedHeaders.
# ExcludedCookies = ["CF_Authorization"] # Remove only the named cookies from app requests.

# Paid operation requires an on-chain network, account password, RPC, face
# value, winning probability, and one conversion source.
# Paid operation requires an on-chain network, account password, RPC, baseline
# ticket face value, and one conversion source.
# Runner prices are USD per hour or per fixed request. Choose WeiPerUSD
# for a fixed conversion OR ETHUSDFeed for an ETH/USD feed on the payment
# chain. The fee ceiling and PriceMaxAge are optional. See docs/orchestrator.md.
Expand All @@ -43,10 +43,12 @@ HealthGrants = []
# WeiPerUSD = "1000000000000000"
# ETHUSDFeed = "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612" # Arbitrum default.
# PriceMaxAge = "2h"
# Ticket EV is approximately 2e11 wei; a 100-ticket batch fits the signer
# default 2e13 wei cap. Fund sufficient deposit and recipient-claimable reserve.
# TicketFaceValue = "400000000000"
# TicketWinProb = "57896044618658097711785492504343953926634992332820282019728792003956564819967"
# Baseline payout for a winning ticket, in wei.
# TicketFaceValue = "1000000000000000"
# MaxTicketEV = "3000000000000"
# MaxBatchEV = "20000000000000"
# MeteredTicketSeconds = 3
# PayerDepositMultiplier = 1

# Remote redemption: set a public recipient address and omit local wallet/tx settings.
# OrchestratorAddress = "0xYOUR_REGISTERED_ORCHESTRATOR"
Expand Down
6 changes: 6 additions & 0 deletions docs/http-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ example `"X-List: a,b",Authorization: Bearer credential`.

## Redeemer HTTP

`GET /fee-estimate` requires no ticket submission credential. It returns
`fee_wei` (a decimal string) and `expires_at` (RFC 3339) for the 95th percentile
of successful, finalized redemption fees. It returns `204` when fewer than 20
samples are available in the last 24 hours. Do not use an estimate after its
expiry.

`POST /tickets` submits one winning ticket to a standalone redeemer. Send a JSON
object with `chain_id` (a decimal string), `controller` (an Ethereum address),
and `ticket`. The chain and Controller must match the redeemer's configuration.
Expand Down
1 change: 1 addition & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ gauges; timestamps use Unix seconds. Most event families appear on first use.
| Lifecycle | `runner_events_total{event}`, `runner_health_checks_total{outcome}`, `session_reservations_total{outcome}`, `session_ends_total{reason}`, `session_duration_seconds`, with app identity. Reservations include allocations pending payment; only activated sessions contribute lifetime observations. |
| Streams | `trickle_channels{kind="control\|session"}`, `trickle_buffered_bytes` for retained published segment bytes; `stream_transfer_bytes_total{app,app_id,runner_id,mode,protocol,direction}`, `stream_errors_total{app,app_id,runner_id,mode,protocol,outcome}`. Trickle requests are transport activity, not extra app invocations. |
| Payments | `payment_operations_total{operation,outcome}` for challenge/receive/refresh/charge; `payment_operation_duration_seconds{operation}` for challenge/receive/refresh; `payment_tickets_total{kind="accepted\|winning"}`, `payment_credit_eth_total`, `payment_charge_eth_total`, `payment_billed_seconds_total`, `payment_fixed_charges_total`, with app identity. Credit is accepted expected ticket value; charges are successfully debited service usage. |
| Ticket sizing | `payment_gas_target_unmet_total` counts quotes whose funded face value is below the gas target. `payment_fee_estimate_errors_total` counts failed estimate polls. Both are aggregate counters. |
| Signer | `signer_payments_total{type,outcome}`, `signer_payment_duration_seconds{type}`, `signer_tickets_total{type}`, `signer_sign_operations_total{kind,outcome}`. Signing kinds are ticket, segment, state, and orchestrator_info. Partial signing before a failed request remains visible. Successful payment/ticket totals follow required outbox persistence, even if response delivery is interrupted. |
| Authorization | `signer_auth_webhook_requests_total{status,outcome}`, `signer_auth_webhook_duration_seconds`, `signer_auth_cache_hits_total`. Status zero means no webhook response; outcomes distinguish success, denied, and error. |
| Redeemer authorization | `redeemer_auth_webhook_requests_total{status,outcome}`, `redeemer_auth_webhook_duration_seconds`. Status is the upstream HTTP status, or zero without a response; outcomes are `success`, `denied`, and `error`. |
Expand Down
24 changes: 22 additions & 2 deletions docs/orchestrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ For paid operation, select an on-chain `Network` and supply:
[Ethereum keystores](configuration.md#ethereum-keystores).
- `RPCURLFile` or `LIVEPEER_ORCHESTRATOR_RPC_URL`: RPC credential.
- `ChainID` and `Controller` for custom networks.
- `TicketFaceValue` and `TicketWinProb`: positive uint256 ticket parameters.
The winning probability must be less than `2^256 - 1`.
- `TicketFaceValue`: baseline payout for a winning ticket in wei.
- Exactly one conversion source: `WeiPerUSD` or `ETHUSDFeed` (Arbitrum supplies a feed).

The payment database has a [default path](configuration.md); `RedeemerDB` /
Expand All @@ -142,6 +141,27 @@ Incomplete paid configuration fails startup. The orchestrator address must be ac
on the configured chain. Runner prices use USD per hour for live work or USD per
fixed request. Hourly discovery prices are normalized to USD and wei per second.

Node sizes tickets when it issues or refreshes paid session parameters. Face
value is limited by the payer's deposit divided by `PayerDepositMultiplier`
(default 1) and by recipient-claimable reserve after locally known unsettled wins.
Available reserve must cover every ticket winning in a fixed-price quote or a
metered session's ten-second opening batch. Node checks funding again when it
receives tickets. Later metered top-ups may have more tickets than the opening
batch.

Node aims to keep redemption gas costs at 0.5% of face value, using the 95th
percentile of recent finalized redemption fees. Node continues to quote if
funding limits prevent it from meeting that target. When the estimate is
missing or stale, Node uses the funded baseline. Arbitrum fees include the L1
posting charge.

Fixed-price quotes use the fewest tickets that cover the price, up to 100.
Metered tickets target `MeteredTicketSeconds` seconds of quoted usage (default
3). The signer bills elapsed time and carries forward credit. Set `MaxTicketEV`
and `MaxBatchEV` to match the signer's limits, in wei. Their defaults are
`3000000000000` and `20000000000000`. Node accepts legacy `TicketWinProb`
configuration. Ticket odds are calculated from expected value and face value.

`WeiPerUSD` sets a fixed conversion. Alternatively, set `ETHUSDFeed` to a
Chainlink-compatible ETH/USD feed on the payment chain. The feed is checked
every hour; `PriceMaxAge` must be positive and defaults to two hours. Startup
Expand Down
7 changes: 7 additions & 0 deletions docs/payment-recovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ data, including payment/accounting tables in the initial migrations. If downgrad
is incompatible, retain the latest state for a compatible fix; restoring an old
snapshot can lose events, winners, and transaction identities.

To roll back `006_fee_samples.sql`, stop each orchestrator and standalone
redeemer writer and back up its database. Use the newer binary's `migrate status`
to confirm migration 006 is the latest applied migration, then run `migrate down`
once with that binary and database path. This removes only fee sample history.
Restore the previous image and its matching configuration, and check migration
status with the previous binary before starting it.

## Signer accounting recovery

Keep `Kafka.OutboxDB` on persistent local storage, one file per replica. It uses
Expand Down
24 changes: 16 additions & 8 deletions eth/payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,39 @@ func (c PaymentChain) activeAt(ctx context.Context, address, recipient ethcommon

// FinalizedReceipt retains canonical inclusion evidence for durable collateral admission.
func (c PaymentChain) FinalizedReceipt(ctx context.Context, hash ethcommon.Hash) (*types.Receipt, error) {
receipt, _, err := c.FinalizedReceiptWithTime(ctx, hash)
return receipt, err
}

func (c PaymentChain) FinalizedReceiptWithTime(ctx context.Context, hash ethcommon.Hash) (*types.Receipt, time.Time, error) {
receipt, err := c.Contracts.RPC.TransactionReceipt(ctx, hash)
if errors.Is(err, ethereum.NotFound) {
return nil, nil
return nil, time.Time{}, nil
}
if err != nil {
return nil, err
return nil, time.Time{}, err
}
finalized, err := c.Contracts.RPC.header(ctx, "finalized")
if err != nil {
return nil, err
return nil, time.Time{}, err
}
if finalized.Number == nil {
return nil, errors.New("invalid finalized header")
return nil, time.Time{}, errors.New("invalid finalized header")
}
if (*big.Int)(finalized.Number).Cmp(receipt.BlockNumber) < 0 {
return nil, nil
return nil, time.Time{}, nil
}
canonical, err := c.Contracts.RPC.header(ctx, hexutil.EncodeBig(receipt.BlockNumber))
if err != nil {
return nil, err
return nil, time.Time{}, err
}
if canonical.Hash != receipt.BlockHash {
return nil, nil
return nil, time.Time{}, nil
}
return receipt, nil
if canonical.Timestamp == nil {
return receipt, time.Time{}, nil
}
return receipt, time.Unix(int64(*canonical.Timestamp), 0), nil
}

// Address retention adapts livepeer/go-livepeer eth/client.go setContracts at
Expand Down
Loading
Loading