Add off-chain voting anchor tests - #3498
Conversation
56ebbcb to
7f2eee1
Compare
|
Local cluster tests: 💚 Full log: |
5121d90 to
fa341ef
Compare
There was a problem hiding this comment.
Pull request overview
Adds new Conway-era end-to-end coverage for cardano-db-sync’s off-chain voting anchor ingestion, specifically validating how db-sync stores anchor payloads (including non-decodable and invalid JSON cases) and records parse outcomes via off_chain_vote_data.is_valid. It also extends db-sync helper utilities to reliably target the correct off_chain_vote_data row when multiple anchors share the same content hash.
Changes:
- Add a new
tests_conway/test_offchain_voting_anchor.pysuite covering gov-action and DRep anchors foris_valid= TRUE/FALSE/NULL scenarios. - Extend db-sync helpers to (a) resolve a gov-action’s
voting_anchor_id, (b) wait for the off-chain row to appear, and (c) makecheck_action_dataselect the correct row and assertis_valid=True. - Add/rename committed anchor-vector files and expose their raw GitHub URLs via new
common.pyconstants; makeGovActionProposalDBRow.param_proposalnullable.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cardano_node_tests/utils/dbsync_utils.py | Adds db-sync-specific timeout error, voting-anchor-id resolution, and robust wait/selection logic for off-chain vote data; updates check_action_data to target correct rows. |
| cardano_node_tests/utils/dbsync_queries.py | Makes GovActionProposalDBRow.param_proposal nullable to match info-action behavior. |
| cardano_node_tests/tests/tests_conway/test_offchain_voting_anchor.py | New db-sync Conway tests for off-chain voting anchor storage/decoding outcomes across gov-actions and DReps. |
| cardano_node_tests/tests/tests_conway/test_info.py | Updates check_action_data call to pass the action txid for voting-anchor-id resolution. |
| cardano_node_tests/tests/data/ga_anchor_nonconf.json | Adds valid-JSON but non-decodable/non-conformant test vector. |
| cardano_node_tests/tests/data/ga_anchor_invalid.json | Adds intentionally invalid JSON test vector. |
| cardano_node_tests/tests/common.py | Adds new public raw GitHub URL constants for the new anchor vectors. |
Suppressed comments (2)
cardano_node_tests/utils/dbsync_utils.py:1522
typing.castshould receive the type object (e.g.dict[str, tp.Any]), not a string literal; otherwise static type checking can’t validate the cast.
gov_action_data=tp.cast("dict[str, tp.Any]", gov_action or {}),
cardano_node_tests/utils/dbsync_utils.py:1575
typing.castexpects a type object, not a quoted string. Using the actual class here keeps the cast useful for static analysis.
return tp.cast(
"dbsync_types.OffChainVoteDataRecord",
retry_query(query_func=_query_func, timeout=timeout),
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Verify db-sync off-chain voting anchor handling (PR #2005, issue #1995): an anchor whose hash matches is stored regardless of whether it parses, with off_chain_vote_data.is_valid set to TRUE (CIP decodable), FALSE (valid JSON, not decodable) or NULL (not valid JSON), for both gov-action and DRep anchors. The test vector files use short names so their public raw-content URLs stay under the 128-byte on-chain anchor limit; the URLs are kept as PUBLIC_ACTION_ANCHOR_* constants in common. Supporting helper changes: - get_action_data / check_action_data: optional voting_anchor_id to pick the right row when several anchors share a content hash, and assert is_valid. - GovActionProposalDBRow.param_proposal made nullable; it is NULL for info actions and only set for parameter-change actions.
Address multi-round review findings: * Use VERSIONS.CONWAY_FIRST for the era check so the module is not skipped on protocol versions 9 and 10. * Add the needs_dbsync marker so tests skip instead of failing with a raw db connection error when db-sync is not available. * Promote the off-chain vote data wait helper to dbsync_utils, make voting_anchor_id required and report fetch errors, elapsed time and a data-presence diagnostic on timeout, so a db-sync regression, a failed download, a too short timeout and a wrong anchor id are all distinguishable. * Require voting_anchor_id in get_action_data. The same content can back several anchors, so a hash-only lookup can silently validate a row fetched for a different anchor and mask a failure. * Make check_action_data self-contained: it resolves the gov action's own voting_anchor_id from the proposal's tx when not provided and waits for the off-chain data row, so tests don't need any db-sync related logic of their own. * Raise dedicated DbSyncTimeoutError from retry_query so low-level socket timeouts are not misattributed to db-sync waits. * Check is_valid and the presence of the gov action data row in check_action_data. * Cover the CIP-100 fallback on DRep anchors (is_valid=TRUE with empty off_chain_vote_drep_data). * Register the DRep retirement finalizer before submitting the registration tx and skip retirement when the DRep is not registered, so a failed test cannot leak a registered DRep. * Correct the module docstring claim about gov action hash validation and fix various docstring inaccuracies.
fa341ef to
1cf5321
Compare
Summary
Conway tests verifying cardano-db-sync's off-chain voting anchor handling (db-sync PR #2005, issue #1995). When an anchor's hash matches, db-sync stores it regardless of whether it parses, recording the outcome in
off_chain_vote_data.is_valid:TRUE- valid JSON db-sync can decode (CIP-100 / CIP-108 / CIP-119)FALSE- valid JSON it cannot decode against any CIP schema (warningrecords why)NULL- not valid JSON (error object injson, rawbytespreserved)Covered for both gov-action (info action) and DRep anchors.
Helper changes
get_action_data/check_action_data: optionalvoting_anchor_idto select the correct row when several anchors share the same content hash;check_action_datanow assertsis_validisTRUE.GovActionProposalDBRow.param_proposalmade nullable - it isNULLfor info actions and only set for parameter-change actions.test_pparam_updatestill passes.Anchor data files and URLs
Each vector lives in a committed file under
cardano_node_tests/tests/data/, fetched by db-sync over HTTP from its publicraw.githubusercontent.comURL. The URLs are kept asPUBLIC_ACTION_ANCHOR_*constants incommon.py, following #3531 (no tinyurl). File names are short so the raw URL stays under the 128-byte on-chain anchor limit:ga_anchor.json- conformant (already on master)ga_anchor_nonconf.json- valid JSON, not CIP-decodablega_anchor_invalid.json- not valid JSONThe last two were added with long names in #3497 and are renamed here.
Verification
Verified end-to-end on a local dev cluster - 5 passed on db-sync
13.7.2.1(revdb8cdf6, which includes PR #2005):Note on CI / merge order
The
ga_anchor_nonconf.json/ga_anchor_invalid.jsonURLs point atmaster, so the four non-conformant / invalid tests only go green once those renamed files are onmaster(the same bootstrap this PR originally had with #3497). The conformant test passes already. Local verification used a byte-identical shortlink for the two pending files - hashes are computed from the committed files, so db-sync behaves identically once the URLs resolve.