Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Verify frozen bank from snapshot by hashing#8184

Merged
ryoqun merged 1 commit intosolana-labs:masterfrom
ryoqun:verify-frozen-bank
Feb 11, 2020
Merged

Verify frozen bank from snapshot by hashing#8184
ryoqun merged 1 commit intosolana-labs:masterfrom
ryoqun:verify-frozen-bank

Conversation

@ryoqun
Copy link
Copy Markdown
Contributor

@ryoqun ryoqun commented Feb 10, 2020

Problem

The actually recorded frozen hash of the bank in a snapshot isn't verified. It seems that it's lacking simply because of unintentional omission like #7559.

Summary of Changes

Just start to verify it.

Also, this is the base of the upcoming PR of more exhaustive protection for various bank fields. Currently, there are numerous unprotected fields, which could result in accepting tampered snapshot with unpredictable future behavior.

Part of #7167

@ryoqun ryoqun requested a review from sakridge February 10, 2020 04:09
Comment thread runtime/src/bank.rs
let calculated_hash = self.hash_internal_state();
let expected_hash = self.hash();

if calculated_hash == expected_hash {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm being conservative here. I'm ballooning calculated_hash == expected_hash into a complete if now a days hard to debug hash mismatch errors are common. ;)

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 10, 2020

Codecov Report

Merging #8184 into master will increase coverage by <.1%.
The diff coverage is 100%.

@@           Coverage Diff            @@
##           master   #8184     +/-   ##
========================================
+ Coverage    81.3%   81.3%   +<.1%     
========================================
  Files         251     251             
  Lines       53962   53986     +24     
========================================
+ Hits        43876   43903     +27     
+ Misses      10086   10083      -3

sakridge
sakridge previously approved these changes Feb 10, 2020
Copy link
Copy Markdown
Contributor

@sakridge sakridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks

@ryoqun ryoqun force-pushed the verify-frozen-bank branch from 089f3e7 to 1fe6a90 Compare February 11, 2020 06:29
@mergify mergify Bot dismissed sakridge’s stale review February 11, 2020 06:29

Pull request has been modified.

Comment thread runtime/src/bank.rs
#[must_use]
fn verify_hash(&self) -> bool {
assert!(self.is_frozen());
let calculated_hash = self.hash_internal_state();
Copy link
Copy Markdown
Contributor Author

@ryoqun ryoqun Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the record: I'm little concerned about the verification failure for the restarted (hard-forked) cluster, but it should not be a problem because the renewed hard_fork information itself should be included in the bank of updated snapshot. Current ops doesn't use solana-validator's --hard-fork.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solana-validator's --hard-fork is only there for a validator that never wants to consume a snapshot, for example a node that wants to archive the entire ledger to long-term storage for posterity.

Copy link
Copy Markdown
Contributor Author

@ryoqun ryoqun Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Then, necessitated manual restarts (with command argument adjustment) for the hard-fork should be acceptable for such a scenario. Thanks for clarification!

@ryoqun ryoqun merged commit 7614af2 into solana-labs:master Feb 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants