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

Get tx by id #1795

Merged
merged 15 commits into from
Jun 26, 2020
Merged

Get tx by id #1795

merged 15 commits into from
Jun 26, 2020

Conversation

paweljakubas
Copy link
Contributor

@paweljakubas paweljakubas commented Jun 24, 2020

Issue Number

#1789

Overview

  • I have added getTransaction endpoint, and all needed implementations, errors
  • I have updated swagger
  • I have added integration test
  • I have added CLI support
  • I have updated CLI unit tests
  • I have added CLI integration tests
  • I have added support in ByronTransaction
  • I have added getTx to DB
  • I have implemented getTx in Sqlite
  • I have implemented getTx in MVar
  • I added properties for getTx and improved on MVar impl as a result

Comments

@paweljakubas paweljakubas added this to the (ADP-323) Get tx by id milestone Jun 24, 2020
@paweljakubas paweljakubas self-assigned this Jun 24, 2020
@paweljakubas paweljakubas force-pushed the paweljakubas/1789/get-tx-by-id branch from 56871c3 to 41ab6f3 Compare June 24, 2020 18:17
@paweljakubas paweljakubas marked this pull request as ready for review June 24, 2020 20:08
@paweljakubas
Copy link
Contributor Author

bors try

iohk-bors bot added a commit that referenced this pull request Jun 24, 2020
@paweljakubas paweljakubas requested review from KtorZ, rvl and Anviking June 24, 2020 20:43
@paweljakubas paweljakubas added the ADDING FEATURE Mark a PR as adding a new feature, for auto-generated CHANGELOG label Jun 24, 2020
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 24, 2020

Copy link
Member

@KtorZ KtorZ left a comment

Choose a reason for hiding this comment

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

Nice work, very clean.
Yet we gotta need a new database query for fetching a single transaction from the database; we can't possibly load the entire history in memory.

[ expectResponseCode HTTP.status200
, expectField (#direction . #getApiT) (`shouldBe` Outgoing)
, expectField (#status . #getApiT) (`shouldBe` Pending)
]
Copy link
Member

Choose a reason for hiding this comment

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

Note that this is subject to race-condition, especially with a slot-length of 0.2s. There are good chances that the transaction is already inserted at this stage. I'd remove this assertion and the next one about the wallet balance (which is collateral to this test), and simply keep the last two assertions of this scenario behind an eventually.

These would be sufficient for this test to show that transactions can be obtained using their ID 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree here. this poses potential race condition - corrected in d898b0d

@@ -839,7 +840,112 @@ spec = do
oJson2 <- expectValidJSON (Proxy @([ApiTransaction n])) o2
length <$> [oJson1, oJson2] `shouldSatisfy` all (== 0)

it "TRANS_DELETE_01 - Cannot forget pending transaction when not pending anymorevia CLI" $ \ctx -> do
it "TRANS_GET_01 - Can get Incoming and Outgoing transaction" $ \ctx -> do
Copy link
Member

Choose a reason for hiding this comment

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

Same comment than for the API scenario applies here too 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in d898b0d

withNoSuchWallet wid $ readCheckpoint pk
txs <- lift $ readTxHistory pk Descending wholeRange Nothing
case (filter txPresent txs) of
[] -> do
Copy link
Member

Choose a reason for hiding this comment

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

Arg! This defies a bit the purpose of such endpoint. Being able to fetch a single transaction should be quick and swift; here we are loading the entire transaction history in memory and filtering it by hand! For exchanges processing MANY transactions a day, that's not going to work (especially because they'll be the primary consumer of this endpoint).

This should be replaced by a single SQL query to retrieve a single transaction from the database 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

introduced getTx in d898b0d and 9f5eba3

@paweljakubas paweljakubas force-pushed the paweljakubas/1789/get-tx-by-id branch from 9622834 to 9f5eba3 Compare June 25, 2020 15:05
@paweljakubas paweljakubas requested a review from KtorZ June 25, 2020 15:54
let err' = ErrNoSuchTransaction tid
throwE (ErrGetTransactionNoSuchTransaction err')
Right (Just tx) ->
pure tx
Copy link
Member

Choose a reason for hiding this comment

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

👍

@paweljakubas paweljakubas force-pushed the paweljakubas/1789/get-tx-by-id branch from d898b0d to 01150fb Compare June 25, 2020 16:32
@paweljakubas
Copy link
Contributor Author

paweljakubas commented Jun 25, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 25, 2020
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 25, 2020

@paweljakubas paweljakubas force-pushed the paweljakubas/1789/get-tx-by-id branch from 01150fb to e454ede Compare June 26, 2020 08:59
@paweljakubas
Copy link
Contributor Author

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 26, 2020
1795: Get tx by id r=paweljakubas a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->
#1789

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added getTransaction endpoint, and all needed implementations, errors
- [x] I have updated swagger
- [x] I have added integration test
- [x] I have added CLI support
- [x] I have updated CLI unit tests
- [x] I have added CLI integration tests
- [x] I have added support in ByronTransaction 
- [x] I have added getTx to DB
- [x] I have implemented getTx in Sqlite
- [x] I have implemented getTx in MVar
- [x] I added properties for getTx and improved on MVar impl as a result

# Comments

<!-- 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: Pawel Jakubas <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 26, 2020

Build failed

@paweljakubas paweljakubas force-pushed the paweljakubas/1789/get-tx-by-id branch from e454ede to 8e071fc Compare June 26, 2020 09:28
@paweljakubas
Copy link
Contributor Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 26, 2020

@iohk-bors iohk-bors bot merged commit 99a48fb into master Jun 26, 2020
@iohk-bors iohk-bors bot deleted the paweljakubas/1789/get-tx-by-id branch June 26, 2020 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADDING FEATURE Mark a PR as adding a new feature, for auto-generated CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants