Skip to content

Conversation

@laruh
Copy link

@laruh laruh commented Oct 11, 2023

continuation of this PR.
solves comment and issue.

  • nft_cache_db was added in NftCtx for non wasm target.
  • Changelog of Async sqlite wrapper gist
  • AsyncConnection structure was created in mm2src/db_common/src/async_sql_conn.rs. It can be used as async wrapper for sqlite connection.
  • async_sqlite_connection field was added in MmCtx.

note:

According to this transaction_receipt(hash) can return None 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"

@laruh laruh changed the title feat(nft): move db lock feat(nft): move db lock, add tx fee and confirmations Oct 25, 2023
@artemii235 artemii235 self-requested a review October 30, 2023 04:42
Copy link

@artemii235 artemii235 left a 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.

.into_iter()
.map(|(_item_id, transfer)| transfer);
let filtered = Self::filter_transfers(transfer_tables, filters)?;
let filtered = filter_transfers(transfer_tables, filters)?;

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?

Copy link
Author

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.

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.

Copy link
Author

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.

Copy link

@artemii235 artemii235 Nov 7, 2023

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:

  1. Use next instead of collect where applicable.
  2. Check if Uncaught Error: closure invoked recursively or after being dropped happens again.
  3. If yes, create an issue in the DeFi framework repo.
  4. Troubleshoot and fix the problem.

cc @shamardy

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 🙂

Copy link
Collaborator

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 :)

@shamardy shamardy changed the base branch from spam-nft-refactor-db to dev November 6, 2023 10:25
@shamardy shamardy changed the base branch from dev to spam-nft-refactor-db November 6, 2023 10:25
@shamardy
Copy link
Collaborator

shamardy commented Nov 6, 2023

@laruh please rebase this PR to dev and then we need to change the base branch in this page.

Edit: After discussions with @laruh, there is no need to rebase now to continue the review process without interrupting it with force pushing.

Copy link

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

Next iteration 🙂

Copy link

@artemii235 artemii235 left a 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 🙂

Copy link
Collaborator

@shamardy shamardy left a 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.

Copy link
Collaborator

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.

Copy link
Author

@laruh laruh Nov 8, 2023

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.

Copy link
Author

Choose a reason for hiding this comment

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

artemii235
artemii235 previously approved these changes Nov 8, 2023
Copy link

@artemii235 artemii235 left a 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 🙂

Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Next Review Iteration :)

Copy link
Collaborator

@shamardy shamardy left a 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!

Copy link
Collaborator

@onur-ozkan onur-ozkan left a 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:

@laruh
Copy link
Author

laruh commented Nov 10, 2023

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.

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.

onur-ozkan
onur-ozkan previously approved these changes Nov 10, 2023
@laruh laruh changed the base branch from spam-nft-refactor-db to dev November 21, 2023 03:49
@laruh laruh dismissed stale reviews from shamardy, onur-ozkan, and artemii235 November 21, 2023 03:49

The base branch was changed.

@laruh
Copy link
Author

laruh commented Nov 21, 2023

@laruh now you need to change the base branch to dev as discussed on DM some time ago

Done!

shamardy
shamardy previously approved these changes Nov 21, 2023
@shamardy
Copy link
Collaborator

@laruh if there are any changes to docs for @KomodoPlatform/qa please provide these changes.

@smk762
Copy link

smk762 commented Nov 27, 2023

Docs r2r at GLEECBTC/komodo-docs-mdx#42

@laruh
Copy link
Author

laruh commented Dec 11, 2023

@smk762 @shamardy added commit 4ba539f which fixes redundant moralis reqs during update_nft call.

@smk762
Copy link

smk762 commented Dec 11, 2023

@smk762 @shamardy added commit 4ba539f which fixes redundant moralis reqs during update_nft call.

tested in isolation and confirmed working

@Alrighttt
Copy link

Alrighttt commented Dec 11, 2023

@laruh please provide a brief justification for each dependency added.

