// Executes transactions on proxyAppCtx. func (s *State) execBlockOnProxyApp(proxyAppCtx proxy.AppContext, block *types.Block) error { // Execute transactions and get hash var invalidTxErr error proxyCb := func(req tmsp.Request, res tmsp.Response) { switch res := res.(type) { case tmsp.ResponseAppendTx: reqAppendTx := req.(tmsp.RequestAppendTx) if res.RetCode != tmsp.RetCodeOK { if invalidTxErr == nil { invalidTxErr = InvalidTxError{reqAppendTx.TxBytes, res.RetCode} } } case tmsp.ResponseEvent: s.evc.FireEvent(types.EventStringApp(), types.EventDataApp{res.Key, res.Data}) } } proxyAppCtx.SetResponseCallback(proxyCb) for _, tx := range block.Data.Txs { proxyAppCtx.AppendTxAsync(tx) if err := proxyAppCtx.Error(); err != nil { return err } } hash, err := proxyAppCtx.GetHashSync() if err != nil { log.Warn("Error computing proxyAppCtx hash", "error", err) return err } if invalidTxErr != nil { log.Warn("Invalid transaction in block") return invalidTxErr } // Check that appHash matches if !bytes.Equal(block.AppHash, hash) { log.Warn(Fmt("App hash in proposal was %X, computed %X instead", block.AppHash, hash)) return InvalidAppHashError{block.AppHash, hash} } return nil }