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

[r2r]Tx wait for confirmation error return fix #1443

Closed
wants to merge 9 commits into from

Conversation

borngraced
Copy link
Member

I can confirm that wait_for_confirmation is used correctly in other protocols
fixes #1442

@borngraced borngraced requested a review from shamardy August 15, 2022 04:47
@borngraced borngraced self-assigned this Aug 15, 2022
@borngraced borngraced changed the title Tx wait for confirmation error return fix [r2r]Tx wait for confirmation error return fix Aug 15, 2022
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.

Good start :)
First review iteration!

@@ -173,6 +173,12 @@ impl UtxoRpcClientEnum {
}
},
Err(e) => {
if matches!(&e.get_inner(), UtxoRpcError::Transport(_))
&& e.to_string().contains("No information available about transaction")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not a good practice to check for a certain string in the error returned since this string can be changed in blockchain code and/or can be different for different coins, for instance this message can be returned from the bitcoin daemon https://github.com/bitcoin/bitcoin/blob/c5ba1d92b633e703c25121c0d73dc0e04baae01b/src/rpc/rawtransaction.cpp#L260

It's better to check for error codes instead. Fortunately, we already have such check since this is the error code for a missing transaction https://github.com/KomodoPlatform/atomicDEX-API/blob/317510d9a85ba6ca3aa71831d0494ca52444c3d9/mm2src/coins/utxo/rpc_clients.rs#L70
and there is a function that returns a transaction if it's on-chain or None otherwise https://github.com/KomodoPlatform/atomicDEX-API/blob/317510d9a85ba6ca3aa71831d0494ca52444c3d9/mm2src/coins/utxo/rpc_clients.rs#L355
I think you will need to implement another function similar to the above one for verbose transactions and use it instead of get_verbose_transaction.

Also to check for this error code for Transport error, I think you will need to refactor JsonRpcErrorType :: Transport https://github.com/KomodoPlatform/atomicDEX-API/blob/317510d9a85ba6ca3aa71831d0494ca52444c3d9/mm2src/common/jsonrpc_client.rs#L245

And this part of transport fn
https://github.com/KomodoPlatform/atomicDEX-API/blob/317510d9a85ba6ca3aa71831d0494ca52444c3d9/mm2src/coins/utxo/rpc_clients.rs#L670-L679

Copy link
Member Author

Choose a reason for hiding this comment

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

Do I really need to do this? Since I can just create a helper function to check for this instead of adding new trait method?

I think you will need to implement another function similar to the above one for verbose transactions and use it instead of get_verbose_transaction.

Copy link
Member Author

Choose a reason for hiding this comment

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

I refactored the error type for Transport and added an helper function to check for the error code instead

@borngraced borngraced changed the title [r2r]Tx wait for confirmation error return fix [wip]Tx wait for confirmation error return fix Aug 15, 2022
@borngraced borngraced changed the title [wip]Tx wait for confirmation error return fix [r2r]Tx wait for confirmation error return fix Aug 17, 2022
@borngraced
Copy link
Member Author

@shamardy it's ready for another round of review

onur-ozkan and others added 3 commits August 17, 2022 09:01
* refactor p2p message processing flow

Signed-off-by: ozkanonur <work@onurozkan.dev>

* drop `message` mutability in `process_p2p_message`

Signed-off-by: ozkanonur <work@onurozkan.dev>

* refactor `fn tx_enum_from_bytes` error type

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* check topics in `lp_topic_list_validation`

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* optimize

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* check if there is any byte left in tx deserialization

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* add backwards comparison in `fn deserialization`

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* rollback 78c6810

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* set JEMALLOC_SYS_WITH_MALLOC_CONF on build pipelines

Signed-off-by: ozkanonur <work@onurozkan.dev>

* Update README.md

* add `_` to unused variables

Signed-off-by: ozkanonur <work@onurozkan.dev>

* refactor `lp_topic_list_validation` as `topic_prefix_and_coin_validation`

Signed-off-by: ozkanonur <work@onurozkan.dev>

* fix reviews

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* update `tx_enum_from_bytes` and write unit test

Signed-off-by: ozkanonur <work@onurozkan.dev>

* update `tx_enum_from_bytes` in tendermint

Signed-off-by: ozkanonur <work@onurozkan.dev>

* update error log of `process_p2p_message`

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* create `TxMarshalingErr`

Signed-off-by: ozkanonur <work@onurozkan.dev>

* fix `test_tx_enum_from_bytes`

Signed-off-by: ozkanonur <work@onurozkan.dev>

* fix test compilation

Signed-off-by: ozkanonur <work@onurozkan.dev>

Signed-off-by: ozkanonur <work@onurozkan.dev>
Signed-off-by: Onur Özkan <work@onurozkan.dev>
@borngraced borngraced closed this Aug 17, 2022
@borngraced borngraced deleted the tx_wait_for_confirmation_fix branch August 17, 2022 08:50
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.

3 participants