Skip to content

Commit a7c1489

Browse files
authored
chore: remove legacy support in devnet (#1603)
1 parent e25bad4 commit a7c1489

File tree

6 files changed

+40
-222
lines changed

6 files changed

+40
-222
lines changed

crates/devnet/README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ rpcs:
5656
- url: https://test.rpc.fastnear.com
5757
rate_limit: 5
5858
max_concurrency: 30
59+
infra_ops_path: path-to-infra-ops-repo
5960
```
6061
6162
* (Optional) Configure a `funding_account` to use a specific account for funding operations:
@@ -130,12 +131,8 @@ In addition, You can find the VMs created in GCP under [this link](https://conso
130131
mpc-devnet mpc $MPC_NETWORK_NAME deploy-nomad
131132
```
132133

133-
The docker image to be deployed can be change with the `--docker-image` flag. By
134-
default, devnet assumes that a legacy docker image is deployed (with node
135-
version strictly older than 2.2.0). For newer versions, one must pass the
136-
`--not-legacy` flag, because they require different terraform variables (TODO:
137-
remove the flag [(#710)](https://github.com/near/mpc/issues/710)). A recent
138-
docker image can be found in our
134+
The docker image to be deployed can be change with the `--docker-image` flag. A
135+
recent docker image can be found in our
139136
[dockerhub](https://hub.docker.com/r/nearone/mpc-node/tags)
140137

141138
Both the `deploy-infra` and `deploy-nomad` commands can be repeated as needed.
@@ -164,8 +161,6 @@ Finally, initialize the contract
164161
mpc-devnet mpc $MPC_NETWORK_NAME init-contract --init-participants 2 --threshold 2
165162
```
166163

167-
(TODO: [(#710)](https://github.com/near/mpc/issues/710) merge these two steps)
168-
169164
The `--init-participants` can be fewer than the total number of participants,
170165
if we wish to have fewer participants join the network at the beginning.
171166

crates/devnet/src/account.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ pub struct OperatingAccessKey {
8585
recent_block_hash: CryptoHash,
8686
client: Arc<NearRpcClients>,
8787
signer: Signer,
88-
signing_key: SigningKey,
8988
}
9089

9190
/// Returns {prefix}{random string}{suffix}.
@@ -120,7 +119,6 @@ impl OperatingAccessKey {
120119
recent_block_hash,
121120
client,
122121
signer,
123-
signing_key,
124122
}
125123
}
126124

@@ -302,10 +300,6 @@ impl OperatingAccessKey {
302300
0,
303301
)
304302
}
305-
306-
pub fn secret_key(&self) -> SigningKey {
307-
self.signing_key.clone()
308-
}
309303
}
310304

311305
impl OperatingAccount {

crates/devnet/src/cli.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,6 @@ pub struct MpcTerraformDeployNomadCmd {
335335
/// The default is `constants::DEFAULT_MPC_DOCKER_IMAGE`.
336336
#[clap(long)]
337337
pub docker_image: Option<String>,
338-
/// By default, we deploy the default docker image, which is a legacy node, requiring secret
339-
/// shares.
340-
/// Set this flag if you deploy a newer node that generates its secrets on its own.
341-
#[clap(long)]
342-
pub not_legacy: bool, // todo: remove [(#710)](https://github.com/near/mpc/issues/710)
343338
}
344339

345340
#[derive(clap::Parser)]

crates/devnet/src/mpc.rs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,11 @@ async fn update_mpc_network(
106106
accounts
107107
.account_mut(&account_id)
108108
.set_mpc_participant(MpcParticipantSetup {
109-
p2p_private_key,
110109
responding_account_id: funded_accounts[i * 2 + 1].clone(),
111-
p2p_public_key: Some(p2p_public_key),
110+
p2p_public_key,
112111
});
113112
mpc_setup.participants.push(account_id);
114113
}
115-
116-
// todo: remove this logic [(#710)](https://github.com/near/mpc/issues/710)
117-
println!("Generating responding access keys - this step is not required after update to v2.2.");
118-
let responding_accounts = mpc_setup
119-
.participants
120-
.iter()
121-
.map(|participant| {
122-
accounts
123-
.account(participant)
124-
.get_mpc_participant()
125-
.unwrap()
126-
.responding_account_id
127-
.clone()
128-
})
129-
.collect::<Vec<_>>();
130-
131-
// Ensure that the responding accounts have enough access keys.
132-
let futs = accounts
133-
.accounts_mut(&responding_accounts)
134-
.into_values()
135-
.map(|account| account.ensure_have_n_access_keys(mpc_setup.num_responding_access_keys))
136-
.collect::<Vec<_>>();
137-
futures::future::join_all(futs).await;
138114
}
139115

140116
impl NewMpcNetworkCmd {
@@ -241,8 +217,7 @@ impl MpcAddKeysCmd {
241217
let public_data: StaticWebData = response.json::<StaticWebData>().await.unwrap();
242218

243219
let mpc_participant = MpcParticipantSetup {
244-
p2p_private_key: participant.p2p_private_key.clone(), // todo: remove this [(#710)](https://github.com/near/mpc/issues/710)
245-
p2p_public_key: Some(public_data.near_p2p_public_key),
220+
p2p_public_key: public_data.near_p2p_public_key,
246221
responding_account_id: participant.responding_account_id.clone(),
247222
};
248223

@@ -399,10 +374,8 @@ struct InitV2Args {
399374

400375
fn mpc_account_to_participant_info(account: &OperatingAccount, index: usize) -> ParticipantInfo {
401376
let mpc_setup = account.get_mpc_participant().unwrap();
402-
let p2p_public_key_bytes: [u8; ed25519_dalek::PUBLIC_KEY_LENGTH] = *mpc_setup
403-
.p2p_public_key
404-
.expect("P2P key is required for all nodes")
405-
.as_bytes();
377+
let p2p_public_key_bytes: [u8; ed25519_dalek::PUBLIC_KEY_LENGTH] =
378+
*mpc_setup.p2p_public_key.as_bytes();
406379

407380
let near_sdk_public_key =
408381
near_sdk::PublicKey::from_parts(CurveType::ED25519, p2p_public_key_bytes.to_vec())

crates/devnet/src/terraform.rs

Lines changed: 5 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ use crate::cli::{
99
};
1010
use crate::constants::DEFAULT_MPC_DOCKER_IMAGE;
1111
use crate::devnet::OperatingDevnetSetup;
12-
use crate::types::{near_crypto_compatible_serialization, MpcNetworkSetup, ParsedConfig};
12+
use crate::types::{MpcNetworkSetup, ParsedConfig};
1313
use describe::TerraformInfraShowOutput;
14-
use ed25519_dalek::{SigningKey, VerifyingKey};
1514
use near_account_id::AccountId;
1615
use serde::Serialize;
1716
use std::path::PathBuf;
@@ -72,52 +71,13 @@ async fn export_terraform_vars(
7271
name: &str,
7372
accounts: &OperatingAccounts,
7473
mpc_setup: &MpcNetworkSetup,
75-
not_legacy: bool,
7674
docker_image: Option<String>,
7775
) -> PathBuf {
7876
let contract = mpc_setup
7977
.contract
8078
.clone()
8179
.expect("Contract is not deployed");
82-
let terraform_file = if !not_legacy {
83-
// todo: eventually remove [(#710)](https://github.com/near/mpc/issues/710)
84-
let mut mpc_nodes = Vec::new();
85-
for (i, account_id) in mpc_setup.participants.iter().enumerate() {
86-
let account = accounts.account(account_id);
87-
let participant = account
88-
.get_mpc_participant()
89-
.expect("Not an MPC participant");
90-
let responding_account = accounts.account(&participant.responding_account_id);
91-
let respond_config = RespondConfigFile {
92-
account_id: participant.responding_account_id.clone(),
93-
access_keys: responding_account
94-
.all_access_keys()
95-
.await
96-
.into_iter()
97-
.map(|k| k.secret_key())
98-
.collect(),
99-
};
100-
101-
let account_sk = account.any_access_key().await.secret_key();
102-
let mpc_node = LegacyTerraformMpcNode {
103-
account: account_id.clone(),
104-
account_pk: account_sk.verifying_key(),
105-
account_sk,
106-
sign_sk: participant.p2p_private_key.clone(),
107-
sign_pk: participant.p2p_private_key.verifying_key(),
108-
url: format!("http://mpc-node-{}.service.mpc.consul:3000", i),
109-
respond_yaml: serde_yaml::to_string(&respond_config).unwrap(),
110-
};
111-
mpc_nodes.push(mpc_node);
112-
}
113-
let terraform_file = LegacyTerraformFile {
114-
cluster_prefix: name.to_string(),
115-
legacy_mpc_nodes: mpc_nodes,
116-
mpc_contract_signer: contract,
117-
ssd: mpc_setup.ssd,
118-
};
119-
serde_json::to_string_pretty(&terraform_file).unwrap()
120-
} else {
80+
let terraform_file = {
12181
let mut mpc_nodes = Vec::new();
12282
for (i, account_id) in mpc_setup.participants.iter().enumerate() {
12383
let responding_account_id = accounts
@@ -164,29 +124,6 @@ struct TerraformDeployInfraFile {
164124
ssd: bool,
165125
}
166126

167-
#[derive(Serialize)]
168-
struct LegacyTerraformFile {
169-
cluster_prefix: String,
170-
legacy_mpc_nodes: Vec<LegacyTerraformMpcNode>,
171-
mpc_contract_signer: AccountId,
172-
ssd: bool,
173-
}
174-
175-
#[derive(Serialize)]
176-
struct LegacyTerraformMpcNode {
177-
account: AccountId,
178-
#[serde(with = "near_crypto_compatible_serialization::verifying_key")]
179-
account_pk: VerifyingKey,
180-
#[serde(with = "near_crypto_compatible_serialization::signing_key")]
181-
account_sk: SigningKey,
182-
#[serde(with = "near_crypto_compatible_serialization::verifying_key")]
183-
sign_pk: VerifyingKey,
184-
#[serde(with = "near_crypto_compatible_serialization::signing_key")]
185-
sign_sk: SigningKey,
186-
url: String,
187-
respond_yaml: String,
188-
}
189-
190127
#[derive(Serialize)]
191128
struct TerraformFile {
192129
cluster_prefix: String,
@@ -205,14 +142,6 @@ struct TerraformMpcNode {
205142
near_responder_account_id: AccountId,
206143
}
207144

208-
// From MPC code.
209-
#[derive(Serialize)]
210-
pub struct RespondConfigFile {
211-
pub account_id: AccountId,
212-
#[serde(with = "near_crypto_compatible_serialization::signing_keys")]
213-
pub access_keys: Vec<SigningKey>,
214-
}
215-
216145
impl MpcTerraformDeployInfraCmd {
217146
pub async fn run(&self, name: &str, config: ParsedConfig) {
218147
println!(
@@ -294,14 +223,9 @@ impl MpcTerraformDeployNomadCmd {
294223
.mpc_setups
295224
.get(name)
296225
.expect(&format!("MPC network {} does not exist", name));
297-
let terraform_vars_file = export_terraform_vars(
298-
name,
299-
&setup.accounts,
300-
mpc_setup,
301-
self.not_legacy,
302-
self.docker_image.clone(),
303-
)
304-
.await;
226+
let terraform_vars_file =
227+
export_terraform_vars(name, &setup.accounts, mpc_setup, self.docker_image.clone())
228+
.await;
305229
let nomad_server_url = mpc_setup
306230
.nomad_server_url
307231
.clone()

0 commit comments

Comments
 (0)