aiken_design_patterns/governance_validation

Governance-authenticated protocol update pattern

AddProposal atomically inserts a proposal node and submits exactly one matching protocol-parameter governance action. The proposal authenticates a complete live cost model as a splice around one selected cost-model parameter. Passage is later witnessed by the complete accepted model appearing in the live language view for the Plutus language this contract compiles to. This proves the approved value is live; it does not identify which governance action enacted that value.

Approval-signal identity

The motion authenticated by this pattern is the complete target cost model, not a GovernanceActionId. Every enacted governance action that produces exactly that model is deliberately equivalent evidence that Cardano governance ratified the motion. MintPassedProposal neither identifies nor needs to identify which action produced it.

The single global registry associates that motion with its application payload and prevents two active proposals from using the same cost-model parameter. The governance premise is that participants review and support the motion through that association. If an identical motion is enacted through another action, the validator intentionally treats it as approval of the active proposal. This is the defined approval model, not a separate action-identity guarantee.

This hard assumption is considered practical because the global list is intended to become the socially canonical channel for this signal, for example through a future CIP or comparable agreement among governance participants. An action outside that convention would need to change exactly one cost-model entry by +1 or -1, preserve every other entry, and do so without the application purpose recorded in the list. It would then still need enough DRep support to be ratified and enacted before the active proposal expires. The combined likelihood of an otherwise purposeless exact duplicate clearing those governance thresholds is assumed low enough to make cost-model equality a sensible passage proof.

Governance-address custody

The governance validator address is dedicated to the root, proposal-node, and passed-proposal UTxOs created by this pattern. Its spending endpoint is a paired minting-policy gate for those state transitions; it does not independently protect unrelated UTxOs at that address. Do not use the address as a general-purpose payment destination.

Digest-based transaction authentication

Proposal insertion reconstructs Conway transaction-body bytes from the Plutus context plus witnesses for information the context omits. Equality with Transaction.id binds the entire reconstructed body byte-for-byte, including every opaque CBOR fragment, under the hash’s collision resistance. Script-data-hash reconstruction similarly binds the executed redeemers, budgets, and language views. The ledger has already validated the syntax and ledger semantics of the committed transaction. Parsing opaque fragments again would add no assurance for the properties this module uses; a caller only needs additional decoding if its own application assigns independent meaning to one of those fields.

Values serialized by the module use the hardware-wallet canonical CBOR profile: shortest integers and lengths, definite arrays and maps, canonical map-key ordering, and tag 258 on sets. This is a serialization profile, not the hardware-wallet body-field allowlist; insertion necessarily includes the proposal procedure. Certificates, voting procedures, and collateral-related regions are supplied as opaque CBOR fragments and inserted verbatim. They are not decoded or interpreted as independent semantic evidence by this module. The authenticated insertion body always includes its validity-interval start and excludes the optional transaction-body network ID entry.

The supported shape has exactly one proposal procedure: a protocol-parameter update containing only the cost model for this contract’s Plutus language. Context-visible ordinary no-datum outputs use the two-element array form; ordinary inline datums use the three-key map form. Redeemers use the definite list or definite map representation selected by the authorizing redeemer’s encoding flag; entries remain in ascending ledger-pointer order. Language views contain the authenticated model for that language plus opaque cost-model values for any other live languages. Plutus Data byte strings longer than 64 bytes retain the ledger-mandated indefinite chunked form.

Unsupported transaction features

To reduce complexity of transaction reconstruction, proposal insertion does not support:

Here, ordinary output means an entry in the transaction body’s normal output field, as opposed to a collateral return output. Collateral-related fields are supplied as opaque CBOR and inserted verbatim; this module does not classify them.

Unsupported governance-proposal shapes fail the insertion invariants. Datum-hash ordinary outputs fail directly. Opaque witness fragments are not parsed independently; normal ledger validation remains responsible for the well-formedness and consistency of the transaction components they encode.

Collateral inputs commit only output references. Their resolved outputs are absent from ScriptContext, so this module cannot classify their address family.

Other transitions retain their narrower body shapes. All shared collection serializers nevertheless use general shortest-form length headers.

Finalization responsibility split

A PASS burn proves authorization by a stable subject withdrawal, while the proposal-specific required withdrawal enforces the actual state transition. Both scripts inspect the full transaction. The governance policy therefore restricts its own PASS burn and reimbursement but deliberately leaves unrelated-policy minting, other transaction effects, and application state rules to those two scripts. Finalization is permissionless because caller identity is not part of that authorization.

