Skip to content

Commit f3e97d5

Browse files
committed
Avoid 'sender'
1 parent fb05cf1 commit f3e97d5

41 files changed

Lines changed: 303 additions & 306 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎cmd/livepeer/testdata/python_payment_refresh.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99

1010
import aiohttp
1111
from livepeer_gateway import lp_rpc_pb2
12-
from livepeer_gateway.remote_signer import (
13-
LivePaymentChallenge,
14-
LivePaymentSession,
15-
get_signer_info,
16-
)
12+
from livepeer_gateway.remote_signer import LivePaymentChallenge, LivePaymentSession, get_signer_info
1713

1814

1915
async def main(orchestrator: str, signer: str) -> None:

‎docs/development.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ local SDK edits.
6060

6161
The fixtures cover persistent and single-shot sessions, proxy modes, discovery,
6262
runner callbacks, Trickle, and Python media/control round trips. Payment tests
63-
cover live/fixed calls, sustained refresh, sender exposure, concurrent liability,
63+
cover live/fixed calls, sustained refresh, payer exposure, concurrent liability,
6464
and crash/reorg/finality handling with deterministic Ethereum interfaces. These
6565
do not replace [staging against real contracts](cutover.md).
6666

‎docs/http-api.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ configuration.
1616
| `POST /apps/{runner_id}/session` | Reserve persistent session | JSON `session_id`, `app_url`, `control_url`; paid mode may first return a payment challenge. |
1717
| `POST /apps/{runner_id}/session/{session_id}/stop` | Stop client session | Session authorization and callback reconciliation. |
1818
| `POST /apps/{runner_id}/session/{session_id}/payment` | Submit a ticket payment | On-chain only. |
19-
| `POST /refresh-payment` | Refresh ticket parameters for the same sender and manifest | On-chain only; used by the Python remote signer client. |
19+
| `POST /refresh-payment` | Refresh ticket parameters for the same payer and manifest | On-chain only; JSON `sender` and `manifest_id`. |
2020
| `* /apps/{runner_id}/session/{session_id}/app/{app_path...}` | Persistent proxy | Preserve HTTP method, streaming, SSE and WebSocket semantics and Livepeer session headers. |
2121
| `* /apps/{runner_id}/app/{app_path...}` | Single-shot proxy | Transient capacity-limited reservation; identical session/control headers and cancellation ownership. |
2222
| `POST /runner/{runner_id}/session/{session_id}/channels` | Create generic trickle channels | Scoped session callback token; JSON `channels`. |
@@ -109,10 +109,10 @@ Fixed rates never refresh or expire.
109109
| `DepositMultiplier` | 1; face value cannot exceed deposit divided by this value. Must be at least 1. |
110110
| Batch size | At most 100 tickets; issued credit covers at least the greater of the fee and one ticket's EV. Unused credit remains in signed state. |
111111

112-
Payment generation requires sender deposit and recipient-claimable reserve,
112+
Payment generation requires payer deposit and recipient-claimable reserve,
113113
the last initialized round and its canonical hash, and a ticket recipient
114114
matching the orchestrator address. Expiring parameters/authentication, obsolete
115-
rounds, mismatched hashes, or a carried sender nonce at least 500 require
115+
rounds, mismatched hashes, or a carried ticket nonce at least 500 require
116116
refresh (480). A new recipient randomness hash resets the nonce; individual
117117
ticket nonces must be from 1 through 599. On Arbitrum, parameter expiry uses the L1
118118
clock. Parameter expiry is supplied by the caller; these checks do not establish
@@ -177,7 +177,7 @@ example `"X-List: a,b",Authorization: Bearer credential`.
177177

178178
`pm/wire` retains only the consumed fields and original field numbers:
179179
`OrchestratorInfo` 1–4 and 6, `TicketParams` 1–7, `PriceInfo` 1–2,
180-
`AuthToken` 1–3, `TicketExpirationParams` 1–2, `Payment` 1–5, sender params
180+
`AuthToken` 1–3, `TicketExpirationParams` 1–2, `Payment` 1–5, payer params
181181
1–2, and `SegData` 1, 3, 5 and 8. Other fields are skipped on decode.
182182
Binary fixtures produced by the pinned Python runner check the wire
183183
format in `pm/wire/wire_test.go`. Capability payloads and `lv2v` requests
@@ -198,13 +198,13 @@ and the [Trickle protocol](../trickle/README.md) for channel behavior.
198198
| 413 | Reduce the accounting event size; no payment credentials were returned. |
199199
| 480 | Refresh payment parameters or orchestrator authentication. |
200200
| 481 | The price exceeds a ceiling or the initial session price. |
201-
| 482 | No tickets are needed, or sender funds are unavailable. |
201+
| 482 | No tickets are needed, or payer funds are unavailable. |
202202
| 502 | Restore the authorization webhook or correct its response. |
203203
| 503 | Retry after payment dependencies, discovery sources, or accounting storage recover. |
204204

