From 859d4db87e376d71bec97cbda145c446c858d83a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 15 May 2020 14:36:54 -0700 Subject: [PATCH] validator: Forge a confirmed root before halting for RPC inspection (bp #10061) (#10066) * Forge a confirmed root before halting for RPC inspection (#10061) (cherry picked from commit 1da16679203c55ba4b1d9eea0c566db69f948f1a) # Conflicts: # core/src/commitment.rs * Update commitment.rs Co-authored-by: Michael Vines --- core/src/commitment.rs | 1 - core/src/validator.rs | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/commitment.rs b/core/src/commitment.rs index ea1bdf463c..2f945d51c6 100644 --- a/core/src/commitment.rs +++ b/core/src/commitment.rs @@ -162,7 +162,6 @@ impl BlockCommitmentCache { } } - #[cfg(test)] pub(crate) fn set_get_largest_confirmed_root(&mut self, root: Slot) { self.largest_confirmed_root = root; } diff --git a/core/src/validator.rs b/core/src/validator.rs index f669f23aa4..9bb2177559 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -314,6 +314,13 @@ impl Validator { ); if config.dev_halt_at_slot.is_some() { + // Simulate a confirmed root to avoid RPC errors with CommitmentmentConfig::max() and + // to ensure RPC endpoints like getConfirmedBlock, which require a confirmed root, work + block_commitment_cache + .write() + .unwrap() + .set_get_largest_confirmed_root(bank_forks.read().unwrap().root()); + // Park with the RPC service running, ready for inspection! warn!("Validator halted"); std::thread::park();