Skip to content
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

Merged
merged 9 commits into from
Jul 20, 2021
Merged

Fix weeder 2.x config and remove weeds #2765

merged 9 commits into from
Jul 20, 2021

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Jul 19, 2021

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(-)

@rvl rvl self-assigned this Jul 19, 2021
@rvl rvl mentioned this pull request Jul 19, 2021
@rvl rvl force-pushed the rvl/2695/weeder branch 2 times, most recently from 79ed59d to 6d765f1 Compare July 19, 2021 13:38
Copy link
Member

@Anviking Anviking left a 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")
Copy link
Member

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?

Copy link
Contributor Author

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 ""
Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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 !

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah!

Copy link
Contributor Author

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.

Copy link
Member

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...

  1. 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
  2. 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

iohk-bors bot added a commit that referenced this pull request Jul 20, 2021
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]>
Copy link
Member

@jonathanknowles jonathanknowles left a 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:

  1. Makes some behavioural changes to tests
  2. 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!

@rvl rvl force-pushed the rvl/2695/weeder branch 2 times, most recently from 541b31b to 4aeb220 Compare July 20, 2021 05:17
@rvl
Copy link
Contributor Author

rvl commented Jul 20, 2021

OK done @jonathanknowles - here is your PR: #2768.

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)
Copy link
Member

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. :)

Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rvl

This looks mostly good, though I think there is still one behavioural change w.r.t. shrinking that got left behind (see review comment).

Could you also move this to the other PR (#2768), so it can be considered together with the other changes?

Many thanks!

jonathanknowles added a commit that referenced this pull request Jul 20, 2021
The shrinker for `Arbitrary TokenQuantity` should allow zero values.

See:

#2765 (review)
jonathanknowles added a commit that referenced this pull request Jul 20, 2021
The shrinker for `Arbitrary TokenQuantity` should allow zero values.

See:

#2765 (review)
@jonathanknowles jonathanknowles self-requested a review July 20, 2021 07:29
@rvl
Copy link
Contributor Author

rvl commented Jul 20, 2021

bors r+

iohk-bors bot added a commit that referenced this pull request Jul 20, 2021
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]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jul 20, 2021

Build failed:

weeder
--
  | incompatible hie file: /build/cardano-wallet/lib/shelley/.stack-work/dist/x86_64-linux/Cabal-3.2.1.0/build/unit/unit-tmp/Cardano/Wallet/Shelley/LaunchSpec.hie
  | expected .hie file version 8104 but got 8105
  | weeder must be built with the same GHC version as the project it is used on
  | error: Command exited with code 1!

#expected - wrong weeder build used

@rvl rvl force-pushed the rvl/2695/weeder branch from cb2c01d to 3f6fe49 Compare July 20, 2021 09:51
@Anviking
Copy link
Member

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jul 20, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit f8455ff into master Jul 20, 2021
@iohk-bors iohk-bors bot deleted the rvl/2695/weeder branch July 20, 2021 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weeder: Command exited with code -9
3 participants