Skip to content

Conversation

@notJoon
Copy link
Member

@notJoon notJoon commented Jan 2, 2026

Description

Replace nested AVL tree structure with single tree using composite keys (proposalID:voter).

  • Eliminate write amplication on vote updates
  • Removes need to pre-create empty trees for each proposal
  • Simplifies Get/Set operations to single-item access
Operation Before (Nested Tree) After (Composite Key)
Vote Storage O(log P) + O(log V) + full subtree serialization O(log N) single entry only
Vote Lookup O(log P) + O(log V) two traversals O(log N) single traversal
Per-Proposal Full Iteration O(V) only votes for that proposal O(N) full iteration + prefix filter
  • P = number of proposals, V = votes per proposal, N = total votes

not met

Change to process as `StatusRejected` based on `IsPassed()` after voting
ends
- Modified `NewProposalTextData()` and `NewProposalExecutionData()` in
  `proposal_data.gno` to create non-applicable fields as `nil`.
- Added explicit error handling in the validation logic of
  `proposal_data.gno` for cases where `communityPoolSpend`/`execution`
  is `nil`, and modified `ParameterChangesInfos()` to return an empty
  result when nil.
- Updated `CommunityPoolSpendTokenPath()` in `proposal.gno` to safely
  return an empty string when `communityPoolSpend` is `nil`.
Replace nested AVL tree structure with single tree using composite keys
(`proposalID:voter`).

- Eliminate write amplication on vote updates
- Removes need to pre-create empty trees for each proposal
- Simplifies `Get`/`Set` operations to single-item access

| Operation | Before (Nested Tree) | After (Composite Key) |
|-----------|----------------------|-----------------------| | Vote
Storage | O(log P) + O(log V) + full subtree serialization | O(log N)
single entry only | | Vote Lookup | O(log P) + O(log V) two traversals |
O(log N) single traversal | | Per-Proposal Full Iteration | O(V) only
votes for that proposal | O(N) full iteration + prefix filter |

- P = number of proposals, V = votes per proposal, N = total votes
@coderabbitai
Copy link

coderabbitai bot commented Jan 2, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 2, 2026

@notJoon notJoon marked this pull request as ready for review January 2, 2026 06:39
@notJoon notJoon changed the title fix: flatten nested AVL tree for voting info storage fix(governance): flatten nested AVL tree for voting info storage Jan 2, 2026
@notJoon notJoon marked this pull request as draft January 2, 2026 08:59
Base automatically changed from fix/governance to main January 8, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants