Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ near-sdk = { version = "5.24.1", features = [
near-workspaces = { version = "0.22.1" }
num_enum = { version = "0.7.6", features = ["complex-expressions"] }
pairing = { version = "0.23.0" }
paste = "1.0"
pprof = { version = "0.15.0", features = [
"cpp",
"flamegraph",
Expand All @@ -177,7 +178,10 @@ regex = "1.12.3"
reqwest = { version = "0.13.2", features = ["multipart", "json"] }
rmp-serde = "1.3.1"
rstest = { version = "0.26.1" }
rustls = { version = "0.23.37", default-features = false, features = ["ring", "std"] }
rustls = { version = "0.23.37", default-features = false, features = [
"ring",
"std",
] }
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11.19"
serde_json = "1.0"
Expand Down
70 changes: 34 additions & 36 deletions crates/contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ impl MpcContract {
};

let participant = AuthenticatedParticipantId::new(threshold_parameters.participants())?;
let votes = self.tee_state.vote(code_hash.clone(), &participant);
let votes = self.tee_state.vote(code_hash, &participant);

let tee_upgrade_deadline_duration =
Duration::from_secs(self.config.tee_upgrade_deadline_duration_seconds);
Expand Down Expand Up @@ -1391,7 +1391,7 @@ impl MpcContract {
};

let participant = AuthenticatedParticipantId::new(threshold_parameters.participants())?;
let action = LauncherVoteAction::Add(launcher_hash.clone());
let action = LauncherVoteAction::Add(launcher_hash);
let votes = self.tee_state.vote_launcher(action, &participant);

let tee_upgrade_deadline_duration =
Expand Down Expand Up @@ -1429,7 +1429,7 @@ impl MpcContract {
};

let participant = AuthenticatedParticipantId::new(threshold_parameters.participants())?;
let action = LauncherVoteAction::Remove(launcher_hash.clone());
let action = LauncherVoteAction::Remove(launcher_hash);
let votes = self.tee_state.vote_launcher(action, &participant);

// Removal requires ALL participants to vote
Expand Down Expand Up @@ -4504,9 +4504,7 @@ mod tests {
.block_timestamp(block_timestamp_ns)
.build());

contract
.vote_code_hash(mpc_hash.clone())
.expect("vote succeeds");
contract.vote_code_hash(*mpc_hash).expect("vote succeeds");
}
}

Expand All @@ -4527,7 +4525,7 @@ mod tests {
.build());

contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("launcher vote succeeds");
}
}
Expand Down Expand Up @@ -4821,7 +4819,7 @@ mod tests {
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("vote should succeed");
}
assert!(
Expand All @@ -4836,7 +4834,7 @@ mod tests {
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("vote should succeed");

let allowed = contract.allowed_launcher_image_hashes();
Expand All @@ -4858,10 +4856,10 @@ mod tests {

// Same participant votes twice — should count as 1 vote
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("vote should succeed");
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("duplicate vote should succeed");

assert!(
Expand All @@ -4878,14 +4876,14 @@ mod tests {
let launcher_hash_2 = make_launcher_hash(0xDD);

// Add two launcher hashes so removal of one doesn't hit the "last entry" guard
for hash in [&launcher_hash, &launcher_hash_2] {
for hash in [launcher_hash, launcher_hash_2] {
for (account_id, _, _) in participant_list {
testing_env!(VMContextBuilder::new()
.signer_account_id(account_id.clone())
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_add_launcher_hash(hash.clone())
.vote_add_launcher_hash(hash)
.expect("add vote should succeed");
}
}
Expand All @@ -4898,7 +4896,7 @@ mod tests {
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_remove_launcher_hash(launcher_hash.clone())
.vote_remove_launcher_hash(launcher_hash)
.expect("remove vote should succeed");
}
assert_eq!(
Expand All @@ -4914,7 +4912,7 @@ mod tests {
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_remove_launcher_hash(launcher_hash.clone())
.vote_remove_launcher_hash(launcher_hash)
.expect("remove vote should succeed");

assert_eq!(
Expand All @@ -4937,7 +4935,7 @@ mod tests {
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("add vote should succeed");
}
assert_eq!(contract.allowed_launcher_image_hashes().len(), 1);
Expand All @@ -4949,7 +4947,7 @@ mod tests {
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_remove_launcher_hash(launcher_hash.clone())
.vote_remove_launcher_hash(launcher_hash)
.expect("remove vote should succeed");
}
assert_eq!(
Expand Down Expand Up @@ -4977,7 +4975,7 @@ mod tests {
.block_timestamp(block_ts)
.build());
contract
.vote_code_hash(mpc_hash.clone())
.vote_code_hash(mpc_hash)
.expect("mpc vote should succeed");
}

Expand All @@ -4989,7 +4987,7 @@ mod tests {
.block_timestamp(block_ts)
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("launcher vote should succeed");
}

Expand Down Expand Up @@ -5020,7 +5018,7 @@ mod tests {
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("vote should succeed");
}
assert_eq!(contract.allowed_launcher_image_hashes().len(), 1);
Expand All @@ -5033,7 +5031,7 @@ mod tests {
.predecessor_account_id(account_id.clone())
.build());
contract
.vote_add_launcher_hash(launcher_hash_2.clone())
.vote_add_launcher_hash(launcher_hash_2)
.expect("vote should succeed");

// Only 1 vote for hash_2, should not be added yet
Expand Down Expand Up @@ -5063,12 +5061,12 @@ mod tests {
.predecessor_account_id(account_0.clone())
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("vote should succeed");

let votes = &contract.launcher_hash_votes().vote_by_account;
assert_eq!(votes.len(), 1);
let expected_action = LauncherVoteAction::Add(launcher_hash.clone());
let expected_action = LauncherVoteAction::Add(launcher_hash);
assert!(votes.values().all(|v| *v == expected_action));

// Second vote
Expand All @@ -5078,7 +5076,7 @@ mod tests {
.predecessor_account_id(account_1.clone())
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("vote should succeed");

let votes = &contract.launcher_hash_votes().vote_by_account;
Expand All @@ -5092,7 +5090,7 @@ mod tests {
.predecessor_account_id(account_2.clone())
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("vote should succeed");

assert!(
Expand Down Expand Up @@ -5121,7 +5119,7 @@ mod tests {
.predecessor_account_id(account.clone())
.build());
contract
.vote_code_hash(code_hash.clone())
.vote_code_hash(code_hash)
.expect("vote should succeed");

let votes = &contract.code_hash_votes().proposal_by_account;
Expand Down Expand Up @@ -5153,7 +5151,7 @@ mod tests {
.block_timestamp(block_ts)
.build());
contract
.vote_code_hash(mpc_hash_1.clone())
.vote_code_hash(mpc_hash_1)
.expect("mpc vote should succeed");
}

Expand All @@ -5165,7 +5163,7 @@ mod tests {
.block_timestamp(block_ts)
.build());
contract
.vote_add_launcher_hash(launcher_hash.clone())
.vote_add_launcher_hash(launcher_hash)
.expect("launcher vote should succeed");
}
assert_eq!(contract.allowed_launcher_compose_hashes().len(), 1);
Expand All @@ -5179,7 +5177,7 @@ mod tests {
.block_timestamp(block_ts)
.build());
contract
.vote_code_hash(mpc_hash_2.clone())
.vote_code_hash(mpc_hash_2)
.expect("mpc vote 2 should succeed");
}

Expand Down Expand Up @@ -5218,7 +5216,7 @@ mod tests {
.block_timestamp(ts)
.build());
contract
.vote_code_hash(hash.clone())
.vote_code_hash(hash)
.expect("mpc vote should succeed");
}
};
Expand All @@ -5231,7 +5229,7 @@ mod tests {
.block_timestamp(ts)
.build());
contract
.vote_add_launcher_hash(hash.clone())
.vote_add_launcher_hash(hash)
.expect("launcher vote should succeed");
}
};
Expand All @@ -5242,12 +5240,12 @@ mod tests {
let m2 = NodeImageHash::from([0x22; 32]);
let m3 = NodeImageHash::from([0x33; 32]);

vote_mpc(&mut contract, m1.clone(), t0);
vote_launcher(&mut contract, l1.clone(), t0);
vote_mpc(&mut contract, m1, t0);
vote_launcher(&mut contract, l1, t0);
assert_eq!(contract.allowed_launcher_compose_hashes().len(), 1);

let t1 = t0 + day;
vote_mpc(&mut contract, m2.clone(), t1);
vote_mpc(&mut contract, m2, t1);
assert_eq!(contract.allowed_launcher_compose_hashes().len(), 2);

let t2 = t1 + upgrade_deadline + sec;
Expand All @@ -5262,14 +5260,14 @@ mod tests {
"stored compose hashes persist even after MPC hash expires"
);

vote_launcher(&mut contract, l2.clone(), t2);
vote_launcher(&mut contract, l2, t2);
assert_eq!(
contract.allowed_launcher_compose_hashes().len(),
3,
"L2 paired only with valid M2, not expired M1"
);

vote_mpc(&mut contract, m3.clone(), t2);
vote_mpc(&mut contract, m3, t2);
assert_eq!(
contract.allowed_launcher_compose_hashes().len(),
5,
Expand Down
Loading
Loading