Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
c44830eb
Unverified
Commit
c44830eb
authored
Dec 16, 2016
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core, light: allow zero cost txs from inexistent accounts too
parent
38827dd9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
32 deletions
+9
-32
tx_pool.go
core/tx_pool.go
+8
-16
tx_pool_test.go
core/tx_pool_test.go
+0
-4
txpool.go
light/txpool.go
+1
-12
No files found.
core/tx_pool.go
View file @
c44830eb
...
@@ -37,15 +37,14 @@ import (
...
@@ -37,15 +37,14 @@ import (
var
(
var
(
// Transaction Pool Errors
// Transaction Pool Errors
ErrInvalidSender
=
errors
.
New
(
"Invalid sender"
)
ErrInvalidSender
=
errors
.
New
(
"Invalid sender"
)
ErrNonce
=
errors
.
New
(
"Nonce too low"
)
ErrNonce
=
errors
.
New
(
"Nonce too low"
)
ErrCheap
=
errors
.
New
(
"Gas price too low for acceptance"
)
ErrCheap
=
errors
.
New
(
"Gas price too low for acceptance"
)
ErrBalance
=
errors
.
New
(
"Insufficient balance"
)
ErrBalance
=
errors
.
New
(
"Insufficient balance"
)
ErrNonExistentAccount
=
errors
.
New
(
"Account does not exist or account balance too low"
)
ErrInsufficientFunds
=
errors
.
New
(
"Insufficient funds for gas * price + value"
)
ErrInsufficientFunds
=
errors
.
New
(
"Insufficient funds for gas * price + value"
)
ErrIntrinsicGas
=
errors
.
New
(
"Intrinsic gas too low"
)
ErrIntrinsicGas
=
errors
.
New
(
"Intrinsic gas too low"
)
ErrGasLimit
=
errors
.
New
(
"Exceeds block gas limit"
)
ErrGasLimit
=
errors
.
New
(
"Exceeds block gas limit"
)
ErrNegativeValue
=
errors
.
New
(
"Negative value"
)
ErrNegativeValue
=
errors
.
New
(
"Negative value"
)
)
)
var
(
var
(
...
@@ -287,13 +286,6 @@ func (pool *TxPool) validateTx(tx *types.Transaction) error {
...
@@ -287,13 +286,6 @@ func (pool *TxPool) validateTx(tx *types.Transaction) error {
if
err
!=
nil
{
if
err
!=
nil
{
return
ErrInvalidSender
return
ErrInvalidSender
}
}
// Make sure the account exist. Non existent accounts
// haven't got funds and well therefor never pass.
if
!
currentState
.
Exist
(
from
)
{
return
ErrNonExistentAccount
}
// Last but not least check for nonce errors
// Last but not least check for nonce errors
if
currentState
.
GetNonce
(
from
)
>
tx
.
Nonce
()
{
if
currentState
.
GetNonce
(
from
)
>
tx
.
Nonce
()
{
return
ErrNonce
return
ErrNonce
...
...
core/tx_pool_test.go
View file @
c44830eb
...
@@ -129,10 +129,6 @@ func TestInvalidTransactions(t *testing.T) {
...
@@ -129,10 +129,6 @@ func TestInvalidTransactions(t *testing.T) {
pool
,
key
:=
setupTxPool
()
pool
,
key
:=
setupTxPool
()
tx
:=
transaction
(
0
,
big
.
NewInt
(
100
),
key
)
tx
:=
transaction
(
0
,
big
.
NewInt
(
100
),
key
)
if
err
:=
pool
.
Add
(
tx
);
err
!=
ErrNonExistentAccount
{
t
.
Error
(
"expected"
,
ErrNonExistentAccount
)
}
from
,
_
:=
deriveSender
(
tx
)
from
,
_
:=
deriveSender
(
tx
)
currentState
,
_
:=
pool
.
currentState
()
currentState
,
_
:=
pool
.
currentState
()
currentState
.
AddBalance
(
from
,
big
.
NewInt
(
1
))
currentState
.
AddBalance
(
from
,
big
.
NewInt
(
1
))
...
...
light/txpool.go
View file @
c44830eb
...
@@ -346,19 +346,8 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error
...
@@ -346,19 +346,8 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error
if
from
,
err
=
types
.
Sender
(
pool
.
signer
,
tx
);
err
!=
nil
{
if
from
,
err
=
types
.
Sender
(
pool
.
signer
,
tx
);
err
!=
nil
{
return
core
.
ErrInvalidSender
return
core
.
ErrInvalidSender
}
}
// Make sure the account exist. Non existent accounts
// haven't got funds and well therefor never pass.
currentState
:=
pool
.
currentState
()
if
h
,
err
:=
currentState
.
HasAccount
(
ctx
,
from
);
err
==
nil
{
if
!
h
{
return
core
.
ErrNonExistentAccount
}
}
else
{
return
err
}
// Last but not least check for nonce errors
// Last but not least check for nonce errors
currentState
:=
pool
.
currentState
()
if
n
,
err
:=
currentState
.
GetNonce
(
ctx
,
from
);
err
==
nil
{
if
n
,
err
:=
currentState
.
GetNonce
(
ctx
,
from
);
err
==
nil
{
if
n
>
tx
.
Nonce
()
{
if
n
>
tx
.
Nonce
()
{
return
core
.
ErrNonce
return
core
.
ErrNonce
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment