-
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
Add constraints
field to TransactionLayer
#2620
Add constraints
field to TransactionLayer
#2620
Conversation
356242e
to
20c3255
Compare
txConstraints
field to TransactionLayer
constraints
field to TransactionLayer
20c3255
to
1cf1668
Compare
1cf1668
to
93eab53
Compare
36a01a8
to
d98beeb
Compare
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!
@@ -540,45 +550,82 @@ _decodeSignedTx era bytes = do | |||
_ -> | |||
Left ErrDecodeSignedTxNotSupported | |||
|
|||
data TxSkeleton = TxSkeleton |
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.
Might as well put the
his record type includes the minimal set of fields that are absolutely
necessary for theestimateTxSize
function to perform its calculations,
and nothing else.As such, the fields of
TxSkeleton
contain a subset of the data included
in the union ofSelectionSkeleton
andTransactionCtx
.
From the commit message as a doc comment here.
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.
Ah good point! I'll add some comments in there. 👍🏻
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.
Fixed in d7ff662.
-- between 'txOutputSize' and 'txOutputMaximumSize' should also indicate that | ||
-- the bundle is oversized. | ||
-- | ||
prop_txConstraints_txOutputMaximumSize :: Large TokenBundle -> Property |
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.
👍
-- selection produces a result that is consistent with the result of using | ||
-- 'estimateTxCost'. | ||
-- | ||
prop_txConstraints_txCost :: MockSelection -> Property |
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.
👍
lib/shelley/test/unit/Cardano/Wallet/Shelley/TransactionSpec.hs
Outdated
Show resolved
Hide resolved
bors r+ |
2620: Add `constraints` field to `TransactionLayer` r=jonathanknowles a=jonathanknowles # Issue Number ADP-839 # Overview This PR: - [x] adds field `constraints` of type `TxConstraints` to the `TransactionLayer` record type. - [x] adds an implementation of `constraints` to `Shelley.Transaction.TransactionLayer`. - [x] adds property tests to demonstrate the correctness of `Shelley.Transaction.TransactionLayer.constraints`. # Refactoring This PR also: - [x] makes `TxSize` into a concrete type exported by `Primitive.Types.Tx`. - [x] removes `calcMinimumCoinValue` from `TransactionLayer`, as `TxConstraints.txOutputMinimumAdaQuantity` makes this redundant. # Future work This PR will make it possible to: - remove `tokenBundleSizeAssessor` from `TransactionLayer`, as `TxConstraints.txOutputMaximumSize` makes this redundant. Co-authored-by: Jonathan Knowles <[email protected]>
Build failed: Looks like this was a cache failure. |
bors r+ |
2620: Add `constraints` field to `TransactionLayer` r=jonathanknowles a=jonathanknowles # Issue Number ADP-839 # Overview This PR: - [x] adds field `constraints` of type `TxConstraints` to the `TransactionLayer` record type. - [x] adds an implementation of `constraints` to `Shelley.Transaction.TransactionLayer`. - [x] adds property tests to demonstrate the correctness of `Shelley.Transaction.TransactionLayer.constraints`. # Refactoring This PR also: - [x] makes `TxSize` into a concrete type exported by `Primitive.Types.Tx`. - [x] removes `calcMinimumCoinValue` from `TransactionLayer`, as `TxConstraints.txOutputMinimumAdaQuantity` makes this redundant. # Future work This PR will make it possible to: - remove `tokenBundleSizeAssessor` from `TransactionLayer`, as `TxConstraints.txOutputMaximumSize` makes this redundant. Co-authored-by: Jonathan Knowles <[email protected]>
Build failed: Looks like this was a cache failure. After rerunning some of the tests, I ran into this failure: (https://hydra.iohk.io/build/6207105/nixlog/1/tail)
Looks like a instance of: |
2099f94
to
c9470ca
Compare
bors r+ |
bors r- Let's do the release first, then try to merge this. |
Canceled. |
bors r+ |
2620: Add `constraints` field to `TransactionLayer` r=jonathanknowles a=jonathanknowles # Issue Number ADP-839 # Overview This PR: - [x] adds field `constraints` of type `TxConstraints` to the `TransactionLayer` record type. - [x] adds an implementation of `constraints` to `Shelley.Transaction.TransactionLayer`. - [x] adds property tests to demonstrate the correctness of `Shelley.Transaction.TransactionLayer.constraints`. # Refactoring This PR also: - [x] makes `TxSize` into a concrete type exported by `Primitive.Types.Tx`. - [x] removes `calcMinimumCoinValue` from `TransactionLayer`, as `TxConstraints.txOutputMinimumAdaQuantity` makes this redundant. # Future work This PR will make it possible to: - remove `tokenBundleSizeAssessor` from `TransactionLayer`, as `TxConstraints.txOutputMaximumSize` makes this redundant. Co-authored-by: Jonathan Knowles <[email protected]>
bors r- |
Canceled. |
…ve.Tx`. Ultimately, transaction sizes are all expressible in terms of natural numbers, regardless of whether the sizes are expressed in terms of bytes, or in terms of some other unit. So there's currently little need for a type class abstraction here, when a newtype will suffice.
The purpose of `SelectionSkeleton` is to provide all the data necessary to calculate the fee associated with a selection. However, this calculation only depends on the number of inputs, and not the contents of each input. Therefore, it's only necessary to include a count of the selected inputs within `SelectionSkeleton`, and unnecessary to include the actual inputs themselves.
…on` prefix. This makes the record field names a bit more consistent.
This record type includes the minimal set of fields that are absolutely necessary for the `estimateTxSize` function to perform its calculations, and nothing else. As such, the fields of `TxSkeleton` contain a subset of the data included in the union of `SelectionSkeleton` and `TransactionCtx`. Using this type means that future tests for `estimateTxSize` will only need to supply values that will actually be used by the function, simplifying the effort to write tests.
This will allow it to be tested in conjunction with `txConstraints`.
The `constraints` field provides a value of `TxConstraints`.
Replace these uses with `constraints.txOutputMinimumAdaQuantity`.
This is made redundant by `constraints`.
We probably want to avoid spamming the test log with the output of `show` for very large token bundles. We already have a large set of counterexample data. In response to review feedback: https://github.com/input-output-hk/cardano-wallet/pull/2620/files#r622669907
c9470ca
to
e687560
Compare
bors r+ |
Build succeeded: |
Issue Number
ADP-839
Overview
This PR:
constraints
of typeTxConstraints
to theTransactionLayer
record type.constraints
toShelley.Transaction.TransactionLayer
.Shelley.Transaction.TransactionLayer.constraints
.Refactoring
This PR also:
TxSize
into a concrete type exported byPrimitive.Types.Tx
.calcMinimumCoinValue
fromTransactionLayer
, asTxConstraints.txOutputMinimumAdaQuantity
makes this redundant.Future work
This PR will make it possible to:
tokenBundleSizeAssessor
fromTransactionLayer
, asTxConstraints.txOutputMaximumSize
makes this redundant.