Skip to content

Commit 42bc35c

Browse files
authored
Show locked; filter by weight; fetch all missing senders. (#4764)
## Motivation It's sometimes useful to see the current locked block of each validator, e.g. when debugging why a chain isn't making progress. It's also helpful to focus on only the validators with a lot of voting weight, since they matter most in that case. For proposals we learn about from validators, we only fetch one missing sender block. ## Proposal Show some information about the locking block, if present. Add a `--min-votes` option. Fetch _all_ missing sender blocks. ## Test Plan I'm using this for debugging on `testnet_conway`. With the fix for fetching missing senders I managed to get the locked block into my local node's chain manager. ## Release Plan - These changes should be ported to `testnet_conway` and released in a new SDK. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 6b1196d commit 42bc35c

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

CLI.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,12 @@ Show the version and genesis config hash of a new validator, and print a warning
479479

480480
Show the current set of validators for a chain. Also print some information about the given chain while we are at it
481481

482-
**Usage:** `linera query-validators [CHAIN_ID]`
482+
**Usage:** `linera query-validators [CHAIN_ID] [MIN_VOTES]`
483483

484484
###### **Arguments:**
485485

486486
* `<CHAIN_ID>` — The chain to query. If omitted, query the default chain of the wallet
487+
* `<MIN_VOTES>` — Skip validators with less voting weight that this
487488

488489

489490

linera-client/src/client_context.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use linera_base::{
1111
ownership::ChainOwnership,
1212
time::{Duration, Instant},
1313
};
14-
use linera_chain::types::ConfirmedBlockCertificate;
14+
use linera_chain::{manager::LockingBlock, types::ConfirmedBlockCertificate};
1515
use linera_core::{
1616
client::{ChainClient, Client, ListeningMode},
1717
data_types::{ChainInfo, ChainInfoQuery, ClientOutcome},
@@ -179,6 +179,24 @@ impl ValidatorQueryResults {
179179
}) {
180180
println!("Round: {}", info.manager.current_round);
181181
}
182+
if let Some(locking) = &info.manager.requested_locking {
183+
match &**locking {
184+
LockingBlock::Fast(proposal) => {
185+
println!(
186+
"Locking fast block from {}",
187+
proposal.content.block.timestamp
188+
);
189+
}
190+
LockingBlock::Regular(validated) => {
191+
println!(
192+
"Locking block {} in {} from {}",
193+
validated.hash(),
194+
validated.round,
195+
validated.block().header.timestamp
196+
);
197+
}
198+
}
199+
}
182200
}
183201
Err(err) => println!("Error getting chain info: {err}"),
184202
}
@@ -702,7 +720,7 @@ impl<Env: Environment, W: Persist<Target = Wallet>> ClientContext<Env, W> {
702720
node: &impl ValidatorNode,
703721
chain_id: ChainId,
704722
) -> Result<ChainInfo, Error> {
705-
let query = ChainInfoQuery::new(chain_id);
723+
let query = ChainInfoQuery::new(chain_id).with_manager_values();
706724
match node.handle_chain_info_query(query).await {
707725
Ok(response) => {
708726
debug!(
@@ -767,7 +785,7 @@ impl<Env: Environment, W: Persist<Target = Wallet>> ClientContext<Env, W> {
767785
.genesis_config_hash);
768786
let chain_info = self
769787
.make_chain_client(chain_id)
770-
.chain_info()
788+
.chain_info_with_manager_values()
771789
.await
772790
.map(|info| *info)
773791
.map_err(|e| e.into());

linera-core/src/client/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,12 @@ impl<Env: Environment> Client<Env> {
11241124
}
11251125
}
11261126

1127+
if certificates.is_empty() {
1128+
self.local_node
1129+
.retry_pending_cross_chain_requests(sender_chain_id)
1130+
.await?;
1131+
}
1132+
11271133
// Process certificates in ascending block height order (BTreeMap keeps them sorted).
11281134
for certificate in certificates.into_values() {
11291135
self.receive_sender_certificate(
@@ -1335,7 +1341,7 @@ impl<Env: Environment> Client<Env> {
13351341
}
13361342
}
13371343
}
1338-
if let LocalNodeError::WorkerError(WorkerError::ChainError(chain_err)) = &err {
1344+
while let LocalNodeError::WorkerError(WorkerError::ChainError(chain_err)) = &err {
13391345
if let ChainError::MissingCrossChainUpdate {
13401346
chain_id,
13411347
origin,
@@ -1357,8 +1363,10 @@ impl<Env: Environment> Client<Env> {
13571363
{
13581364
err = new_err;
13591365
} else {
1360-
continue;
1366+
continue 'proposal_loop;
13611367
}
1368+
} else {
1369+
break;
13621370
}
13631371
}
13641372

@@ -1965,7 +1973,7 @@ impl<Env: Environment> ChainClient<Env> {
19651973

19661974
/// Obtains the basic `ChainInfo` data for the local chain, with chain manager values.
19671975
#[instrument(level = "trace")]
1968-
async fn chain_info_with_manager_values(&self) -> Result<Box<ChainInfo>, LocalNodeError> {
1976+
pub async fn chain_info_with_manager_values(&self) -> Result<Box<ChainInfo>, LocalNodeError> {
19691977
let query = ChainInfoQuery::new(self.chain_id)
19701978
.with_manager_values()
19711979
.with_committees();

linera-service/src/cli/command.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ pub enum ClientCommand {
350350
QueryValidators {
351351
/// The chain to query. If omitted, query the default chain of the wallet.
352352
chain_id: Option<ChainId>,
353+
/// Skip validators with less voting weight that this.
354+
min_votes: Option<u64>,
353355
},
354356

355357
/// Synchronizes a validator with the local state of chains.

linera-service/src/cli/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,10 @@ impl Runnable for Job {
452452
}
453453
}
454454

455-
QueryValidators { chain_id } => {
455+
QueryValidators {
456+
chain_id,
457+
min_votes,
458+
} => {
456459
let mut context =
457460
options.create_client_context(storage, wallet, signer.into_value());
458461
let chain_id = chain_id.unwrap_or_else(|| context.default_chain());
@@ -470,6 +473,9 @@ impl Runnable for Job {
470473
let node_provider = context.make_node_provider();
471474
let mut validator_results = Vec::new();
472475
for (name, state) in committee.validators() {
476+
if min_votes.is_some_and(|votes| state.votes < votes) {
477+
continue; // Skip validator with little voting weight.
478+
}
473479
let address = &state.network_address;
474480
let node = node_provider.make_node(address)?;
475481
let results = context

0 commit comments

Comments
 (0)