Skip to content

Commit

Permalink
core, light: allow zero cost txs from inexistent accounts too
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed Dec 16, 2016
1 parent 38827dd commit c44830e
Showing 3 changed files with 9 additions and 32 deletions.
24 changes: 8 additions & 16 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
@@ -37,15 +37,14 @@ import (

var (
// Transaction Pool Errors
ErrInvalidSender = errors.New("Invalid sender")
ErrNonce = errors.New("Nonce too low")
ErrCheap = errors.New("Gas price too low for acceptance")
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")
ErrIntrinsicGas = errors.New("Intrinsic gas too low")
ErrGasLimit = errors.New("Exceeds block gas limit")
ErrNegativeValue = errors.New("Negative value")
ErrInvalidSender = errors.New("Invalid sender")
ErrNonce = errors.New("Nonce too low")
ErrCheap = errors.New("Gas price too low for acceptance")
ErrBalance = errors.New("Insufficient balance")
ErrInsufficientFunds = errors.New("Insufficient funds for gas * price + value")
ErrIntrinsicGas = errors.New("Intrinsic gas too low")
ErrGasLimit = errors.New("Exceeds block gas limit")
ErrNegativeValue = errors.New("Negative value")
)

var (
@@ -287,13 +286,6 @@ func (pool *TxPool) validateTx(tx *types.Transaction) error {
if err != nil {
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
if currentState.GetNonce(from) > tx.Nonce() {
return ErrNonce
4 changes: 0 additions & 4 deletions core/tx_pool_test.go
Original file line number Diff line number Diff line change
@@ -129,10 +129,6 @@ func TestInvalidTransactions(t *testing.T) {
pool, key := setupTxPool()

tx := transaction(0, big.NewInt(100), key)
if err := pool.Add(tx); err != ErrNonExistentAccount {
t.Error("expected", ErrNonExistentAccount)
}

from, _ := deriveSender(tx)
currentState, _ := pool.currentState()
currentState.AddBalance(from, big.NewInt(1))
13 changes: 1 addition & 12 deletions light/txpool.go
Original file line number Diff line number Diff line change
@@ -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 {
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
currentState := pool.currentState()
if n, err := currentState.GetNonce(ctx, from); err == nil {
if n > tx.Nonce() {
return core.ErrNonce

0 comments on commit c44830e

Please sign in to comment.