e2e/qa: accommodate seat-withdraw prorating in multicast settlement test#3559
Merged
e2e/qa: accommodate seat-withdraw prorating in multicast settlement test#3559
Conversation
testnet enables prorated-service in the shred-subscription program while mainnet does not; the strict balance-delta assertion fails on testnet when a partial refund arrives on withdraw. gate the assertion on a new -seat-prorating-enabled flag driven by the CI workflow, and on that path replicate the onchain formula — refund = (effective_price * remaining_slots) / slots_per_epoch — bracketing Clock::get().slot with GetSlot() calls either side of FeedSeatWithdraw. new helpers in qa.Client (GetSlot, ComputeProratedRefundBounds) plus pure math helpers (firstSlotInEpoch, saturatingSubU64, proratedAmount) with unit tests. the infra workflow gains -seat-prorating-enabled for testnet in a separate PR.
the tests just restated the formulas they were checking — no real verification value. the onchain-match is validated by the e2e run.
…fund Replicating the onchain prorating formula from client RPC state proved fragile (epoch schedule quirks on DZ ledger, timing of current_subscription_epoch reads vs tx execution). Swap to qualitative invariants that catch a real prorating regression without re-deriving onchain math: refund > 0, retained > 0, refund < effective_price, and refund + retained == effective_price.
e22f612 to
ffdd1dd
Compare
martinsander00
approved these changes
Apr 21, 2026
Replace the -seat-prorating-enabled CLI flag with a runtime check that reads ProgramConfig.Flags bit 2 via the existing Go shreds SDK. Mirrors the Rust is_prorated_service_enabled() accessor. The multicast settlement test now self-adapts across environments (testnet has prorating on, mainnet does not) with no CI workflow changes needed. Also adds IsPaused() and IsMigrated() accessors for symmetry with the Rust flag helpers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
TestQA_MulticastSettlement/validate_balance_after_withdrawon a new-seat-prorating-enabledflag so the same test binary works on both testnet (prorated-service enabled) and mainnet (disabled).doublezero-shreds—refund = (effective_price * remaining_slots) / slots_per_epoch— usingExecutionController.current_subscription_epochand the RPC epoch schedule. The client'sClock::get().slotis unobservable, so bracket it withGetSlot()either side ofFeedSeatWithdrawand assert the observed refund falls within[lower, upper].qa.Client(GetSlot,ComputeProratedRefundBounds) plus pure math helpers (firstSlotInEpoch,saturatingSubU64,proratedAmountusingmath/bigto match the program's u128 intermediate).-seat-prorating-enabledto testnet QA runs) ships in a separate PR inmalbeclabs/infra.Why
QA run malbeclabs/infra/actions/runs/24733964249 failed with:
testnet's shred-subscription program has prorated-service enabled; the strict
balance_after_withdraw == balance_before_pay − effective_priceassertion doesn't hold when a partial refund arrives. Operators know per-environment whether prorating is deployed, so a CI-controlled flag is the clearest switch.Testing Verification
go test -tags=qa -run=^$ ./e2e -env=testnet— qa-tagged test file compiles under the build tag.make go-lint— clean.