Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] snapshot bank fields protection #8185

Closed

Conversation

ryoqun
Copy link
Member

@ryoqun ryoqun commented Feb 10, 2020

Problem

struct Bank fields aren't protected when loaded from snapshots.

For example, some fields like capitalization is only used at the epoch boundary. So, unless we cover the integrity check for those fields at snapshot restore, victim validator could divert from the cluster at the next epoch a lot later even if they did SPV when restoring from a third-party snapshot.

Summary of Changes

Introduce BankConfig which is hashed into the slot hash and SPV-ed (ref: #6936).
And make child bank's all state be derived only from it.

This PR still is a draft; I may be wrong. :)

I want to gather feedback about my understanding for the current situation and above problem/solution making senses and general implementation directions. :)

Part of #7167

@ryoqun ryoqun added the work in progress This isn't quite right yet label Feb 10, 2020
@ryoqun ryoqun added the noCI Suppress CI on this Pull Request label Feb 10, 2020
slot,
epoch,
blockhash_queue: RwLock::new(parent.blockhash_queue.read().unwrap().clone()),

// TODO: clean this up, soo much special-case copying...
Copy link
Member Author

Choose a reason for hiding this comment

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

Phew, this initialization code block holds quite a lot fields. ;)

I've examined each fields for BankConfig or not; As this is still a draft, the categorization is rough and some might be wrong.

@ryoqun ryoqun requested a review from mvines February 10, 2020 05:56
self.last_blockhash().as_ref(),
bank_config_buf.as_ref(), // mainly for snapshot
status_cache_hash.as_ref(), // as par #7053
Copy link
Member Author

Choose a reason for hiding this comment

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

ref: #7053

// Its serialized binary is hashed into the `slot_hash` for the slot of a frozen bank.
// So, this struct will be hashed at every slot boundary, so this is preferred to be small
#[derive(Serialize)]
pub struct BankConfig { // or BankState // slot_config
Copy link
Member

Choose a reason for hiding this comment

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

Is the idea then that Bank is no longer serialized into snapshots? Just this new BankConfig struct?

Copy link
Member 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.

@mvines Yeah, ideally, it could be made so for the security separation perspective. However, I don't think that the serialization target change (Bank->BankConfig) is the scope of this PR at the moment. I want to minimize the required work here because of timing pressure. So, I want to just reuse some already-existing snapshot code as is, which is deeply rooted to the Bank while being secured enough (Like accounts db setup).

@t-nelson
Copy link
Contributor

I like the direction! Only the network-wide relevant data is required to be in snapshots. Removing the local-only state should ease verification and security

@stale
Copy link

stale bot commented Feb 18, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Feb 18, 2020
@stale
Copy link

stale bot commented Feb 26, 2020

This stale pull request has been automatically closed. Thank you for your contributions.

@stale stale bot closed this Feb 26, 2020
@ryoqun ryoqun mentioned this pull request Mar 24, 2020
@ryoqun ryoqun reopened this Mar 31, 2020
@stale stale bot removed the stale [bot only] Added to stale content; results in auto-close after a week. label Mar 31, 2020
@stale
Copy link

stale bot commented Apr 7, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Apr 7, 2020
@stale
Copy link

stale bot commented Apr 14, 2020

This stale pull request has been automatically closed. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
noCI Suppress CI on this Pull Request stale [bot only] Added to stale content; results in auto-close after a week. work in progress This isn't quite right yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants