mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 22:32:15 +00:00
* mempool: remove only valid (Code==0) txs on Update so evil proposers can't drop valid txs in Commit stage. Also remove invalid (Code!=0) txs from the cache so they can be resubmitted. Fixes #3322 @rickyyangz: In the end of commit stage, we will update mempool to remove all the txs in current block. // Update mempool. err = blockExec.mempool.Update( block.Height, block.Txs, TxPreCheck(state), TxPostCheck(state), ) Assum an account has 3 transactions in the mempool, the sequences are 100, 101 and 102 separately, So an evil proposal can only package the 101 and 102 transactions into its proposal block, and leave 100 still in mempool, then the two txs will be removed from all validators' mempool when commit. So the account lost the two valid txs. @ebuchman: In the longer term we may want to do something like #2639 so we can validate txs before we commit the block. But even in this case we'd only want to run the equivalent of CheckTx, which means the DeliverTx could still fail even if the CheckTx passes depending on how the app handles the ABCI Code semantics. So more work will be required around the ABCI code. See also #2185 * add changelog entry and tests * improve changelog message * reformat code
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package mock
|
|
|
|
import (
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
"github.com/tendermint/tendermint/libs/clist"
|
|
mempl "github.com/tendermint/tendermint/mempool"
|
|
"github.com/tendermint/tendermint/types"
|
|
)
|
|
|
|
// Mempool is an empty implementation of a Mempool, useful for testing.
|
|
type Mempool struct{}
|
|
|
|
var _ mempl.Mempool = Mempool{}
|
|
|
|
func (Mempool) Lock() {}
|
|
func (Mempool) Unlock() {}
|
|
func (Mempool) Size() int { return 0 }
|
|
func (Mempool) CheckTx(_ types.Tx, _ func(*abci.Response)) error {
|
|
return nil
|
|
}
|
|
func (Mempool) CheckTxWithInfo(_ types.Tx, _ func(*abci.Response),
|
|
_ mempl.TxInfo) error {
|
|
return nil
|
|
}
|
|
func (Mempool) ReapMaxBytesMaxGas(_, _ int64) types.Txs { return types.Txs{} }
|
|
func (Mempool) ReapMaxTxs(n int) types.Txs { return types.Txs{} }
|
|
func (Mempool) Update(
|
|
_ int64,
|
|
_ types.Txs,
|
|
_ []*abci.ResponseDeliverTx,
|
|
_ mempl.PreCheckFunc,
|
|
_ mempl.PostCheckFunc,
|
|
) error {
|
|
return nil
|
|
}
|
|
func (Mempool) Flush() {}
|
|
func (Mempool) FlushAppConn() error { return nil }
|
|
func (Mempool) TxsAvailable() <-chan struct{} { return make(chan struct{}) }
|
|
func (Mempool) EnableTxsAvailable() {}
|
|
func (Mempool) TxsBytes() int64 { return 0 }
|
|
|
|
func (Mempool) TxsFront() *clist.CElement { return nil }
|
|
func (Mempool) TxsWaitChan() <-chan struct{} { return nil }
|
|
|
|
func (Mempool) InitWAL() {}
|
|
func (Mempool) CloseWAL() {}
|