Skip to content

Commit

Permalink
More renames
Browse files Browse the repository at this point in the history
  • Loading branch information
deuszx committed Feb 20, 2025
1 parent 16aacba commit 07d9ca9
Show file tree
Hide file tree
Showing 21 changed files with 117 additions and 119 deletions.
10 changes: 5 additions & 5 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ Show the version and genesis config hash of a new validator, and print a warning

###### **Options:**

* `--name <VALIDATOR>` — The public key of the validator. If given, the signature of the chain query info will be checked
* `--public-key <PUBLIC_KEY>` — The public key of the validator. If given, the signature of the chain query info will be checked



Expand Down Expand Up @@ -404,11 +404,11 @@ Synchronizes a validator with the local state of chains

Add or modify a validator (admin only)

**Usage:** `linera set-validator [OPTIONS] --name <VALIDATOR> --address <ADDRESS>`
**Usage:** `linera set-validator [OPTIONS] --public-key <PUBLIC_KEY> --address <ADDRESS>`

###### **Options:**

* `--name <VALIDATOR>` — The public key of the validator
* `--public-key <PUBLIC_KEY>` — The public key of the validator
* `--address <ADDRESS>` — Network address
* `--votes <VOTES>` — Voting power

Expand All @@ -421,11 +421,11 @@ Add or modify a validator (admin only)

Remove a validator (admin only)

**Usage:** `linera remove-validator --name <VALIDATOR>`
**Usage:** `linera remove-validator --public-key <PUBLIC_KEY>`

###### **Options:**

* `--name <VALIDATOR>` — The public key of the validator
* `--public-key <PUBLIC_KEY>` — The public key of the validator



Expand Down
6 changes: 3 additions & 3 deletions linera-chain/src/certificate/lite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ impl<'a> LiteCertificate<'a> {
let LiteVote {
value,
round,
validator,
public_key,
signature,
} = votes.next()?;
let mut signatures = vec![(validator, signature)];
let mut signatures = vec![(public_key, signature)];
for vote in votes {
if vote.value.value_hash != value.value_hash || vote.round != round {
return None;
}
signatures.push((vote.validator, vote.signature));
signatures.push((vote.public_key, vote.signature));
}
Some(LiteCertificate::new(value, round, signatures))
}
Expand Down
26 changes: 13 additions & 13 deletions linera-chain/src/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ struct VoteValue(CryptoHash, Round, CertificateKind);
pub struct Vote<T> {
pub value: Hashed<T>,
pub round: Round,
pub validator: ValidatorPublicKey,
pub public_key: ValidatorPublicKey,
pub signature: ValidatorSignature,
}

Expand All @@ -439,7 +439,7 @@ impl<T> Vote<T> {
Self {
value,
round,
validator: key_pair.public(),
public_key: key_pair.public(),
signature,
}
}
Expand All @@ -452,7 +452,7 @@ impl<T> Vote<T> {
LiteVote {
value: LiteValue::new(&self.value),
round: self.round,
validator: self.validator,
public_key: self.public_key,
signature: self.signature,
}
}
Expand All @@ -469,7 +469,7 @@ impl<T> Vote<T> {
pub struct LiteVote {
pub value: LiteValue,
pub round: Round,
pub validator: ValidatorPublicKey,
pub public_key: ValidatorPublicKey,
pub signature: ValidatorSignature,
}

Expand All @@ -483,7 +483,7 @@ impl LiteVote {
Some(Vote {
value,
round: self.round,
validator: self.validator,
public_key: self.public_key,
signature: self.signature,
})
}
Expand Down Expand Up @@ -816,15 +816,15 @@ impl LiteVote {
Self {
value,
round,
validator: key_pair.public(),
public_key: key_pair.public(),
signature,
}
}

/// Verifies the signature in the vote.
pub fn check(&self) -> Result<(), ChainError> {
let hash_and_round = VoteValue(self.value.value_hash, self.round, self.value.kind);
Ok(self.signature.check(&hash_and_round, self.validator)?)
Ok(self.signature.check(&hash_and_round, self.public_key)?)
}
}

