-
Notifications
You must be signed in to change notification settings - Fork 23
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
Replace TxProposalProcedures unsafe constructor with an unidirectional pattern #726
base: master
Are you sure you want to change the base?
Replace TxProposalProcedures unsafe constructor with an unidirectional pattern #726
Conversation
8c7adb6
to
3193e8c
Compare
3193e8c
to
1616394
Compare
@@ -1557,13 +1564,19 @@ substituteExecutionUnits | |||
] | |||
|
|||
substitutedExecutionUnits <- traverseScriptWitnesses eSubstitutedExecutionUnits | |||
-- join again with osetProposalProcedures, just in case anything from there was not included in substituteExecutionUnits |
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.
We should either know or not know if everything was included in substituteExecutionUnits.
@@ -1471,7 +1472,7 @@ data TxProposalProcedures build era where | |||
TxProposalProceduresNone :: TxProposalProcedures build era | |||
-- | Create Tx proposal procedures. Prefer 'mkTxProposalProcedures' smart constructor to using this constructor | |||
-- directly. | |||
TxProposalProcedures | |||
UnsafeTxProposalProcedures |
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.
We should change this to:
TxProposalProcedures
:: Ledger.EraPParams (ShelleyLedgerEra era)
=> BuildTxWith build (Map (L.ProposalProcedure (ShelleyLedgerEra era)) (Maybe (ScriptWitness WitCtxStake era)))
-> TxProposalProcedures build era
Then we can avoid having a separate OSet
. Any ProposalProcedure
with a corresponding Nothing
is key does not require a script witness.
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.
But then conversion from ledger tx body to our tx body will result in our datatype having no proposal procedures, because build ~ ViewTx
.
Ideally it should be something like (similar to TxCertificates
):
TxProposalProcedures
:: Ledger.EraPParams (ShelleyLedgerEra era)
=> OMap
(L.ProposalProcedure (ShelleyLedgerEra era))
(BuildTxWith build (Maybe(ScriptWitness WitCtxStake era)))
-> TxProposalProcedures build era
But it was rejected on a review, when I was making a first fix to TxProposalProcedures
issue with missing proposals.
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.
Let's go with your counter suggestion 👍
We need to remove BuildTxWith
at some point as it's not a useful abstraction.
Changelog
Context
Previously
TxProposalProcedures
was not guaranteeing the type consistency: when used, you could insert proposals only to its second argument without inserting it to the first. The logic incardano-api
relies on a fact that the first argument would contain a complete list of proposals, so this would introduce a bug.This PR replaces
TxProposalProcedures
constructor with an unidirectional pattern, which does not allow constructing of a type.mkTxProposalProcedures
should be used for that.Checklist