refactor(proposal): replace UpdateShamirParameters with parameterless TriggerRekey
This commit is contained in:
@@ -42,9 +42,7 @@ pub enum ProposalKind {
|
||||
old_operator_id: i32,
|
||||
new_pubkey: Vec<u8>,
|
||||
},
|
||||
UpdateShamirParameters {
|
||||
new_n: u8,
|
||||
},
|
||||
TriggerRekey,
|
||||
ApprovePersistentGrant {
|
||||
payload_bytes: Vec<u8>,
|
||||
},
|
||||
@@ -77,7 +75,7 @@ impl ProposalKind {
|
||||
buf.extend_from_slice(new_pubkey);
|
||||
buf
|
||||
}
|
||||
Self::UpdateShamirParameters { new_n } => vec![*new_n],
|
||||
Self::TriggerRekey => vec![],
|
||||
Self::ApprovePersistentGrant { payload_bytes }
|
||||
| Self::ApproveOneOffTransaction { payload_bytes } => payload_bytes.clone(),
|
||||
}
|
||||
@@ -88,7 +86,7 @@ impl ProposalKind {
|
||||
pub fn requires_full_quorum(kind: &str) -> bool {
|
||||
matches!(
|
||||
kind.parse::<ProposalKindTag>(),
|
||||
Ok(ProposalKindTag::ReplaceOperator | ProposalKindTag::UpdateShamirParameters)
|
||||
Ok(ProposalKindTag::ReplaceOperator | ProposalKindTag::TriggerRekey)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -131,12 +129,7 @@ impl ProposalKind {
|
||||
new_pubkey,
|
||||
})
|
||||
}
|
||||
ProposalKindTag::UpdateShamirParameters => {
|
||||
let &[new_n] = payload else {
|
||||
return Err("invalid payload for update_shamir_parameters".to_owned());
|
||||
};
|
||||
Ok(Self::UpdateShamirParameters { new_n })
|
||||
}
|
||||
ProposalKindTag::TriggerRekey => Ok(Self::TriggerRekey),
|
||||
ProposalKindTag::ApprovePersistentGrant => Ok(Self::ApprovePersistentGrant {
|
||||
payload_bytes: payload.to_vec(),
|
||||
}),
|
||||
@@ -696,9 +689,7 @@ impl ProposalManager {
|
||||
self.execute_replace_operator(old_operator_id, new_pubkey)
|
||||
.await
|
||||
}
|
||||
ProposalKind::UpdateShamirParameters { new_n } => {
|
||||
self.execute_update_shamir_parameters(new_n).await
|
||||
}
|
||||
ProposalKind::TriggerRekey => self.execute_trigger_rekey().await,
|
||||
ProposalKind::ApprovePersistentGrant { payload_bytes } => {
|
||||
self.execute_approve_persistent_grant(payload_bytes).await
|
||||
}
|
||||
@@ -764,7 +755,7 @@ impl ProposalManager {
|
||||
}
|
||||
|
||||
/// Triggers a Shamir re-key with the current operator set (§3.3).
|
||||
async fn execute_update_shamir_parameters(&self, _new_n: u8) -> Result<(), Error> {
|
||||
async fn execute_trigger_rekey(&self) -> Result<(), Error> {
|
||||
self.vault_coordinator
|
||||
.ask(StartRekey {})
|
||||
.await
|
||||
|
||||
@@ -62,7 +62,7 @@ enum CoordinatorState {
|
||||
ordinary_passphrases: HashMap<i32, Vec<u8>>,
|
||||
recovery_passphrases: HashMap<i32, Vec<u8>>,
|
||||
},
|
||||
/// Shamir re-key after `replace_operator` or `update_shamir_parameters` is approved (§3.3).
|
||||
/// Shamir re-key after `replace_operator` or `trigger_rekey` is approved (§3.3).
|
||||
/// Collects new passphrases from all current operators, then generates a fresh seal key,
|
||||
/// re-splits it, and re-encrypts the vault root key.
|
||||
Rekeying {
|
||||
@@ -297,7 +297,7 @@ async fn finalize_unseal(
|
||||
}
|
||||
|
||||
/// §3.3: Generate a fresh seal key, split across current operators, re-encrypt the vault root key.
|
||||
/// Called after `replace_operator` or `update_shamir_parameters` is approved and all contributors submit.
|
||||
/// Called after `replace_operator` or `trigger_rekey` is approved and all contributors submit.
|
||||
async fn finalize_rekey(
|
||||
db: db::DatabasePool,
|
||||
vault: ActorRef<Vault>,
|
||||
|
||||
@@ -56,14 +56,7 @@ async fn handle_create(
|
||||
old_operator_id: p.old_operator_id,
|
||||
new_pubkey: p.new_pubkey,
|
||||
},
|
||||
Some(ProtoKind::UpdateShamirParameters(p)) => ProposalKind::UpdateShamirParameters {
|
||||
#[expect(
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::as_conversions,
|
||||
reason = "new_n is always a small operator count"
|
||||
)]
|
||||
new_n: p.new_n as u8,
|
||||
},
|
||||
Some(ProtoKind::TriggerRekey(())) => ProposalKind::TriggerRekey,
|
||||
Some(ProtoKind::ApprovePersistentGrant(p)) => {
|
||||
use prost::Message as _;
|
||||
ProposalKind::ApprovePersistentGrant {
|
||||
|
||||
@@ -827,7 +827,7 @@ async fn replace_operator_updates_pubkey_and_starts_rekey() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn update_shamir_parameters_reaches_quorum() {
|
||||
async fn trigger_rekey_reaches_quorum() {
|
||||
let db = db::create_test_pool().await;
|
||||
let actors = GlobalActors::spawn(db.clone()).await.unwrap();
|
||||
actors
|
||||
@@ -842,7 +842,7 @@ async fn update_shamir_parameters_reaches_quorum() {
|
||||
let proposal_id = actors
|
||||
.proposal_manager
|
||||
.ask(CreateProposal {
|
||||
kind: ProposalKind::UpdateShamirParameters { new_n: 5 },
|
||||
kind: ProposalKind::TriggerRekey,
|
||||
initiator_id: op_id,
|
||||
ttl_secs: None,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user