Repository navigation
DRAFT: Add the proxy delegation wire types and delegate registry - #520
Draft
czarcas7ic wants to merge 39 commits into
Draft
czarcas7ic wants to merge 39 commits into
czarcas7ic wants to merge 39 commits into
Conversation
docs/proxy-delegation/contracts-v1.md is the contract for the whole proxy delegation feature: transaction tags, messages, state, digests, validation order, errors, events, queries, genesis and the client formats. This adds the parts of it that need no chain behavior yet: - The protos for the 0x09 MsgProxyDelegationBatch, the 0x0B MsgDelegateOp, the three coordinator payloads, the registry and ballot state, the queries and the genesis fields, with their ValidateBasic checks. - The D1 batch sighash and the registry digests, the 0x1A and 0x1B key layout, errors 51 to 69 and the event names. - The Ed25519 key rule and ZIP-215 verification for delegate and verifier keys. - The shared golden vectors, with tests that check the Go code against them and pin each file's hash. All of it sits behind types.ProxyDelegationEnabled, a constant that is false in production builds. The test-only proxyenabled build tag opens it, and CI now runs the Go suites both ways. While it is closed the codec does not decode 0x09 or 0x0B, standard Cosmos transactions refuse the new Msgs, and existing ValidateBasic failures keep code 1. With it open they report their registered code, as the contract's section 0 requires. The new Msgs get no-op Cosmos signers either way, since the SDK validates every Msg RPC's signer at startup.
A delegate registers an X or GitHub handle with a 0x0B register op:
an Ed25519 delegate key, the canonical handle and proof id, its own
signature, and attestations from the verifiers in the registry params.
The ante and the handler run the checks of contract section 5.3 in
order, the signatures everywhere but RecheckTx. A handle has at most
one live entry and an entry keeps one key for life, so a key change
means retiring and registering again. Registration closes without
verifiers and stops at max_delegates.
Coordinators manage the registry with three payloads: the params
(verifiers, threshold, max_delegates), the pause flag that 0x09
batches will read, and an entry's status (suspend, lift, retire).
Each needs at least max(2, threshold) current vote-manager approvals,
so it never executes in the proposing tx.
Genesis exports and imports the entries and params and rebuilds the
key, handle and next_index records. The registry has gRPC queries and
REST routes, and POST /delegate-op submits an op. Proxy routes always
answer with codespace. The existing submission endpoints and
/tx/{hash} add it only when the request sends X-Svote-Codespace: 1,
since deployed clients parse those bodies strictly.
0x09 batches, delegate ballots and proxy rounds are refused with
ErrProxyDelegationDisabled for now. They come with delegation itself.
Everything here stays behind the gate.
For adam/proxy-registry. Keeps one test per registry rule at the layer that implements it, plus the vector tests, and cuts the rest: - Dormancy: the ante gate test, the app tests of dormant pool shares and ValidateBasic codes, and the separate app tag and payload tests, now one TestProxyDelegationDormant. The keeper's dormant handler test stays as the negative. - Rules another layer owns: the upgrade test that ran a no-op handler to re-read the keeper defaults, approval floor tests of main's approval counting, the coordinator retire and re-register path, and payload code rows the types tests already cover. - Defensive checks with no realistic trigger: Ed25519 and store key length guards, digest field length checks, nil requests and nil messages. - Tests the vectors already pin: the digest writer helpers and the proto round trip. - Permutation rows in the ValidateBasic, attestation, paging and status tables, and copy checks like metric labels and command lists. Marks the proxy delegation vector files as generated so GitHub collapses them in diffs.
Behavior-preserving cuts for adam/proxy-registry (PR 520). Codes, events, gas, state and REST bodies are unchanged. - 1: the chain vector file's docs say it is committed and checked by the tests, instead of naming a generator script. - 4: REGISTER, ATTEST and D1 read DelegateRegister and MsgProxyDelegationBatch directly, so the wrapper structs and SighashFields go. - 5: one middleware answers 404 on the registry's REST routes while proxy delegation is dormant, and one helper serves their queries. - 6: VerifyEd25519ZIP215 leaves the ZIP-215 checks to CometBFT's verifier, and the nine Ed25519 sentinel errors go. A malformed signature's log now just says it does not verify. The vector test checks pass or fail. - 9: the coordinator doc points at contracts-v1 for the payload fields, bounds, codes and events instead of repeating them.
Wallets should show nothing a delegate wrote. A row's name is chosen by whoever signs the wallet's list, so it is the wallet's own label, like a vote server's name, and the handle is an account identifier the attester verified. Without free text or images the app carries no user-generated content, so it needs no report, hide or content-terms controls. The list format hasn't shipped, since no list has been signed or published, so v1 changes in place rather than becoming v2. In contracts-v1 section 12.3 a row is now index, provider, handle, dk and name, and WalletListPayloadV1 ends each row at lp8(name). The statement and picture rules, their errors and the WebP decoding note are gone, and browse and search show only the row's name. vote-sdk's copy of the client vectors follows the file zcash_voting regenerated, so section 13 and the Go test pin the new hashes.
Rows no longer carry pictures or statements, so the 4 MiB cap was far above anything a valid list can reach. The largest list the field rules allow has 1,000 rows (a 10-digit index, provider 2, a 39-character handle, a 63-character dk and a 50-scalar name of 4-byte UTF-8), 1,000 reserved names of 64 characters, 8 signatures with a 64-byte key_id of escaped control characters, a 32-byte wallet_id, a 64-byte chain_id of escaped quotes, and 20-digit version and issued_at. That is 437,427 bytes as compact JSON and 492,742 bytes with a 2-space indent, the way the admin UI and voting-config write it. The limit is now 1 MiB, the smaller of 512 KiB and 1 MiB that is at least 1.5 times the indented maximum (739,113 bytes), so re-indenting a valid list can never push it over. Go's encoder writes U+2028 in a name as an escape, which takes the worst indented list to 592,742 bytes, still under the limit. contracts-v1 sections 12.3 and 15.1 now say 1 MiB, and 12.3 records the indented maximum.
Delegates are now Keplr accounts on the vote chain instead of Ed25519 delegate keys attested by a verifier service. Two coordinators register a delegate with the new MsgRegisterDelegate payload after reading its X post by hand. The delegate retires with MsgRetireDelegate and ballots with MsgSubmitDelegateBallot, standard zero-fee Cosmos messages signed by the entry's address. Ballots are wired but not accepted yet. The entry keeps its 20-byte address for life, and the registry holds one live entry per address and per handle under 0x1A 0x02 and 0x1A 0x03. X is the only provider. Registration is closed while max_delegates is 0. Code 61 becomes ErrDelegateAddressInUse. Tag 0x0B, MsgDelegateOp, the registry digests, attestations, the verifier set, the Ed25519 key rule, the delegate-op route and the by-key query go. The standard ante runs the delegate messages' state checks before the signature checks, and REST renders entry addresses as sv1 strings. The contract, the coordinator actions doc, the CLI and the chain vectors follow.
Copies zcash_voting's regenerated client vector file, without the dc_secrets, marker and lookalike sections as before, and pins its new hash. The file identifies delegates by their sv1 address, drops the registry digests, the delegate key and the Ed25519 key cases, and lists the four prefix-free domains.
Wallet list signer keys are compiled-in pins, so the contract no longer states an Ed25519 key rule for them; signatures still verify under ZIP-215. A pasted address or fingerprint resolves to the address's live entry, or its newest retired entry when it has none, since an address can register again after retiring.
The by-address and by-handle query tests ran the same lifecycle, active, suspended, retired and registered again, then the unknown and malformed keys. Run it once in requireLiveLookup, parameterized by the lookup and its keys.
The vector tests cover every canonical form of the address, handle and post id. The ValidateBasic test only needs to show the payload applies each rule, so it keeps one bad value per field.
D1 is the only contracts-v1 section 4 digest left, so its hash setup moves into computeProxyDelegationBatchSighash.
No REST-borne message has variants any more, so the no-oneof rule stands on its own.
The section restated the contract's payloads, the CLI list below it and a delegate's own transactions. Keep what a coordinator needs, the approval floor and the post check before registering, and leave the rest to contracts-v1.
Re-copies zcash_voting's client vector file after it dropped cases that repeated an existing error, and pins its new hash here and in the contract. The contract no longer lists Ed25519 signature failure names, since a wallet list only ever reports that no pinned signature verified.
czarcas7ic
force-pushed
the
adam/proxy-registry
branch
from
November 28, 2026 23:56
7b08607 to
f12020a
Compare
A "retire me" message names no index. Since an address can register again once its entry retires, a late MsgRetireDelegate could land on the address's newer entry. Only coordinators retire now, through MsgSetDelegateStatus action 3, which names each index. Remove MsgRetireDelegate with its handler, keeper checks, ante case, whitelist entry, codec registration, CLI command and delegate_retired event, and the rule that a suspended entry cannot retire itself. The contract, the coordinator actions doc and the changelog say a delegate who wants to stop, rename or change accounts asks the coordinators to retire the entry. status_reason is 0 while an entry is ACTIVE.
The request a delegate signs names no chain, so one signed against staging could be replayed to production's admin server within the timestamp window. The contract now has the request carry the chain ID, which the admin server checks against its own node's.
The contract's sections 2, 3.1 and 8 copied every new proto message, and a reflection test kept a third copy of every field and RPC in sync with both. The .proto files already carry each field's size and meaning, so the contract now names the messages and keeps only what the schemas cannot say: signers, field presence and ordering. The test now checks just the wire rules that matter beyond the fields: no oneof in the REST-borne batch, and the reserved field numbers. The entry vectors already pin the entry's bytes against the client implementation.
The wallet searches its downloaded copy of the registry for a handle, so the node never learns which delegate a voter looked up, and the admin UI reads entries by address. Nothing calls ProxyDelegateByHandle or its REST route, so both go, with their tests. The handle record stays: registration and retirement use it to keep one live entry per handle.
ProxyDelegationRoundState recorded the registry's next index when a proxy round was created, only so wallets could label delegates who registered later as new this round. Wallets drop that label, so the field goes and its number is reserved.
The registry never assigns more than 2,000 indices over its lifetime, and a round holds at most one ballot per index, so a page of 2,000 holds either whole list. Raising the page limit to that cap lets a wallet fetch each list in one response. The default page stays 100, so clients that page in smaller steps are unaffected.
Every submission handler read the X-Svote-Codespace header and passed the answer to broadcastVoteTx, so the tests built a valid body for each of the five existing endpoints to check the same header logic. broadcastVoteTx now reads the header itself, and one test pins its exact legacy and opted-in bytes, with and without a batch_digest. The bodies clients receive are unchanged.
The codec and ValidateBasic tests each built their own DCs and batches with the same fields. proxytest now has one seeded DC and batch builder that takes the round, anchor, expiry and optional registration from the caller, so the api package can use it without importing the app.
Wallets no longer warn that a handle looks like a listed delegate or a reserved name, so the fold, the lookalike set and the wallet list's reserved_names go from the contract. The list's signed payload loses its reserved name block, and the largest list the field rules allow shrinks to 358,716 bytes. Coordinators refuse impersonating handles at registration instead, which the contract and the coordinator runbook now say.
The dynamic config's proxy_delegation_v1 extension only carried proof_rpc_urls. Registry proofs authenticate themselves, so wallets fetch them from the same compiled-in vote chain RPC host as their governance nullifier proofs, or on regtest the participation check's local endpoint. Section 12.1 goes, and section 11.6 names the host.
A wallet now finds a delegate from pasted or scanned text by its first whitespace-separated word that is a canonical sv1 address, so the text can be the address alone, a QR code or a whole copied X post. The index and fingerprint lookups go, and so does the marker parser: the marker line stays defined because delegates post it and the admin page shows it, but nothing parses it.
The client file drops its marker and lookalike sections, the wallet list's reserved names, and the store keys and error codes only the chain uses; its entry refusals take the prost codec's error names. The chain-only kv_keys and errors rows move, unchanged, into the chain vector file, so the key and error tests keep their coverage from both files. The contract pins both files' new hashes.
Section 15.1 now lists zcash_voting's client calls in round order and the flat wire types they answer: the one-response registry and ballot list reads at limit=2000, the wallet list resolution, the paste lookup, the confirm check, and a commit that takes the round hotkey. Section 11.11 says what the confirm check takes.
TestExistingValidateBasicCodes declared its table shape twice and rebuilt each message through a factory and a type-asserting mutation. Build each broken message directly, reusing the package's existing cast batch and composite fixtures, and check every result through one assertion. The five tags, their exact messages and both gate states' codes are unchanged.
The genesis round-trip test kept its own copy of proxytest.Values for the 0x1A prefix. Use the shared helper instead.
proxy_sighash_test.go built a second batch and hash helper to check that a new expiry changes D1 but not batch_digest, that batch_digest is D1 at expiry 0, and that the registration is signed. Check the same relations on each D1 vector's message instead, next to its expected bytes.
The client file's accepted entry cases already show that the chain's deterministic encoding is what wallets decode, and TestRegistryStoreLayout shows the keeper stores exactly that encoding. So entry_value and TestRegistryEntryValueVectors repeat a check. With entry_value gone, nothing outside vote-sdk reads the chain file. Its kv_keys and errors cases become tables in the Go tests that read them: the chain-only keys join the client file's entry keys, and each error's code joins the registered error map, which the client file's codes are checked against. The routing cases follow with the routing test. The hash pins only noticed that a file changed, which the diff shows, since every runner recomputes its expected outputs and refuses unmodeled fields. The section inventory test repeated what decoding a section already checks. Contract §13 now lists two files with their homes and no hashes, and drops its section inventories.
The config tooling needs the chain's canonical delegate address and handle checks but must build without the vote module, which links the circuits library in tests. Put the two checks in internal/delegateid, which imports only the bech32 package, and have the chain's validators wrap its errors in ErrInvalidField. The chain's error text and code are unchanged.
§15.1 listed each client call with its type names, and §1 listed the SDK plumbing behind the new messages' registration. Neither is a format another repo builds against. Point §15.1 at zcash_voting's proxy and proxy::registry module docs, keep the whole ballot list privacy rule and the type meanings other repos share, and drop the two meanings that only repeat §11.4 and §11.11.
The contract restated client lifecycle rules that zcash_voting's invariant docs state with their tests: batch resends and split-off recovery, why a saved vote share plan blocks delegating, and DC share hand-off and tracking. It also restated the config repo's wallet list operations and the coordinators' registration checks. Point at each rule's home instead. docs/vote-coordinator-actions.md keeps the operator guidance, and drops its copy of the approval floor in the action steps and its copy of the contract's retirement rules (§3.3), which it now references.
Re-vendor zcash_voting's client vector file at 0e5836d0, without dc_secrets and the new client-only entry_refusals section. The canonical file drops cases that repeat another case and fields no runner reads. entry now holds only the accepted entries, so TestProxyVectorsEntry loses its skip branch, and the delegate address encoding cases no longer carry a display form or its delegate index.
With no height given, CometBFT answers the validator-set route for the next block, so the wallet takes one less than its block_height.
Vizor now bridges only some of zcash_voting's wire types and flattens others, so the sentence was no longer true.
The wallet now tracks a DC's shares from its batch's landing, reads status without the ballot list for the job, and asks for codespace only on proxy batch requests, so direct rejections keep main's reading. The old codes paragraph also called any non-vote codespace terminal, which §6's resend rule contradicts.
This branch has not been deployed
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.
What changed
Proxy delegation lets a voter hand round weight to public delegates registered under an X handle. This adds the contract for the whole feature (
docs/proxy-delegation/contracts-v1.md), every proto, message check, digest, key layout, error and event it defines, and the shared golden vectors with tests against them. It also adds the delegate registry that works on top of them. A delegate is a vote chain account. Coordinators register it with aMsgRegisterDelegatepayload after reading its X post, and only coordinators retire it, through the entry status payload. The registry holds one live entry per handle and per address. Its four coordinator payloads (register, params, pause flag, entry status) each need at least two approvals, and it comes with genesis export and import and the registry queries and REST routes.Everything sits behind
types.ProxyDelegationEnabled, a constant that is false in production builds. Only the test-onlyproxyenabledbuild tag opens it, and CI now runs the Go suites both ways. With the gate closed the chain answers every new tag, payload, query and route as if it didn't exist, the delegate messages fail withErrProxyDelegationDisabled, and existing failures keep their codes. 0x09 batches, delegate ballots and proxy rounds stay refused even with the gate open until the next PR. One change is live while dormant: a request may sendX-Svote-Codespace: 1to getcodespacein a submission or/tx/{hash}answer, and without the header the bodies are byte-identical.This is 3 of 5 in the vote-sdk proxy delegation stack, on top of the Sentry change. About 3.3k of its lines are generated protobuf code and vector JSON.
Validation
Circuits tests with both backends,
make lint,make test,make test-proxyenabled.State compatibility
V:state/compatiblewhile dormant. The new store prefixes are never written, the new tags don't decode, and failed transactions keep their codes. Opening the gate is a later coordinated upgrade.Backport
None.