Skip to content

refactor: optimize council_members auth checks via byte comparison (#58)#90

Merged
JerryIdoko merged 2 commits intoGrant-Stream:mainfrom
Chucks1093:refactor/council-member-byte-comparison-58
Feb 26, 2026
Merged

refactor: optimize council_members auth checks via byte comparison (#58)#90
JerryIdoko merged 2 commits intoGrant-Stream:mainfrom
Chucks1093:refactor/council-member-byte-comparison-58

Conversation

@Chucks1093
Copy link
Contributor

Closes #58

Changes

  • Introduced CouncilMembers storage key holding Vec<Bytes> (pre-serialised
    XDR) instead of Vec<Address>, eliminating Address object construction
    inside the membership-check loop
  • Caller address is converted to bytes once before the loop via addr_to_bytes;
    all iterations are plain byte comparisons
  • Added set_council_members, is_council_member, require_council_auth
  • execute_proposal now requires council auth
  • Added NotCouncilMember error (113)

Testing

  • Two benchmarks added to benchmarks.rs: naive Vec loop vs
    optimized Vec loop — CPU instruction count is measured at
    worst-case (caller is last member in a 10-member council)

Notes

  • Council was not previously implemented; built and optimized in one pass
    per the issue's intent to avoid the expensive pattern from day one

…rant-Stream#58)

- Add CouncilMembers key to GovernanceDataKey storing Vec<Bytes>
  instead of Vec<Address> to avoid per-iteration address deserialization
- Add addr_to_bytes, is_council_member, require_council_auth helpers;
  caller address is serialised to XDR exactly once before the loop
- Add set_council_members (serialises at write time, reads are free)
- Gate execute_proposal behind require_council_auth
- Add NotCouncilMember (113) error variant
- Add benchmark_council_member_check vs benchmark_council_member_check_optimized
  to benchmarks.rs to measure CPU instruction reduction
@Chucks1093
Copy link
Contributor Author

@JerryIdoko can you review and merge this before the wave ends

@JerryIdoko JerryIdoko merged commit df9eebb into Grant-Stream:main Feb 26, 2026
1 check failed
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.

#48 Issue 48: [Optimization] Removal of Address Objects in Iteration

2 participants