Skip to content

e2e/qa: accommodate seat-withdraw prorating in multicast settlement test#3559

Merged
packethog merged 4 commits intomainfrom
ss/pedantic-diffie-ecfef2
Apr 21, 2026
Merged

e2e/qa: accommodate seat-withdraw prorating in multicast settlement test#3559
packethog merged 4 commits intomainfrom
ss/pedantic-diffie-ecfef2

Conversation

@packethog
Copy link
Copy Markdown
Contributor

@packethog packethog commented Apr 21, 2026

Summary of Changes

  • Gate TestQA_MulticastSettlement/validate_balance_after_withdraw on a new -seat-prorating-enabled flag so the same test binary works on both testnet (prorated-service enabled) and mainnet (disabled).
  • On the prorating path, replicate the onchain formula from doublezero-shredsrefund = (effective_price * remaining_slots) / slots_per_epoch — using ExecutionController.current_subscription_epoch and the RPC epoch schedule. The client's Clock::get().slot is unobservable, so bracket it with GetSlot() either side of FeedSeatWithdraw and assert the observed refund falls within [lower, upper].
  • Add helpers on qa.Client (GetSlot, ComputeProratedRefundBounds) plus pure math helpers (firstSlotInEpoch, saturatingSubU64, proratedAmount using math/big to match the program's u128 intermediate).
  • Infra workflow change (pass -seat-prorating-enabled to testnet QA runs) ships in a separate PR in malbeclabs/infra.

Why

QA run malbeclabs/infra/actions/runs/24733964249 failed with:

--- FAIL: TestQA_MulticastSettlement/validate_balance_after_withdraw
    Messages: USDC balance should equal before_pay minus the effective seat price

testnet's shred-subscription program has prorated-service enabled; the strict balance_after_withdraw == balance_before_pay − effective_price assertion 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.

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.
@packethog packethog force-pushed the ss/pedantic-diffie-ecfef2 branch from e22f612 to ffdd1dd Compare April 21, 2026 19:09
@packethog packethog marked this pull request as ready for review April 21, 2026 19:09
@packethog packethog self-assigned this Apr 21, 2026
@packethog packethog marked this pull request as draft April 21, 2026 19:13
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.
@packethog packethog marked this pull request as ready for review April 21, 2026 19:19
@packethog packethog merged commit 8f2cc9a into main Apr 21, 2026
44 of 46 checks passed
@packethog packethog deleted the ss/pedantic-diffie-ecfef2 branch April 21, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants