mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-16 18:00:46 +00:00
core, miner: fix inconsistent tx blacklist enforcement, close XFN-98 (#1674)
This commit is contained in:
parent
3b3aa9b013
commit
f8553d5871
3 changed files with 17 additions and 16 deletions
|
|
@ -94,7 +94,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, tra
|
||||||
// Iterate over and process the individual transactions
|
// Iterate over and process the individual transactions
|
||||||
for i, tx := range block.Transactions() {
|
for i, tx := range block.Transactions() {
|
||||||
// check black-list txs after hf
|
// check black-list txs after hf
|
||||||
if (block.Number().Uint64() >= common.BlackListHFNumber) && !common.IsTestnet {
|
if block.Number().Uint64() >= common.BlackListHFNumber {
|
||||||
// check if sender is in black list
|
// check if sender is in black list
|
||||||
if common.IsInBlacklist(tx.From()) {
|
if common.IsInBlacklist(tx.From()) {
|
||||||
return nil, nil, 0, fmt.Errorf("block contains transaction with sender in black-list: %v", tx.From().Hex())
|
return nil, nil, 0, fmt.Errorf("block contains transaction with sender in black-list: %v", tx.From().Hex())
|
||||||
|
|
@ -187,7 +187,7 @@ func (p *StateProcessor) ProcessBlockNoValidator(cBlock *CalculatedBlock, stated
|
||||||
receipts = make([]*types.Receipt, block.Transactions().Len())
|
receipts = make([]*types.Receipt, block.Transactions().Len())
|
||||||
for i, tx := range block.Transactions() {
|
for i, tx := range block.Transactions() {
|
||||||
// check black-list txs after hf
|
// check black-list txs after hf
|
||||||
if (block.Number().Uint64() >= common.BlackListHFNumber) && !common.IsTestnet {
|
if block.Number().Uint64() >= common.BlackListHFNumber {
|
||||||
// check if sender is in black list
|
// check if sender is in black list
|
||||||
if common.IsInBlacklist(tx.From()) {
|
if common.IsInBlacklist(tx.From()) {
|
||||||
return nil, nil, 0, fmt.Errorf("block contains transaction with sender in black-list: %v", tx.From().Hex())
|
return nil, nil, 0, fmt.Errorf("block contains transaction with sender in black-list: %v", tx.From().Hex())
|
||||||
|
|
|
||||||
|
|
@ -630,13 +630,20 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||||
if uint64(tx.Size()) > txMaxSize {
|
if uint64(tx.Size()) > txMaxSize {
|
||||||
return ErrOversizedData
|
return ErrOversizedData
|
||||||
}
|
}
|
||||||
// check if sender is in black list
|
// Get current block number
|
||||||
if common.IsInBlacklist(tx.From()) {
|
var number *big.Int = nil
|
||||||
return fmt.Errorf("reject transaction with sender in black-list: %v", tx.From().Hex())
|
if pool.chain.CurrentHeader() != nil {
|
||||||
|
number = pool.chain.CurrentHeader().Number
|
||||||
}
|
}
|
||||||
// check if receiver is in black list
|
if number == nil || number.Uint64() >= common.BlackListHFNumber {
|
||||||
if common.IsInBlacklist(tx.To()) {
|
// check if sender is in black list
|
||||||
return fmt.Errorf("reject transaction with receiver in black-list: %v", tx.To().Hex())
|
if common.IsInBlacklist(tx.From()) {
|
||||||
|
return fmt.Errorf("reject transaction with sender in black-list: %v", tx.From().Hex())
|
||||||
|
}
|
||||||
|
// check if receiver is in black list
|
||||||
|
if common.IsInBlacklist(tx.To()) {
|
||||||
|
return fmt.Errorf("reject transaction with receiver in black-list: %v", tx.To().Hex())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Transactions can't be negative. This may never happen using RLP decoded
|
// Transactions can't be negative. This may never happen using RLP decoded
|
||||||
// transactions but may occur if you create a transaction using the RPC.
|
// transactions but may occur if you create a transaction using the RPC.
|
||||||
|
|
@ -691,10 +698,6 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||||
// cost == V + GP * GL
|
// cost == V + GP * GL
|
||||||
balance := pool.currentState.GetBalance(from)
|
balance := pool.currentState.GetBalance(from)
|
||||||
cost := tx.Cost()
|
cost := tx.Cost()
|
||||||
var number *big.Int = nil
|
|
||||||
if pool.chain.CurrentHeader() != nil {
|
|
||||||
number = pool.chain.CurrentHeader().Number
|
|
||||||
}
|
|
||||||
minGasPrice := common.GetMinGasPrice(number)
|
minGasPrice := common.GetMinGasPrice(number)
|
||||||
feeCapacity := big.NewInt(0)
|
feeCapacity := big.NewInt(0)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -919,8 +919,7 @@ func (w *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Addr
|
||||||
// first priority for special Txs
|
// first priority for special Txs
|
||||||
for _, tx := range specialTxs {
|
for _, tx := range specialTxs {
|
||||||
to := tx.To()
|
to := tx.To()
|
||||||
//HF number for black-list
|
if w.header.Number.Uint64() >= common.BlackListHFNumber {
|
||||||
if (w.header.Number.Uint64() >= common.BlackListHFNumber) && !common.IsTestnet {
|
|
||||||
from := tx.From()
|
from := tx.From()
|
||||||
// check if sender is in black list
|
// check if sender is in black list
|
||||||
if common.IsInBlacklist(from) {
|
if common.IsInBlacklist(from) {
|
||||||
|
|
@ -1029,9 +1028,8 @@ func (w *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Addr
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
//HF number for black-list
|
|
||||||
to := tx.To()
|
to := tx.To()
|
||||||
if (w.header.Number.Uint64() >= common.BlackListHFNumber) && !common.IsTestnet {
|
if w.header.Number.Uint64() >= common.BlackListHFNumber {
|
||||||
from := tx.From()
|
from := tx.From()
|
||||||
// check if sender is in black list
|
// check if sender is in black list
|
||||||
if common.IsInBlacklist(from) {
|
if common.IsInBlacklist(from) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue