diff --git a/evidence/pool.go b/evidence/pool.go index 820fead47..fab29be60 100644 --- a/evidence/pool.go +++ b/evidence/pool.go @@ -69,16 +69,18 @@ func (evpool *EvidencePool) State() sm.State { // Update loads the latest func (evpool *EvidencePool) Update(block *types.Block, state sm.State) { - evpool.mtx.Lock() - defer evpool.mtx.Unlock() // sanity check if state.LastBlockHeight != block.Height { panic(fmt.Sprintf("Failed EvidencePool.Update sanity check: got state.Height=%d with block.Height=%d", state.LastBlockHeight, block.Height)) } + + // update the state + evpool.mtx.Lock() evpool.state = state + evpool.mtx.Unlock() - // NOTE: shouldn't need the mutex + // remove evidence from pending and mark committed evpool.MarkEvidenceAsCommitted(block.Evidence.Evidence) } diff --git a/evidence/store.go b/evidence/store.go index abfc5e1fe..6af5d75d8 100644 --- a/evidence/store.go +++ b/evidence/store.go @@ -17,10 +17,6 @@ Impl: - First commit atomically in outqueue, pending, lookup. - Once broadcast, remove from outqueue. No need to sync - Once committed, atomically remove from pending and update lookup. - - TODO: If we crash after committed but before removing/updating, - we'll be stuck broadcasting evidence we never know we committed. - so either share the state db and atomically MarkCommitted - with ApplyBlock, or check all outqueue/pending on Start to see if its committed Schema for indexing evidence (note you need both height and hash to find a piece of evidence): diff --git a/state/execution.go b/state/execution.go index cf27e3958..770911597 100644 --- a/state/execution.go +++ b/state/execution.go @@ -92,7 +92,7 @@ func (blockExec *BlockExecutor) ApplyBlock(state State, blockID types.BlockID, b return state, fmt.Errorf("Commit failed for application: %v", err) } - // lock mempool, commit state, update mempoool + // lock mempool, commit app state, update mempoool appHash, err := blockExec.Commit(block) if err != nil { return state, fmt.Errorf("Commit failed for application: %v", err)