Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Comment on lines +898 to +900
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it's not completely an error since this is expected right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah true, but this seemed like the best way to interrupt the dependency graph creation and have the sequential behavior. any idea on a better pattern to use?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's fair -- perhaps we could just leave a comment here noting why gov messages are handled this way

msgDependencies := app.AccessControlKeeper.GetResourceDependencyMapping(ctx, acltypes.GenerateMessageKey(msg))
for _, accessOp := range msgDependencies.GetAccessOps() {
// make a new node in the dependency dag
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 4 additions & 1 deletion app/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)