File tree Expand file tree Collapse file tree
pkg/chain/ethereum/ethutil Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,9 +8,10 @@ import (
88 "github.com/ethereum/go-ethereum/common"
99)
1010
11- // The time for which the nonce value cached locally is valid. The local copy
12- // is invalidated after the certain duration to let the nonce recover in case
13- // the mempool crashed before propagating the last transaction sent.
11+ // The inactivity time after which the local nonce is refreshed with the value
12+ // from the chain. The local value is invalidated after the certain duration to
13+ // let the nonce recover in case the mempool crashed before propagating the last
14+ // transaction sent.
1415const localNonceTrustDuration = 5 * time .Second
1516
1617// NonceManager tracks the nonce for the account and allows to update it after
@@ -89,6 +90,14 @@ func (nm *NonceManager) CurrentNonce() (uint64, error) {
8990 }
9091 }
9192
93+ // After localNonceTrustDuration of inactivity (no CurrentNonce() calls),
94+ // the local copy is considered as no longer up-to-date and it's always
95+ // reset to the pending nonce value as seen by the chain.
96+ //
97+ // We do it to recover from potential mempool crashes.
98+ //
99+ // Keep in mind, the local copy is considered valid as long as transactions
100+ // are submitted one after another.
92101 nm .expirationDate = now .Add (localNonceTrustDuration )
93102
94103 if pendingNonce > nm .localNonce {
You can’t perform that action at this time.
0 commit comments