-
Notifications
You must be signed in to change notification settings - Fork 154
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
Type safety bugfixes #3934
Merged
Merged
Type safety bugfixes #3934
Conversation
This file contains 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
lehins
force-pushed
the
lehins/safety-bugfixes
branch
3 times, most recently
from
December 18, 2023 02:56
7796d19
to
8d20337
Compare
teodanciu
reviewed
Dec 18, 2023
libs/cardano-ledger-binary/src/Cardano/Ledger/Binary/Decoding/Decoder.hs
Outdated
Show resolved
Hide resolved
teodanciu
approved these changes
Dec 18, 2023
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.
Looks good to me
lehins
force-pushed
the
lehins/safety-bugfixes
branch
from
December 18, 2023 18:43
8d20337
to
ac6352e
Compare
* `decodeVMap` previously mistakenly allowed duplicates, because it used pre-Conway semantics for decoding Maps. It is safe to switch it without a protocol version bump, because `VMap` is currently not used for any type that is stored on-chain. We only use it for some of the fields in the ledger state, which is guaranteed to not have duplicates * Switch from checking membership of elemens in the data structure, which can be at the very least O(log n) complexity to checking the size of the final data structure and comparing to the number of elements that was decoded. If there were duplicates the size will not match the number of elements that was decoded * Improve performance of `Set` and `Map` decoding
Fix a bug introduced in #3893
Fix a bug introduced in #3893
Fix a bug introduced in #3893
lehins
force-pushed
the
lehins/safety-bugfixes
branch
from
December 18, 2023 18:51
ac6352e
to
38d275c
Compare
teodanciu
reviewed
Dec 19, 2023
-- `Map`, where keys are hashes of the values encoded on the wire. The final size of the | ||
-- data strucutre taht isreturned will be used to enforce the invariant of a Set, that | ||
-- the number of elements decoded matches the final size of the Set, thus ensuring no | ||
-- duplicates were encountered. |
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.
That's an awesome explanation, thank you!
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.
Description
#3893 exported a bunch of constructors that it shouldn't have
This PR fixes that.
Besides that there are two more fixes:
Word64
decodeVMap
did not enforce no duplicate. Which is safe to fix without a hard fork, because that type is not used for the on-chain dataChecklist
.cabal
andCHANGELOG.md
files according to theversioning process.
.cabal
files for all affected packages are updated. If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)CHANGELOG.md
for the affected packages. New section is never added with the code changes. (See RELEASING.md)fourmolu
(usescripts/fourmolize.sh
)scripts/cabal-format.sh
)hie.yaml
has been updated (usescripts/gen-hie.sh
)