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

Make wallet run on Mary #2400

Merged
merged 14 commits into from
Jan 12, 2021
Merged

Make wallet run on Mary #2400

merged 14 commits into from
Jan 12, 2021

Conversation

Anviking
Copy link
Member

@Anviking Anviking commented Dec 16, 2020

Issue Number

ADP-623

Overview

Comments

@rvl rvl changed the title WIP: Very course Mary-integration WIP: Very coarse Mary-integration Dec 17, 2020
@rvl rvl force-pushed the anviking/ADP-623/mary branch from 362deec to 3daae77 Compare December 17, 2020 12:40
@rvl
Copy link
Contributor

rvl commented Dec 17, 2020

I pushed some more WIP:

@rvl rvl force-pushed the anviking/ADP-623/mary branch 4 times, most recently from 2052ac9 to 6fd0966 Compare December 23, 2020 16:26
@KtorZ KtorZ added the ADDING FEATURE Mark a PR as adding a new feature, for auto-generated CHANGELOG label Dec 31, 2020
@rvl rvl force-pushed the anviking/ADP-623/mary branch 2 times, most recently from 8464693 to 8c6cf68 Compare January 4, 2021 08:43
@KtorZ
Copy link
Member

KtorZ commented Jan 4, 2021

@Anviking why was it necessary to re-generate all the faucet keys 🤔 ?

@Anviking
Copy link
Member Author

Anviking commented Jan 4, 2021

@KtorZ I think @rvl renamed shelley-test-cluster to local-cluster, including the folder the keys where in

@rvl rvl force-pushed the anviking/ADP-623/mary branch 2 times, most recently from 8e1811f to ec663f1 Compare January 5, 2021 06:56
@rvl
Copy link
Contributor

rvl commented Jan 5, 2021

I pulled out the local-cluster rename commits. We can do that another time.