Expand All @@ -851,26 +851,26 @@ impl<'a, T> SignatureAggregator<'a, T> {
/// of `check` below. Returns an error if the signed value cannot be aggregated.
pub fn append(
&mut self,
validator: ValidatorPublicKey,
public_key: ValidatorPublicKey,
signature: ValidatorSignature,
) -> Result<Option<GenericCertificate<T>>, ChainError>
where
T: CertificateValue,
{
let hash_and_round = VoteValue(self.partial.hash(), self.partial.round, T::KIND);
signature.check(&hash_and_round, validator)?;
signature.check(&hash_and_round, public_key)?;
// Check that each validator only appears once.
ensure!(
!self.used_validators.contains(&validator),
!self.used_validators.contains(&public_key),
ChainError::CertificateValidatorReuse
);
self.used_validators.insert(validator);
self.used_validators.insert(public_key);
// Update weight.
let voting_rights = self.committee.weight(&validator);
let voting_rights = self.committee.weight(&public_key);
ensure!(voting_rights > 0, ChainError::InvalidSigner);
self.weight += voting_rights;
// Update certificate.
self.partial.add_signature((validator, signature));
self.partial.add_signature((public_key, signature));

if self.weight >= self.committee.quorum_threshold() {
self.weight = 0; // Prevent from creating the certificate twice.
Expand Down
4 changes: 2 additions & 2 deletions linera-chain/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ impl<T: CertificateValue> VoteTestExt<T> for Vote<T> {
votes: 100,
};
let committee = Committee::new(
vec![(self.validator, state)].into_iter().collect(),
vec![(self.public_key, state)].into_iter().collect(),
ResourceControlPolicy::only_fuel(),
);
SignatureAggregator::new(self.value, self.round, &committee)
.append(self.validator, self.signature)
.append(self.public_key, self.signature)
.unwrap()
.unwrap()
}
Expand Down
13 changes: 8 additions & 5 deletions linera-chain/src/unit_tests/data_types_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn test_signed_values() {
);

let mut v = LiteVote::new(LiteValue::new(&confirmed_value), Round::Fast, &key2);
v.validator = validator_1;
v.public_key = validator_1;
assert!(v.check().is_err());

assert!(validated_vote.check().is_ok());
Expand Down Expand Up @@ -106,18 +106,21 @@ fn test_certificates() {

let mut builder = SignatureAggregator::new(value.clone(), Round::Fast, &committee);
assert!(builder
.append(v1.validator, v1.signature)
.append(v1.public_key, v1.signature)
.unwrap()
.is_none());
let mut c = builder.append(v2.validator, v2.signature).unwrap().unwrap();
let mut c = builder
.append(v2.public_key, v2.signature)
.unwrap()
.unwrap();
assert!(c.check(&committee).is_ok());
c.signatures_mut().pop();
assert!(c.check(&committee).is_err());

let mut builder = SignatureAggregator::new(value, Round::Fast, &committee);
assert!(builder
.append(v1.validator, v1.signature)
.append(v1.public_key, v1.signature)
.unwrap()
.is_none());
assert!(builder.append(v3.validator, v3.signature).is_err());
assert!(builder.append(v3.public_key, v3.signature).is_err());
}
4 changes: 2 additions & 2 deletions linera-client/src/client_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ where
trace!(
"Processing vote on {:?}'s block by {:?}",
chain_id,
vote.validator,
vote.public_key,
);
let aggregator = aggregators.entry(chain_id).or_insert_with(|| {
SignatureAggregator::new(
Expand All @@ -1027,7 +1027,7 @@ where
&committee,
)
});
match aggregator.append(vote.validator, vote.signature) {
match aggregator.append(vote.public_key, vote.signature) {
Ok(Some(certificate)) => {
trace!("Found certificate: {:?}", certificate);
certificates.push(certificate);
Expand Down
12 changes: 6 additions & 6 deletions linera-client/src/client_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ pub enum ClientCommand {
chain_id: Option<ChainId>,
/// The public key of the validator. If given, the signature of the chain query
/// info will be checked.
#[arg(long = "name")]
validator: Option<ValidatorPublicKey>,
#[arg(long)]
public_key: Option<ValidatorPublicKey>,
},

/// Show the current set of validators for a chain. Also print some information about
Expand All @@ -474,8 +474,8 @@ pub enum ClientCommand {
/// Add or modify a validator (admin only)
SetValidator {
/// The public key of the validator.
#[arg(long = "name")]
validator: ValidatorPublicKey,
#[arg(long)]
public_key: ValidatorPublicKey,

/// Network address
#[arg(long)]
Expand All @@ -493,8 +493,8 @@ pub enum ClientCommand {
/// Remove a validator (admin only)
RemoveValidator {
/// The public key of the validator.
#[arg(long = "name")]
validator: ValidatorPublicKey,
#[arg(long)]
public_key: ValidatorPublicKey,
},

/// Deprecates all committees except the last one.
Expand Down
4 changes: 2 additions & 2 deletions linera-client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ util::impl_from_dynamic!(Error:Persistence, persistent::file::Error);
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ValidatorConfig {
/// The public key of the validator.
pub validator: ValidatorPublicKey,
pub public_key: ValidatorPublicKey,
/// The network configuration for the validator.
pub network: ValidatorPublicNetworkConfig,
}
Expand Down Expand Up @@ -79,7 +79,7 @@ impl CommitteeConfig {
.into_iter()
.map(|v| {
(
v.validator,
v.public_key,
ValidatorState {
network_address: v.network.to_string(),
votes: 100,
Expand Down
4 changes: 2 additions & 2 deletions linera-client/src/unit_tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub fn make_genesis_config(builder: &TestBuilder<MemoryStorageBuilder>) -> Genes
};
let validator_names = builder.initial_committee.validators().keys();
let validators = validator_names
.map(|validator| ValidatorConfig {
validator: *validator,
.map(|public_key| ValidatorConfig {
public_key: *public_key,
network: network.clone(),
})
.collect();
Expand Down
30 changes: 15 additions & 15 deletions linera-core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ where
.client
.validator_node_provider
.make_nodes(committee)?
.map(|(validator, node)| RemoteNode { validator, node })
.map(|(public_key, node)| RemoteNode { public_key, node })
.collect())
}

Expand Down Expand Up @@ -1309,7 +1309,7 @@ where
.await?
.received_certificate_trackers
.get()
.get(&remote_node.validator)
.get(&remote_node.public_key)
.copied()
.unwrap_or(0);
let (committees, max_epoch) = self.known_committees().await?;
Expand Down Expand Up @@ -1409,7 +1409,7 @@ where
}

Ok(ReceivedCertificatesFromValidator {
validator: remote_node.validator,
public_key: remote_node.public_key,
tracker,
certificates,
other_sender_chains,
Expand Down Expand Up @@ -1456,7 +1456,7 @@ where
let mut new_trackers = BTreeMap::new();
for response in received_certificates_batches {
other_sender_chains.extend(response.other_sender_chains);
new_trackers.insert(response.validator, response.tracker);
new_trackers.insert(response.public_key, response.tracker);
for certificate in response.certificates {
certificates
.entry(certificate.block().header.chain_id)
Expand Down Expand Up @@ -1771,7 +1771,7 @@ where
if let Err(err) = self.try_process_locking_block_from(remote_node, cert).await {
warn!(
"Skipping certificate {hash} from validator {}: {err}",
remote_node.validator
remote_node.public_key
);
}
}
Expand All @@ -1797,8 +1797,8 @@ where
{
Ok(content) => content,
Err(err) => {
let validator = &remote_node.validator;
warn!("Skipping proposal from {owner} and validator {validator}: {err}");
let public_key = &remote_node.public_key;
warn!("Skipping proposal from {owner} and validator {public_key}: {err}");
continue;
}
};
Expand Down Expand Up @@ -1837,8 +1837,8 @@ where
}
}

let validator = &remote_node.validator;
warn!("Skipping proposal from {owner} and validator {validator}: {err}");
let public_key = &remote_node.public_key;
warn!("Skipping proposal from {owner} and validator {public_key}: {err}");
}
}
Ok(())
Expand Down Expand Up @@ -3350,8 +3350,8 @@ where
});
// Add tasks for new validators.
let validator_tasks = FuturesUnordered::new();
for (validator, node) in nodes {
let hash_map::Entry::Vacant(entry) = senders.entry(validator) else {
for (public_key, node) in nodes {
let hash_map::Entry::Vacant(entry) = senders.entry(public_key) else {
continue;
};
let stream = stream::once({
Expand All @@ -3360,9 +3360,9 @@ where
})
.filter_map(move |result| async move {
if let Err(error) = &result {
warn!(?error, "Could not connect to validator {validator}");
warn!(?error, "Could not connect to validator {public_key}");
} else {
info!("Connected to validator {validator}");
info!("Connected to validator {public_key}");
}
result.ok()
})
Expand All @@ -3371,7 +3371,7 @@ where
let mut stream = Box::pin(stream);
let this = self.clone();
let local_node = local_node.clone();
let remote_node = RemoteNode { validator, node };
let remote_node = RemoteNode { public_key, node };
validator_tasks.push(async move {
while let Some(notification) = stream.next().await {
this.process_notification(
Expand Down Expand Up @@ -3502,7 +3502,7 @@ impl Drop for AbortOnDrop {
/// The result of `synchronize_received_certificates_from_validator`.
struct ReceivedCertificatesFromValidator {
/// The name of the validator we downloaded from.
validator: ValidatorPublicKey,
public_key: ValidatorPublicKey,
/// The new tracker value for that validator.
tracker: u64,
/// The downloaded certificates. The signatures were already checked and they are ready
Expand Down
Loading

0 comments on commit 07d9ca9

Please sign in to comment.