Skip to content

Commit 03173c1

Browse files
authored
Remove receive_certificate_and_update_validators; fix flaky test. (#4805)
## Motivation `test_memory_cross_chain_message` is flaky; `receive_certificate_and_update_validators` sometimes fails. But this method is not expected to work anymore since sender chains are now sparse and it tries to get the local chain info for the sender chain. Also, it is used only in tests. ## Proposal Remove it. Use `synchronize_from_validators` or `synchronize_chain_state` instead. ## Test Plan CI ## Release Plan - These changes should be backported to `testnet_conway`. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent fedf71f commit 03173c1

File tree

4 files changed

+68
-202
lines changed

4 files changed

+68
-202
lines changed

linera-core/benches/client_benchmarks.rs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,39 +54,30 @@ pub async fn run_claim_bench<B>(
5454
let amt = Amount::ONE;
5555

5656
let account = Account::new(chain2.chain_id(), owner1);
57-
let cert = chain1
57+
chain1
5858
.transfer_to_account(AccountOwner::CHAIN, amt, account)
5959
.await
6060
.unwrap()
6161
.unwrap();
6262

63-
chain2
64-
.receive_certificate_and_update_validators(cert)
65-
.await
66-
.unwrap();
63+
chain2.synchronize_from_validators().await.unwrap();
6764
chain2.process_inbox().await.unwrap();
6865
assert_eq!(
6966
chain1.local_balance().await.unwrap(),
7067
Amount::from_tokens(9)
7168
);
7269

7370
let account = Account::chain(chain1.chain_id());
74-
let cert = chain1
71+
chain1
7572
.claim(owner1, chain2.chain_id(), account, amt)
7673
.await
7774
.unwrap()
7875
.unwrap();
7976

80-
chain2
81-
.receive_certificate_and_update_validators(cert)
82-
.await
83-
.unwrap();
84-
let cert = chain2.process_inbox().await.unwrap().0.pop().unwrap();
77+
chain2.synchronize_from_validators().await.unwrap();
78+
chain2.process_inbox().await.unwrap().0.pop().unwrap();
8579

86-
chain1
87-
.receive_certificate_and_update_validators(cert)
88-
.await
89-
.unwrap();
80+
chain1.synchronize_from_validators().await.unwrap();
9081
chain1.process_inbox().await.unwrap();
9182
assert_eq!(
9283
chain1.local_balance().await.unwrap(),

linera-core/src/client/mod.rs

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ impl<Env: Environment> Client<Env> {
621621
let certificate = self
622622
.communicate_chain_action(committee, finalize_action, hashed_value)
623623
.await?;
624-
self.receive_certificate(certificate.clone(), ReceiveCertificateMode::AlreadyChecked)
624+
self.receive_certificate_with_checked_signatures(certificate.clone())
625625
.await?;
626626
Ok(certificate)
627627
}
@@ -735,51 +735,16 @@ impl<Env: Environment> Client<Env> {
735735
Ok(certificate)
736736
}
737737

738-
/// Processes the confirmed block certificate and its ancestors in the local node, then
739-
/// updates the validators up to that certificate.
738+
/// Processes the confirmed block certificate in the local node without checking signatures.
739+
/// Also downloads and processes all ancestors that are still missing.
740740
#[instrument(level = "trace", skip_all)]
741-
async fn receive_certificate_and_update_validators(
741+
async fn receive_certificate_with_checked_signatures(
742742
&self,
743743
certificate: ConfirmedBlockCertificate,
744-
mode: ReceiveCertificateMode,
745-
) -> Result<(), ChainClientError> {
746-
let block_chain_id = certificate.block().header.chain_id;
747-
let block_height = certificate.block().header.height;
748-
749-
self.receive_certificate(certificate, mode).await?;
750-
751-
// Make sure a quorum of validators (according to the chain's new committee) are up-to-date
752-
// for data availability.
753-
let local_committee = self
754-
.chain_info_with_committees(block_chain_id)
755-
.await?
756-
.into_current_committee()?;
757-
self.communicate_chain_updates(
758-
&local_committee,
759-
block_chain_id,
760-
block_height.try_add_one()?,
761-
CrossChainMessageDelivery::Blocking,
762-
)
763-
.await?;
764-
Ok(())
765-
}
766-
767-
/// Processes the confirmed block certificate in the local node. Also downloads and processes
768-
/// all ancestors that are still missing.
769-
#[instrument(level = "trace", skip_all)]
770-
async fn receive_certificate(
771-
&self,
772-
certificate: ConfirmedBlockCertificate,
773-
mode: ReceiveCertificateMode,
774744
) -> Result<(), ChainClientError> {
775745
let certificate = Box::new(certificate);
776746
let block = certificate.block();
777747

778-
// Verify the certificate before doing any expensive networking.
779-
let (max_epoch, committees) = self.admin_committees().await?;
780-
if let ReceiveCertificateMode::NeedsCheck = mode {
781-
Self::check_certificate(max_epoch, &committees, &certificate)?.into_result()?;
782-
}
783748
// Recover history from the network.
784749
self.download_certificates(block.header.chain_id, block.header.height)
785750
.await?;
@@ -3405,24 +3370,6 @@ impl<Env: Environment> ChainClient<Env> {
34053370
self.update_state(|state| state.clear_pending_proposal());
34063371
}
34073372

3408-
/// Processes a confirmed block for which this chain is a recipient and updates validators.
3409-
#[instrument(
3410-
level = "trace",
3411-
skip(certificate),
3412-
fields(certificate_hash = ?certificate.hash()),
3413-
)]
3414-
pub async fn receive_certificate_and_update_validators(
3415-
&self,
3416-
certificate: ConfirmedBlockCertificate,
3417-
) -> Result<(), ChainClientError> {
3418-
self.client
3419-
.receive_certificate_and_update_validators(
3420-
certificate,
3421-
ReceiveCertificateMode::NeedsCheck,
3422-
)
3423-
.await
3424-
}
3425-
34263373
/// Rotates the key of the chain.
34273374
///
34283375
/// Replaces current owners of the chain with the new key pair.

0 commit comments

Comments
 (0)