Skip to content

Commit

Permalink
Fix missed renames
Browse files Browse the repository at this point in the history
  • Loading branch information
deuszx committed Feb 19, 2025
1 parent 7471c40 commit 7bcec3b
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 64 deletions.
1 change: 0 additions & 1 deletion examples/rust-toolchain.toml

This file was deleted.

4 changes: 2 additions & 2 deletions linera-client/src/client_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ pub enum ClientCommand {
SetValidator {
/// The public key of the validator.
#[arg(long)]
name: ValidatorPublicKey,
validator: ValidatorPublicKey,

/// Network address
#[arg(long)]
Expand All @@ -494,7 +494,7 @@ pub enum ClientCommand {
RemoveValidator {
/// The public key of the validator.
#[arg(long)]
name: ValidatorPublicKey,
validator: 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 name: ValidatorPublicKey,
pub validator: 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.name,
v.validator,
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(|name| ValidatorConfig {
name: *name,
.map(|validator| ValidatorConfig {
validator: *validator,
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(|(name, node)| RemoteNode { name, node })
.map(|(validator, node)| RemoteNode { validator, node })
.collect())
}

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

Ok(ReceivedCertificatesFromValidator {
name: remote_node.name,
validator: remote_node.validator,
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.name, response.tracker);
new_trackers.insert(response.validator, 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.name
remote_node.validator
);
}
}
Expand All @@ -1797,8 +1797,8 @@ where
{
Ok(content) => content,
Err(err) => {
let name = &remote_node.name;
warn!("Skipping proposal from {owner} and validator {name}: {err}");
let validator = &remote_node.validator;
warn!("Skipping proposal from {owner} and validator {validator}: {err}");
continue;
}
};
Expand Down Expand Up @@ -1837,8 +1837,8 @@ where
}
}

let name = &remote_node.name;
warn!("Skipping proposal from {owner} and validator {name}: {err}");
let validator = &remote_node.validator;
warn!("Skipping proposal from {owner} and validator {validator}: {err}");
}
}
Ok(())
Expand Down Expand Up @@ -3350,8 +3350,8 @@ where
});
// Add tasks for new validators.
let validator_tasks = FuturesUnordered::new();
for (name, node) in nodes {
let hash_map::Entry::Vacant(entry) = senders.entry(name) else {
for (validator, node) in nodes {
let hash_map::Entry::Vacant(entry) = senders.entry(validator) 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 {name}");
warn!(?error, "Could not connect to validator {validator}");
} else {
info!("Connected to validator {name}");
info!("Connected to validator {validator}");
}
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 { name, node };
let remote_node = RemoteNode { validator, 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.
name: ValidatorPublicKey,
validator: ValidatorPublicKey,
/// The new tracker value for that validator.
tracker: u64,
/// The downloaded certificates. The signatures were already checked and they are ready
Expand Down
29 changes: 16 additions & 13 deletions linera-core/src/remote_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::{
/// A validator node together with the validator's name.
#[derive(Clone, Debug)]
pub struct RemoteNode<N> {
pub name: ValidatorPublicKey,
pub validator: ValidatorPublicKey,
#[debug(skip)]
pub node: N,
}
Expand Down Expand Up @@ -105,15 +105,15 @@ impl<N: ValidatorNode> RemoteNode<N> {
certificate: &ValidatedBlockCertificate,
delivery: CrossChainMessageDelivery,
) -> Result<Box<ChainInfo>, NodeError> {
if certificate.is_signed_by(&self.name) {
if certificate.is_signed_by(&self.validator) {
let result = self
.handle_lite_certificate(certificate.lite_certificate(), delivery)
.await;
match result {
Err(NodeError::MissingCertificateValue) => {
warn!(
"Validator {} forgot a certificate value that they signed before",
self.name
self.validator
);
}
_ => return result,
Expand All @@ -127,15 +127,15 @@ impl<N: ValidatorNode> RemoteNode<N> {
certificate: &ConfirmedBlockCertificate,
delivery: CrossChainMessageDelivery,
) -> Result<Box<ChainInfo>, NodeError> {
if certificate.is_signed_by(&self.name) {
if certificate.is_signed_by(&self.validator) {
let result = self
.handle_lite_certificate(certificate.lite_certificate(), delivery)
.await;
match result {
Err(NodeError::MissingCertificateValue) => {
warn!(
"Validator {} forgot a certificate value that they signed before",
self.name
self.validator
);
}
_ => return result,
Expand All @@ -156,7 +156,7 @@ impl<N: ValidatorNode> RemoteNode<N> {
ensure!(
proposed.map_or(true, |proposal| proposal.content.block.chain_id == chain_id)
&& locking.map_or(true, |cert| cert.chain_id() == chain_id)
&& response.check(&self.name).is_ok(),
&& response.check(&self.validator).is_ok(),
NodeError::InvalidChainInfoResponse
);
Ok(response.info)
Expand All @@ -169,7 +169,7 @@ impl<N: ValidatorNode> RemoteNode<N> {
start: BlockHeight,
limit: u64,
) -> Result<Option<Vec<ConfirmedBlockCertificate>>, NodeError> {
tracing::debug!(name = ?self.name, ?chain_id, ?start, ?limit, "Querying certificates");
tracing::debug!(name = ?self.validator, ?chain_id, ?start, ?limit, "Querying certificates");
let range = BlockHeightRange {
start,
limit: Some(limit),
Expand Down Expand Up @@ -202,7 +202,7 @@ impl<N: ValidatorNode> RemoteNode<N> {
if !certificate.requires_blob(&blob_id) {
warn!(
"Got invalid last used by certificate for blob {} from validator {}",
blob_id, self.name
blob_id, self.validator
);
return Err(NodeError::InvalidCertificateForBlob(blob_id));
}
Expand Down Expand Up @@ -253,7 +253,10 @@ impl<N: ValidatorNode> RemoteNode<N> {
Ok(blob) => {
let blob = Blob::new(blob);
if blob.id() != blob_id {
tracing::info!("Validator {} sent an invalid blob {blob_id}.", self.name);
tracing::info!(
"Validator {} sent an invalid blob {blob_id}.",
self.validator
);
None
} else {
Some(blob)
Expand All @@ -262,7 +265,7 @@ impl<N: ValidatorNode> RemoteNode<N> {
Err(error) => {
tracing::debug!(
"Failed to fetch blob {blob_id} from validator {}: {error}",
self.name
self.validator
);
None
}
Expand Down Expand Up @@ -361,16 +364,16 @@ impl<N: ValidatorNode> RemoteNode<N> {
) -> Result<(), NodeError> {
ensure!(!blob_ids.is_empty(), NodeError::EmptyBlobsNotFound);
let required = certificate.inner().required_blob_ids();
let name = &self.name;
let validator = &self.validator;
for blob_id in blob_ids {
if !required.contains(blob_id) {
warn!("validator {name} requested blob {blob_id:?} but it is not required");
warn!("validator {validator} requested blob {blob_id:?} but it is not required");
return Err(NodeError::UnexpectedEntriesInBlobsNotFound);
}
}
let unique_missing_blob_ids = blob_ids.iter().cloned().collect::<HashSet<_>>();
if blob_ids.len() > unique_missing_blob_ids.len() {
warn!("blobs requested by validator {name} contain duplicates");
warn!("blobs requested by validator {validator} contain duplicates");
return Err(NodeError::DuplicatesInBlobsNotFound);
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions linera-core/src/unit_tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ impl<S> LocalValidatorClient<S>
where
S: Storage + Clone + Send + Sync + 'static,
{
fn new(name: ValidatorPublicKey, state: WorkerState<S>) -> Self {
fn new(validator: ValidatorPublicKey, state: WorkerState<S>) -> Self {
let client = LocalValidator {
fault_type: FaultType::Honest,
state,
notifier: Arc::new(ChannelNotifier::default()),
};
Self {
validator_pk: name,
validator_pk: validator,
client: Arc::new(Mutex::new(client)),
}
}
Expand Down
6 changes: 3 additions & 3 deletions linera-core/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ where
let mut responses: futures::stream::FuturesUnordered<_> = validator_clients
.iter()
.filter_map(|remote_node| {
if committee.weight(&remote_node.name) == 0 {
if committee.weight(&remote_node.validator) == 0 {
// This should not happen but better prevent it because certificates
// are not allowed to include votes with weight 0.
return None;
}
let execute = execute.clone();
let remote_node = remote_node.clone();
Some(async move { (remote_node.name, execute(remote_node).await) })
Some(async move { (remote_node.validator, execute(remote_node).await) })
})
.collect();

Expand Down Expand Up @@ -463,7 +463,7 @@ where
}
};
match vote {
Some(vote) if vote.validator == self.remote_node.name => {
Some(vote) if vote.validator == self.remote_node.validator => {
vote.check()?;
Ok(vote)
}
Expand Down
6 changes: 3 additions & 3 deletions linera-faucet/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub struct ClaimOutcome {

#[derive(Debug, Deserialize, SimpleObject)]
pub struct Validator {
pub name: ValidatorPublicKey,
pub validator: ValidatorPublicKey,
pub network_address: String,
}

Expand All @@ -94,8 +94,8 @@ where
Ok(committee
.validators()
.iter()
.map(|(name, validator)| Validator {
name: *name,
.map(|(public_key, validator)| Validator {
validator: *public_key,
network_address: validator.network_address.clone(),
})
.collect())
Expand Down
6 changes: 3 additions & 3 deletions linera-rpc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub type ValidatorPublicNetworkConfig = ValidatorPublicNetworkPreConfig<NetworkP
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ValidatorInternalNetworkPreConfig<P> {
/// The public key of the validator.
pub name: ValidatorPublicKey,
pub validator: ValidatorPublicKey,
/// The network protocol to use for all shards.
pub protocol: P,
/// The available shards. Each chain UID is mapped to a unique shard in the vector in
Expand All @@ -122,7 +122,7 @@ pub struct ValidatorInternalNetworkPreConfig<P> {
impl<P> ValidatorInternalNetworkPreConfig<P> {
pub fn clone_with_protocol<Q>(&self, protocol: Q) -> ValidatorInternalNetworkPreConfig<Q> {
ValidatorInternalNetworkPreConfig {
name: self.name,
validator: self.validator,
protocol,
shards: self.shards.clone(),
host: self.host.clone(),
Expand Down Expand Up @@ -234,7 +234,7 @@ impl<P> ValidatorInternalNetworkPreConfig<P> {
use std::hash::{Hash, Hasher};
let mut s = std::collections::hash_map::DefaultHasher::new();
// Use the validator public key to randomise shard assignment.
self.name.hash(&mut s);
self.validator.hash(&mut s);
chain_id.hash(&mut s);
(s.finish() as ShardId) % self.shards.len()
}
Expand Down
Loading

0 comments on commit 7bcec3b

Please sign in to comment.