Skip to content

Carry the paid manifest_id on call_runner streams and errors - #71

Draft
eliteprox wants to merge 3 commits into
livepeer:mainfrom
eliteprox:feat/call-runner-manifest-id
Draft

eliteprox wants to merge 3 commits into
livepeer:mainfrom
eliteprox:feat/call-runner-manifest-id

Conversation

@eliteprox

Copy link
Copy Markdown
Collaborator

Summary

  • A successful unary call_runner already returns the paid challenge's manifest_id as LiveRunnerCallResult.session_id. A stream now does the same on LiveRunnerCallStream.session_id, and it is "" when no challenge was answered.
  • Errors raised from a call_runner attempt carry payment_sent and manifest_id. payment_sent is true only after that attempt's request included Livepeer-Payment headers, so a gateway can fail over to another runner only before payment. manifest_id is the paid challenge's id, so a failed paid call can still be joined to the signer's create_signed_ticket event. It is not the signer state id or pm_session_id.
  • When challenge retries are exhausted, payment_sent covers every attempt and manifest_id is the last paid one.

Test plan

  • uv run --frozen --group lint ruff check on the three changed files
  • uv run --frozen --group test pytest --cov=livepeer_gateway --cov-branch (254 passed)
  • Snyk Code on errors.py and live_runner.py (no issues)
  • Review the failover rule: another runner is safe only while payment_sent is false

LiveRunnerCallStream.session_id carries the answered payment challenge's
manifest_id, as LiveRunnerCallResult.session_id already does for unary calls;
it is "" when no challenge was answered.

Errors raised from a call_runner attempt carry payment_sent, True when that
attempt's request already carried Livepeer-Payment headers, and manifest_id,
the paid challenge's manifest_id ("" when unpaid). A gateway may fail over to
another runner only while payment_sent is False, and can attribute the
network cost of a paid call that failed. When the challenge retries run out,
payment_sent covers every attempt and manifest_id is the last paid one.

manifest_id is the key the signer's create_signed_ticket Kafka event carries
as manifest_id; it is not the event's session_id (the signer state id) or
pm_session_id (the orchestrator ticket params' recipientRandHash).

Replayed onto livepeer/livepeer-python-gateway main without the multipart
commit this change was previously stacked on.
Selection keeps each failed attempt as capacity, unreachable, or other, and copies payment_sent and the paid manifest id onto the rejection so a gateway can stop after a paid attempt.
Refactor the error handling in LivepeerGatewayError and related classes to replace the manifest_id with auth_ids, which now captures the signer auth IDs for each payment session. This change allows for better tracking of payment sessions across errors and runner rejections, ensuring that the system can accurately attribute costs and manage retries based on the associated auth IDs. Update tests to reflect these changes and ensure proper functionality.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant