-
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
Make wallet run on Mary #2400
Make wallet run on Mary #2400
Conversation
362deec
to
3daae77
Compare
I pushed some more WIP:
|
2052ac9
to
6fd0966
Compare
8464693
to
8c6cf68
Compare
@Anviking why was it necessary to re-generate all the faucet keys 🤔 ? |
8e1811f
to
ec663f1
Compare
I pulled out the local-cluster rename commits. We can do that another time. |
32c5d03
to
eb433f7
Compare
9ec04e9
to
43b357c
Compare
975ebde
to
84f250b
Compare
b736706
to
a6b8874
Compare
@@ -5,10 +5,10 @@ | |||
module Cardano.Wallet.Primitive.Types.TokenPolicy | |||
( | |||
-- * Token Policies | |||
TokenPolicyId | |||
TokenPolicyId (..) |
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.
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.
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 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?
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 exported those constructors, because it's impractical not to have them. PolicyId and AssetName values coming from the node are already validated.
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 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:
-
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.
-
When people reviewing code see a new call to
unsafeX
, they can ask the question: "Has this input been validated?" -
We can easily track usages of
unsafe
functions with a simple call togrep
(orag
). This is a bit harder to do with the default data constructor.
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 type constructor itself could be called UnsafePolicyId if you like.
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.
@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
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.
@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)
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 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.
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.
@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!
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.
Ok, fair, perhaps.
b0c4cbd
to
991cc68
Compare
Co-authored-by: Johannes Lund <[email protected]> Co-authored-by: Rodney Lorrimar <[email protected]>
It's not pretty, sorry.
ec3df0f
to
83ecc78
Compare
bors try |
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.
lgtm
return $ fromPoolDistr <$> result | ||
AnyCardanoEra ByronEra -> | ||
-- see also: #2419 | ||
throwE $ ErrStakeDistributionQuery "Can't query stake distribution in byron era" |
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.
👍
Seems both buildkite and hydra passed in the |
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]>
tryTimed out. Nix eval error |
Build failed:
|
bors r+ |
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]>
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.
🤞 |
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]>
Build failed:
|
bors r+ |
Build succeeded: |
Issue Number
ADP-623
Overview
Comments