MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / execBlockOnProxyApp

Function execBlockOnProxyApp

state/execution.go:259–335  ·  view source on GitHub ↗

--------------------------------------------------------- Helper functions for executing blocks and updating state Executes block's transactions on proxyAppConn. Returns a list of transaction results and updates to the validator set

(
	logger log.Logger,
	proxyAppConn proxy.AppConnConsensus,
	block *types.Block,
	store Store,
	initialHeight int64,
)

Source from the content-addressed store, hash-verified

257// Executes block's transactions on proxyAppConn.
258// Returns a list of transaction results and updates to the validator set
259func execBlockOnProxyApp(
260 logger log.Logger,
261 proxyAppConn proxy.AppConnConsensus,
262 block *types.Block,
263 store Store,
264 initialHeight int64,
265) (*tmstate.ABCIResponses, error) {
266 var validTxs, invalidTxs = 0, 0
267
268 txIndex := 0
269 abciResponses := new(tmstate.ABCIResponses)
270 dtxs := make([]*abci.ResponseDeliverTx, len(block.Txs))
271 abciResponses.DeliverTxs = dtxs
272
273 // Execute transactions and get hash.
274 proxyCb := func(req *abci.Request, res *abci.Response) {
275 if r, ok := res.Value.(*abci.Response_DeliverTx); ok {
276 // TODO: make use of res.Log
277 // TODO: make use of this info
278 // Blocks may include invalid txs.
279 txRes := r.DeliverTx
280 if txRes.Code == abci.CodeTypeOK {
281 validTxs++
282 } else {
283 logger.Debug("invalid tx", "code", txRes.Code, "log", txRes.Log)
284 invalidTxs++
285 }
286
287 abciResponses.DeliverTxs[txIndex] = txRes
288 txIndex++
289 }
290 }
291 proxyAppConn.SetResponseCallback(proxyCb)
292
293 commitInfo := getBeginBlockValidatorInfo(block, store, initialHeight)
294
295 byzVals := make([]abci.Evidence, 0)
296 for _, evidence := range block.Evidence.Evidence {
297 byzVals = append(byzVals, evidence.ABCI()...)
298 }
299
300 // Begin block
301 var err error
302 pbh := block.Header.ToProto()
303 if pbh == nil {
304 return nil, errors.New("nil header")
305 }
306
307 abciResponses.BeginBlock, err = proxyAppConn.BeginBlockSync(abci.RequestBeginBlock{
308 Hash: block.Hash(),
309 Header: *pbh,
310 LastCommitInfo: commitInfo,
311 ByzantineValidators: byzVals,
312 })
313 if err != nil {
314 logger.Error("error in proxyAppConn.BeginBlock", "err", err)
315 return nil, err
316 }

Callers 2

ApplyBlockMethod · 0.85
ExecCommitBlockFunction · 0.85

Calls 11

DebugMethod · 0.65
SetResponseCallbackMethod · 0.65
ABCIMethod · 0.65
BeginBlockSyncMethod · 0.65
HashMethod · 0.65
ErrorMethod · 0.65
DeliverTxAsyncMethod · 0.65
EndBlockSyncMethod · 0.65
InfoMethod · 0.65
ToProtoMethod · 0.45

Tested by

no test coverage detected