Skip to content

Commit

Permalink
Forge a confirmed root before halting for RPC inspection (#10061)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1da1667)

# Conflicts:
#	core/src/commitment.rs
  • Loading branch information
mvines authored and mergify-bot committed May 15, 2020
1 parent 1163144 commit 2464a79
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/src/commitment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ impl BlockCommitmentCache {
}

#[cfg(test)]
<<<<<<< HEAD
=======
pub fn new_for_tests_with_blockstore_bank(
blockstore: Arc<Blockstore>,
bank: Arc<Bank>,
root: Slot,
) -> Self {
let mut block_commitment: HashMap<Slot, BlockCommitment> = HashMap::new();
block_commitment.insert(0, BlockCommitment::default());
Self {
block_commitment,
blockstore,
total_stake: 42,
largest_confirmed_root: root,
bank,
root,
}
}

>>>>>>> 1da166792... Forge a confirmed root before halting for RPC inspection (#10061)
pub(crate) fn set_get_largest_confirmed_root(&mut self, root: Slot) {
self.largest_confirmed_root = root;
}
Expand Down
7 changes: 7 additions & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2464a79

Please sign in to comment.