-
Notifications
You must be signed in to change notification settings - Fork 645
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
feat: protocol schema check #11749
feat: protocol schema check #11749
Conversation
abdeea3
to
8bb952f
Compare
Run `cargo update` for couple crates, allowing syn to bump to `2.0.70`. Not sure if it is necessary, but cargo did it automatically for #11749.
@nagisa now I'm a bit more serious about implementation, added readme, ensured that |
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.
Overall the direction looks good to me, I identified a potential source of your hash instability. But I don't see anything fundamentally wrong that I'd object to, and the implementation seems pretty close to being ready to land.
9a5ddfe
to
14b60d0
Compare
e1157d1
to
bd0d638
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #11749 +/- ##
==========================================
- Coverage 71.81% 71.77% -0.04%
==========================================
Files 792 796 +4
Lines 162765 162922 +157
Branches 162765 162922 +157
==========================================
+ Hits 116884 116943 +59
- Misses 40831 40921 +90
- Partials 5050 5058 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Should pass the clippy and udeps checks now. Also hashing TypeIds looks unstable as well. When I run it on mac and linux, hashes are different. Should I find some stable way to replace type ids with their equivalency classes and manually assign type ids to some primitive types? (integers, strings, vectors...) |
895e6d7
to
169eab2
Compare
Hashes being different between different targets is unsurprising to me. In fact, Rust can only give a guarantee that they stay the same between compilations if the exact same code is compiled with the exact same compiler version. Easy way out is to have your snapshot be per-platform and test on both platforms in CI. Or not and only support running this tool on |
Addressed new suggestions. I computed hashes on two different linux machines and still got mismatch for all structs though.
Maybe I should use TypeId only for finding the right child structs to compute hash recursively? UPD: Actually they had different nightly versions. When I upgraded nightly to 1.81, it stabilized everywhere except ValidatorKickoutReason. Maybe this is something specific about enums. UPD 2: falling back to type names only. |
For all structs with derived
ProtocolStruct
,ProtocolStructInfo
is created which defines a schema by underlying field names.All
ProtocolStructInfo
creations are registered byinventory
crate.Script uses
compute_hash
to recursively compute hash of protocol struct, which should stay the same if borsh-serialization format didn't change.Run:
cargo +nightly run -p protocol-schema-check
Checked on
cargo build -p near-primitives
that only 2 more crates are introduced which are near empty.Hashes are expected to stay stable now.