Skip to content

Commit

Permalink
chore(core-node)!: Cleanup Narwhal related fields in IOTA Framework c…
Browse files Browse the repository at this point in the history
…odebase (Move and Rust) (#3151)

* renamed narwhal_primary_address and narwhal_worker_address

* fixed rustfmt remarks

* fixed more rustfmt remarks

* renamed additional files

* cleaned up comments in move

* started removing worker_address

* Make PubKey naming more sane.

* More renames

* Continue renaming, including missed renames.

* Continue renaming in Move files

* Revert incorrect format

* Cleanup some yaml files

* Fix cargo fmt issues

* addressed fmt issues

* Fix rustfmt

* Cleanup naming

* addressed fmt issues

* addressed clippy errors

* Update crates/iota-config/src/node.rs

Co-authored-by: Thoralf-M <[email protected]>

* Remove unused consensus parameter.

* Address review comments.

* Address review comments and rename missed occurrences.

* Remove worker address from iptables.yaml

* Add a comment explaining `primary_address` field.

* Address review comments and missed renames

* Fix dprint

* Another round of missed renames

* Yet another round of missed renames

* Update manifest.json

* Fix docs

* Regenerate all snapshots

* generated auto-generated files

* Revert graphql auto-generated changes and generate files script

* Update crates/iota-framework/packages/iota-system/sources/validator.move

* fix(iota-graphql-{rpc,e2e-tests}): restore tests (#3572)

* fix(iota-graphql-e2e-tests): update baselines and source files

* fix(iota-graphql-rpc): update schema snapshot

* chore(iota-framework-snapshot): update manifest

* fix(iota-graphql-e2e-tests): update baselines and source files

* chore(iota-graphql-e2e-tests): comment digest resolution in event_connection tests

* chore(swarm-config): re-generated snapshots

---------

Co-authored-by: Hans Moog <[email protected]>
Co-authored-by: Piotr Macek <[email protected]>
Co-authored-by: Thoralf-M <[email protected]>
Co-authored-by: Alexander Sporn <[email protected]>
Co-authored-by: Konstantinos Demartinos <[email protected]>
  • Loading branch information
6 people authored Oct 23, 2024
1 parent 100ded3 commit 32016aa
Show file tree
Hide file tree
Showing 168 changed files with 3,380 additions and 3,996 deletions.
9 changes: 6 additions & 3 deletions consensus/config/src/committee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,14 @@ pub struct Authority {
pub address: Multiaddr,
/// The authority's hostname, for metrics and logging.
pub hostname: String,
/// The authority's public key as Iota identity.
/// The public key bytes corresponding to the private key that the validator
/// holds to sign transactions.
pub authority_key: AuthorityPublicKey,
/// The authority's public key for verifying blocks.
/// The public key bytes corresponding to the private key that the validator
/// holds to sign consensus blocks.
pub protocol_key: ProtocolPublicKey,
/// The authority's public key for TLS and as network identity.
/// The public key bytes corresponding to the private key that the validator
/// uses to establish TLS connections.
pub network_key: NetworkPublicKey,
}

Expand Down
2 changes: 1 addition & 1 deletion crates/iota-benchmark/src/benchmark_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Env {
for v in cluster.swarm.config().validator_configs() {
eprintln!(
"Metric address for validator {}: {}",
v.protocol_public_key().concise(),
v.authority_public_key().concise(),
v.metrics_address
);
}
Expand Down
10 changes: 5 additions & 5 deletions crates/iota-bridge-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ async fn main() -> anyhow::Result<()> {
.active_validators
.into_iter()
.map(|summary| {
let protocol_key =
AuthorityPublicKeyBytes::from_bytes(&summary.protocol_pubkey_bytes)
let authority_key =
AuthorityPublicKeyBytes::from_bytes(&summary.authority_pubkey_bytes)
.unwrap();
(summary.iota_address, (protocol_key, summary.name))
(summary.iota_address, (authority_key, summary.name))
})
.collect::<HashMap<_, _>>();
let mut authorities = vec![];
Expand Down Expand Up @@ -326,8 +326,8 @@ async fn main() -> anyhow::Result<()> {
};
let url = url.to_string();

let (protocol_key, name) = names.get(&iota_address).unwrap();
let stake = stakes.get(protocol_key).unwrap();
let (authority_key, name) = names.get(&iota_address).unwrap();
let stake = stakes.get(authority_key).unwrap();
authorities.push((name, iota_address, pubkey, eth_address, url, stake));
}
let total_stake = authorities
Expand Down
8 changes: 4 additions & 4 deletions crates/iota-config/data/fullnode-template-with-path.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ authority-store-pruning-config:
max-transactions-in-batch: 1000
pruning-run-delay-seconds: 60

protocol-key-pair:
path: "protocol.key"
authority-key-pair:
path: "authority.key"
network-key-pair:
path: "network.key"
account-key-pair:
path: "account.key"
worker-key-pair:
path: "worker.key"
protocol-key-pair:
path: "protocol.key"
49 changes: 25 additions & 24 deletions crates/iota-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ pub const DEFAULT_COMMISSION_RATE: u64 = 200;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct NodeConfig {
/// The public key bytes corresponding to the private key that the validator
/// holds to sign transactions.
#[serde(default = "default_authority_key_pair")]
pub protocol_key_pair: AuthorityKeyPairWithPath,
pub authority_key_pair: AuthorityKeyPairWithPath,
/// The public key bytes corresponding to the private key that the validator
/// holds to sign consensus blocks.
#[serde(default = "default_key_pair")]
pub worker_key_pair: KeyPairWithPath,
pub protocol_key_pair: KeyPairWithPath,
#[serde(default = "default_key_pair")]
pub account_key_pair: KeyPairWithPath,
/// The public key bytes corresponding to the private key that the validator
/// uses to establish TLS connections.
#[serde(default = "default_key_pair")]
pub network_key_pair: KeyPairWithPath,
pub db_path: PathBuf,
Expand Down Expand Up @@ -367,15 +373,15 @@ fn is_true(value: &bool) -> bool {
impl Config for NodeConfig {}

impl NodeConfig {
pub fn protocol_key_pair(&self) -> &AuthorityKeyPair {
self.protocol_key_pair.authority_keypair()
pub fn authority_key_pair(&self) -> &AuthorityKeyPair {
self.authority_key_pair.authority_keypair()
}

pub fn worker_key_pair(&self) -> &NetworkKeyPair {
match self.worker_key_pair.keypair() {
pub fn protocol_key_pair(&self) -> &NetworkKeyPair {
match self.protocol_key_pair.keypair() {
IotaKeyPair::Ed25519(kp) => kp,
other => panic!(
"invalid keypair type: {:?}, only Ed25519 is allowed for worker key",
"invalid keypair type: {:?}, only Ed25519 is allowed for protocol key",
other
),
}
Expand All @@ -391,8 +397,8 @@ impl NodeConfig {
}
}

pub fn protocol_public_key(&self) -> AuthorityPublicKeyBytes {
self.protocol_key_pair().public().into()
pub fn authority_public_key(&self) -> AuthorityPublicKeyBytes {
self.authority_key_pair().public().into()
}

pub fn db_path(&self) -> PathBuf {
Expand Down Expand Up @@ -503,16 +509,10 @@ pub struct ConsensusConfig {
/// estimates.
pub submit_delay_step_override_millis: Option<u64>,

pub address: Multiaddr,

pub parameters: Option<ConsensusParameters>,
}

impl ConsensusConfig {
pub fn address(&self) -> &Multiaddr {
&self.address
}

pub fn db_path(&self) -> &Path {
&self.db_path
}
Expand Down Expand Up @@ -1169,17 +1169,18 @@ mod tests {

#[test]
fn load_key_pairs_to_node_config() {
let protocol_key_pair: AuthorityKeyPair =
let authority_key_pair: AuthorityKeyPair =
get_key_pair_from_rng(&mut StdRng::from_seed([0; 32])).1;
let worker_key_pair: NetworkKeyPair =
let protocol_key_pair: NetworkKeyPair =
get_key_pair_from_rng(&mut StdRng::from_seed([0; 32])).1;
let network_key_pair: NetworkKeyPair =
get_key_pair_from_rng(&mut StdRng::from_seed([0; 32])).1;

write_authority_keypair_to_file(&protocol_key_pair, PathBuf::from("protocol.key")).unwrap();
write_authority_keypair_to_file(&authority_key_pair, PathBuf::from("authority.key"))
.unwrap();
write_keypair_to_file(
&IotaKeyPair::Ed25519(worker_key_pair.copy()),
PathBuf::from("worker.key"),
&IotaKeyPair::Ed25519(protocol_key_pair.copy()),
PathBuf::from("protocol.key"),
)
.unwrap();
write_keypair_to_file(
Expand All @@ -1191,16 +1192,16 @@ mod tests {
const TEMPLATE: &str = include_str!("../data/fullnode-template-with-path.yaml");
let template: NodeConfig = serde_yaml::from_str(TEMPLATE).unwrap();
assert_eq!(
template.protocol_key_pair().public(),
protocol_key_pair.public()
template.authority_key_pair().public(),
authority_key_pair.public()
);
assert_eq!(
template.network_key_pair().public(),
network_key_pair.public()
);
assert_eq!(
template.worker_key_pair().public(),
worker_key_pair.public()
template.protocol_key_pair().public(),
protocol_key_pair.public()
);
}
}
Expand Down
Loading

0 comments on commit 32016aa

Please sign in to comment.