Skip to content

Commit

Permalink
Reset index in loop to restart member search (#16955)
Browse files Browse the repository at this point in the history
## Description

Found from audit, we need to reset the start of the loop when looking
for members

## Test Plan

Added unit test

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
dariorussi authored and patrickkuo committed May 8, 2024
1 parent 860be83 commit af2a22c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/sui-framework/docs/bridge/committee.md
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ title: Module `0xb::committee`
member.blocklisted = blocklisted;
pub_keys.push_back(*pub_key);
found = <b>true</b>;
member_idx = 0;
<b>break</b>
};

Expand Down
11 changes: 11 additions & 0 deletions crates/sui-framework/packages/bridge/sources/committee.move
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ module bridge::committee {
member.blocklisted = blocklisted;
pub_keys.push_back(*pub_key);
found = true;
member_idx = 0;
break
};

Expand Down Expand Up @@ -680,6 +681,16 @@ module bridge::committee {
let blocklist = message::extract_blocklist_payload(&blocklist);
execute_blocklist(&mut committee, blocklist);

// Blocklist both reverse order
let blocklist = message::create_blocklist_message(
chain_ids::sui_testnet(),
0, // seq
0, // type 0 is blocklist
vector[eth_address1, eth_address0]
);
let blocklist = message::extract_blocklist_payload(&blocklist);
execute_blocklist(&mut committee, blocklist);

// val 0 is blocklisted
let (_, blocked_member) = vec_map::get_entry_by_idx(&committee.members, 0);
assert!(blocked_member.blocklisted, 0);
Expand Down

0 comments on commit af2a22c

Please sign in to comment.