Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
modify executeNonFraudulentStateTransactions to accomodate case when …
Browse files Browse the repository at this point in the history
…EndBlock is fraudulent
  • Loading branch information
Manav-Aggarwal committed Oct 20, 2022
1 parent 7f82c06 commit 2d8866b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ func (app *BaseApp) GetAppHash(req abci.RequestGetAppHash) (res abci.ResponseGet
return res
}

func (app *BaseApp) executeNonFraudulentTransactions(req abci.RequestGenerateFraudProof) {
nonFraudulentRequests := req.DeliverTxRequests[:len(req.DeliverTxRequests)-1]
func (app *BaseApp) executeNonFraudulentTransactions(req abci.RequestGenerateFraudProof, isDeliverTxFraudulent bool) {
numNonFraudulentRequests := len(req.DeliverTxRequests)
if isDeliverTxFraudulent {
numNonFraudulentRequests = numNonFraudulentRequests - 1
}
nonFraudulentRequests := req.DeliverTxRequests[:numNonFraudulentRequests]
for _, deliverTxRequest := range nonFraudulentRequests {
app.DeliverTx(*deliverTxRequest)
}
Expand All @@ -194,7 +198,7 @@ func (app *BaseApp) GenerateFraudProof(req abci.RequestGenerateFraudProof) (res
app.BeginBlock(beginBlockRequest)
if !isBeginBlockFraudulent {
// BeginBlock is not the fraudulent state transition
app.executeNonFraudulentTransactions(req)
app.executeNonFraudulentTransactions(req, isDeliverTxFraudulent)

cms.ResetAllTraceWriters()

Expand All @@ -220,7 +224,7 @@ func (app *BaseApp) GenerateFraudProof(req abci.RequestGenerateFraudProof) (res
// Fast-forward to right before fradulent state transition occured
app.BeginBlock(beginBlockRequest)
if !isBeginBlockFraudulent {
app.executeNonFraudulentTransactions(req)
app.executeNonFraudulentTransactions(req, isDeliverTxFraudulent)
}

// Export the app's current trace-filtered state into a Fraud Proof and return it
Expand Down

0 comments on commit 2d8866b

Please sign in to comment.