Add a const spec_id and build markers from it - #1974
Closed
leighmcculloch wants to merge 2 commits into
Closed
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Spike. Part of a stack of PRs that must merge in this order:
This PR targets #1965's
handcode-spec-refs-in-derivesbranch, so the diff here is only the spec id changes. Split out of #1970, which now targets this branch because it depends on this change.What
Give every user-defined type that has a spec entry a
spec_id()const fn, the first eight bytes of the SHA256 of that type's own spec entry XDR hashed at const evaluation time, and assemble the spec shaking v2 marker from that id instead of hashing the entry in the proc macro.Why
A marker only matches if it hashes the same bytes the spec entry encodes to in the wasm, and the proc macro cannot always know those bytes, because it sees the tokens of the type it expands and nothing more. #1970 makes that concrete by naming a type with
module_path!(), which no macro can resolve, so a macro-computed hash misses every entry and spec shaking strips the whole spec. Hashing where the entry is built keeps the two in step by construction. Naming the resultspec_id()also gives a spec entry an identifier short enough to be referred to by something other than its full XDR.Known limitations
Hashing at const evaluation needs a const SHA256, which the
sha2crate does not offer, so this addssha2-constas a dependency ofsoroban-sdk.