Skip to content

Commit 309c45d

Browse files
committed
Replace accounts with wallets in Dirk config
1 parent f776bca commit 309c45d

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

config.example.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ url = "http://0xa119589bb33ef52acbb8116832bec2b58fca590fe5c85eac5d3230b44d5bc09f
171171
# server_name = "localhost-1"
172172
# Complete URL of a Dirk gateway
173173
# url = "https://localhost:8881"
174-
# Accounts to use as consensus keys
175-
# accounts = ["Wallet1/Account1", "DistributedWallet/Account1"]
174+
# Wallets to load consensus keys from
175+
# accounts = ["Wallet1", "DistributedWallet"]
176176

177177
# [[signer.dirk.hosts]]
178178
# server_name = "localhost-2"
179179
# url = "https://localhost:8882"
180-
# accounts = ["Wallet2/Account2", "DistributedWallet/Account1"]
180+
# accounts = ["Wallet2", "DistributedWallet"]
181181

182182
# Configuration for how the Signer module should store proxy delegations.
183183
# OPTIONAL

crates/common/src/config/signer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub struct DirkHostConfig {
3737
pub server_name: Option<String>,
3838
/// Complete URL of the Dirk server
3939
pub url: Url,
40-
/// Accounts used as consensus keys
41-
pub accounts: Vec<String>,
40+
/// Wallets to load consensus keys from
41+
pub wallets: Vec<String>,
4242
}
4343

4444
#[derive(Debug, Serialize, Deserialize, Clone)]

crates/signer/src/manager/dirk.rs

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
use std::{
2-
collections::{HashMap, HashSet},
3-
io::Write,
4-
path::PathBuf,
5-
};
1+
use std::{collections::HashMap, io::Write, path::PathBuf};
62

73
use alloy::{hex, rpc::types::beacon::constants::BLS_SIGNATURE_BYTES_LEN};
84
use blsful::inner_types::{Field, G2Affine, G2Projective, Group, Scalar};
@@ -107,14 +103,8 @@ impl DirkManager {
107103
}
108104
};
109105

110-
let wallets: HashSet<String> = host
111-
.accounts
112-
.iter()
113-
.map(|account| decompose_name(account).unwrap_or_default().0)
114-
.collect();
115-
116106
let accounts_response = match ListerClient::new(channel.clone())
117-
.list_accounts(ListAccountsRequest { paths: wallets.into_iter().collect() })
107+
.list_accounts(ListAccountsRequest { paths: host.wallets.clone() })
118108
.await
119109
{
120110
Ok(res) => res,
@@ -130,12 +120,7 @@ impl DirkManager {
130120
}
131121

132122
let accounts_response = accounts_response.into_inner();
133-
load_simple_accounts(
134-
accounts_response.accounts,
135-
&host,
136-
&channel,
137-
&mut consensus_accounts,
138-
);
123+
load_simple_accounts(accounts_response.accounts, &channel, &mut consensus_accounts);
139124
load_distributed_accounts(
140125
accounts_response.distributed_accounts,
141126
&host,
@@ -144,15 +129,6 @@ impl DirkManager {
144129
)
145130
.map_err(|error| warn!("{error}"))
146131
.ok();
147-
148-
for account in host.accounts {
149-
if !consensus_accounts
150-
.values()
151-
.any(|account| account.full_name() == account.full_name())
152-
{
153-
warn!("Account {account} not found in server {}", host.url);
154-
}
155-
}
156132
}
157133

158134
debug!(
@@ -595,15 +571,10 @@ fn decompose_name(full_name: &str) -> eyre::Result<(String, String)> {
595571
/// Load `SimpleAccount`s into the consensus accounts map
596572
fn load_simple_accounts(
597573
accounts: Vec<crate::proto::v1::Account>,
598-
host: &DirkHostConfig,
599574
channel: &Channel,
600575
consensus_accounts: &mut HashMap<BlsPublicKey, Account>,
601576
) {
602577
for account in accounts {
603-
if !host.accounts.contains(&account.name) {
604-
continue;
605-
}
606-
607578
let Ok((wallet, name)) = decompose_name(&account.name) else {
608579
warn!("Invalid account name {}", account.name);
609580
continue;
@@ -643,10 +614,6 @@ fn load_distributed_accounts(
643614
.ok_or(eyre::eyre!("Host name not found for server {}", host.url))?;
644615

645616
for account in accounts {
646-
if !host.accounts.contains(&account.name) {
647-
continue;
648-
}
649-
650617
let Ok(public_key) = BlsPublicKey::try_from(account.composite_public_key.as_slice()) else {
651618
warn!("Failed to parse composite public key for account {}", account.name);
652619
continue;

0 commit comments

Comments
 (0)