Skip to content

Commit

Permalink
fix encoding (metadata) (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds authored Oct 17, 2024
1 parent 176a237 commit 9afadea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions contracts/src/mcms.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ const MANY_CHAIN_MULTI_SIG_DOMAIN_SEPARATOR_OP: u256 =
const MANY_CHAIN_MULTI_SIG_DOMAIN_SEPARATOR_METADATA: u256 =
0xe6b82be989101b4eb519770114b997b97b3c8707515286748a871717f0e4ea1c;

fn hash_metadata(metadata: RootMetadata, valid_until: u32) -> u256 {
fn hash_metadata(metadata: RootMetadata) -> u256 {
let encoded_metadata: Bytes = BytesTrait::new_empty()
.encode(MANY_CHAIN_MULTI_SIG_DOMAIN_SEPARATOR_METADATA)
.encode(valid_until)
.encode(metadata.chain_id)
.encode(metadata.multisig)
.encode(metadata.pre_op_count)
Expand Down Expand Up @@ -347,7 +346,7 @@ mod ManyChainMultiSig {
);

// verify metadataProof
let hashed_metadata_leaf = hash_metadata(metadata, valid_until);
let hashed_metadata_leaf = hash_metadata(metadata);
assert(
verify_merkle_proof(metadata_proof, root, hashed_metadata_leaf),
'proof verification failed'
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/tests/test_mcms/test_set_root.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn setup_mcms_deploy_set_config_and_set_root_WRONG_MULTISIG() -> (
let op1_hash = hash_op(op1);
let op2_hash = hash_op(op2);

let metadata_hash = hash_metadata(metadata, valid_until);
let metadata_hash = hash_metadata(metadata);

// create merkle tree
let (root, metadata_proof, ops_proof) = merkle_root(array![op1_hash, op2_hash, metadata_hash]);
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/tests/test_mcms/utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fn set_root_args(
let op1_hash = hash_op(op1);
let op2_hash = hash_op(op2);

let metadata_hash = hash_metadata(metadata, valid_until);
let metadata_hash = hash_metadata(metadata);

// create merkle tree
let (root, metadata_proof, ops_proof) = merkle_root(array![op1_hash, op2_hash, metadata_hash]);
Expand Down

0 comments on commit 9afadea

Please sign in to comment.