@Anviking Anviking force-pushed the anviking/ADP-623/mary branch from 32c5d03 to eb433f7 Compare January 5, 2021 14:24
@Anviking Anviking changed the title WIP: Very coarse Mary-integration Make wallet run on Mary (without native token support) Jan 5, 2021
@Anviking Anviking force-pushed the anviking/ADP-623/mary branch 5 times, most recently from 9ec04e9 to 43b357c Compare January 7, 2021 12:28
@rvl rvl force-pushed the anviking/ADP-623/mary branch from 975ebde to 84f250b Compare January 7, 2021 12:41
@rvl rvl linked an issue Jan 8, 2021 that may be closed by this pull request
@rvl rvl force-pushed the anviking/ADP-623/mary branch 2 times, most recently from b736706 to a6b8874 Compare January 8, 2021 10:35
@@ -5,10 +5,10 @@
module Cardano.Wallet.Primitive.Types.TokenPolicy
(
-- * Token Policies
TokenPolicyId
TokenPolicyId (..)
Copy link
Member

@jonathanknowles jonathanknowles Jan 8, 2021

Choose a reason for hiding this comment

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

@Anviking

Just a thought.

Rather than exporting the default data constructors for TokenPolicyId and TokenName, perhaps we could define and export smart constructors instead?

It would be my preference to not export these default constructors, as it opens the door to people accidentally creating invalid token policy IDs (which should have a certain length), and this could cause subtle regressions in other places.

In the case of TokenName, there is actually already a FromText instance. Right now, this never fails, but if token names were to require validation, then calling fromText would be safer than using the default constructor.

Copy link
Member Author

Choose a reason for hiding this comment

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

It would be my preference to not export these default constructors, as it opens the door to people accidentally

👍 Good catch, agree.

Though, I wonder what the best solution is 🤔

were to require validation, then calling fromText would be safer than using the default constructor.

If fromText fails in the node-to-wallet type-conversion, then the wallet and node have different validation rules, and surely the node's must be the correct ones. Do we actually want to validate in the conversion?

Copy link
Contributor

Choose a reason for hiding this comment

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

I exported those constructors, because it's impractical not to have them. PolicyId and AssetName values coming from the node are already validated.

Copy link
Member

@jonathanknowles jonathanknowles Jan 9, 2021

Choose a reason for hiding this comment

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

I exported those constructors, because it's impractical not to have them. PolicyId and AssetName values coming from the node are already validated.

Well, one alternative is to create functions unsafePolicyId and unsafePolicyName and export these instead of the default data constructors.

Advantages:

  1. Callers of these functions are explicitly reminded that they're using unsafe functions. The onus is on them to check that the input is valid.

  2. When people reviewing code see a new call to unsafeX, they can ask the question: "Has this input been validated?"

  3. We can easily track usages of unsafe functions with a simple call to grep (or ag). This is a bit harder to do with the default data constructor.

Copy link
Contributor

Choose a reason for hiding this comment

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

The type constructor itself could be called UnsafePolicyId if you like.

Copy link
Member

Choose a reason for hiding this comment

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

@jonathanknowles I think we do not care much about that last bit 😊 ... if that really bothers you: https://hackage.haskell.org/package/quiet-0.2/docs/Quiet.html

Copy link
Member

Choose a reason for hiding this comment

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

@jonathanknowles I think we do not care much about that last bit blush ...

Fair enough.

if that really bothers you: https://hackage.haskell.org/package/quiet-0.2/docs/Quiet.html

We actually are already using Quiet here:

newtype TokenPolicyId = TokenPolicyId
    { unTokenPolicyId :: Hash "TokenPolicy" }
    deriving stock (Eq, Ord, Generic)
    deriving (Read, Show) via (Quiet TokenPolicyId)

Copy link
Member Author

@Anviking Anviking Jan 11, 2021

Choose a reason for hiding this comment

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

I would have been slightly in favour of unsafePolicyId over UnsafePolicyId for the sake of:

  • Less confusing Show output
  • No unintended de-construction outside the module

but won't object, either.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Anviking we also need de-construction in Compatibility.hs.

The situation is a bit ridiculous with the multiple layers of wrapping around a 32 byte bytestring (maximum length not enforced by our code by the way). And Text is probably not the correct inner type anyway!

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, fair, perhaps.

@rvl rvl force-pushed the anviking/ADP-623/mary branch from b0c4cbd to 991cc68 Compare January 9, 2021 08:34
@rvl
Copy link
Contributor

rvl commented Jan 12, 2021

bors try

iohk-bors bot added a commit that referenced this pull request Jan 12, 2021
Copy link
Member Author

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

lgtm

return $ fromPoolDistr <$> result
AnyCardanoEra ByronEra ->
-- see also: #2419
throwE $ ErrStakeDistributionQuery "Can't query stake distribution in byron era"
Copy link
Member Author

Choose a reason for hiding this comment

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

👍

@Anviking
Copy link
Member Author

Seems both buildkite and hydra passed in the bors try, but the bors status has failed to be updated
bors r+

iohk-bors bot added a commit that referenced this pull request Jan 12, 2021
2400: Make wallet run on Mary r=Anviking a=Anviking

# Issue Number

ADP-623

# Overview

- [x] Make the wallet run on Mary,
- [x] MA Value types are converted to/from TokenBundles.
- [x] Roundtrip tests for Value/TokenBundle
- [x] Fix disabled era error https://input-output-rnd.slack.com/archives/CFKLUH4R0/p1608146419455500
- [x] Test cluster does hard forks at start up - instantly.
- [x] Uses latest cardano-node master branch, with IntersectMBO/cardano-node#2270 merged.

# Comments

- I imagine properly thinking about and removing the duplication would be pretty fun. (rvl: we can do that in the next PR)
- Local test cluster changes for testing in multiple eras ⇒ #2438



Co-authored-by: Rodney Lorrimar <[email protected]>
Co-authored-by: Johannes Lund <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 12, 2021

try

Timed out.

Nix eval error

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 12, 2021

Build failed:

src/Test/Integration/Scenario/API/Shelley/StakePools.hs:576:5:
--
  | 1) API Specifications, SHELLEY_STAKE_POOLS, STAKE_POOLS_JOIN_04 - Rewards accumulate
  | uncaught exception: RequestException
  | DecodeFailure "{\"code\":\"network_query_failed\",\"message\":\"Unable to query the ledger at the moment. This error has been logged. Trying again in a bit might work.\"}"
  |  
  | To rerun use: --match "/API Specifications/SHELLEY_STAKE_POOLS/STAKE_POOLS_JOIN_04 - Rewards accumulate/"
  |  
  | src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:153:26:
  | 2) CLI Specifications, SHELLEY_CLI_HW_WALLETS, HW_WALLETS_01x - Restoration from account public key preserves funds
  | While verifying ApiWallet {id = ApiT {getApiT = WalletId {getWalletId = 42245c2f417e6f1a62a2b3a7e501d544320d59d5}}, addressPoolGap = ApiT {getApiT = AddressPoolGap {getAddressPoolGap = 20}}, balance = ApiT {getApiT = WalletBalance {available = Quantity {getQuantity = 0}, total = Quantity {getQuantity = 0}, reward = Quantity {getQuantity = 0}}}, delegation = ApiWalletDelegation {active = ApiWalletDelegationNext {status = NotDelegating, target = Nothing, changesAt = Nothing}, next = []}, name = ApiT {getApiT = WalletName {getWalletName = "Wallet from pub key"}}, passphrase = Nothing, state = ApiT {getApiT = Syncing (Quantity {getQuantity = Percentage {getPercentage = 7569 % 10000}})}, tip = ApiBlockReference {absoluteSlotNumber = ApiT {getApiT = SlotNo 4037}, slotId = ApiSlotId {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 80}}, slotNumber = ApiT {getApiT = SlotInEpoch {unSlotInEpoch = 37}}}, time = 2021-01-12 10:48:58.4 UTC, block = ApiBlockInfo {height = Quantity {getQuantity = 2000}}}}
  | Waited longer than 90s to resolve action: "Wallet balance is as expected on wallet from pubKey".
  | expected: Quantity {getQuantity = 1000000}
  | but got: Quantity {getQuantity = 0}
  |  
  | To rerun use: --match "/CLI Specifications/SHELLEY_CLI_HW_WALLETS/HW_WALLETS_01x - Restoration from account public key preserves funds/"

