refactor: optimize council_members auth checks via byte comparison (#58)#90
Merged
JerryIdoko merged 2 commits intoGrant-Stream:mainfrom Feb 26, 2026
Conversation
…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
Contributor
Author
|
@JerryIdoko can you review and merge this before the wave ends |
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.
Closes #58
Changes
CouncilMembersstorage key holdingVec<Bytes>(pre-serialisedXDR) instead of
Vec<Address>, eliminating Address object constructioninside the membership-check loop
addr_to_bytes;all iterations are plain byte comparisons
set_council_members,is_council_member,require_council_authexecute_proposalnow requires council authNotCouncilMembererror (113)Testing
optimized Vec loop — CPU instruction count is measured at
worst-case (caller is last member in a 10-member council)
Notes
per the issue's intent to avoid the expensive pattern from day one