Skip to content

Commit

Permalink
Revert "Add ResetUpdate, so non-block proposers no longer fail to sync (
Browse files Browse the repository at this point in the history
#113)"

This reverts commit 158bcbe.
  • Loading branch information
ValarDragon committed Jun 27, 2024
1 parent 9f773de commit 6ecf14c
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 37 deletions.
1 change: 0 additions & 1 deletion blocksync/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func newReactor(
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
mp.On("ResetUpdate").Return()
mp.On("FlushAppConn", mock.Anything).Return(nil)
mp.On("Update",
mock.Anything,
Expand Down
1 change: 0 additions & 1 deletion consensus/replay_stubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var _ mempl.Mempool = emptyMempool{}

func (emptyMempool) Lock() {}
func (emptyMempool) Unlock() {}
func (emptyMempool) ResetUpdate() {}
func (emptyMempool) Size() int { return 0 }
func (emptyMempool) SizeBytes() int64 { return 0 }
func (emptyMempool) CheckTx(_ types.Tx, _ func(*abci.Response), _ mempl.TxInfo) error {
Expand Down
4 changes: 0 additions & 4 deletions mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ type Mempool interface {
// Unlock unlocks the mempool.
Unlock()

// Cancel's any ongoing mempool Update. Safe to call while Mempool is locked.
// As a consequence, the Lock'd thread is expected to terminate soon after this is called.
ResetUpdate()

// Update informs the mempool that the given txs were committed and can be
// discarded.
//
Expand Down
5 changes: 0 additions & 5 deletions mempool/mocks/mempool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions mempool/nop_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ func (*NopMempool) Lock() {}
// Unlock does nothing.
func (*NopMempool) Unlock() {}

func (*NopMempool) ResetUpdate() {}

// Update does nothing.
func (*NopMempool) Update(
int64,
Expand Down
16 changes: 2 additions & 14 deletions mempool/v0/clist_mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ type CListMempool struct {
// Track whether we're rechecking txs.
// These are not protected by a mutex and are expected to be mutated in
// serial (ie. by abci responses which are called in serial).
recheckCursor *clist.CElement // next expected response
recheckEnd *clist.CElement // re-checking stops here
stopRechecking atomic.Bool
recheckCursor *clist.CElement // next expected response
recheckEnd *clist.CElement // re-checking stops here

// Map for quick access to txs to record sender in CheckTx.
// txsMap: txKey -> CElement
Expand Down Expand Up @@ -141,11 +140,6 @@ func (mem *CListMempool) Unlock() {
mem.updateMtx.Unlock()
}

// Safe for concurrent use by multiple goroutines.
func (mem *CListMempool) ResetUpdate() {
mem.stopRechecking.Store(true)
}

// Safe for concurrent use by multiple goroutines.
func (mem *CListMempool) Size() int {
return mem.txs.Len()
Expand Down Expand Up @@ -665,7 +659,6 @@ func (mem *CListMempool) Update(
}

func (mem *CListMempool) recheckTxs() {
mem.stopRechecking.Store(false)
if mem.Size() == 0 {
panic("recheckTxs is called, but the mempool is empty")
}
Expand All @@ -676,18 +669,13 @@ func (mem *CListMempool) recheckTxs() {
// Push txs to proxyAppConn
// NOTE: globalCb may be called concurrently.
for e := mem.txs.Front(); e != nil; e = e.Next() {
if mem.stopRechecking.Load() {
break
}

memTx := e.Value.(*mempoolTx)
mem.proxyAppConn.CheckTxAsync(abci.RequestCheckTx{
Tx: memTx.tx,
Type: abci.CheckTxType_Recheck,
})
}

mem.stopRechecking.Store(false)
mem.proxyAppConn.FlushAsync()
}

Expand Down
2 changes: 0 additions & 2 deletions mempool/v1/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ func (txmp *TxMempool) Lock() { txmp.mtx.Lock() }
// Unlock releases a write-lock on the mempool.
func (txmp *TxMempool) Unlock() { txmp.mtx.Unlock() }

func (txmp *TxMempool) ResetUpdate() {}

// Size returns the number of valid transactions in the mempool. It is
// thread-safe.
func (txmp *TxMempool) Size() int { return txmp.txs.Len() }
Expand Down
1 change: 0 additions & 1 deletion state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ func (blockExec *BlockExecutor) Commit(
block *types.Block,
deliverTxResponses []*abci.ResponseDeliverTx,
) ([]byte, int64, error) {
blockExec.mempool.ResetUpdate()
blockExec.mempool.Lock()
unlockMempool := func() { blockExec.mempool.Unlock() }

Expand Down
4 changes: 0 additions & 4 deletions state/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func TestApplyBlock(t *testing.T) {
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
mp.On("ResetUpdate").Return()
mp.On("FlushAppConn", mock.Anything).Return(nil)
mp.On("Update",
mock.Anything,
Expand Down Expand Up @@ -223,7 +222,6 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
mp.On("ResetUpdate").Return()
mp.On("FlushAppConn", mock.Anything).Return(nil)
mp.On("Update",
mock.Anything,
Expand Down Expand Up @@ -480,7 +478,6 @@ func TestEndBlockValidatorUpdates(t *testing.T) {
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
mp.On("ResetUpdate").Return()
mp.On("FlushAppConn", mock.Anything).Return(nil)
mp.On("Update",
mock.Anything,
Expand Down Expand Up @@ -607,7 +604,6 @@ func TestEmptyPrepareProposal(t *testing.T) {
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
mp.On("ResetUpdate").Return()
mp.On("FlushAppConn", mock.Anything).Return(nil)
mp.On("Update",
mock.Anything,
Expand Down
3 changes: 0 additions & 3 deletions state/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func TestValidateBlockHeader(t *testing.T) {
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
mp.On("ResetUpdate").Return()
mp.On("FlushAppConn", mock.Anything).Return(nil)
mp.On("Update",
mock.Anything,
Expand Down Expand Up @@ -121,7 +120,6 @@ func TestValidateBlockCommit(t *testing.T) {
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
mp.On("ResetUpdate").Return()
mp.On("FlushAppConn", mock.Anything).Return(nil)
mp.On("Update",
mock.Anything,
Expand Down Expand Up @@ -261,7 +259,6 @@ func TestValidateBlockEvidence(t *testing.T) {
mp := &mpmocks.Mempool{}
mp.On("Lock").Return()
mp.On("Unlock").Return()
mp.On("ResetUpdate").Return()
mp.On("FlushAppConn", mock.Anything).Return(nil)
mp.On("Update",
mock.Anything,
Expand Down

0 comments on commit 6ecf14c

Please sign in to comment.