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

Rewrite confirmTransaction to handle re-orgs #3611

Closed
GregTheGreek opened this issue Jun 30, 2020 · 5 comments
Closed

Rewrite confirmTransaction to handle re-orgs #3611

GregTheGreek opened this issue Jun 30, 2020 · 5 comments
Labels
1.x 1.0 related issues Bug Addressing a bug Discussion Stale Has not received enough activity

Comments

@GregTheGreek
Copy link
Contributor

Problem

#3608 discovered a bug where confirmTransaction doesn't properly handle a re-org. It is most likely occurring within this code block, because there is no concept of a start/previous block theres no ability to perform a check for inconsistencies between blocks.

Potential solution

We probably want to track a few different things:

  • StartBlock - When we began polling
  • PreviousBlock - The block that we just checked (Note: this is not block -1, we must actually cache the received block)
  • IncludedBlock - The block that the transaction was included in

This way we can do a check such as (very naive): currentBlockNumber - PrevioudBlockNumber == 1 to ensure that we're on the sequential chain. We may also want to double check that the includedBlock hasn't changed with the incoming receipt. Doing those checks could identify a reorg took place. To properly account for the number of confirmations the counter, found on line 334 should actually be computed by using currentBlockNumber - PreviousBlockNumber so it can reset if there is a re-org. I believe doing that alone, would probably solve this issue, but it might be interesting to see if we want to log a re-org.

I found an stackoverflow that can be used as inspiration.

cc: @cgewecke

@GregTheGreek GregTheGreek added Bug Addressing a bug Discussion 1.x 1.0 related issues labels Jun 30, 2020
@benjamincburns
Copy link
Contributor

I'm writing a new TransactionManager because of #3632. If I can't fix this issue as part of the initial PR, I'll at least do my best to lay some groundwork. At the very least, the code I submit will be a lot more readable than what's there today.

@GregTheGreek
Copy link
Contributor Author

That would be awesome!

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

@github-actions github-actions bot added the Stale Has not received enough activity label Aug 14, 2020
@GregTheGreek GregTheGreek removed the Stale Has not received enough activity label Aug 14, 2020
@GregTheGreek
Copy link
Contributor Author

@benjamincburns just want to confirm you're not touching on this anymore?

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Bug Addressing a bug Discussion Stale Has not received enough activity
Projects
None yet
Development

No branches or pull requests

2 participants