Skip to content

Commit

Permalink
feat: Generate isr before begin block (cosmos#931)
Browse files Browse the repository at this point in the history
Closes: cosmos#914

---------

Co-authored-by: Tomasz Zdybał <[email protected]>
  • Loading branch information
Manav-Aggarwal and tzdybal committed May 15, 2023
1 parent 01e83ce commit ee81f9c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions state/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ func (e *BlockExecutor) execute(ctx context.Context, state types.State, block *t
currentIsrIndex := 0

if e.fraudProofsEnabled && currentIsrs != nil {
expectedLength := len(block.Data.Txs) + 2
// BeginBlock + DeliverTxs + EndBlock
expectedLength := len(block.Data.Txs) + 3 // before BeginBlock, after BeginBlock, after every Tx, after EndBlock
if len(currentIsrs) != expectedLength {
return nil, fmt.Errorf("invalid length of ISR list: %d, expected length: %d", len(currentIsrs), expectedLength)
}
Expand All @@ -345,6 +344,15 @@ func (e *BlockExecutor) execute(ctx context.Context, state types.State, block *t
}
})

if e.fraudProofsEnabled {
isr, err := e.getAppHash()
if err != nil {
return nil, err
}
ISRs = append(ISRs, isr)
currentIsrIndex++
}

genAndGossipFraudProofIfNeeded := func(beginBlockRequest *abci.RequestBeginBlock, deliverTxRequests []*abci.RequestDeliverTx, endBlockRequest *abci.RequestEndBlock) (err error) {
if !e.fraudProofsEnabled {
return nil
Expand Down

0 comments on commit ee81f9c

Please sign in to comment.