-
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
[r2r] Implement TX history V2 for UTXO coins activated with a Hardware wallet #1467
Conversation
* Add `UtxoTxHistoryOps`, implement it for `BchCoin` * Remove `UtxoStandardOps` implementation for `BchCoin` * TODO implement `WaitForHistoryUpdateTrigger` state
…ardCoin` * Add `taget: MyTxHistoryTarget` field to `my_tx_history` request * Add `utxo_common/utxo_tx_history_common.rs` for TX history related common impl * Add `HDWalletCoinOps::derive_known_addresses` * Refactor `GetTxHistoryFilters` by requiring to set `from_addresses` * Fix `tx_history_v2_tests`
* Implement `UtxoTxHistoryOps` and `CoinWithTxHistoryV2` for `QtumCoin`
* Implement `WaitForHistoryUpdateTrigger` state * Add `ElectrumClient::scripthash_get_history_batch` * Implement `UtxoTxHistoryOps::request_tx_history` according to `DerivationMethod` * Add `CoinBalanceReportOps` trait * Don't spawn legacy tx_history loop on `init_utxo`, `init_qtum` RPCs * Rename `EnableCoinBalance` to `CoinBalanceReport`
* Rename `utxo_tx_history_common.rs` to `utxo_tx_history_v2_common.rs`
…tory V2 * Add `UtxoTxHistoryOps::tx_from_storage_or_rpc` * Fix `CoinWithTxHistoryV2::get_tx_history_filters`, `UtxoTxHistoryOps::request_tx_history`
…ps::tx_details_by_hash`
* Add `UtxoMyAddressesHistoryError` for `UtxoTxHistoryOps::my_addresses` * Optimize `UtxoTxHistoryOps::request_tx_history` by passing `my_addresses` argument
* Use `utxo_common::request_tx_history` for `BchCoin` instead of `utxo_tx_history_v2_common`'s
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 great work! Could you please also add an integration test for history in HD mode similar to https://github.com/KomodoPlatform/atomicDEX-API/blob/e420d60fa1d5df3963418cf25d728ef04c5bbccd/mm2src/mm2_main/src/mm2_tests/bch_and_slp_tests.rs#L390?
mm2src/coins/utxo/bch.rs
Outdated
.compat(), | ||
) | ||
fn process_history_loop(&self, _ctx: MmArc) -> Box<dyn Future<Item = (), Error = ()> + Send> { | ||
warn!("'process_history_loop' is not deprecated for BchCoin! Consider using 'my_tx_history_v2'"); |
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.
It seems you meant is not implemented
or is deprecated
.
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.
Sure!
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.
Done
async fn get_block_timestamp(&self, height: u64) -> MmResult<u64, UtxoRpcError>; | ||
|
||
/// Requests balances of all activated coin's addresses. | ||
async fn get_addresses_balances(&self) -> BalanceResult<HashMap<String, BigDecimal>>; |
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.
my_addresses_balances
seems a more suitable name. I personally would expect this method to accept addresses as argument with current name.
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.
Good note, thank you!
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.
Done
} | ||
|
||
if to_update { | ||
return Self::change_state(FetchingTxHashes::new()); |
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.
In FetchingTxHashes
state, it will fetch history for all addresses - can be quite an overhead. We need only addresses whose balance was changed 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.
Great advice, will do!
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 led to a huge refactoring of some of the TX history storage methods and the TX history states.
I tried to cover most of the cases in tx_history_v2_tests.rs
module.
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! Only minor non-blocker comments
* Optimize TX history states by specifying `FetchingTxHashes::fetch_for_addresses` * Rename `UtxoTxHistoryOps::get_addresses_balances` to `my_addresses_balances` * Add `UtxoTxHistoryOps::address_from_str` to parse addresses within `UtxoTxHistoryOps::my_addresses_balances` result * Add `AddrFromStrError`
… function * Add `SqlQuery::count_distinct`
…s` and `get_unconfirmed_txes_from_history` functions
* Fix `SqlTxHistoryStorage` to repeat the same ordering as in `compare_transaction_details` * Fix tests * Use `utxo_common::utxo_tx_history_v2_common::request_tx_history` within for BCH coin * Move `utxo_coin_fields_for_test` to `utxo_common_tests.rs`
* Add `T_BCH_ELECTRUMS` listening on WSS port
@artemii235 @shamardy this PR is ready for review |
No description provided.