edit: Never mind, all the "deps added" are already used within the project.

@shamardy shamardy merged commit 52dab22 into dev Dec 11, 2023
@shamardy shamardy deleted the nft-move-db-lock branch December 11, 2023 18:08
Copy link

@ca333 ca333 left a comment

Choose a reason for hiding this comment

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

secure code reviewed

@ca333 ca333 requested review from Alrighttt and DeckerSU December 12, 2023 06:48
dimxy pushed a commit to dimxy/komodo-defi-framework that referenced this pull request Dec 21, 2023
* dev: (22 commits)
  chore(config): remove vscode launchjson (GLEECBTC#2040)
  feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (GLEECBTC#2015)
  feat(UTXO): balance event streaming for Electrum clients (GLEECBTC#2013)
  feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (GLEECBTC#1930)
  fix(p2p): handle encode_and_sign errors (GLEECBTC#2038)
  chore(release): add changelog entries for v2.0.0-beta (GLEECBTC#2037)
  chore(network): write network information to stdout (GLEECBTC#2034)
  fix(price_endpoints): add cached url (GLEECBTC#2032)
  deps(network): sync with upstream yamux (GLEECBTC#2030)
  fix(config): accept a string as rpcport value (GLEECBTC#2026)
  feat(nft): move db lock, add tx fee and confirmations (GLEECBTC#1989)
  chore(network): update seednodes for netid 8762 (GLEECBTC#2024)
  chore(network): add todo on peer storage behaviour (GLEECBTC#2025)
  chore(network): exclude `168.119.236.249` from the seednode list (GLEECBTC#2021)
  feat(network): deprecate 7777 network (GLEECBTC#2020)
  chore(release): bump mm2 version to 2.0.0-beta (GLEECBTC#2018)
  feat(UTXO swaps): kmd burn plan impl (GLEECBTC#2006)
  chore(docs): fix the link to simple market maker in README.md (GLEECBTC#2011)
  refactor(cli): cli dependency updates and warn on bad config perm (GLEECBTC#1956)
  chore(containers and docs): update docs and container images (GLEECBTC#2003)
  ...

# Conflicts:
#	mm2src/mm2_main/tests/mm2_tests/mm2_tests_inner.rs
#	mm2src/mm2_test_helpers/src/for_tests.rs
dimxy pushed a commit to dimxy/komodo-defi-framework that referenced this pull request Jan 23, 2024
* dev: (24 commits)
  chore(release): bump mm2 version to 2.1.0-beta (GLEECBTC#2044)
  feat(trezor): add segwit support for withdraw with trezor (GLEECBTC#1984)
  chore(config): remove vscode launchjson (GLEECBTC#2040)
  feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (GLEECBTC#2015)
  feat(UTXO): balance event streaming for Electrum clients (GLEECBTC#2013)
  feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (GLEECBTC#1930)
  fix(p2p): handle encode_and_sign errors (GLEECBTC#2038)
  chore(release): add changelog entries for v2.0.0-beta (GLEECBTC#2037)
  chore(network): write network information to stdout (GLEECBTC#2034)
  fix(price_endpoints): add cached url (GLEECBTC#2032)
  deps(network): sync with upstream yamux (GLEECBTC#2030)
  fix(config): accept a string as rpcport value (GLEECBTC#2026)
  feat(nft): move db lock, add tx fee and confirmations (GLEECBTC#1989)
  chore(network): update seednodes for netid 8762 (GLEECBTC#2024)
  chore(network): add todo on peer storage behaviour (GLEECBTC#2025)
  chore(network): exclude `168.119.236.249` from the seednode list (GLEECBTC#2021)
  feat(network): deprecate 7777 network (GLEECBTC#2020)
  chore(release): bump mm2 version to 2.0.0-beta (GLEECBTC#2018)
  feat(UTXO swaps): kmd burn plan impl (GLEECBTC#2006)
  chore(docs): fix the link to simple market maker in README.md (GLEECBTC#2011)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants