Skip to content

Commit 7ae2acc

Browse files
committed
feat: make setting bootnodes optional when node network key is found or not found
1 parent eb00c3a commit 7ae2acc

File tree

16 files changed

+155
-87
lines changed

16 files changed

+155
-87
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This changelog is based on [Keep A Changelog](https://keepachangelog.com/en/1.1.
55
# Unreleased
66

77
* Added extra constant burn fee in `pallet-address-association` to discourage attacks on pallet storage.
8+
* Wizards don't require `generate-keys` for `prepare-configuration`. Altered recommended order of `create-chain-spec` and `setup-main-chain-state`.
89

910
## Changed
1011

dev/local-environment/configurations/wizard/governance-authority/entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ spawn ./partner-chains-node wizards prepare-configuration
6060
set timeout 180
6161
expect "node base path (./data)"
6262
send "\r"
63+
expect "Do you want to configure a single bootnode with"
64+
send "Y\r"
6365
expect "Your bootnode should be accessible via:"
6466
send "\r"
6567
expect "Enter bootnode TCP port (3033)"
@@ -76,7 +78,7 @@ expect "path to the payment signing key file (payment.skey)"
7678
send "/keys/funded_address.skey\r"
7779
expect "Select an UTXO to use as the genesis UTXO"
7880
send "\r"
79-
expect "Space separated keys hashes of the initial Multisig Governance Authorities (0x$GOVERNANCE_AUTHORITY)"
81+
expect "Enter the space separated keys hashes of the initial Multisig Governance Authorities"
8082
send "\r"
8183
expect "Initial Multisig Governance Threshold (1)"
8284
send "\r"
@@ -164,8 +166,7 @@ expect "Enter R, the number of registered candidates seats, as a non-negative in
164166
send "1\r"
165167
expect "path to the payment signing key file (/keys/funded_address.skey)"
166168
send "\r"
167-
expect "Done. Main chain state is set."
168-
expect eof
169+
expect "Done."
169170
EOF
170171

171172
touch /shared/partner-chains-node-1.ready

docs/user-guides/chain-builder.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Partner Chain builders are organizations that want to build their own blockchain
1212
3. Run the prepare-configuration wizard
1313
1. Set chain parameters
1414
2. Provide signing key
15-
4. Run the create-chain-spec wizard
16-
5. Run the setup-main-chain-state wizard
15+
4. Run the setup-main-chain-state wizard
16+
5. Run the create-chain-spec wizard
1717
6. Run the start-node wizard
1818
7. Distribute chain files to participants
1919

@@ -334,19 +334,7 @@ A sample file:
334334
}
335335
```
336336

337-
### 4. Run the create-chain-spec wizard
338-
339-
The wizard reads the file `pc-chain-config.json`. This file should be present and identical for every node participating in the chain.
340-
341-
1. Start the wizard: `./partner-chains-node wizards create-chain-spec`
342-
343-
The wizard displays the contents of `chain_parameters` and `initial_permissioned_candidates` from the `pc-chain-config.json` file. You can manually modify these values before running this wizard.
344-
345-
The wizard creates the chain specification file `chain-spec.json` using these values.
346-
347-
The wizard informs you of the full path to the `chain-spec.json` file. You can now distribute this file to block production committee candidates.
348-
349-
### 5. Run the setup-main-chain-state wizard
337+
### 4. Run the setup-main-chain-state wizard
350338

351339
1. Start the wizard: `./partner-chains-node wizards setup-main-chain-state`
352340

@@ -365,6 +353,18 @@ The configuration of the chain is stored in the file `pc-chain-config.json`. Thi
365353

366354
Information about the resources used by each node is stored in the file `partner-chain-cli-resources-config.json`. This file should be present for every node participating in the chain, but its contents are specific to each node.
367355

356+
### 5. Run the create-chain-spec wizard
357+
358+
The wizard reads the file `pc-chain-config.json`. This file should be present and identical for every node participating in the chain.
359+
360+
1. Start the wizard: `./partner-chains-node wizards create-chain-spec`
361+
362+
The wizard displays the contents of `chain_parameters` and `initial_permissioned_candidates` from the `pc-chain-config.json` file. You can manually modify these values before running this wizard.
363+
364+
The wizard creates the chain specification file `chain-spec.json` using these values.
365+
366+
The wizard informs you of the full path to the `chain-spec.json` file. You can now distribute this file to block production committee candidates.
367+
368368
### 6. Run the partner chain node
369369

370370
The start-node wizard is used to start a partner chain node. Make sure that `cardano-node` is running with DB Sync running and fully synced. You will need to provide a link to a PostgreSQL server running with DB Sync as part of starting the node.

toolkit/partner-chains-cli/src/config.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'a> ConfigFieldDefinition<'a, String> {
4444
if let Some(value) = self.load_from_file_and_print(context) {
4545
value
4646
} else {
47-
let value = context.prompt(self.name, self.default);
47+
let value = context.prompt(&format!("Enter the {}", self.name), self.default);
4848
self.save_to_file(&value, context);
4949
value
5050
}
@@ -55,8 +55,10 @@ impl<'a> ConfigFieldDefinition<'a, String> {
5555
&self,
5656
context: &C,
5757
) -> String {
58-
let value =
59-
context.prompt(self.name, self.load_from_file(context).as_deref().or(self.default));
58+
let value = context.prompt(
59+
&format!("Enter the {}", self.name),
60+
self.load_from_file(context).as_deref().or(self.default),
61+
);
6062
self.save_to_file(&value, context);
6163
value
6264
}
@@ -72,7 +74,7 @@ impl<'a, T> ConfigFieldDefinition<'a, T> {
7274
{
7375
let loaded_value = self.load_from_file(context).map(|v| v.to_string());
7476
let default_value = loaded_value.as_deref().or(self.default);
75-
let value = context.prompt(self.name, default_value);
77+
let value = context.prompt(&format!("Enter the {}", self.name), default_value);
7678
let parsed_value: T = value.parse()?;
7779
self.save_to_file(&parsed_value, context);
7880
Ok(parsed_value)
@@ -655,7 +657,7 @@ pub(crate) mod config_fields {
655657
> = ConfigFieldDefinition {
656658
config_file: CHAIN_CONFIG_FILE_PATH,
657659
path: &["initial_governance", "authorities"],
658-
name: "Space separated keys hashes of the initial Multisig Governance Authorities",
660+
name: "space separated keys hashes of the initial Multisig Governance Authorities",
659661
default: Some("[]"),
660662
_marker: PhantomData,
661663
};

toolkit/partner-chains-cli/src/create_chain_spec/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ impl<T: PartnerChainRuntime> CmdRun for CreateChainSpecCmd<T> {
3939
context.print(
4040
"If you are the governance authority, you can distribute it to the validators.",
4141
);
42-
context.print("Run 'setup-main-chain-state' command to set D-parameter and permissioned candidates on Cardano.");
4342
Ok(())
4443
} else {
4544
context.print("Aborted.");

toolkit/partner-chains-cli/src/create_chain_spec/tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,5 @@ fn show_outro() -> MockIO {
411411
MockIO::print(
412412
"If you are the governance authority, you can distribute it to the validators.",
413413
),
414-
MockIO::print(
415-
"Run 'setup-main-chain-state' command to set D-parameter and permissioned candidates on Cardano.",
416-
),
417414
])
418415
}

toolkit/partner-chains-cli/src/deregister/tests.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,19 @@ fn read_keys_io() -> MockIO {
140140
}
141141

142142
fn read_payment_signing_key() -> MockIO {
143-
MockIO::prompt("path to the payment signing key file", Some("payment.skey"), MY_PAYMEMENT_SKEY)
143+
MockIO::prompt(
144+
"Enter the path to the payment signing key file",
145+
Some("payment.skey"),
146+
MY_PAYMEMENT_SKEY,
147+
)
144148
}
145149

146150
fn read_cold_verification_key() -> MockIO {
147-
MockIO::prompt("path to the cold verification key file", Some("cold.vkey"), MY_COLD_VKEY)
151+
MockIO::prompt(
152+
"Enter the path to the cold verification key file",
153+
Some("cold.vkey"),
154+
MY_COLD_VKEY,
155+
)
148156
}
149157

150158
fn test_chain_config_content() -> serde_json::Value {

toolkit/partner-chains-cli/src/generate_keys/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub mod scenarios {
3939
}
4040

4141
pub fn prompt_all_config_fields() -> MockIO {
42-
MockIO::prompt("node base path", Some("./data"), DATA_PATH)
42+
MockIO::prompt("Enter the node base path", Some("./data"), DATA_PATH)
4343
}
4444

4545
pub fn resources_file_content() -> serde_json::Value {

toolkit/partner-chains-cli/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ pub enum Command<T: PartnerChainRuntime> {
5555
GenerateKeys(generate_keys::GenerateKeysCmd),
5656
/// Wizard to obtain the configuration needed for the partner-chain governance authority. This configuration should be shared with chain participants and used to create the chain spec json file.
5757
PrepareConfiguration(prepare_configuration::PrepareConfigurationCmd),
58-
/// Wizard for creating a chain spec json file based on the chain configuration (see `prepare-configuration`).
59-
CreateChainSpec(create_chain_spec::CreateChainSpecCmd<T>),
6058
/// Wizard for setting D-parameter and Permissioned Candidates list on the main chain.
6159
/// Uses 'chain config' obtained after running `prepare-configuration`.
6260
SetupMainChainState(setup_main_chain_state::SetupMainChainStateCmd),
61+
/// Wizard for creating a chain spec json file based on the chain configuration (see `prepare-configuration`).
62+
CreateChainSpec(create_chain_spec::CreateChainSpecCmd<T>),
6363
/// Wizard for starting a substrate node in the environment set up by `generate-keys`,
6464
/// `prepare-config`, and `create-chain-spec`. It also assists in setting the `resources configuration`.
6565
StartNode(start_node::StartNodeCmd),
@@ -107,8 +107,8 @@ const HELP_EXAMPLES: &str = r#"
107107
║ Governance Authority: ║
108108
║ 1. generate-keys : generate necessary cryptographic keys ║
109109
║ 2. prepare-configuration : set up the partner chain configuration ║
110-
║ 3. create-chain-spec : create the chain specification file
111-
║ 4. setup-main-chain-state: configure the main chain parameters
110+
║ 3. setup-main-chain-state: configure the main chain parameters
111+
║ 4. create-chain-spec : create the chain specification file
112112
║ 5. start-node : start the validator node ║
113113
╟────────────────────────────────────────────────────────────────────────────────╢
114114
║ Registered Validator: ║

toolkit/partner-chains-cli/src/ogmios/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ pub(crate) fn prompt_ogmios_configuration<C: IOContext>(
1616
context: &C,
1717
) -> anyhow::Result<ServiceConfig> {
1818
let ogmios_protocol = OGMIOS_PROTOCOL
19-
.select_options_with_default_from_file_and_save(OGMIOS_PROTOCOL.name, context)
19+
.select_options_with_default_from_file_and_save(
20+
&format!("Select {}", OGMIOS_PROTOCOL.name),
21+
context,
22+
)
2023
.map_err(anyhow::Error::msg)?;
2124
let ogmios_hostname = OGMIOS_HOSTNAME.prompt_with_default_from_file_and_save(context);
2225
let ogmios_port = OGMIOS_PORT.prompt_with_default_from_file_parse_and_save(context)?;

0 commit comments

Comments
 (0)