-
Notifications
You must be signed in to change notification settings - Fork 217
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
Fix weeder 2.x config and remove weeds #2765
Conversation
79ed59d
to
6d765f1
Compare
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.
👍 My, that's a lot of changes (skimmed them)
, ("{\"transaction\": 1020344, \"passphase\": \"Secure Passphrase\"}", "Error in $.transaction: parsing 'Base64 ByteString failed, expected String, but encountered Number") | ||
, ("{\"transaction\": { \"body\": 1020344 }, \"passphase\": \"Secure Passphrase\"}", "Error in $.transaction: parsing 'Base64 ByteString failed, expected String, but encountered Object") | ||
, ("{\"transaction\": \"lah\", \"passphrase\": \"Secure Passphrase\"}", "Error in $.transaction: Parse error. Expecting Base64-encoded format.") | ||
, ("{\"transaction\": 1020344, \"passphrase\": \"Secure Passphrase\"}", "Error in $.transaction: parsing 'Base64 ByteString failed, expected String, but encountered Number") |
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 mis-spelling wasn't intentional?
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.
It was a mistake - found when changing to strictRecordTypeOptions.
-- some non-trivial changes. Not fixing this right now is also a | ||
-- possibility. | ||
, parentHeaderHash = W.Hash "parentHeaderHash - unused in Shelley" | ||
, parentHeaderHash = W.Hash "" |
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.
Removing parentHeaderHash
would be nice, but is this "parentHeaderHash - unused in Shelley"
to ""
change safe? It couldn't affect compatibility with existing DBs somehow?
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.
No, I think we only do logic with the BlockHeader after converting it to a Point CardanoBlock
, so this should be fine.
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.
I tried removing parentHeaderHash
but then found that it is sort of used in Cardano.Wallet.restoreBlocks
!
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.
Ah!
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.
Perhaps you could try removing parentHeaderHash? To keep DB compatibility, just leave the field there, but don't use it.
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.
I suspect it might make sense to do with/after #2750 if we can replace BlockHeader
with Point CardanoBlock
and be able to persist the Origin point in a nicer way. Currently I think rollbacks to Origin
might break:
G 0 1 <-- Wallet has checkpoints at genesis, slot 0 and slot 1
Node asks wallet to rollback to G
Wallet believes genesis has slotNo 0:
G 0
Node asks wallet to re-apply block in slot 0:
G 0 0 <- Wrong!
Although...
- This invariant is nice to have, particularly as we lack great chain-following testing
https://github.com/input-output-hk/cardano-wallet/blob/8d1b692fec0c77e488a724dba97c9fa51ab9f4e5/lib/core/src/Cardano/Wallet.hs#L888-L893 - I am a bit concerned about how to handle backward compatibility regarding how
Origin
is encoded https://github.com/input-output-hk/cardano-wallet/blob/914668d4e40db6a0b999869c4c4f5222fa6884d0/lib/shelley/src/Cardano/Wallet/Shelley/Compatibility.hs#L392-L398
2766: Misc dev env fixes r=rvl a=rvl ### Issue Number Found while working on #2765. ### Overview This is a mixed bag of small tweaks. - ~Adds `.dir-locals.el` with conservative presets for Emacs users.~ - Add tracing of job names to Hydra evaluation (thanks for the tip @hamishmack) - Delete some unneeded code in `shell.nix` (thanks for the tip @jbgi @nrdxp) - Change `scripts/gen-hie.sh` to make symlinks if `hie.yaml` and `.ghci` don't exist. - `.gitignore` and `.editorconfig` tweaks. Co-authored-by: Rodney Lorrimar <[email protected]>
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.
Hi @rvl.
It's good to see all these weeds removed!
However, I think this PR also does a couple of other things:
- Makes some behavioural changes to tests
- Renames some functions
These behavioural changes are bundled together into a single commit with the weeding changes.
Request: Would it be possible to move the behavioural changes (and function renamings) into a separate PR?
This would make it easier to give these non-weeding changes the scrutiny they deserve, I think.
Example of a function renaming:
- shrinkCoinSmall :: Coin -> [Coin]
- shrinkCoinSmall (Coin c) = Coin <$> shrink c
+ shrinkCoin :: Coin -> [Coin]
+ shrinkCoin (Coin c) = Coin <$> shrink c
Example of a behavioural change:
instance Arbitrary Coin where
arbitrary = genCoinSmallPositive
- shrink = shrinkCoinSmallPositive
+ shrink = shrinkCoin
- Before: The shrinker was limited to positive, non-zero values.
- After: The shrinker can now produce zero values.
It might be the case that generating zero values is fine here. But I think we should make sure, just in case. And there are other similar changes like this, within a relatively large commit that otherwise just deletes weeds.
It would be great if we could move these changes into a separate PR and give them a good review of their own!
541b31b
to
4aeb220
Compare
OK done @jonathanknowles - here is your PR: #2768. |
lib/core/test/unit/Cardano/Wallet/Primitive/Types/TokenMapSpec.hs
Outdated
Show resolved
Hide resolved
return (Nothing, UTxO utxo) | ||
| otherwise = do | ||
ix <- randomRIO (0, toEnum (Map.size utxo - 1)) | ||
return (Just $ Map.elemAt ix utxo, UTxO $ Map.deleteAt ix utxo) |
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.
Ah yes! This is a vestige of the old coin selection algorithm. :)
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.
The shrinker for `Arbitrary TokenQuantity` should allow zero values. See: #2765 (review)
The shrinker for `Arbitrary TokenQuantity` should allow zero values. See: #2765 (review)
83e51d5
to
cb2c01d
Compare
bors r+ |
2765: Fix weeder 2.x config and remove weeds r=rvl a=rvl ### Issue Number This could fix #2695, I really hope it does. ### Overview I was looking into #2695, running `weeder` locally to see what it could be doing. But it turns out that Weeder has been doing nothing at all since upgrading `weeder` to 2.1.3, which happened when we upgraded to ghc-8.10.4. It needed to have a ghc option added to generate `.hie` files, which I didn't set before. If Weeder can't find `.hie` files, it just reports zero weeds (ocharles/weeder#19). So I have: 1. Fixed the Weeder config for Stack and Cabal. 2. Removed weeds which would have been introduced while weeder wasn't working. 3. Removed weeds found by Weeder 2.x, which were never found by Weeder 1.0.9. ### Comments ``` 49 files changed, 109 insertions(+), 1681 deletions(-) ``` Co-authored-by: Rodney Lorrimar <[email protected]> Co-authored-by: Jonathan Knowles <[email protected]>
Build failed:
#expected - wrong weeder build used |
Makes the function definition clearer as well.
The shrinker for `Arbitrary TokenQuantity` should allow zero values. See: #2765 (review)
bors r+ |
Build succeeded: |
Issue Number
This could fix #2695, I really hope it does.
Overview
I was looking into #2695, running
weeder
locally to see what it could be doing.But it turns out that Weeder has been doing nothing at all since upgrading
weeder
to 2.1.3, which happened when we upgraded to ghc-8.10.4.It needed to have a ghc option added to generate
.hie
files, which I didn't set before. If Weeder can't find.hie
files, it just reports zero weeds (ocharles/weeder#19).So I have:
Comments