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

fix: don't mark tx as REVERTED when in block, check tx receipt status instead. #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tmilar
Copy link

@tmilar tmilar commented Sep 1, 2020

Fixes #81.

@@ -83,11 +83,21 @@ export async function getTransaction(

const receipt = await eth.getTransactionReceipt(hash)

if (receipt == null) {
Copy link
Contributor

@nachomazzara nachomazzara Sep 2, 2020

Choose a reason for hiding this comment

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

I'm not sure about this, sometimes the tx can be dropped or reorg leaving it outside the main-chain. If I'm not wrong, the receipt will be null too leaving it forever loading.

Maybe if receipt == null we can check again what we do at line 53.

What was the case that motivates the PR?

Copy link
Author

@tmilar tmilar Sep 2, 2020

Choose a reason for hiding this comment

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

If it would get dropped, then wouldn't it be checked later on and moved from "pending" to "dropped" status?

Motivation for this PR: I was sending transactions in my app and listening to later actions FETCH_TRANSACTION_SUCCESS and FETCH_TRANSACTION_FAILURE, to update/refresh my app status accordingly. It became a problem though when I was
wrongly having FETCH_TRANSACTION_FAILURE as if they were reverted, when they actually weren't.

Copy link
Contributor

@nachomazzara nachomazzara Sep 2, 2020

Choose a reason for hiding this comment

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

Cool! do you have examples?

Dropped & replaced yes, will happen what you said. But it was reorg and not included in the chain the tx will be a ghost one like it never happened.

Copy link
Author

Choose a reason for hiding this comment

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

I was just creating a transaction, and listening to updates by using selectors to grab pending/confirmed transactions from the redux state.

Not sure how to handle the reorg case. In this scenario, what would be the expected result? Following the original code logic + your logic, I think you imply that it should be marked as Reverted? However maybe that is a different issue, in order to be sure if the tx was actually placed in the main-chain (ie. "confirmed ~100%"?) , there should be some check of the # of confirmations, and act on the tx result after asserting that enough confirmations have been achieved.

The current change on this PR, just keeps the tx status as "Pending" (instead of wrongly "Reverted"), until more information is available to say otherwise. Should this change also include logic about the block hash and # confirmations? This SO answer proposes a strategy for achieving this

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this change also include logic about the block hash and # confirmations? This SO answer proposes a strategy for achieving this.

This is exactly what I was trying to explain.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tmilar is this still in your backlog?

Copy link
Author

Choose a reason for hiding this comment

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

Hi @nachomazzara , I'm sorry but I'm not actively working on this project anymore.
Though if it still matters to you let me know, I can make an effort to complete the PR when I have some free time.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great if you can complete it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrongly marking a transaction as "reverted" when it didn't
3 participants