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

[ADP 3491] Relax policy key guard #4850

Merged
merged 3 commits into from
Dec 19, 2024

Conversation

paweljakubas
Copy link
Contributor

@paweljakubas paweljakubas commented Nov 20, 2024

policyXPub is needed in constructTransaction in two cases:

  • tx contains minting/burning action
  • tx deals with reference scripting and has reference script template nonempty

instead of using policyXPub we use policyXPubM throught the function and only deconstruct it when checking those two cases. ErrReadPolicyPublicKeyAbsen is used for the those two valid situations when policy xpub is missing.

Comments

Issue Number

Fix #4872

@paweljakubas paweljakubas self-assigned this Nov 20, 2024
@@ -2650,7 +2653,7 @@ constructTransaction api knownPools poolStatus apiWalletId body = do
makeLeft $
toTokenMapAndScript ShelleyKeyS
scriptT
(Map.singleton (Cosigner 0) policyXPub)
(Map.singleton (Cosigner 0) $ fromJust policyXPubM)
Copy link
Member

Choose a reason for hiding this comment

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

🤔 Having to resort to an approach with fromJust seems unfortunate...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, fair point. Now no partial function fixing ;-)

@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3491/relax-policy-key-guard branch 2 times, most recently from ea516e3 to 3d54963 Compare November 20, 2024 09:35
@paweljakubas paweljakubas marked this pull request as draft November 20, 2024 15:21
@paweljakubas
Copy link
Contributor Author

waiting for the daedalus team to confirm if the fix works. If yes then we will undraft it.

@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3491/relax-policy-key-guard branch from 9971ae7 to d443f0e Compare December 6, 2024 15:34
@abailly abailly force-pushed the paweljakubas/adp-3491/relax-policy-key-guard branch from d443f0e to eab1d67 Compare December 16, 2024 14:24
@abailly
Copy link
Collaborator

abailly commented Dec 16, 2024

There's a remaining issue: constructTransaction depends on decodeTransaction which unconditionally extract the policy pub key and throws an exception if it cannot find one.

@abailly
Copy link
Collaborator

abailly commented Dec 17, 2024

Fix #4872

@abailly abailly marked this pull request as ready for review December 17, 2024 09:42
@abailly abailly force-pushed the paweljakubas/adp-3491/relax-policy-key-guard branch from 5b4f4de to ca7546a Compare December 17, 2024 09:57
@Anviking
Copy link
Member

Anviking commented Dec 17, 2024

@abailly the last commit is huge (+3,919 −3,109). Unintentionally caused by some autoformatter?

@abailly
Copy link
Collaborator

abailly commented Dec 18, 2024

@Anviking I don't know, I ran the code checker and it did not complain 🤷

@abailly
Copy link
Collaborator

abailly commented Dec 18, 2024

I must confess I pay exactly 0 attention to code format as I expect this to be handled by the tooling. In our case, I understand this is stylish-haskell, which I ran.

@abailly
Copy link
Collaborator

abailly commented Dec 18, 2024

@paweljakubas I think I would like to write a proper test for this, your guidance would be much appreciated.

@paweljakubas
Copy link
Contributor Author

paweljakubas commented Dec 18, 2024

The most beautiful (and persuasive also) test (integration one) would be the following:

  1. Create wallet with funds, walMnemonic
  2. Get extended account public key from walMnemonic, xAcctPub
  3. Create account public key wallet from xAcctPub, walAcct
  4. Create constructTransation for walAcct that joinDep in conway only (no babbage)
  5. Hand over cbor of point 4 to walMnemonic and sign and submit it
  6. Make sure both walAcct and walMnemonic are voting.

In essense, walMnemonic can be treated as hardware wallet.

@abailly abailly force-pushed the paweljakubas/adp-3491/relax-policy-key-guard branch 2 times, most recently from 3af10dd to 0937538 Compare December 18, 2024 11:57
@abailly
Copy link
Collaborator

abailly commented Dec 18, 2024

@Anviking I updated the PR, the size of the diff is much more reasonable :)
I really wish we move to a formatter that actually enforces proper formatting, eg. ormolu or fourmolu, in order to streamline this whole thing

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.

lgtm, if you've tested this. I suspect the fromJust pattern could be dropped but that already existed before this pr.

paweljakubas and others added 3 commits December 18, 2024 16:22
handle reference script situation

resign from fremJust
@abailly abailly force-pushed the paweljakubas/adp-3491/relax-policy-key-guard branch from 0937538 to 085f5c1 Compare December 18, 2024 15:22
@abailly
Copy link
Collaborator

abailly commented Dec 18, 2024

@Anviking I agree an integration test would be useful, but I also don't want to add too many of those as they might become a liability pretty quickly.

@Anviking
Copy link
Member

Yeah, I just meant that I presume you've verified (manually) that this did what you wanted it to

@abailly
Copy link
Collaborator

abailly commented Dec 18, 2024

Of course, but you're right and this feels a bit sloppy

@Anviking
Copy link
Member

but I also don't want to add too many of those as they might become a liability pretty quickly.

Fully share this concern though

@abailly abailly added this pull request to the merge queue Dec 19, 2024
Merged via the queue into master with commit 5256d98 Dec 19, 2024
24 checks passed
@abailly abailly deleted the paweljakubas/adp-3491/relax-policy-key-guard branch December 19, 2024 10:30
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.

Issue with constructTransaction endpoint for a wallet created from xpub
3 participants