|
1 | 1 | use std::path::PathBuf;
|
2 | 2 |
|
3 |
| -use alloy::providers::{Provider, ProviderBuilder}; |
4 | 3 | use anyhow::{Context, Result, bail};
|
5 |
| -use cliquenet::AddressableCommittee; |
6 | 4 | use multisig::CommitteeId;
|
7 |
| -use multisig::{Committee, Keypair, x25519}; |
| 5 | +use multisig::{Keypair, x25519}; |
| 6 | +use timeboost::committee::CommitteeInfo; |
8 | 7 | use timeboost::{Timeboost, TimeboostConfig};
|
9 | 8 | use timeboost_builder::robusta;
|
10 |
| -use timeboost_contract::{CommitteeMemberSol, KeyManager}; |
11 |
| -use timeboost_crypto::prelude::DkgEncKey; |
12 |
| -use timeboost_types::{KeyStore, ThresholdKeyCell}; |
| 9 | +use timeboost_types::ThresholdKeyCell; |
13 | 10 | use tokio::select;
|
14 | 11 | use tokio::signal;
|
15 | 12 | use tokio::task::spawn;
|
@@ -73,99 +70,18 @@ async fn main() -> Result<()> {
|
73 | 70 | let dh_keypair = x25519::Keypair::from(node_config.keys.dh.secret.clone());
|
74 | 71 |
|
75 | 72 | // syncing with contract to get peers keys and network addresses
|
76 |
| - let provider = ProviderBuilder::new().connect_http(node_config.chain.parent.rpc_url.clone()); |
77 |
| - let chain_id = provider.get_chain_id().await?; |
78 |
| - |
79 |
| - assert_eq!( |
80 |
| - chain_id, node_config.chain.parent.id, |
81 |
| - "parent chain rpc has mismatched chain_id" |
82 |
| - ); |
83 |
| - |
84 |
| - let contract = KeyManager::new(node_config.chain.parent.key_manager_contract, &provider); |
85 |
| - |
86 |
| - let members: Vec<CommitteeMemberSol> = contract |
87 |
| - .getCommitteeById(cli.committee_id.into()) |
88 |
| - .call() |
89 |
| - .await? |
90 |
| - .members; |
91 |
| - |
| 73 | + let comm_info = CommitteeInfo::fetch( |
| 74 | + node_config.chain.parent.rpc_url.clone(), |
| 75 | + node_config.chain.parent.key_manager_contract, |
| 76 | + cli.committee_id.into(), |
| 77 | + ) |
| 78 | + .await?; |
92 | 79 | info!(label = %sign_keypair.public_key(), committee_id = %cli.committee_id, "committee info synced");
|
93 | 80 |
|
94 |
| - let peer_hosts_and_keys = members |
95 |
| - .iter() |
96 |
| - .map(|peer| -> Result<_> { |
97 |
| - let sig_key = multisig::PublicKey::try_from(peer.sigKey.as_ref()) |
98 |
| - .with_context(|| "Failed to parse sigKey bytes")?; |
99 |
| - let dh_key = x25519::PublicKey::try_from(peer.dhKey.as_ref()) |
100 |
| - .with_context(|| "Failed to parse dhKey bytes")?; |
101 |
| - let dkg_enc_key = DkgEncKey::from_bytes(peer.dkgKey.as_ref()) |
102 |
| - .with_context(|| "Failed to parse dkgKey bytes")?; |
103 |
| - let sailfish_address = cliquenet::Address::try_from(peer.networkAddress.as_ref()) |
104 |
| - .with_context(|| "Failed to parse networkAddress string")?; |
105 |
| - Ok((sig_key, dh_key, dkg_enc_key, sailfish_address)) |
106 |
| - }) |
107 |
| - .collect::<Result<Vec<_>>>()?; |
108 |
| - |
109 |
| - let mut sailfish_peer_hosts_and_keys = Vec::new(); |
110 |
| - let mut decrypt_peer_hosts_and_keys = Vec::new(); |
111 |
| - let mut certifier_peer_hosts_and_keys = Vec::new(); |
112 |
| - let mut dkg_enc_keys = Vec::new(); |
113 |
| - |
114 |
| - for (signing_key, dh_key, dkg_enc_key, sailfish_addr) in peer_hosts_and_keys.iter().cloned() { |
115 |
| - sailfish_peer_hosts_and_keys.push((signing_key, dh_key, sailfish_addr.clone())); |
116 |
| - decrypt_peer_hosts_and_keys.push(( |
117 |
| - signing_key, |
118 |
| - dh_key, |
119 |
| - sailfish_addr.clone().with_offset(DECRYPTER_PORT_OFFSET), |
120 |
| - )); |
121 |
| - certifier_peer_hosts_and_keys.push(( |
122 |
| - signing_key, |
123 |
| - dh_key, |
124 |
| - sailfish_addr.clone().with_offset(CERTIFIER_PORT_OFFSET), |
125 |
| - )); |
126 |
| - dkg_enc_keys.push(dkg_enc_key.clone()); |
127 |
| - } |
128 |
| - |
129 |
| - let sailfish_committee = { |
130 |
| - let c = Committee::new( |
131 |
| - cli.committee_id, |
132 |
| - sailfish_peer_hosts_and_keys |
133 |
| - .iter() |
134 |
| - .enumerate() |
135 |
| - .map(|(i, (k, ..))| (i as u8, *k)), |
136 |
| - ); |
137 |
| - AddressableCommittee::new(c, sailfish_peer_hosts_and_keys.iter().cloned()) |
138 |
| - }; |
139 |
| - |
140 |
| - let decrypt_committee = { |
141 |
| - let c = Committee::new( |
142 |
| - cli.committee_id, |
143 |
| - decrypt_peer_hosts_and_keys |
144 |
| - .iter() |
145 |
| - .enumerate() |
146 |
| - .map(|(i, (k, ..))| (i as u8, *k)), |
147 |
| - ); |
148 |
| - AddressableCommittee::new(c, decrypt_peer_hosts_and_keys.iter().cloned()) |
149 |
| - }; |
150 |
| - |
151 |
| - let certifier_committee = { |
152 |
| - let c = Committee::new( |
153 |
| - cli.committee_id, |
154 |
| - certifier_peer_hosts_and_keys |
155 |
| - .iter() |
156 |
| - .enumerate() |
157 |
| - .map(|(i, (k, ..))| (i as u8, *k)), |
158 |
| - ); |
159 |
| - AddressableCommittee::new(c, certifier_peer_hosts_and_keys.iter().cloned()) |
160 |
| - }; |
161 |
| - |
162 |
| - let key_store = KeyStore::new( |
163 |
| - sailfish_committee.committee().clone(), |
164 |
| - dkg_enc_keys |
165 |
| - .into_iter() |
166 |
| - .enumerate() |
167 |
| - .map(|(i, k)| (i as u8, k)), |
168 |
| - ); |
| 81 | + let sailfish_committee = comm_info.sailfish_committee(); |
| 82 | + let decrypt_committee = comm_info.decrypt_committee(); |
| 83 | + let certifier_committee = comm_info.certifier_committee(); |
| 84 | + let key_store = comm_info.dkg_key_store(); |
169 | 85 |
|
170 | 86 | let is_recover = !cli.ignore_stamp && node_config.stamp.is_file();
|
171 | 87 |
|
|
0 commit comments