Skip to content

Commit 0d1bdd1

Browse files
authored
[testnet] Show locked; filter by weight; fetch all missing senders. (#4751)
Backport of #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 released in a new SDK. ## Links - PR to main: #4764 - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent b5ddc0b commit 0d1bdd1

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
@@ -453,11 +453,12 @@ Show the version and genesis config hash of a new validator, and print a warning
453453

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

456-
**Usage:** `linera query-validators [CHAIN_ID]`
456+
**Usage:** `linera query-validators [CHAIN_ID] [MIN_VOTES]`
457457

458458
###### **Arguments:**
459459

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

462463

463464

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},
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
}
@@ -673,7 +691,7 @@ impl<Env: Environment, W: Persist<Target = Wallet>> ClientContext<Env, W> {
673691
node: &impl ValidatorNode,
674692
chain_id: ChainId,
675693
) -> Result<ChainInfo, Error> {
676-
let query = ChainInfoQuery::new(chain_id);
694+
let query = ChainInfoQuery::new(chain_id).with_manager_values();
677695
match node.handle_chain_info_query(query).await {
678696
Ok(response) => {
679697
debug!(
@@ -738,7 +756,7 @@ impl<Env: Environment, W: Persist<Target = Wallet>> ClientContext<Env, W> {
738756
.genesis_config_hash);
739757
let chain_info = self
740758
.make_chain_client(chain_id)
741-
.chain_info()
759+
.chain_info_with_manager_values()
742760
.await
743761
.map(|info| *info)
744762
.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
@@ -1014,6 +1014,12 @@ impl<Env: Environment> Client<Env> {
10141014
}
10151015
}
10161016

1017+
if certificates.is_empty() {
1018+
self.local_node
1019+
.retry_pending_cross_chain_requests(sender_chain_id)
1020+
.await?;
1021+
}
1022+
10171023
// Process certificates in ascending block height order (BTreeMap keeps them sorted).
10181024
for certificate in certificates.into_values() {
10191025
self.receive_sender_certificate(
@@ -1225,7 +1231,7 @@ impl<Env: Environment> Client<Env> {
12251231
}
12261232
}
12271233
}
1228-
if let LocalNodeError::WorkerError(WorkerError::ChainError(chain_err)) = &err {
1234+
while let LocalNodeError::WorkerError(WorkerError::ChainError(chain_err)) = &err {
12291235
if let ChainError::MissingCrossChainUpdate {
12301236
chain_id,
12311237
origin,
@@ -1247,8 +1253,10 @@ impl<Env: Environment> Client<Env> {
12471253
{
12481254
err = new_err;
12491255
} else {
1250-
continue;
1256+
continue 'proposal_loop;
12511257
}
1258+
} else {
1259+
break;
12521260
}
12531261
}
12541262

@@ -1840,7 +1848,7 @@ impl<Env: Environment> ChainClient<Env> {
18401848

18411849
/// Obtains the basic `ChainInfo` data for the local chain, with chain manager values.
18421850
#[instrument(level = "trace")]
1843-
async fn chain_info_with_manager_values(&self) -> Result<Box<ChainInfo>, LocalNodeError> {
1851+
pub async fn chain_info_with_manager_values(&self) -> Result<Box<ChainInfo>, LocalNodeError> {
18441852
let query = ChainInfoQuery::new(self.chain_id)
18451853
.with_manager_values()
18461854
.with_committees();

linera-service/src/cli/command.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ pub enum ClientCommand {
343343
QueryValidators {
344344
/// The chain to query. If omitted, query the default chain of the wallet.
345345
chain_id: Option<ChainId>,
346+
/// Skip validators with less voting weight that this.
347+
min_votes: Option<u64>,
346348
},
347349

348350
/// 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
@@ -505,7 +505,10 @@ impl Runnable for Job {
505505
}
506506
}
507507

508-
QueryValidators { chain_id } => {
508+
QueryValidators {
509+
chain_id,
510+
min_votes,
511+
} => {
509512
let mut context = ClientContext::new(
510513
storage,
511514
options.context_options.clone(),
@@ -527,6 +530,9 @@ impl Runnable for Job {
527530
let node_provider = context.make_node_provider();
528531
let mut validator_results = Vec::new();
529532
for (name, state) in committee.validators() {
533+
if min_votes.is_some_and(|votes| state.votes < votes) {
534+
continue; // Skip validator with little voting weight.
535+
}
530536
let address = &state.network_address;
531537
let node = node_provider.make_node(address)?;
532538
let results = context

0 commit comments

Comments
 (0)