-
Notifications
You must be signed in to change notification settings - Fork 220
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
v2.0: Supports deserializing accounts lt hash in snapshots (backport of #2994) #3014
Conversation
Cherry-pick of 690fad0 has failed:
To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
523f428
to
adc79cb
Compare
(cherry picked from commit 690fad0) # Conflicts: # accounts-db/src/accounts_hash.rs # runtime/src/serde_snapshot.rs
adc79cb
to
a1975d8
Compare
Rebased to pick up the increased CI timeout from #3017 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
If some future version adds lattice hash to snapshot and some node doesn't have this code, what happens? I thought it would just never get read in but we would otherwise continue to function. I don't understand how that's different from reading/deserializing it and dropping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
runtime/Cargo.toml
Outdated
@@ -46,6 +46,7 @@ regex = { workspace = true } | |||
serde = { workspace = true, features = ["rc"] } | |||
serde_derive = { workspace = true } | |||
serde_json = { workspace = true } | |||
serde_with = { workspace = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we aren't introducing dependencies in backports to what will imminently be stable branch. is this strictly necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dependency is already used in the monorepo, just not in the accounts-db crate. It likely is not strictly necessary. Would it be preferable to do a manual implementation vs use serde_with? I'll code that up and see what it looks like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit 1910669 removes the use of serde_with
.
The code is based on the discussion in serde-rs/serde#1937, and also the code from expanding the original serde_with macros.
I've done additional testing on this commit by creating a snapshot with master that serializes a Some to this new snapshot field, and then ensured this PR can deserialize-and-ignore the field and load from the snapshot successfully.
I think overall I'm more in favor of the version using serde_with, but I do understand the concerns in general of backports adding dependencies.
Then the node will panic during snapshot loading, due to encountering an unexpected field.
We have to be explicit about all fields, even if we intend to ignore them. |
6db1291
6db1291
to
e9ed7a1
Compare
pub [u16; 1024], | ||
); | ||
|
||
impl<'de> Deserialize<'de> for SerdeAccountsLtHash { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yuck. I do not like to review this. @t-nelson thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we aren't willing to review logic, we have no business using a dependency that to hide it from us. especially the case for a backport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case the dependency was already used by runtime, just not by accounts-db, as I understand it. So, yes, we can review it, but it sure feels nicer reviewing the simple thing than this. But, you certainly have a point. The fact we're adding a dependency feels more like a code modularization byproduct than it does a new risk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I review, "serde_as" procedure macro is already being used for packet class, which is u8[1232]. And here we are just using it again in a similar way for u16[1024]. Therefore, I think it should be fine.
Line 93 in 489f483
#[serde_as] |
Also, looking at the source repo for "serde_as", there is already sufficient tests coverage of "serde_as" for the fixed size array case that we used here.
https://github.com/jonasbb/serde_with/blob/f1b79f27cac7545513c4f14f7c295db2b843cc4f/serde_with/tests/serde_as/lib.rs#L321
Here, instead of using "serde_as", we basically implement just deserialize specially for the u16[1024] by hand, which I have reviewed and believe it is correct. And I trust that books has already tested it manually. But as far as the test for this manually written the code goes, the coverage may not be as good as those tests already in the "serde_as" crate. Beside, with "serde_as" we also get the 'serialize' for free.
Therefore, IMHO, I prefer use "serde_as" in this case (less code). But I am fine with the hand implementation too. They don't make much difference.
e9ed7a1
to
1910669
Compare
I'd like to get another v2.0 release out (to get the gossip changes soaking in testnet)... if v2.0.12 doesn't include this change that just means that nodes running v2.0.12 can't load snapshots produces by v2.1, right? And the solution would be upgrading to a later version of v2.0 that does include this change? If those assumptions are correct I'm going to tag a release soon, and this can go in the next release (probably on Friday). |
I haven't pushed any changes into master w.r.t. writing the new field to the snapshot, so v2.0 won't be broken. I won't write the new field in master until this backport PR is merged. So feel free to tag a new release; this PR does not need to hold that process up. Thanks for checking! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
After a discussion on the backport review meeting, it was decided to not backport this PR. It was the combination of how soon v2.0 is going to stable/mnb PLUS not having an approved SIMD for the feature itself PLUS the original backport touching a cargo.lock file. Assuming we continue with ~3 releases per year, timing may work out just fine. We may also investigate putting the accounts lt hash value in a sysvar (or other account) instead of in the snapshot. |
Problem
The accounts lattice hash will be serialized to/deserialized from snapshots. In order to maintain snapshot compatibility between adjacent versions (edge <-> beta, and beta <-> stable), we must be able to deserialize (and ignore) the new field in adjacent version before we serialize the new field into snapshots.
Summary of Changes
Add support for deserializing the accounts lt hash in snapshots.
Note, the field is ignored (if present) for now.
Note 2, this PR will be backported to v2.0.
Justification to Backport
We're adding a new field to the snapshot. We also must guarantee that snapshots can be read by adjacent versions (e.g. a snapshot created by v2.1 must be loadable by v2.0). In order to maintain compatibility, v2.0 must be able to read this new field (and ignore it). v2.1 will be the first version to write to this new field.
This is an automatic backport of pull request #2994 done by [Mergify](https://mergify.com).