#2320

#2428

@Anviking
Copy link
Member Author

bors r+

iohk-bors bot added a commit that referenced this pull request Jan 12, 2021
2400: Make wallet run on Mary r=Anviking a=Anviking

# Issue Number

ADP-623

# Overview

- [x] Make the wallet run on Mary,
- [x] MA Value types are converted to/from TokenBundles.
- [x] Roundtrip tests for Value/TokenBundle
- [x] Fix disabled era error https://input-output-rnd.slack.com/archives/CFKLUH4R0/p1608146419455500
- [x] Test cluster does hard forks at start up - instantly.
- [x] Uses latest cardano-node master branch, with IntersectMBO/cardano-node#2270 merged.

# Comments

- I imagine properly thinking about and removing the duplication would be pretty fun. (rvl: we can do that in the next PR)
- Local test cluster changes for testing in multiple eras ⇒ #2438



Co-authored-by: Rodney Lorrimar <[email protected]>
Co-authored-by: Johannes Lund <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 12, 2021

Timed out.

#nix eval error

Removing this seems to fix the nix build on my old mac. Hopefully this
fixes CI too.

I'd guess the fix now already exists somewhere upstream.
@Anviking
Copy link
Member Author

🤞
bors r+

iohk-bors bot added a commit that referenced this pull request Jan 12, 2021
2400: Make wallet run on Mary r=Anviking a=Anviking

# Issue Number

ADP-623

# Overview

- [x] Make the wallet run on Mary,
- [x] MA Value types are converted to/from TokenBundles.
- [x] Roundtrip tests for Value/TokenBundle
- [x] Fix disabled era error https://input-output-rnd.slack.com/archives/CFKLUH4R0/p1608146419455500
- [x] Test cluster does hard forks at start up - instantly.
- [x] Uses latest cardano-node master branch, with IntersectMBO/cardano-node#2270 merged.

# Comments

- I imagine properly thinking about and removing the duplication would be pretty fun. (rvl: we can do that in the next PR)
- Local test cluster changes for testing in multiple eras ⇒ #2438



Co-authored-by: Rodney Lorrimar <[email protected]>
Co-authored-by: Johannes Lund <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 12, 2021

Build failed:

Failures:

  test/unit/Cardano/Wallet/DB/StateMachine.hs:1333:28:
  1) Cardano.Wallet.DB.Sqlite, Validate generators & shrinkers, Shrinker for CreateWallet
       Timed out.

  To rerun use: --match "/Cardano.Wallet.DB.Sqlite/Validate generators & shrinkers/Shrinker for CreateWallet/"

Randomized with seed 2076883091

#2393

@Anviking
Copy link
Member Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jan 12, 2021

Build succeeded:

@iohk-bors iohk-bors bot merged commit f7fdc3c into master Jan 12, 2021
@iohk-bors iohk-bors bot deleted the anviking/ADP-623/mary branch January 12, 2021 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADDING FEATURE Mark a PR as adding a new feature, for auto-generated CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky: ProcessHasExited "cluster didn't start correctly
4 participants