From 97bde994925f66c431e217ccbcfa562c817d11da Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Wed, 23 Oct 2024 15:49:44 +0200 Subject: [PATCH 1/3] Ensure received certificates' messages are delivered. --- linera-core/src/client/mod.rs | 17 +++++++---------- linera-core/src/local_node.rs | 16 ---------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/linera-core/src/client/mod.rs b/linera-core/src/client/mod.rs index 10c2d2aa0cf..561076b4f1b 100644 --- a/linera-core/src/client/mod.rs +++ b/linera-core/src/client/mod.rs @@ -1233,7 +1233,7 @@ where // `advance_with_local` might have drained the whole `block_batch`. // In that case, move to the next chain batch, but remember to wait for // the messages to be delivered to the inboxes. - other_sender_chains.push((chain_id, last_height)); + other_sender_chains.push(chain_id); continue; }; let batch_size = last_height.saturating_sub(first_height).0 + 1; @@ -1396,17 +1396,14 @@ where return; } } - for (chain_id, height) in other_sender_chains { + for chain_id in other_sender_chains { if let Err(error) = self .client .local_node - .wait_for_outgoing_messages(chain_id, height) + .retry_pending_cross_chain_requests(chain_id) .await { - error!( - "Failed trying to wait for outgoing messages from {chain_id} \ - up to {height}: {error}" - ); + error!("Failed trying to wait for outgoing messages from {chain_id}: {error}"); } } // Update tracker. @@ -3287,7 +3284,7 @@ struct ReceivedCertificatesFromValidator { /// The downloaded certificates. The signatures were already checked and they are ready /// to be processed. certificates: Vec, - /// Sender chains that were already up to date locally. We need to wait for their messages - /// to be delivered, at least up to the given block height. - other_sender_chains: Vec<(ChainId, BlockHeight)>, + /// Sender chains that were already up to date locally. We need to ensure their messages + /// are delivered. + other_sender_chains: Vec, } diff --git a/linera-core/src/local_node.rs b/linera-core/src/local_node.rs index 6ebb891d6da..8c28e1d4cb8 100644 --- a/linera-core/src/local_node.rs +++ b/linera-core/src/local_node.rs @@ -333,22 +333,6 @@ where info } - /// Returns only after the outbox of the given chain does not contain any entries up to - /// `height` anymore. - #[tracing::instrument(level = "trace", skip_all)] - pub async fn wait_for_outgoing_messages( - &self, - chain_id: ChainId, - height: BlockHeight, - ) -> Result<(), LocalNodeError> { - // TODO(#2692): Implement this, once #2689 is merged. - warn!( - "Not waiting for outgoing messages from {chain_id:.8} up to height {height}: \ - not implemented yet." - ); - Ok(()) - } - /// Returns a read-only view of the [`ChainStateView`] of a chain referenced by its /// [`ChainId`]. /// From 5cf2e6cebcc837c1dc760367ab3345da47495285 Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Wed, 23 Oct 2024 15:25:16 +0200 Subject: [PATCH 2/3] Remove unnecessary client mutex locking. --- linera-core/src/client/mod.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/linera-core/src/client/mod.rs b/linera-core/src/client/mod.rs index 561076b4f1b..61a47f34d88 100644 --- a/linera-core/src/client/mod.rs +++ b/linera-core/src/client/mod.rs @@ -955,9 +955,6 @@ where ); } if self.state().has_other_owners(&info.manager.ownership) { - let mutex = self.state().client_mutex(); - let _guard = mutex.lock_owned().await; - // For chains with any owner other than ourselves, we could be missing recent // certificates created by other owners. Further synchronize blocks from the network. // This is a best-effort that depends on network conditions. @@ -1403,7 +1400,7 @@ where .retry_pending_cross_chain_requests(chain_id) .await { - error!("Failed trying to wait for outgoing messages from {chain_id}: {error}"); + error!("Failed to retry outgoing messages from {chain_id}: {error}"); } } // Update tracker. @@ -3233,16 +3230,11 @@ where &self, remote_node: RemoteNode, ) -> Result<(), ChainClientError> { - let mutex = self.state().client_mutex(); - let _guard = mutex.lock_owned().await; - let chain_id = self.chain_id; // Proceed to downloading received certificates. let received_certificates = self .synchronize_received_certificates_from_validator(chain_id, &remote_node) .await?; - - drop(_guard); // Process received certificates. If the client state has changed during the // network calls, we should still be fine. self.receive_certificates_from_validator(received_certificates) From 54d4194db4110172fb7a9a27b07e88ad49681a69 Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Wed, 23 Oct 2024 16:09:02 +0200 Subject: [PATCH 3/3] Add a comment: Why are we retrying? --- linera-core/src/client/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linera-core/src/client/mod.rs b/linera-core/src/client/mod.rs index 61a47f34d88..5d63e1e9681 100644 --- a/linera-core/src/client/mod.rs +++ b/linera-core/src/client/mod.rs @@ -1394,6 +1394,9 @@ where } } for chain_id in other_sender_chains { + // Certificates for this chain were omitted from `certificates` because they were + // already processed locally. If they were processed in a concurrent task, it is not + // guaranteed that their cross-chain messages were already handled. if let Err(error) = self .client .local_node