Withdrawal quantities are not authorization data and are intentionally not checked. In a ledger-valid transaction, the presence of a script withdrawal necessarily executes that credential, so a second lookup in the redeemer collection would add no authorization. The example withdrawal scripts permit registration but reject delegation certificates, so they are not intended to accrue pool-delegation rewards. Under the current ledger rules, a non-empty reward account must be withdrawn in full; the transaction cannot choose a smaller amount. If a subject needs constraints on the resulting value flow, its stable or required withdrawal script is the correct place to enforce them. Revisit this boundary if the ledger enables partial withdrawals for Plutus-backed credentials.

Proposal script hashes are likewise not length-checked at admission. A valid finalization must use each value as an actual ledger withdrawal credential, and the stable subject must recognize the complete PASS || script_hash asset name. A malformed value therefore cannot impersonate a valid script; it can only prevent passage or finalization. Any passed-proposal UTxO it strands is outside the root/node namespace, so the failure cannot corrupt or permanently occupy a proposal-list position.

Types

Transaction-body data carried by the AddProposal redeemer. certificates, voting_procedures, and the collateral fields are opaque CBOR fragments inserted verbatim during body-hash reconstruction; they are not independently decoded as standalone field values. All other fields, including the flattened proposal anchor, contain semantic values omitted from ScriptContext. The body profile always includes validity_start and excludes the optional network ID entry.

Constructors

  • AddProposalBodyWitness {
      ttl: Int,
      certificates: ByteArray,
      auxiliary_data_hash: Option<ByteArray>,
      validity_start: Int,
      collateral_inputs: ByteArray,
      collateral_return: ByteArray,
      total_collateral: ByteArray,
      voting_procedures: ByteArray,
      proposal_anchor_url: ByteArray,
      proposal_anchor_data_hash: ByteArray,
    }

Alias

Datum = linked_list.Element<Empty, Proposal>

Alias

Empty = ByteArray

A live cost-model witness for another Plutus language used by the insertion transaction. cost_model is inserted verbatim into language-view hash reconstruction and is not independently decoded.

Constructors

  • LanguageCostModel { language_id: Int, cost_model: ByteArray }

Constructors

  • Init { nonce_input_index: Int, root_output_index: Int }
  • AddProposal {
      gov_action_lifespan_reference_input_index: Int,
      redeemer_encoding: RedeemerEncoding,
      anchor_output_index: Int,
      proposal_node_output_index: Int,
      initial_cost_model_parameter_value: Int,
      redeemer_metadata: List<RedeemerMetadata>,
      other_language_cost_models: List<LanguageCostModel>,
      body_witness: AddProposalBodyWitness,
    }
  • MintPassedProposal {
      redeemer_encoding: RedeemerEncoding,
      anchor_input_outref: OutputReference,
      anchor_output_index: Int,
      passed_proposal_output_index: Int,
      anchor_spend_redeemer_index: Int,
      proposal_spend_redeemer_index: Int,
      anchor_spend_cpu: Int,
      anchor_spend_mem: Int,
      node_spend_cpu: Int,
      node_spend_mem: Int,
      mint_cpu: Int,
      mint_mem: Int,
      ttl: Int,
      collateral_inputs: ByteArray,
      collateral_output: ByteArray,
      collateral_fee: ByteArray,
    }
  • FinalizePassedProposal {
      proposer_output_index: Int,
      subject_withdrawal_index: Int,
      required_script_withdrawal_index: Int,
    }
  • RemoveExpiredProposal {
      anchor_input_outref: OutputReference,
      anchor_output_index: Int,
      proposer_output_index: Int,
    }

Linked list Element occupies constructor ID 0. Its first field contains the nested Root or Node element-data constructor. Keep passed proposals disjoint from list elements at the outer datum level.

Constructors

  • PassedProposal {
      proposer: Address,
      passed_proposal_script_data_hash: ByteArray,
      required_script_for_final_burn: ScriptHash,
    }

cost_model_prefix includes the cost model’s definite-array CBOR header and exactly the complete integer entries before the cost-model parameter selected by the node key. cost_model_postfix starts immediately after that parameter’s integer and preserves the rest of the model byte-for-byte. The insertion redeemer’s transient initial_cost_model_parameter_value reconstructs the live model. The proposal inserts cbor.serialise(acceptance_cost_model_parameter_value) between them.

subject_script_hash identifies a stable withdrawal script to which the subject contract delegates authorization. Its hash is encoded after PASS in the resulting token name. required_script_for_final_burn is a distinct, proposal-specific withdrawal script that enforces the final action.

These byte arrays are not length-checked when the proposal enters the list. Finalization proves their validity by requiring the corresponding ledger withdrawal credentials to execute. A malformed value can only prevent passage or finalization; it cannot authenticate as another script. Any passed-proposal UTxO it strands is outside the proposal list.

