feat(signer): bill BYOC live payments from CapabilitiesPrices#3976
Conversation
Resolve per-capability BYOC fees from the orchestrator's advertised CapabilitiesPrices, keyed on Capability_BYOC constraints already present in the request capabilities blob. No RemotePaymentRequest format change. Gated behind default-OFF -byocPerCapPricing. When OFF or no usable cap price matches, behavior stays on the base-price / lv2v pixel path.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Select the pricing basis from the request capability type rather than req.Type: a BYOC capability is charged per-capability over compute-seconds, while lv2v (and everything else) keeps its existing pricing. Since BYOC jobs always send type:"lv2v", the capability in the request is the real signal; resolveByocPrice returns nil for non-BYOC caps so lv2v is unchanged. Extract the per-capability price lookup into a shared findCapPriceInfo helper reused by resolveByocPrice and remote_discovery capabilityPrice. The requirePositiveRate flag preserves each caller's semantics (signer skips non-positive rates and keeps scanning; discovery allows a zero/free rate on first match).
| if useByocPricing { | ||
| // BYOC prices are per compute-second; bill seconds instead of lv2v pixels. | ||
| if billableSecs <= 0 { | ||
| billableSecs = (60 * time.Second).Seconds() | ||
| } | ||
| pixels = int64(math.Ceil(billableSecs)) | ||
| } else if req.Type == RemoteType_LiveVideoToVideo { |
There was a problem hiding this comment.
@seanhanca I think this is what you're looking to get corrected on pricing?
Eliminate the ByocPerCapPricing configuration option from the LivepeerConfig structure and its associated logic throughout the codebase. Update related tests to reflect the change in naming and functionality, ensuring consistency in pricing behavior for live payments.
Summary
OrchestratorInfo.CapabilitiesPriceswhen a matchingCapability_BYOCmodel constraint is present, instead of the flat base price.capabilitiesblob (ModelIDForCapability(Capability_BYOC)), matching how orch already advertises BYOC prices.lv2v(and BYOC with no matching price) → keep base price + pixel billing.capability/model_idstring fields toRemotePaymentRequest. Usage attribution already works when the gateway sends BYOC capabilities (see livepeer-python-gatewaybd8e780).-byocPerCapPricingremoved).This is the minimal pricing half of what #3972 bundled with a redundant request-format change for usage labels.
Test plan
TestResolveByocPrice— match / fallback / invalid-duplicate skip, keyed off BYOC capsTestGenerateLivePayment_ByocCapabilityPricing— per-cap seconds fee, 2:1 tariff ratio, unknown-cap fallback to base + pixels, doubling-guard not tripped