-
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 transaction TTL to payments API #2167
Conversation
1d6b0e2
to
2e2c62c
Compare
cebf2d3
to
f3b251d
Compare
0c634ac
to
c938a0c
Compare
f6fc3bd
to
6bb0383
Compare
bors try |
tryBuild failed: |
6bb0383
to
e4b840e
Compare
Fixed code warning, doh. bors try |
tryBuild failed: Need to fix something. |
e4b840e
to
e8e1e41
Compare
lib/core-integration/src/Test/Integration/Scenario/API/Shelley/Transactions.hs
Show resolved
Hide resolved
e8e1e41
to
7781555
Compare
31b9a57
to
a736044
Compare
5de8604
to
c824d00
Compare
|
||
-- Expected and actual are fairly close. Any difference should only be | ||
-- due to slot rounding. | ||
slotDiff txExpectedExp txActualExp `shouldSatisfy` (< 50) |
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.
What about also waiting for the transaction to expire and verify that its state eventually becomes reported as expired?
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.
This test case is testing that a custom transaction expiry works, and then I test expiry and reporting of the tx status in the next test case TRANS_TTL_03.
@@ -43,7 +43,7 @@ | |||
|
|||
module Cardano.Wallet | |||
( | |||
-- * Developement | |||
-- * Development |
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.
2-year old typo, never too late to fix 😅
expTime <- addUTCTime ttl <$> getCurrentTime | ||
try $ ti $ ceilingSlotAt expTime | ||
where | ||
ttl = fromMaybe defaultTTL maybeTTL |
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.
👍
} deriving (Eq, Generic, Show) | ||
|
||
data PostTransactionFeeData (n :: NetworkDiscriminant) = PostTransactionFeeData | ||
{ payments :: (NonEmpty (AddressAmount (ApiT Address, Proxy n))) | ||
, withdrawal :: !(Maybe ApiWithdrawalPostData) | ||
, metadata :: !(Maybe (ApiT TxMetadata)) | ||
, timeToLive :: !(Maybe (Quantity "second" NominalDiffTime)) |
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.
👍
bors r+ |
2167: Add transaction TTL to payments API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Add transaction TTL to swagger spec. User provides the value in seconds. - [x] Add transaction TTL to API types - [x] Add TTL slot calculation to API handler function - [x] Adjust mkStdTx to make ttl easier - it now takes the expiry slot directly. - [x] Integration tests ### Comments Next PR - [ ] Add CLI option `cardano-wallet transaction create [--ttl=SECONDS]` - [ ] Perhaps clean up the large number of function arguments and return values in transaction layer functions. Co-authored-by: Rodney Lorrimar <[email protected]>
Timed out. |
bors r+ |
2167: Add transaction TTL to payments API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Add transaction TTL to swagger spec. User provides the value in seconds. - [x] Add transaction TTL to API types - [x] Add TTL slot calculation to API handler function - [x] Adjust mkStdTx to make ttl easier - it now takes the expiry slot directly. - [x] Integration tests ### Comments Next PRs - [x] Allow deleting expired transactions ⇒ #2262 - [x] Add CLI option `cardano-wallet transaction create [--ttl=SECONDS]` ⇒ #2267 - [ ] Perhaps clean up the large number of function arguments and return values in transaction layer functions. Co-authored-by: Rodney Lorrimar <[email protected]>
Build failed:
|
|
||
-- this transaction is going to expire really soon. | ||
basePayload <- mkTxPayload ctx wb amt fixturePassphrase | ||
let payload = addTxTTL 0.1 basePayload |
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.
Sounds like this is a bit flaky :s, we should choose a time slightly larger in front of the time slot.
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.
Hmm yes, not good.
The TTL must be small enough that the tx expires before it can get into a block, but large enough that the node allows it into its mempool.
I need another approach to testing this which isn't flaky.
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.
@rvl a possible approach could be to double-spend? If we make two transactions that are using a common UTxO, both should be "accepted" in the mempool and only one would go through ultimately. Then, we can set a large-enough but still short TTL and simply wait for either one to expire.
So, the test could be:
a) Setup a wallet with a single UTxO
b) Send funds to A with TTL t
c) Forget transaction
d) Send funds to B with TTL t
Yet, this maybe does not test what you intend to test? If we want to check that the transaction is not inserted because it is expired (and not because it is double-spending), then it doesn't work :/
bors r+ |
2167: Add transaction TTL to payments API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Add transaction TTL to swagger spec. User provides the value in seconds. - [x] Add transaction TTL to API types - [x] Add TTL slot calculation to API handler function - [x] Adjust mkStdTx to make ttl easier - it now takes the expiry slot directly. - [x] Integration tests ### Comments Next PRs - [x] Allow deleting expired transactions ⇒ #2262 - [x] Add CLI option `cardano-wallet transaction create [--ttl=SECONDS]` ⇒ #2267 - [ ] Perhaps clean up the large number of function arguments and return values in transaction layer functions. Co-authored-by: Rodney Lorrimar <[email protected]>
Build failed:
|
bors retry |
Build succeeded: |
2262: Allow deleting expired transactions from the API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Using the existing transaction delete endpoint, also permit removing expired transactions. - [x] Simplify DB model and state machine tests for this function - [x] Integration test ### Comments - Based on PR #2167 branch - merge that first. 2282: Increase bors timeout from 2h to 3h r=Anviking a=Anviking # Issue Number #2279 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - [x] Increase bors timeout from 2h to 3h # Comments It seems hydra is often slow to schedule/run the jobs, causing ≈18% of bors r+ to fail. It should be better to increase the timeout to 3h, than to have it fail. This doesn't affect the timeout of buildkite or hydra themselves. <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: Rodney Lorrimar <[email protected]> Co-authored-by: Johannes Lund <[email protected]>
2262: Allow deleting expired transactions from the API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Using the existing transaction delete endpoint, also permit removing expired transactions. - [x] Simplify DB model and state machine tests for this function - [x] Integration test ### Comments - Based on PR #2167 branch - merge that first. Co-authored-by: Rodney Lorrimar <[email protected]>
2262: Allow deleting expired transactions from the API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Using the existing transaction delete endpoint, also permit removing expired transactions. - [x] Simplify DB model and state machine tests for this function - [x] Integration test ### Comments - Based on PR #2167 branch - merge that first. Co-authored-by: Rodney Lorrimar <[email protected]>
2262: Allow deleting expired transactions from the API r=rvl a=rvl ### Issue Number ADP-93 / #1840 ### Overview - [x] Using the existing transaction delete endpoint, also permit removing expired transactions. - [x] Simplify DB model and state machine tests for this function - [x] Integration test ### Comments - Based on PR #2167 branch - merge that first. Co-authored-by: Rodney Lorrimar <[email protected]>
Issue Number
ADP-93 / #1840
Overview
Comments
Next PRs
cardano-wallet transaction create [--ttl=SECONDS]
⇒ Add CLI option for transaction TTL #2267