Constructors

  • Proposal {
      proposer: Address,
      gov_action_script_data_hash: ByteArray,
      cost_model_prefix: ByteArray,
      acceptance_cost_model_parameter_value: Int,
      cost_model_postfix: ByteArray,
      valid_until: Int,
      subject_script_hash: ScriptHash,
      required_script_for_final_burn: ScriptHash,
    }

Exact encoding of the transaction redeemer collection authenticated by script-data-hash reconstruction. The flag is itself part of the authorizing redeemer’s Data. Ledger validation still determines whether the selected representation is permitted by the active protocol version.

Constructors

  • ListEncoding
  • MapEncoding

Missing ledger-pointer and execution-budget data for one context redeemer. context_index selects its purpose and Data; the purpose determines its tag.

Constructors

  • RedeemerMetadata { context_index: Int, ledger_index: Int, mem: Int, cpu: Int }

Constructors

  • DelegateToMint

Constants

gov_action_lifespan_asset_name: ByteArray = "GOV_ACTION_LIFESPAN"

Asset name of the configuration NFT that carries the governance-action lifespan in its inline integer datum. The validator that controls this NFT selects the lifespan as trusted configuration; this module authenticates and uses that value but does not derive or semantically bound it. The baseline lifespan must be the current governance-action ratification period plus one epoch for enactment, observation, and PASS minting. Thus a six-epoch ratification period requires a seven-epoch lifespan, before any additional allowance for delaying-action extensions.

Functions

init(
  nonce: OutputReference,
  nonce_input_index: Int,
  root_output_index: Int,
  governance_nft_policy: PolicyId,
  tx: Transaction,
) -> Bool

Validator for initializing the linked list that all proposals live within. The list permits at most one live proposal per cost-model parameter index. Each node key is exactly the index’s four-byte big-endian encoding. The assumption is that there will be a single canonical list for all protocols to utilize.

add_proposal(
  network_tag: Int,
  governance_nft_policy: PolicyId,
  gov_action_lifespan_policy: PolicyId,
  gov_action_lifespan_reference_input_index: Int,
  redeemer_encoding: RedeemerEncoding,
  anchor_output_index: Int,
  proposal_node_output_index: Int,
  initial_cost_model_parameter_value: Int,
  redeemer_metadata: List<RedeemerMetadata>,
  other_language_cost_models: List<LanguageCostModel>,
  body_witness: AddProposalBodyWitness,
  tx: Transaction,
) -> Bool

mint_passed_proposal(
  network_tag: Int,
  governance_nft_policy: PolicyId,
  redeemer_encoding: RedeemerEncoding,
  anchor_input_outref: OutputReference,
  anchor_output_index: Int,
  passed_proposal_output_index: Int,
  anchor_spend_redeemer_index: Int,
  proposal_spend_redeemer_index: Int,
  anchor_spend_cpu: Int,
  anchor_spend_mem: Int,
  node_spend_cpu: Int,
  node_spend_mem: Int,
  mint_cpu: Int,
  mint_mem: Int,
  ttl: Int,
  collateral_inputs: ByteArray,
  collateral_output: ByteArray,
  collateral_fee: ByteArray,
  redeemer: MintRedeemer,
  tx: Transaction,
) -> Bool

finalize_passed_proposal(
  governance_nft_policy: PolicyId,
  proposer_output_index: Int,
  subject_withdrawal_index: Int,
  required_script_withdrawal_index: Int,
  tx: Transaction,
) -> Bool

Burn one out-of-list passed-proposal token and require both authorization layers to execute.

Withdrawal amounts are deliberately irrelevant here: presence of the stable subject credential proves subject authorization, and presence of the proposal-specific credential enforces the final action. Under current Cardano ledger rules, any accumulated reward balance must be withdrawn in full, so the transaction cannot select a smaller partial amount. Either withdrawal script may impose application-specific value-flow rules when needed.

remove_expired_proposal(
  anchor_input_outref: OutputReference,
  anchor_output_index: Int,
  proposer_output_index: Int,
  governance_nft_policy: PolicyId,
  tx: Transaction,
) -> Bool

validate_recognized_pass_burn(
  governance_nft_policy: PolicyId,
  recognized_script_hash: ScriptHash,
  governance_finalize_redeemer_index: Int,
  mint: Assets,
  redeemers: Pairs<ScriptPurpose, Redeemer>,
) -> Bool

Require a passed-proposal burn whose suffix is a withdrawal script recognized by the subject contract. Minting and burning under every other policy remain unrestricted.

This helper is the stable subject’s authorization hook, not the proposal-specific state-transition validator. The required withdrawal script inspects the same transaction and is responsible for the final action and any restrictions on otherwise unrelated transaction effects.

Search Document