Convert Banks#9033
Conversation
| BankVersions::Bank1_0(deserialize_from_snapshot(stream.by_ref())?) | ||
| } | ||
| SNAPSHOT_VERSION_1_1 => { | ||
| BankVersions::Bank1_1(deserialize_from_snapshot(stream.by_ref())?) |
There was a problem hiding this comment.
@mvines, @sakridge, I ran ledger-tool verify on an old 1.0 snapshot and this works fine.
At first I was like great, the change works!
But on second thought, isn't this a vulnerability? I fundamentally changed a field in the bank that's used by many parts of the system, and the snapshot hash still verified fine...
There was a problem hiding this comment.
We don't require the Bank struct be immutable. There could exist another Solana implementation written in bash that produces the same snapshot hash as the current mostly-Rust implementation
There was a problem hiding this comment.
Seems like critical fields in the bank that should be verified(please check if any are missing!)
parent_hashhard_forkstransaction_counttick_heightsignature_countcapitalizationmax_tick_heighthashes_per_tickticks_per_slotns_per_slotgenesis_creation_timeslots_per_yearslots_per_segmentslotepochblock_heightcollector_idcollector_feesfee_calculatorfee_rate_governorcollected_rentrent_collectorepoch_scheduleinflationstakesstorage_accountsepoch_stakesis_deltamessage_processor
There was a problem hiding this comment.
@mvines seems like I could just replace a stake account, or a epoch stakes account, or inflation/rent in the bank, and it would affect this node's view of consensus
There was a problem hiding this comment.
That would cause a bank hash mismatch
There was a problem hiding this comment.
Speed is not a reason to not do it, the whole serialized size of the bank is 200KB, that should take about 500us to hash with sha-2. We are already spending 100s of ms to hash the account states.
There was a problem hiding this comment.
We can, and we'll probably need one of these painful snapshot/Bank adaption PRs every time we do so.
There was a problem hiding this comment.
That, or you re-compute these values from the account state which is hashed. That seems like more work to me.
There was a problem hiding this comment.
hehe I'm just saying that I'm pretty sure that all of the 29 Bank fields that Carl listed above do not all need be included in the bank hash.
There was a problem hiding this comment.
That's part of #7167 and on @ryoqun 's radar. Part of why we are using the flags to get verified snapshots from only trusted nodes.
@carllin FYI: As @sakridge said, this is the wip-stale-closed PR for the exact thing of this discussion: #8185. I'm steadily approaching to it. There are still other bunch of security issues in the snapshot to tackle first, though. ;)
|
|
||
| pub enum BankVersions { | ||
| Bank1_0(Bank1_0), | ||
| Bank1_1(Bank), |
There was a problem hiding this comment.
Bank1_1 we can just call Current, and it only gets a version when it's an older bank that we care about
|
|
||
| pub const SNAPSHOT_VERSION: &str = "1.0.0"; | ||
| pub const SNAPSHOT_VERSION_1_0: &str = "1.0.0"; | ||
| pub const SNAPSHOT_VERSION_1_1: &str = "1.1.0"; |
There was a problem hiding this comment.
This can just be SNAPSHOT_VERSION ("Current" is the default, only name the legacy versions)
Codecov Report
@@ Coverage Diff @@
## v1.0 #9033 +/- ##
=======================================
- Coverage 80.4% 80.3% -0.1%
=======================================
Files 263 265 +2
Lines 57363 57553 +190
=======================================
+ Hits 46126 46228 +102
- Misses 11237 11325 +88 |
3fb7776 to
0bbc048
Compare
mvines
left a comment
There was a problem hiding this comment.
The runtime/src/bank.rs → runtime/src/bank/mod.rs rename seems unnecessary but I'm not strongly opposed.
Let's wait until 1.0.9 ships before landing this in v1.0 though please. I didn't review runtime/src/epoch_stakes.rs, I assume that's been covered in the other PR for master
3900a53 to
225a6d1
Compare
|
@mvines Green! |
mvines
left a comment
There was a problem hiding this comment.
Thanks, this looks good! I'm 👎 this PR until we ship v1.0.10 this evening. I'd like to get this in v1.0.11 instead
mvines
left a comment
There was a problem hiding this comment.
1.0.10 has shipped, all clear
Problem
Old bank structure is incompatible with changes to bank implemented here: #8958
Summary of Changes
With 1 + 2, when validators all upgrade to 1.1, only 1.1 snapshots should be present in the system and we can throw away this code.
Note that with this change, any validators that don't upgrade to this change will be unable to process the new 1.1 snapshots.
Fixes #