205205
Healthy empty discovery returns HTTP 200 with `[]`. Rate and readiness policy
206206
are described in [the signer guide](signer.md). Signed state preserves its
207-
sequence through parameter refresh and resets the sender nonce for new
207+
sequence through parameter refresh and resets the ticket nonce for new
208208
randomness. Replicas with the same key and webhook configuration can continue
209209
that state, but there is no server-side replay database: earlier state can be
210210
reused and retries can receive different tickets. Recipients reject duplicates.
@@ -276,5 +276,5 @@ conventions:
276276

277277
The selected-field Protobuf decoder is compared with the generated runtime for
278278
merged message fields, unknown and wrong-wire fields, UTF-8, and bounds.
279-
Sender nonces outside uint32 are rejected. See [development](development.md)
279+
Ticket nonces outside uint32 are rejected. See [development](development.md)
280280
for fixtures and test commands.

‎docs/payment-recovery.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ replicas with the same key and webhook configuration; outbox files must not be s
4949

5050
## Orchestrator transaction recovery
5151

52-
Redemption attempts use these states:
52+
The orchestrator account is the redeemer. Redemption attempts use these states:
5353

5454
| State | Meaning and recovery |
5555
| --- | --- |

‎docs/signer.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ allow a budget to be exceeded before authorization stops further signing.
209209

210210
Use the metrics listener (default `127.0.0.1:8938`) for `/healthz`, `/readyz`,
211211
and `/metrics`.
212-
Readiness checks chain access, sender funds, exchange-rate freshness, and enabled
212+
Readiness checks chain access, payer funds, exchange-rate freshness, and enabled
213213
outbox storage. Monitor pending events, oldest event age, publish errors, and
214214
filesystem space. Kafka connectivity alone does not determine readiness.
215215

‎eth/payment.go‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,22 @@ type RedeemTicket struct {
170170
RecipientRand *big.Int
171171
}
172172

