diff --git a/app/app.go b/app/app.go index afe16a3781..0ab29d22d0 100644 --- a/app/app.go +++ b/app/app.go @@ -876,6 +876,15 @@ func (app *App) ProcessProposalHandler(ctx sdk.Context, req *abci.RequestProcess }, nil } +func isGovMessage(msg sdk.Msg) bool { + switch msg.(type) { + case *govtypes.MsgVoteWeighted, *govtypes.MsgVote, *govtypes.MsgSubmitProposal, *govtypes.MsgDeposit: + return true + default: + return false + } +} + func (app *App) BuildDependencyDag(ctx sdk.Context, txs [][]byte) (*Dag, error) { // contains the latest msg index for a specific Access Operation dependencyDag := NewDag() @@ -886,6 +895,9 @@ func (app *App) BuildDependencyDag(ctx sdk.Context, txs [][]byte) (*Dag, error) } msgs := tx.GetMsgs() for messageIndex, msg := range msgs { + if isGovMessage(msg) { + return nil, ErrGovMsgInBlock + } msgDependencies := app.AccessControlKeeper.GetResourceDependencyMapping(ctx, acltypes.GenerateMessageKey(msg)) for _, accessOp := range msgDependencies.GetAccessOps() { // make a new node in the dependency dag @@ -1088,15 +1100,17 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ // app.batchVerifier.VerifyTxs(ctx, typedTxs) dependencyDag, err := app.BuildDependencyDag(ctx, txs) - txResults := []*abci.ExecTxResult{} + var txResults []*abci.ExecTxResult // TODO:: add metrics for async vs sync - if err != nil { + switch err { + case ErrGovMsgInBlock: + ctx.Logger().Info(fmt.Sprintf("Gov msg found while building DAG, processing synchronously: %s", err)) + txResults = app.ProcessBlockSynchronous(ctx, txs) + case nil: ctx.Logger().Error(fmt.Sprintf("Error while building DAG, processing synchronously: %s", err)) - if err == ErrCycleInDAG { - txResults = app.ProcessBlockSynchronous(ctx, txs) - } - } else { + txResults = app.ProcessBlockSynchronous(ctx, txs) + default: completionSignalingMap, blockingSignalsMap := dependencyDag.BuildCompletionSignalMaps() txResults = app.ProcessBlockConcurrent(ctx, txs, completionSignalingMap, blockingSignalsMap) } diff --git a/app/graph.go b/app/graph.go index b97e2c3710..d999d5b573 100644 --- a/app/graph.go +++ b/app/graph.go @@ -326,4 +326,7 @@ func (dag *Dag) BuildCompletionSignalMaps() ( return completionSignalingMap, blockingSignalsMap } -var ErrCycleInDAG = fmt.Errorf("cycle detected in DAG") +var ( + ErrCycleInDAG = fmt.Errorf("cycle detected in DAG") + ErrGovMsgInBlock = fmt.Errorf("gov msg in block") +)