Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions linera-client/src/client_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,23 @@ impl ValidatorQueryResults {
Ok(version_info) => {
if ref_version.is_none_or(|ref_v| ref_v.crate_version != version_info.crate_version)
{
println!("Linera protocol: v{}", version_info.crate_version);
println!("Linera protocol differs: v{}", version_info.crate_version);
}
if ref_version.is_none_or(|ref_v| ref_v.rpc_hash != version_info.rpc_hash) {
println!("RPC API hash: {}", version_info.rpc_hash);
println!("RPC API hash differs: {}", version_info.rpc_hash);
}
if ref_version.is_none_or(|ref_v| ref_v.graphql_hash != version_info.graphql_hash) {
println!("GraphQL API hash: {}", version_info.graphql_hash);
println!("GraphQL API hash differs: {}", version_info.graphql_hash);
}
if ref_version.is_none_or(|ref_v| ref_v.wit_hash != version_info.wit_hash) {
println!("WIT API hash: v{}", version_info.wit_hash);
println!("WIT API hash differs: v{}", version_info.wit_hash);
}
if ref_version.is_none_or(|ref_v| {
(&ref_v.git_commit, ref_v.git_dirty)
!= (&version_info.git_commit, version_info.git_dirty)
}) {
println!(
"Source code: {}/tree/{}{}",
"Source code differs: {}/tree/{}{}",
env!("CARGO_PKG_REPOSITORY"),
version_info.git_commit,
if version_info.git_dirty {
Expand All @@ -149,7 +149,7 @@ impl ValidatorQueryResults {
reference.and_then(|ref_results| ref_results.genesis_config_hash.as_ref().ok());
match &self.genesis_config_hash {
Ok(hash) if ref_genesis_hash.is_some_and(|ref_hash| ref_hash == hash) => {}
Ok(hash) => println!("Genesis config hash: {hash}"),
Ok(hash) => println!("Genesis config hash differs: {hash}"),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're apparently parsing this text but that's not even the value it used to be any more

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where? In CI? I can't find where we parse it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err(err) => println!("Error getting genesis config: {err}"),
}

Expand All @@ -158,26 +158,26 @@ impl ValidatorQueryResults {
Ok(info) => {
if ref_info.is_none_or(|ref_info| info.block_hash != ref_info.block_hash) {
if let Some(hash) = info.block_hash {
println!("Block hash: {}", hash);
println!("Block hash differs: {}", hash);
} else {
println!("Block hash: None");
println!("Block hash differs: None");
}
}
if ref_info
.is_none_or(|ref_info| info.next_block_height != ref_info.next_block_height)
{
println!("Next height: {}", info.next_block_height);
println!("Next height differs: {}", info.next_block_height);
}
if ref_info.is_none_or(|ref_info| info.timestamp != ref_info.timestamp) {
println!("Timestamp: {}", info.timestamp);
println!("Timestamp differs: {}", info.timestamp);
}
if ref_info.is_none_or(|ref_info| info.epoch != ref_info.epoch) {
println!("Epoch: {}", info.epoch);
println!("Epoch differs: {}", info.epoch);
}
if ref_info.is_none_or(|ref_info| {
info.manager.current_round != ref_info.manager.current_round
}) {
println!("Round: {}", info.manager.current_round);
println!("Round differs: {}", info.manager.current_round);
}
if let Some(locking) = &info.manager.requested_locking {
match &**locking {
Expand Down Expand Up @@ -721,8 +721,10 @@ impl<Env: Environment, W: Persist<Target = Wallet>> ClientContext<Env, W> {
address: &str,
node: &impl ValidatorNode,
chain_id: ChainId,
create_network_actions: bool,
) -> Result<ChainInfo, Error> {
let query = ChainInfoQuery::new(chain_id).with_manager_values();
let mut query = ChainInfoQuery::new(chain_id).with_manager_values();
query.create_network_actions = create_network_actions;
match node.handle_chain_info_query(query).await {
Ok(response) => {
debug!(
Expand Down Expand Up @@ -761,11 +763,18 @@ impl<Env: Environment, W: Persist<Target = Wallet>> ClientContext<Env, W> {
node: &impl ValidatorNode,
chain_id: ChainId,
public_key: Option<&ValidatorPublicKey>,
create_network_actions: bool,
) -> ValidatorQueryResults {
let version_info = self.check_compatible_version_info(address, node).await;
let genesis_config_hash = self.check_matching_network_description(address, node).await;
let chain_info = self
.check_validator_chain_info_response(public_key, address, node, chain_id)
.check_validator_chain_info_response(
public_key,
address,
node,
chain_id,
create_network_actions,
)
.await;

ValidatorQueryResults {
Expand Down
8 changes: 8 additions & 0 deletions linera-service/src/cli/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ pub enum ClientCommand {
/// info will be checked.
#[arg(long)]
public_key: Option<ValidatorPublicKey>,
/// Whether the query should trigger the chain's network actions on the validator
/// side.
#[arg(long)]
create_network_actions: bool,
},

/// Show the current set of validators for a chain. Also print some information about
Expand All @@ -381,6 +385,10 @@ pub enum ClientCommand {
/// Skip validators with less voting weight that this.
#[arg(long)]
min_votes: Option<u64>,
/// Whether the query should trigger the chain's network actions on the validator
/// side.
#[arg(long)]
create_network_actions: bool,
},

/// Query validators for shard information about a specific chain.
Expand Down
36 changes: 26 additions & 10 deletions linera-service/src/cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,20 @@ impl Runnable for Job {
address,
chain_id,
public_key,
create_network_actions,
} => {
let context = options.create_client_context(storage, wallet, signer.into_value());
let node = context.make_node_provider().make_node(&address)?;
let chain_id = chain_id.unwrap_or_else(|| context.default_chain());
println!("Querying validator about chain {chain_id}.\n");
let results = context
.query_validator(&address, &node, chain_id, public_key.as_ref())
.query_validator(
&address,
&node,
chain_id,
public_key.as_ref(),
create_network_actions,
)
.await;

for error in results.errors() {
Expand All @@ -455,6 +462,7 @@ impl Runnable for Job {
QueryValidators {
chain_id,
min_votes,
create_network_actions,
} => {
let mut context =
options.create_client_context(storage, wallet, signer.into_value());
Expand All @@ -479,7 +487,13 @@ impl Runnable for Job {
let address = &state.network_address;
let node = node_provider.make_node(address)?;
let results = context
.query_validator(address, &node, chain_id, Some(name))
.query_validator(
address,
&node,
chain_id,
Some(name),
create_network_actions,
)
.await;
validator_results.push((name, address, state.votes, results));
}
Expand Down Expand Up @@ -511,15 +525,17 @@ impl Runnable for Job {
println!();
}

let num_ok_validators = committee.validators().len() - faulty_validators.len();
if !faulty_validators.is_empty() {
println!("{:#?}", faulty_validators);
if min_votes.is_none() {
let num_ok_validators = committee.validators().len() - faulty_validators.len();
if !faulty_validators.is_empty() {
println!("{:#?}", faulty_validators);
}
info!(
"{}/{} validators are OK.",
num_ok_validators,
committee.validators().len()
);
}
info!(
"{}/{} validators are OK.",
num_ok_validators,
committee.validators().len()
);
}

QueryShardInfo { chain_id } => {
Expand Down
Loading