Merge pull request #667 from kaleido-io/raft-fix-master

Check recovered sender address before including txs in the TransactionsByPriceAndNonce list
This commit is contained in:
Samer Falah 2019-04-03 10:54:19 -04:00 committed by GitHub
commit a5021ac812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
)
@ -401,10 +402,14 @@ func NewTransactionsByPriceAndNonce(signer Signer, txs map[common.Address]Transa
// Initialize a price based heap with the head transactions
heads := make(TxByPrice, 0, len(txs))
for from, accTxs := range txs {
heads = append(heads, accTxs[0])
// Ensure the sender address is from the signer
acc, _ := Sender(signer, accTxs[0])
txs[acc] = accTxs[1:]
acc, err := Sender(signer, accTxs[0])
if (err == nil) {
heads = append(heads, accTxs[0])
txs[acc] = accTxs[1:]
} else {
log.Info("Failed to recovered sender address, this transaction is skipped", "from", from, "nonce", accTxs[0].data.AccountNonce, "err", err)
}
if from != acc {
delete(txs, from)
}