Expose polled_at_ms on arena timers and deepen API integration tests #333
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:open_issues
agents
agent:security_audit
agent:verify
area
timecurve
arena
arena-v2
audit
block:feature_review
block:security
bug
contracts
design
devops
docs
documentation
enhancement
epic
feature
frontend
indexer
low priority
megaeth
operations
ops
performance
QA
qa checklist
referrals
removal
security
smart-contracts
tech-debt
testing
time-arena
timecurve
visual-qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/yieldomega#333
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
Gap analysis follow-up from #331.
Current codebase
ChainTimerSnapshotandTimecurveHeadSnapshotalready trackpolled_at_msinternally (indexer/src/chain_timer.rs,indexer/src/chain_timer_poll.rs·refresh_snapshot_polled_at_ms).GET /v1/arena/timershandler (indexer/src/api_arena.rs·arena_timers) serializes head fields but omitspolled_at_msfrom the JSON body.ArenaTimersResponse(frontend/src/lib/indexerApi.ts) has nopolled_at_ms;fetchLegacyArenaSaleStateandcoreReadRowsFromArenaTimerssubstituteDate.now()— causing countdown drift vs indexer poll instant.useArenaHeroTimeranchors skew fromblock_timestamp_sec+ localfetchedAtSec, not indexer poll time.indexer/tests/integration_stage2.rs(api_http_smoke) asserts HTTP 200 and coarse JSON presence only — no field-parity checks for timers, activity kinds/shapes, or wallet-stats bonus fields beyond dedicated partial tests.Why needed
Approved in #331 comment (2026-06-19): expose timer poll freshness to clients and harden API contract tests so UX countdown logic can align with indexer poll instants without guessing wall clock.
Constraints / guardrails
polled_at_ms, not invent poll time.INV-INDEXER-308-TIMER-FRESHNESS).x-schema-versionif response shape changes; document inindexer/README.mdanddocs/indexer/design.md.VITE_INDEXER_URLis set.Relevant files
indexer/src/api_arena.rsindexer/src/chain_timer_poll.rs,indexer/src/chain_timer.rsindexer/tests/integration_stage2.rsfrontend/src/lib/indexerApi.ts,frontend/src/pages/arena/useArenaHeroTimer.ts,frontend/src/pages/arena/useArenaSaleState.tsdocs/indexer/rpc-load-benchmark.md,docs/testing/invariants-and-business-logic.mdRecommended direction
"polled_at_ms": h.timer.polled_at_ms(numeric) toGET /v1/arena/timersJSON; extendArenaTimersResponseand wire consumers to prefer API value overDate.now().useArenaHeroTimerskew anchoring to usepolled_at_mswhen present (fallback for older indexers).integration_stage2.rs:/v1/arena/timersincludes required keys (polled_at_ms,podium_timer_armed,charm_price_wad, …) with typed values./v1/arena/activityrow shapes (kind,bp_delta,amount_doub_wad, steal/guard/revenge/buy) — extend beyond kind presence./v1/arena/wallet/{address}/statsreturns expected bonus-field keys for fixture wallets.Acceptance criteria
GET /v1/arena/timersreturnspolled_at_msmatching internal snapshot (within test tolerance).polled_at_mswhen available.cd indexer && cargo clippy --all-targets -- -D warnings && cargo testpasses.cd frontend && npm run typecheck && npm testpasses.Test plan
cd indexer && cargo clippy --all-targets -- -D warnings && cargo testindexer/YIELDOMEGA_PG_TEST_URL=postgres://yieldomega:password@127.0.0.1:5433/yieldomega_indexer_test cargo test --test integration_stage2indexer/tests/integration_stage2.rscd frontend && npm run typecheck && npm run lint && npm testfrontend/bash scripts/verify-podium-live-anvil.shscripts/Include happy and sad paths for new/changed HTTP handlers (valid head, 503 unavailable, bad wallet address).
Attack / abuse test plan
polled_at_msis read-only metadata — no user input surface.Verification criteria
curl -sf http://127.0.0.1:3100/v1/arena/timers | jq .polled_at_msreturns a recent unix-ms integer when stack is up.cargo test→ PASS.mentioned in issue #331
mentioned in merge request !506
Verification — issue #333 (PASS)
Verified Expose polled_at_ms on arena timers and deepen API integration tests on
mainwith no repo changes required.Acceptance criteria
GET /v1/arena/timersreturnspolled_at_msmatching internal snapshotintegration_stage2.rsapi_http_smokeasserts fixture1_700_000_000_123; live Anvil stack curl returnedpolled_at_ms=1781856365950(Δ 343 ms vs wall clock)polled_at_mswhen availableArenaTimersResponse.polled_at_msinindexerApi.ts;arenaTimersPolledAtMs()prefers API value;useArenaHeroTimeranchors skew frompolled_at_ms;indexerFirstDisplay.test.ts+useArenaSaleState.test.tsapi_http_smokecheckspolled_at_ms,podium_timer_armed,charm_price_wad, activity buy fields, wallet-stats bonus keys; sad paths: 503chain_timer_unavailable, malformed wallet → 400invalid_addressSCHEMA_VERSION = "2.18.0"inapi.rs;x-schema-version: 2.18.0on live curl; documented inindexer/README.mdanddocs/indexer/design.mdcd indexer && cargo clippy --all-targets -- -D warnings && cargo testcd frontend && npm run typecheck && npm testTest plan (issue body)
cargo clippy --all-targets -- -D warnings && cargo testYIELDOMEGA_PG_TEST_URL=… cargo test --test integration_stage2npm run typecheck && npm run lint && npm testbash scripts/verify-podium-live-anvil.shcurl -sf http://127.0.0.1:3102/v1/arena/timers | jq .polled_at_ms(ephemeral Anvil stack)Attack / abuse checks
polled_at_msis read-only metadata (no user input)invalid_address)Invariants / guardrails
Date.now()when present (PASS)Closing as verified on
main.