mirror of https://github.com/poanetwork/quorum.git
Transaction signer mismatch fix (#463)
Always use the EIP155 signer for verifying new transactions being added to the transaction pool and only skip protected public transactions from replay attacks until we reach EIP155 activation.
This commit is contained in:
parent
43424382f2
commit
159d813f35
|
@ -220,7 +220,7 @@ func NewTxPool(config TxPoolConfig, chainconfig *params.ChainConfig, chain block
|
|||
config: config,
|
||||
chainconfig: chainconfig,
|
||||
chain: chain,
|
||||
signer: types.MakeSigner(chainconfig, new(big.Int)),
|
||||
signer: types.NewEIP155Signer(chainconfig.ChainId),
|
||||
pending: make(map[common.Address]*txList),
|
||||
queue: make(map[common.Address]*txList),
|
||||
beats: make(map[common.Address]time.Time),
|
||||
|
|
|
@ -32,6 +32,7 @@ import (
|
|||
"time"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// testTxPoolConfig is a transaction pool configuration without stateful disk
|
||||
|
@ -1522,3 +1523,48 @@ func benchmarkPoolBatchInsert(b *testing.B, size int) {
|
|||
pool.AddRemotes(batch)
|
||||
}
|
||||
}
|
||||
|
||||
//Checks that the EIP155 signer is assigned to the TxPool no matter the configuration, even invalid config
|
||||
func TestEIP155SignerOnTxPool(t *testing.T) {
|
||||
var flagtests = []struct {
|
||||
name string
|
||||
homesteadBlock *big.Int
|
||||
eip155Block *big.Int
|
||||
}{
|
||||
{"hsnileip155nil", nil, nil},
|
||||
{"hsnileip1550", nil, big.NewInt(0)},
|
||||
{"hsnileip155100", nil, big.NewInt(100)},
|
||||
{"hs0eip155nil", big.NewInt(0), nil},
|
||||
{"hs0eip1550", big.NewInt(0), big.NewInt(0)},
|
||||
{"hs0eip155100", big.NewInt(0), big.NewInt(100)},
|
||||
{"hs100eip155nil", big.NewInt(100), nil},
|
||||
{"hs100eip1550", big.NewInt(100), big.NewInt(0)},
|
||||
{"hs100eip155100", big.NewInt(100), big.NewInt(100)},
|
||||
}
|
||||
|
||||
for _, tt := range flagtests {
|
||||
t.Run("", func(t *testing.T) {
|
||||
db, _ := ethdb.NewMemDatabase()
|
||||
statedb, _ := state.New(common.Hash{}, state.NewDatabase(db))
|
||||
blockchain := &testBlockChain{statedb, big.NewInt(1000000), new(event.Feed)}
|
||||
|
||||
chainconfig := ¶ms.ChainConfig{
|
||||
ChainId: big.NewInt(10),
|
||||
HomesteadBlock: tt.homesteadBlock,
|
||||
EIP150Block: big.NewInt(0),
|
||||
EIP155Block: tt.eip155Block,
|
||||
EIP158Block: big.NewInt(0),
|
||||
ByzantiumBlock: big.NewInt(0),
|
||||
Ethash: new(params.EthashConfig),
|
||||
}
|
||||
|
||||
pool := NewTxPool(testTxPoolConfig, chainconfig, blockchain)
|
||||
|
||||
if reflect.TypeOf(types.EIP155Signer{}) != reflect.TypeOf(pool.signer) {
|
||||
t.Fail()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -566,7 +566,7 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB
|
|||
from, _ := types.Sender(env.signer, tx)
|
||||
// Check whether the tx is replay protected. If we're not in the EIP155 hf
|
||||
// phase, start ignoring the sender until we do.
|
||||
if tx.Protected() && !env.config.IsEIP155(env.header.Number) {
|
||||
if tx.Protected() && !env.config.IsEIP155(env.header.Number) && !tx.IsPrivate() {
|
||||
log.Trace("Ignoring reply protected transaction", "hash", tx.Hash(), "eip155", env.config.EIP155Block)
|
||||
|
||||
txs.Pop()
|
||||
|
|
Loading…
Reference in New Issue