Skip to content

server: Report payment interval in payment challenges - #4001

Closed
rickstaa wants to merge 1 commit into
masterfrom
rs/singleshot-payment-interval
Closed

server: Report payment interval in payment challenges#4001
rickstaa wants to merge 1 commit into
masterfrom
rs/singleshot-payment-interval

Conversation

@rickstaa

Copy link
Copy Markdown
Member

Stacked on #4000 (which is stacked on #3999).

What does this pull request do?

Adds payment_interval_ms to the payment challenge JSON so paying clients know the orchestrator's debit cadence and can size and time payments to keep the session balance funded. Without it, clients have no way to learn the interval and risk being released for underpayment between top-ups.

Ports the challenge-interval change from #3998 by @ad-astra-video (originally approved as #3975), rebased onto the #3999/#4000 payment refactor. Credited as co-author.

Specific updates

  • Add payment_interval_ms to liveRunnerPaymentChallengeResponse, populated from node.LivePaymentInterval in all three challenge producers: session reservation / single-shot challenge (runnerChallenge), scope challenge (scopePaymentChallenge), and the remote signer refresh path (RefreshPayment in rpc.go).
  • Assert the field in TestLiveRunnerReserveSessionOnchainReturnsPaymentChallenge.
  • Document the field in doc/live-runner.md.

🤖 Generated with Claude Code

@github-actions github-actions Bot added go Pull requests that update Go code AI Issues and PR related to the AI-video branch. docs labels Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d275f4a7-414d-4879-8e88-4db8e8776d85

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rs/singleshot-payment-interval

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rickstaa
rickstaa marked this pull request as draft July 24, 2026 20:49
Base automatically changed from ja/singleshot-payments to master July 24, 2026 21:40
rickstaa added a commit to livepeer/livepeer-python-gateway that referenced this pull request Jul 30, 2026
livepeer/go-livepeer#4001 adds payment_interval_ms to payment
challenges. Until it lands the client guesses a cadence against the
orchestrator's default debit interval, so record what replaces the
guess.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add payment_interval_ms to the live runner payment challenge JSON
(reservation, scope, and refresh-payment responses) so paying clients
know the orchestrator's debit cadence and can size and time payments
to keep the session balance funded.

Ported from #3998 (originally approved as #3975).

Co-authored-by: Brad P <brad@ad-astra.video>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 30, 2026 16:19
@rickstaa
rickstaa force-pushed the rs/singleshot-payment-interval branch from b333b99 to 9e58323 Compare July 30, 2026 16:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.47615%. Comparing base (df527c3) to head (9e58323).

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #4001         +/-   ##
===================================================
- Coverage   35.53014%   35.47615%   -0.05399%     
===================================================
  Files            174         174                 
  Lines          45111       45112          +1     
===================================================
- Hits           16028       16004         -24     
- Misses         27814       27837         +23     
- Partials        1269        1271          +2     
Files with missing lines Coverage Δ
server/ai_http.go 46.95652% <100.00000%> (+0.04196%) ⬆️
server/rpc.go 69.26714% <100.00000%> (ø)

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df527c3...9e58323. Read the comment docs.

Files with missing lines Coverage Δ
server/ai_http.go 46.95652% <100.00000%> (+0.04196%) ⬆️
server/rpc.go 69.26714% <100.00000%> (ø)

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

rickstaa added a commit to livepeer/livepeer-python-gateway that referenced this pull request Jul 30, 2026
The orchestrator's debit interval does not bound it: both sides bill by
elapsed time at the same rate, so cadence changes how much credit is
banked when a debit lands, not what a session costs. What has to hold is
that a payment arrives inside the signer's opening payment.

Drops the pointer to livepeer/go-livepeer#4001 with it. Reading the
reported interval would not change the cadence we pick, since the bound
comes from the signer, so that PR is closed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rickstaa

Copy link
Copy Markdown
Member Author

Closing — the cadence this reports turns out not to be the number a paying client needs.

Both sides of the ledger bill by elapsed time at the same rate. The signer charges for the seconds since the last payment (server/remote_signer.go:476-490) and the orchestrator debits the seconds since its last tick (server/live_payment_processor.go:72-76, units × secSinceLastProcessed), using the same defaultSegInfo constant on both sides. So the client's cadence does not change what a session costs, only how much credit is banked at the moment AccountPayment runs its balance >= fee check.

Working that through, the safety condition is preroll ≥ cadence — the orchestrator's interval cancels out. A client paying every 3s is equally safe against -livePaymentInterval 1s and 300s; what would break it is a cadence above the signer's opening payment (10s for per-second pricing, 60s for pixel pricing).

So a client that read payment_interval_ms would not pick a different cadence with it than without it. Rather than ship a field that invites clients to size payments off the wrong bound, closing this.

The rebase onto master is done, so if this is wanted later it is a clean 14-line diff to reopen. Credit to @ad-astra-video, whose original this ports (#3998, approved as #3975) — the close is about what the client can do with the value, not the change itself.

@rickstaa rickstaa closed this Jul 30, 2026
rickstaa added a commit to livepeer/livepeer-python-gateway that referenced this pull request Jul 30, 2026
The signer's opening payment bounds it, not the orchestrator's debit
interval: both sides bill by elapsed time at the same rate. Drops the
pointer to livepeer/go-livepeer#4001, closed for the same reason.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
rickstaa added a commit to livepeer/livepeer-python-gateway that referenced this pull request Jul 30, 2026
The signer's opening payment bounds it, not the orchestrator's debit
interval: both sides bill by elapsed time at the same rate. Drops the
pointer to livepeer/go-livepeer#4001, closed for the same reason.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
j0sh pushed a commit to livepeer/livepeer-python-gateway that referenced this pull request Aug 1, 2026
livepeer/go-livepeer#4001 adds payment_interval_ms to payment
challenges. Until it lands the client guesses a cadence against the
orchestrator's default debit interval, so record what replaces the
guess.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
j0sh pushed a commit to livepeer/livepeer-python-gateway that referenced this pull request Aug 1, 2026
The signer's opening payment bounds it, not the orchestrator's debit
interval: both sides bill by elapsed time at the same rate. Drops the
pointer to livepeer/go-livepeer#4001, closed for the same reason.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Issues and PR related to the AI-video branch. docs go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants