refactor(proposal): replace UpdateShamirParameters with parameterless TriggerRekey
This commit is contained in:
@@ -2,6 +2,8 @@ syntax = "proto3";
|
|||||||
|
|
||||||
package arbiter.operator.governance;
|
package arbiter.operator.governance;
|
||||||
|
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
|
|
||||||
message Request {
|
message Request {
|
||||||
oneof payload {
|
oneof payload {
|
||||||
CreateProposalRequest create = 1;
|
CreateProposalRequest create = 1;
|
||||||
@@ -13,13 +15,13 @@ message Request {
|
|||||||
message CreateProposalRequest {
|
message CreateProposalRequest {
|
||||||
oneof kind {
|
oneof kind {
|
||||||
ApproveSdkClientPayload approve_sdk_client = 1;
|
ApproveSdkClientPayload approve_sdk_client = 1;
|
||||||
GrantWalletAccessPayload grant_wallet_access = 3;
|
GrantWalletAccessPayload grant_wallet_access = 2;
|
||||||
ReplaceOperatorPayload replace_operator = 5;
|
ReplaceOperatorPayload replace_operator = 3;
|
||||||
UpdateShamirParametersPayload update_shamir_parameters = 6;
|
google.protobuf.Empty trigger_rekey = 4;
|
||||||
ApprovePersistentGrantPayload approve_persistent_grant = 7;
|
ApprovePersistentGrantPayload approve_persistent_grant = 5;
|
||||||
ApproveOneOffTransactionPayload approve_one_off_transaction = 8;
|
ApproveOneOffTransactionPayload approve_one_off_transaction = 6;
|
||||||
}
|
}
|
||||||
optional uint32 ttl_secs = 2;
|
optional uint32 ttl_secs = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReplaceOperatorPayload {
|
message ReplaceOperatorPayload {
|
||||||
@@ -27,10 +29,6 @@ message ReplaceOperatorPayload {
|
|||||||
bytes new_pubkey = 2;
|
bytes new_pubkey = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UpdateShamirParametersPayload {
|
|
||||||
uint32 new_n = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ApproveSdkClientPayload {
|
message ApproveSdkClientPayload {
|
||||||
int32 client_id = 1;
|
int32 client_id = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,9 +42,7 @@ pub enum ProposalKind {
|
|||||||
old_operator_id: i32,
|
old_operator_id: i32,
|
||||||
new_pubkey: Vec<u8>,
|
new_pubkey: Vec<u8>,
|
||||||
},
|
},
|
||||||
UpdateShamirParameters {
|
TriggerRekey,
|
||||||
new_n: u8,
|
|
||||||
},
|
|
||||||
ApprovePersistentGrant {
|
ApprovePersistentGrant {
|
||||||
payload_bytes: Vec<u8>,
|
payload_bytes: Vec<u8>,
|
||||||
},
|
},
|
||||||
@@ -77,7 +75,7 @@ impl ProposalKind {
|
|||||||
buf.extend_from_slice(new_pubkey);
|
buf.extend_from_slice(new_pubkey);
|
||||||
buf
|
buf
|
||||||
}
|
}
|
||||||
Self::UpdateShamirParameters { new_n } => vec![*new_n],
|
Self::TriggerRekey => vec![],
|
||||||
Self::ApprovePersistentGrant { payload_bytes }
|
Self::ApprovePersistentGrant { payload_bytes }
|
||||||
| Self::ApproveOneOffTransaction { payload_bytes } => payload_bytes.clone(),
|
| Self::ApproveOneOffTransaction { payload_bytes } => payload_bytes.clone(),
|
||||||
}
|
}
|
||||||
@@ -88,7 +86,7 @@ impl ProposalKind {
|
|||||||
pub fn requires_full_quorum(kind: &str) -> bool {
|
pub fn requires_full_quorum(kind: &str) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
kind.parse::<ProposalKindTag>(),
|
kind.parse::<ProposalKindTag>(),
|
||||||
Ok(ProposalKindTag::ReplaceOperator | ProposalKindTag::UpdateShamirParameters)
|
Ok(ProposalKindTag::ReplaceOperator | ProposalKindTag::TriggerRekey)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,12 +129,7 @@ impl ProposalKind {
|
|||||||
new_pubkey,
|
new_pubkey,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ProposalKindTag::UpdateShamirParameters => {
|
ProposalKindTag::TriggerRekey => Ok(Self::TriggerRekey),
|
||||||
let &[new_n] = payload else {
|
|
||||||
return Err("invalid payload for update_shamir_parameters".to_owned());
|
|
||||||
};
|
|
||||||
Ok(Self::UpdateShamirParameters { new_n })
|
|
||||||
}
|
|
||||||
ProposalKindTag::ApprovePersistentGrant => Ok(Self::ApprovePersistentGrant {
|
ProposalKindTag::ApprovePersistentGrant => Ok(Self::ApprovePersistentGrant {
|
||||||
payload_bytes: payload.to_vec(),
|
payload_bytes: payload.to_vec(),
|
||||||
}),
|
}),
|
||||||
@@ -696,9 +689,7 @@ impl ProposalManager {
|
|||||||
self.execute_replace_operator(old_operator_id, new_pubkey)
|
self.execute_replace_operator(old_operator_id, new_pubkey)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
ProposalKind::UpdateShamirParameters { new_n } => {
|
ProposalKind::TriggerRekey => self.execute_trigger_rekey().await,
|
||||||
self.execute_update_shamir_parameters(new_n).await
|
|
||||||
}
|
|
||||||
ProposalKind::ApprovePersistentGrant { payload_bytes } => {
|
ProposalKind::ApprovePersistentGrant { payload_bytes } => {
|
||||||
self.execute_approve_persistent_grant(payload_bytes).await
|
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).
|
/// 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
|
self.vault_coordinator
|
||||||
.ask(StartRekey {})
|
.ask(StartRekey {})
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ enum CoordinatorState {
|
|||||||
ordinary_passphrases: HashMap<i32, Vec<u8>>,
|
ordinary_passphrases: HashMap<i32, Vec<u8>>,
|
||||||
recovery_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,
|
/// Collects new passphrases from all current operators, then generates a fresh seal key,
|
||||||
/// re-splits it, and re-encrypts the vault root key.
|
/// re-splits it, and re-encrypts the vault root key.
|
||||||
Rekeying {
|
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.
|
/// §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(
|
async fn finalize_rekey(
|
||||||
db: db::DatabasePool,
|
db: db::DatabasePool,
|
||||||
vault: ActorRef<Vault>,
|
vault: ActorRef<Vault>,
|
||||||
|
|||||||
@@ -56,14 +56,7 @@ async fn handle_create(
|
|||||||
old_operator_id: p.old_operator_id,
|
old_operator_id: p.old_operator_id,
|
||||||
new_pubkey: p.new_pubkey,
|
new_pubkey: p.new_pubkey,
|
||||||
},
|
},
|
||||||
Some(ProtoKind::UpdateShamirParameters(p)) => ProposalKind::UpdateShamirParameters {
|
Some(ProtoKind::TriggerRekey(())) => ProposalKind::TriggerRekey,
|
||||||
#[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::ApprovePersistentGrant(p)) => {
|
Some(ProtoKind::ApprovePersistentGrant(p)) => {
|
||||||
use prost::Message as _;
|
use prost::Message as _;
|
||||||
ProposalKind::ApprovePersistentGrant {
|
ProposalKind::ApprovePersistentGrant {
|
||||||
|
|||||||
@@ -827,7 +827,7 @@ async fn replace_operator_updates_pubkey_and_starts_rekey() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn update_shamir_parameters_reaches_quorum() {
|
async fn trigger_rekey_reaches_quorum() {
|
||||||
let db = db::create_test_pool().await;
|
let db = db::create_test_pool().await;
|
||||||
let actors = GlobalActors::spawn(db.clone()).await.unwrap();
|
let actors = GlobalActors::spawn(db.clone()).await.unwrap();
|
||||||
actors
|
actors
|
||||||
@@ -842,7 +842,7 @@ async fn update_shamir_parameters_reaches_quorum() {
|
|||||||
let proposal_id = actors
|
let proposal_id = actors
|
||||||
.proposal_manager
|
.proposal_manager
|
||||||
.ask(CreateProposal {
|
.ask(CreateProposal {
|
||||||
kind: ProposalKind::UpdateShamirParameters { new_n: 5 },
|
kind: ProposalKind::TriggerRekey,
|
||||||
initiator_id: op_id,
|
initiator_id: op_id,
|
||||||
ttl_secs: None,
|
ttl_secs: None,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user