Smart Contract — Optimisation
Summary
Weighted governance added new fields to on-chain storage (per-owner weights, a cached total-weight counter, and quorum/approval-weight fields on each proposal), but the storage cost tables in ARCHITECTURE.md still describe the pre-weighted layout. This issue asks a contributor to benchmark the real byte-size impact and bring the documentation back in sync with the deployed contract.
Background
docs/ARCHITECTURE.md's "Storage Layout" section documents the OWNERS entry as a Vec<Address> and lists the Proposal struct with an approvals: u32 field and a plain threshold reference. In the current contract (contracts/accord/src/lib.rs), OWNERS is stored as a Map<Address, u32> (address to voting weight), a new TWEIGHT instance-storage key caches the total weight, and Proposal carries a quorum_weight: u32 field plus a wider ProposalKind enum (it now has six variants instead of one). The XDR byte breakdown tables and the "Storage Cost Per Proposal" section were never updated to reflect any of this.
What Needs to Be Done
- Measure the actual XDR-encoded size of the
OWNERS persistent entry now that it stores a Map<Address, u32> instead of a Vec<Address>, for a representative range of owner counts (e.g. 1, 7, and the 20-owner maximum).
- Measure the actual XDR-encoded size of a
("PROP", id) proposal entry with the current Proposal struct fields, including the quorum_weight field and the largest ProposalKind variant.
- Update the "Instance Storage" table in ARCHITECTURE.md to include the
TWEIGHT key alongside the existing singleton keys, with its type, description, and TTL.
- Update the "Persistent Storage" table and the "Proposal Struct Fields" listing to match the current struct definition and field names exactly.
- Update the "Storage Cost Per Proposal" and "Storage Cost Methodology" sections with the new measured byte counts and recalculated worst-case totals (50 active proposals at the 20-owner cap), showing the before/after delta introduced by weighted governance.
- Update the "Key Naming Conventions" table to include
TWEIGHT among the documented singleton keys.
Acceptance Criteria
Files to Look At
docs/ARCHITECTURE.md — contains the Storage Layout, Storage Cost Per Proposal, and Storage Cost Methodology sections to update
contracts/accord/src/lib.rs — defines the current Proposal struct, ProposalKind enum, and the OWNERS/TWEIGHT storage keys to benchmark against
contracts/accord/src/test.rs — existing tests use env.budget(), a useful reference for measuring on-chain resource costs during benchmarking
Difficulty: Medium
Smart Contract — Optimisation
Summary
Weighted governance added new fields to on-chain storage (per-owner weights, a cached total-weight counter, and quorum/approval-weight fields on each proposal), but the storage cost tables in ARCHITECTURE.md still describe the pre-weighted layout. This issue asks a contributor to benchmark the real byte-size impact and bring the documentation back in sync with the deployed contract.
Background
docs/ARCHITECTURE.md's "Storage Layout" section documents theOWNERSentry as aVec<Address>and lists theProposalstruct with anapprovals: u32field and a plainthresholdreference. In the current contract (contracts/accord/src/lib.rs),OWNERSis stored as aMap<Address, u32>(address to voting weight), a newTWEIGHTinstance-storage key caches the total weight, andProposalcarries aquorum_weight: u32field plus a widerProposalKindenum (it now has six variants instead of one). The XDR byte breakdown tables and the "Storage Cost Per Proposal" section were never updated to reflect any of this.What Needs to Be Done
OWNERSpersistent entry now that it stores aMap<Address, u32>instead of aVec<Address>, for a representative range of owner counts (e.g. 1, 7, and the 20-owner maximum).("PROP", id)proposal entry with the currentProposalstruct fields, including thequorum_weightfield and the largestProposalKindvariant.TWEIGHTkey alongside the existing singleton keys, with its type, description, and TTL.TWEIGHTamong the documented singleton keys.Acceptance Criteria
TWEIGHT, with accurate types and descriptions.Proposal Struct Fieldslisting in ARCHITECTURE.md matches the fields actually defined on theProposalstruct inlib.rs.OWNERSentry and for a("PROP", id)entry under the weighted-governance model.Files to Look At
docs/ARCHITECTURE.md— contains the Storage Layout, Storage Cost Per Proposal, and Storage Cost Methodology sections to updatecontracts/accord/src/lib.rs— defines the currentProposalstruct,ProposalKindenum, and theOWNERS/TWEIGHTstorage keys to benchmark againstcontracts/accord/src/test.rs— existing tests useenv.budget(), a useful reference for measuring on-chain resource costs during benchmarkingDifficulty: Medium