From b27edf3ef9abab81504fda6ea73b970ed6f60a10 Mon Sep 17 00:00:00 2001 From: Andre da Silva Date: Sat, 16 Nov 2024 12:58:54 -0300 Subject: [PATCH] Clear the pending block if the local node rejected the proposal --- linera-core/src/client/mod.rs | 10 +++++++++- linera-core/src/unit_tests/client_tests.rs | 2 -- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/linera-core/src/client/mod.rs b/linera-core/src/client/mod.rs index dae3dcc1c45c..ef8ae82a4982 100644 --- a/linera-core/src/client/mod.rs +++ b/linera-core/src/client/mod.rs @@ -2550,7 +2550,15 @@ where )); }; if manager.can_propose(&identity, round) { - let certificate = self.propose_block(block.clone(), round, manager).await?; + let result = self.propose_block(block.clone(), round, manager).await; + if self.state().pending_block().as_ref() == Some(&block) { + if let Err(ChainClientError::LocalNodeError(_)) = result { + // If we just tried to propose the pending block, and the local node rejected + // the proposal, clear the pending block since we don't want to retry in this case. + self.clear_pending_block(); + } + } + let certificate = result?; Ok(ClientOutcome::Committed(Some(certificate))) } else { // TODO(#1424): Local timeout might not match validators' exactly. diff --git a/linera-core/src/unit_tests/client_tests.rs b/linera-core/src/unit_tests/client_tests.rs index c21440789056..4ac83bd809aa 100644 --- a/linera-core/src/unit_tests/client_tests.rs +++ b/linera-core/src/unit_tests/client_tests.rs @@ -2474,8 +2474,6 @@ where LocalNodeError::WorkerError(WorkerError::ChainError(chain_error)) )) if matches!(*chain_error, ChainError::BlockProposalTooLarge) ); - // TODO(#2906): Remove this once the client properly clears the pending block. - client1.clear_pending_block(); let result = client1.publish_data_blob(large_blob_bytes).await; assert_matches!(