173-
func (c PaymentChain) PrepareRedemption(ctx context.Context, key *Key, chainID *big.Int, t RedeemTicket) (SignedTransaction, error) {
174-
return c.prepareRedemption(ctx, key, chainID, t, nil)
173+
func (c PaymentChain) PrepareRedemption(ctx context.Context, redeemer *Key, chainID *big.Int, t RedeemTicket) (SignedTransaction, error) {
174+
return c.prepareRedemption(ctx, redeemer, chainID, t, nil)
175175
}
176176

177177
// PrepareRedemptionAndStore reserves the nonce only after the caller saves the
178178
// signed redemption identity, before any possible broadcast.
179-
func (c PaymentChain) PrepareRedemptionAndStore(ctx context.Context, key *Key, chainID *big.Int, t RedeemTicket, save func(SignedTransaction) error) (SignedTransaction, error) {
179+
func (c PaymentChain) PrepareRedemptionAndStore(ctx context.Context, redeemer *Key, chainID *big.Int, t RedeemTicket, save func(SignedTransaction) error) (SignedTransaction, error) {
180180
if save == nil {
181181
return SignedTransaction{}, errors.New("transaction persistence is required")
182182
}
183-
return c.prepareRedemption(ctx, key, chainID, t, save)
183+
return c.prepareRedemption(ctx, redeemer, chainID, t, save)
184184
}
185185

186-
func (c PaymentChain) prepareRedemption(ctx context.Context, key *Key, chainID *big.Int, t RedeemTicket, save func(SignedTransaction) error) (SignedTransaction, error) {
187-
if key == nil || key.Address() != t.Recipient || t.FaceValue == nil || t.WinProb == nil || t.RecipientRand == nil {
188-
return SignedTransaction{}, errors.New("redemption recipient key mismatch")
186+
func (c PaymentChain) prepareRedemption(ctx context.Context, redeemer *Key, chainID *big.Int, t RedeemTicket, save func(SignedTransaction) error) (SignedTransaction, error) {
187+
if redeemer == nil || redeemer.Address() != t.Recipient || t.FaceValue == nil || t.WinProb == nil || t.RecipientRand == nil {
188+
return SignedTransaction{}, errors.New("redeemer account does not match ticket recipient")
189189
}
190190
address, err := c.Contracts.Resolve(ctx, "ticketBroker")
191191
if err != nil {
@@ -196,18 +196,18 @@ func (c PaymentChain) prepareRedemption(ctx context.Context, key *Key, chainID *
196196
if err != nil {
197197
return SignedTransaction{}, err
198198
}
199-
plan, err := c.Contracts.PlanTransaction(ctx, key.Address(), address, data, big.NewInt(0))
199+
plan, err := c.Contracts.PlanTransaction(ctx, redeemer.Address(), address, data, big.NewInt(0))
200200
if err != nil {
201201
return SignedTransaction{}, err
202202
}
203203
if save != nil {
204-
return c.Contracts.PrepareAndStore(ctx, plan, key, chainID, save)
204+
return c.Contracts.PrepareAndStore(ctx, plan, redeemer, chainID, save)
205205
}
206-
return c.Contracts.Prepare(ctx, plan, key, chainID)
206+
return c.Contracts.Prepare(ctx, plan, redeemer, chainID)
207207
}
208208

209-
func (c PaymentChain) Redeem(ctx context.Context, key *Key, chainID *big.Int, t RedeemTicket) (ethcommon.Hash, error) {
210-
tx, err := c.PrepareRedemption(ctx, key, chainID, t)
209+
func (c PaymentChain) Redeem(ctx context.Context, redeemer *Key, chainID *big.Int, t RedeemTicket) (ethcommon.Hash, error) {
210+
tx, err := c.PrepareRedemption(ctx, redeemer, chainID, t)
211211
if err != nil {
212212
return ethcommon.Hash{}, err
213213
}

‎orchestrator/app.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,12 @@ func Serve(parent context.Context, p Params, logOut io.Writer) (result error) {
278278
var engine *pm.Engine
279279
var paymentStore *pm.SQLiteStore
280280
var paymentChain eth.PaymentChain
281-
var paymentKey *eth.Key
281+
var redeemerKey *eth.Key
282282
var paymentChainID *big.Int
283283
if p.KeystoreFile != "" {
284284
rate, _ := new(big.Rat).SetString(p.WeiPerUSD)
285285
registry.SetWeiPerUSD(rate)
286-
paymentKey, err = eth.OpenKeystoreFile(p.KeystoreFile, p.KeystorePasswordFile)
286+
redeemerKey, err = eth.OpenKeystoreFile(p.KeystoreFile, p.KeystorePasswordFile)
287287
if err != nil {
288288
return err
289289
}
@@ -321,7 +321,7 @@ func Serve(parent context.Context, p Params, logOut io.Writer) (result error) {
321321
}
322322
face, _ := new(big.Int).SetString(p.TicketFaceValue, 10)
323323
prob, _ := new(big.Int).SetString(p.TicketWinProb, 10)
324-
engine, err = pm.NewEngine(paymentStore, pm.EthereumChain{Client: paymentChain}, paymentKey.Address(), face, prob)
324+
engine, err = pm.NewEngine(paymentStore, pm.EthereumChain{Client: paymentChain}, redeemerKey.Address(), face, prob)
325325
if err != nil {
326326
return err
327327
}
@@ -411,7 +411,7 @@ func Serve(parent context.Context, p Params, logOut io.Writer) (result error) {
411411
}
412412
})
413413
startWorker(p.HeartbeatInterval, 30*time.Second, func(ctx context.Context) {
414-
for _, err := range pm.ProcessRedemptions(ctx, paymentStore, paymentChain, paymentKey, paymentChainID) {
414+
for _, err := range pm.ProcessRedemptions(ctx, paymentStore, paymentChain, redeemerKey, paymentChainID) {
415415
logger.Error("payment redemption", "error", err)
416416
}
417417
})

‎orchestrator/payment.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func (s *Server) challenge(w http.ResponseWriter, r *http.Request, runnerID stri
2727
fail(w, http.StatusServiceUnavailable, "on-chain payment is unavailable")
2828
return
2929
}
30-
senderRaw := r.Header.Get("Livepeer-Payer-Address")
31-
if !eth.ValidAddress(senderRaw) {
30+
payerRaw := r.Header.Get("Livepeer-Payer-Address")
31+
if !eth.ValidAddress(payerRaw) {
3232
fail(w, http.StatusPaymentRequired, "Livepeer-Payer-Address is required")
3333
return
3434
}
@@ -38,7 +38,7 @@ func (s *Server) challenge(w http.ResponseWriter, r *http.Request, runnerID stri
3838
return
3939
}
4040
wei, _ := paymentPrice(price)
41-
challenge, err := s.payment.MakeChallenge(r.Context(), runnerID, manifest, ethcommon.HexToAddress(senderRaw), wei, price.Unit, s.registry.service)
41+
challenge, err := s.payment.MakeChallenge(r.Context(), runnerID, manifest, ethcommon.HexToAddress(payerRaw), wei, price.Unit, s.registry.service)
4242
if err != nil {
4343
s.logger.Error("payment challenge failed", "runner_id", runnerID, "error", err)
4444
fail(w, 502, "payment challenge unavailable")
@@ -210,14 +210,14 @@ func (s *Server) refreshPayment(w http.ResponseWriter, r *http.Request) {
210210
return
211211
}
212212
var request struct {
213-
Sender string `json:"sender"`
214-
ManifestID string `json:"manifest_id"`
213+
PayerAddress string `json:"sender"`
214+
ManifestID string `json:"manifest_id"`
215215
}
216-
if err := decode(r, &request); err != nil || !eth.ValidAddress(request.Sender) || !validRouteID(request.ManifestID) {
216+
if err := decode(r, &request); err != nil || !eth.ValidAddress(request.PayerAddress) || !validRouteID(request.ManifestID) {
217217
fail(w, 400, "invalid refresh request")
218218
return
219219
}
220-
challenge, err := s.payment.RefreshChallenge(r.Context(), request.ManifestID, ethcommon.HexToAddress(request.Sender), s.registry.service)
220+
challenge, err := s.payment.RefreshChallenge(r.Context(), request.ManifestID, ethcommon.HexToAddress(request.PayerAddress), s.registry.service)
221221
if err != nil {
222222
fail(w, 404, "payment challenge not found")
223223
return

‎orchestrator/payment_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ type paymentTestChain struct{}
3333
func (paymentTestChain) Snapshot(context.Context) (pm.ChainSnapshot, error) {
3434
return pm.ChainSnapshot{Block: big.NewInt(50), Round: big.NewInt(5), RoundHash: ethcommon.HexToHash("0x1234")}, nil
3535
}
36-
func (c paymentTestChain) SenderInfo(ctx context.Context, _, _ ethcommon.Address) (eth.SenderInfo, error) {
36+
func (c paymentTestChain) PayerFunds(ctx context.Context, _, _ ethcommon.Address) (pm.PayerFunds, error) {
3737
snapshot, err := c.Snapshot(ctx)
38-
return eth.SenderInfo{Snapshot: snapshot, Deposit: big.NewInt(1000000000), Reserve: big.NewInt(1000000000), WithdrawRound: new(big.Int)}, err
38+
return pm.PayerFunds{Snapshot: snapshot, Deposit: big.NewInt(1000000000), Reserve: big.NewInt(1000000000), WithdrawRound: new(big.Int)}, err
3939
}
4040
func (paymentTestChain) IsActiveAt(context.Context, ethcommon.Address, pm.ChainSnapshot) (bool, error) {
4141
return true, nil
@@ -255,9 +255,9 @@ type advancingPaymentChain struct{ block atomic.Int64 }
255255
func (c *advancingPaymentChain) Snapshot(context.Context) (pm.ChainSnapshot, error) {
256256
return pm.ChainSnapshot{Block: big.NewInt(c.block.Load()), Round: big.NewInt(5), RoundHash: ethcommon.HexToHash("0x1234")}, nil
257257
}
258-
func (c *advancingPaymentChain) SenderInfo(ctx context.Context, _, _ ethcommon.Address) (eth.SenderInfo, error) {
258+
func (c *advancingPaymentChain) PayerFunds(ctx context.Context, _, _ ethcommon.Address) (pm.PayerFunds, error) {
259259
snapshot, err := c.Snapshot(ctx)
260-
return eth.SenderInfo{Snapshot: snapshot, Deposit: big.NewInt(1000000000), Reserve: big.NewInt(1000000000), WithdrawRound: new(big.Int)}, err
260+
return pm.PayerFunds{Snapshot: snapshot, Deposit: big.NewInt(1000000000), Reserve: big.NewInt(1000000000), WithdrawRound: new(big.Int)}, err
261261
}
262262
func (c *advancingPaymentChain) IsActiveAt(context.Context, ethcommon.Address, pm.ChainSnapshot) (bool, error) {
263263
return true, nil

0 commit comments

Comments
 (0)