Skip to content

Commit

Permalink
Merge branch 'solana/mcm-clear-root' into solana/mcm-configset-event
Browse files Browse the repository at this point in the history
  • Loading branch information
jadepark-dev authored Dec 19, 2024
2 parents 5939367 + 379eb5a commit aa7449a
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ pub fn set_config(
root_metadata.override_previous_root = true;
}

// clear_root is equivalent to overriding with a completely empty root
if clear_root {
let expiring_root = &mut ctx.accounts.expiring_root_and_op_count;
let root_metadata = &mut ctx.accounts.root_metadata;

// preserve the current op_count
let current_op_count = expiring_root.op_count;

// clear the expiring root while preserving op_count
expiring_root.root = [0u8; 32]; // clear root (equivalent to bytes32(0) in Solidity)
expiring_root.valid_until = 0; // clear timestamp
expiring_root.op_count = current_op_count;

// set root metadata to a cleared state
root_metadata.chain_id = ctx.accounts.multisig_config.chain_id;
root_metadata.multisig = ctx.accounts.multisig_config.key();
root_metadata.pre_op_count = current_op_count;
root_metadata.post_op_count = current_op_count;
root_metadata.override_previous_root = true;
}

emit!(ConfigSet {
group_parents,
group_quorums,
Expand Down

0 comments on commit aa7449a

Please sign in to comment.