-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat(nft): move db lock, add tx fee and confirmations #1989
Conversation
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.
Thanks for the PR! I have few minor notes and one question.
@@ -492,19 +447,18 @@ impl NftTransferHistoryStorageOps for IndexedDbNftStorage { | |||
.await? | |||
.into_iter() | |||
.map(|(_item_id, transfer)| transfer); | |||
let filtered = Self::filter_transfers(transfer_tables, filters)?; | |||
let filtered = filter_transfers(transfer_tables, filters)?; |
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.
As I understand, we fetch all transfers from IndexedDB and apply filters thereafter. Can cursor be used instead?
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.
Yeah, we can build and open cursor and then use while let Some((_item_id, item)) = cursor.next()
to get next item and apply filters. But seems like cursor.next()
doesnt work properly.
I did such impl previously in wasm storage method to filter transfers only with empty metadata. However, GUI got runtime error mm2lib.js:1731 Uncaught Error: closure invoked recursively or after being dropped
. I will send you full logs in dm.
PR where I started to use cursor collect
method.
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.
Did you look for a way to fix the issue with next
? Using collect
or requesting all items from the table will cause excessive memory usage. Also, cursor is used in Zcoin WASM implementation, so we have a possible problem with it too.
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.
I tried to use spawn_local_abortable
function instead of spawn_local
, but to be honest I dont remember where. Didnt work, I think bcz my idea was wrong. As we needed to do hotfix asap we decided to come back to this issue later.
ps: as I can see now collect
method utilizes next
and collect works fine.
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.
I propose to apply the following plan:
- Use
next
instead ofcollect
where applicable. - Check if
Uncaught Error: closure invoked recursively or after being dropped
happens again. - If yes, create an issue in the DeFi framework repo.
- Troubleshoot and fix the problem.
cc @shamardy
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.
I suppose it can be done in the next iteration 🙂
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.
Thanks for the detailed plan @artemii235 , I totally agree with it :)
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.
Next iteration 🙂
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.
Minor notes and question 🙂
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.
Thank you for the PR! First review iteration with only small comments at this stage of the review.
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.
Is this code ported? In the future it would be good to follow these guidelines for ported code #1861 (review) #1861 (comment) so that we can track the changes in the commit history, and it will also be easy for reviewers to check the changes to the original code. It's not required for this PR though as it will be hard to do that.
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.
Oh, I see, Yes, its ported from https://github.com/programatik29/tokio-rusqlite/blob/master/src/lib.rs
In PR description I can provide gist with the info about changes in ported files and in deps for this lib.
Also I will provide the list of commits where I added async con first time and then changed it.
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.
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.
No more notes from my side 🙂
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.
Next Review Iteration :)
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.
Only one last comment!
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.
Great work!
Can we have different PRs for per scope next time? It was quite hard to review (e.g., trying to understand which changes relate each other) for me as the changes contain changes on different logics/scopes.
Some notes from my side:
yeah, sorry for this. Lets try this strategy in next sprint(s). we can create a chain of pull requests, where the base branch of subsequent RP is the feature branch from prev PR. |
44d93f8
to
c9127ff
Compare
The base branch was changed.
Done! |
@laruh if there are any changes to docs for @KomodoPlatform/qa please provide these changes. |
Docs r2r at KomodoPlatform/komodo-docs-mdx#42 |
edit: Never mind, all the "deps added" are already used within the project. |
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.
secure code reviewed
* dev: (22 commits) chore(config): remove vscode launchjson (KomodoPlatform#2040) feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (KomodoPlatform#2015) feat(UTXO): balance event streaming for Electrum clients (KomodoPlatform#2013) feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (KomodoPlatform#1930) fix(p2p): handle encode_and_sign errors (KomodoPlatform#2038) chore(release): add changelog entries for v2.0.0-beta (KomodoPlatform#2037) chore(network): write network information to stdout (KomodoPlatform#2034) fix(price_endpoints): add cached url (KomodoPlatform#2032) deps(network): sync with upstream yamux (KomodoPlatform#2030) fix(config): accept a string as rpcport value (KomodoPlatform#2026) feat(nft): move db lock, add tx fee and confirmations (KomodoPlatform#1989) chore(network): update seednodes for netid 8762 (KomodoPlatform#2024) chore(network): add todo on peer storage behaviour (KomodoPlatform#2025) chore(network): exclude `168.119.236.249` from the seednode list (KomodoPlatform#2021) feat(network): deprecate 7777 network (KomodoPlatform#2020) chore(release): bump mm2 version to 2.0.0-beta (KomodoPlatform#2018) feat(UTXO swaps): kmd burn plan impl (KomodoPlatform#2006) chore(docs): fix the link to simple market maker in README.md (KomodoPlatform#2011) refactor(cli): cli dependency updates and warn on bad config perm (KomodoPlatform#1956) chore(containers and docs): update docs and container images (KomodoPlatform#2003) ... # Conflicts: # mm2src/mm2_main/tests/mm2_tests/mm2_tests_inner.rs # mm2src/mm2_test_helpers/src/for_tests.rs
* dev: (24 commits) chore(release): bump mm2 version to 2.1.0-beta (KomodoPlatform#2044) feat(trezor): add segwit support for withdraw with trezor (KomodoPlatform#1984) chore(config): remove vscode launchjson (KomodoPlatform#2040) feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (KomodoPlatform#2015) feat(UTXO): balance event streaming for Electrum clients (KomodoPlatform#2013) feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (KomodoPlatform#1930) fix(p2p): handle encode_and_sign errors (KomodoPlatform#2038) chore(release): add changelog entries for v2.0.0-beta (KomodoPlatform#2037) chore(network): write network information to stdout (KomodoPlatform#2034) fix(price_endpoints): add cached url (KomodoPlatform#2032) deps(network): sync with upstream yamux (KomodoPlatform#2030) fix(config): accept a string as rpcport value (KomodoPlatform#2026) feat(nft): move db lock, add tx fee and confirmations (KomodoPlatform#1989) chore(network): update seednodes for netid 8762 (KomodoPlatform#2024) chore(network): add todo on peer storage behaviour (KomodoPlatform#2025) chore(network): exclude `168.119.236.249` from the seednode list (KomodoPlatform#2021) feat(network): deprecate 7777 network (KomodoPlatform#2020) chore(release): bump mm2 version to 2.0.0-beta (KomodoPlatform#2018) feat(UTXO swaps): kmd burn plan impl (KomodoPlatform#2006) chore(docs): fix the link to simple market maker in README.md (KomodoPlatform#2011) ...
continuation of this PR.
solves comment and issue.
nft_cache_db
was added inNftCtx
for non wasm target.AsyncConnection
structure was created inmm2src/db_common/src/async_sql_conn.rs
. It can be used as async wrapper for sqlite connection.async_sqlite_connection
field was added inMmCtx
.note:
According to this
transaction_receipt(hash)
can returnNone
for "old" transactions.transaction_receipt
should work fine for swaps, as we need info about the recently broadcasted transaction.deps added
mm2src/db_common/Cargo.toml
tokio = { version = "1.20", default-features = false, features = ["macros"] }
crossbeam-channel = "0.5.1"
futures = "0.3.1"