good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
b94b9b01
Commit
b94b9b01
authored
Sep 18, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Plain Diff
Merge pull request #1817 from obscuren/nonce-fix
core: transaction nonce recovery
parents
216c486a
b60a2762
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/transaction_pool.go
+2
-2
2 additions, 2 deletions
core/transaction_pool.go
core/transaction_pool_test.go
+19
-0
19 additions, 0 deletions
core/transaction_pool_test.go
with
21 additions
and
2 deletions
core/transaction_pool.go
+
2
−
2
View file @
b94b9b01
...
...
@@ -121,8 +121,8 @@ func (pool *TxPool) resetState() {
if
addr
,
err
:=
tx
.
From
();
err
==
nil
{
// Set the nonce. Transaction nonce can never be lower
// than the state nonce; validatePool took care of that.
if
pool
.
pendingState
.
GetNonce
(
addr
)
<
tx
.
Nonce
()
{
pool
.
pendingState
.
SetNonce
(
addr
,
tx
.
Nonce
())
if
pool
.
pendingState
.
GetNonce
(
addr
)
<
=
tx
.
Nonce
()
{
pool
.
pendingState
.
SetNonce
(
addr
,
tx
.
Nonce
()
+
1
)
}
}
}
...
...
This diff is collapsed.
Click to expand it.
core/transaction_pool_test.go
+
19
−
0
View file @
b94b9b01
...
...
@@ -219,3 +219,22 @@ func TestMissingNonce(t *testing.T) {
t
.
Error
(
"expected 1 queued transaction, got"
,
len
(
pool
.
queue
[
addr
]))
}
}
func
TestNonceRecovery
(
t
*
testing
.
T
)
{
const
n
=
10
pool
,
key
:=
setupTxPool
()
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
pool
.
currentState
()
.
SetNonce
(
addr
,
n
)
pool
.
currentState
()
.
AddBalance
(
addr
,
big
.
NewInt
(
100000000000000
))
pool
.
resetState
()
tx
:=
transaction
(
n
,
big
.
NewInt
(
100000
),
key
)
if
err
:=
pool
.
Add
(
tx
);
err
!=
nil
{
t
.
Error
(
err
)
}
// simulate some weird re-order of transactions and missing nonce(s)
pool
.
currentState
()
.
SetNonce
(
addr
,
n
-
1
)
pool
.
resetState
()
if
fn
:=
pool
.
pendingState
.
GetNonce
(
addr
);
fn
!=
n
+
1
{
t
.
Errorf
(
"expected nonce to be %d, got %d"
,
n
+
1
,
fn
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment