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: Eliminate local transaction nonce cache. #4839

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

attila-lendvai
Copy link
Collaborator

@attila-lendvai attila-lendvai commented Sep 28, 2024

WARNING: i'm not experienced in golang, and i don't know the bee internals either. this commit requires review by someone who understands the codebase.

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Stop keeping the next nonce in our local state. Instead we always calculate it from the blockchain nonce and the local list of pending transactions.

Motivation and Context (Optional)

Fixes issue #4826 where the local nonce cache was out of sync with the blockchain for an unknown reason. Because of that no transactions got incorporated into the blockchain. This made it impossible to unstake or to participation in the reserve incentives, probably forever (until fixed).

It only became apparent when i tried to unstake my nodes at the v2.2.0 upgrade, and some of them got stuck. It also explains why i stopped seeing rewards on my nodes.

With this commit on top of v2.1.0 i've successfully unstaked a previously hung node.

And an eternal guiding principle: do not optimize any program until it works as specified. And the only exception is when it's so slow that it substantially hinders development.

A potential unaddressed issue

If a third party creates a transaction, then the bee's transactions may get stuck. There should be a check that the blockchain nonce is lower than the lowest nonce in our pending tx list. If not, then the nonce of the pending tx'es should be updated.

@janos
Copy link
Member

janos commented Sep 30, 2024

Hi Attila, thanks. This is a nice improvement, but it may need even more changes. The transaction monitor main loop may be problematic and blocking while it does not need to be. This has to be debugged more, but certainly this change is a good step.

TestTransactionSend needs to be adjusted as it fails currently.

Stop keeping the next nonce in our local state. Instead we always
calculate it from the blockchain nonce and the local pending
transactions.

Fixes issue ethersphere#4826 where the local nonce cache was out of sync with the
blockchain for an unknown reason and because of that no transactions
got incorporated into the blockchain. This made unstaking or
participation in the reserve incentives impossible.

Tests adjusted by @martinconic.
Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

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

👍

@martinconic martinconic merged commit e4e4520 into ethersphere:master Oct 8, 2024
14 checks passed
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