diff --git a/.changelog/6523.bugfix.md b/.changelog/6523.bugfix.md new file mode 100644 index 00000000000..12a7ce08d3b --- /dev/null +++ b/.changelog/6523.bugfix.md @@ -0,0 +1 @@ +go/consensus/cometbft/apps/governance: Ignore nodes when runtime votes diff --git a/go/consensus/cometbft/apps/governance/transactions.go b/go/consensus/cometbft/apps/governance/transactions.go index 75da85d314d..fc45723ec08 100644 --- a/go/consensus/cometbft/apps/governance/transactions.go +++ b/go/consensus/cometbft/apps/governance/transactions.go @@ -246,18 +246,27 @@ func (app *Application) castVote( // Query signer entity descriptor. var submitterNodes []signature.PublicKey - registryState := registryState.NewMutableState(ctx.State()) - submitterEntity, err := registryState.Entity(ctx, ctx.TxSigner()) - switch err { - case nil: - submitterNodes = submitterEntity.Nodes - case registryAPI.ErrNoSuchEntity: + switch ctx.IsMessageExecution() { + case true: + // Runtime messages are not real consensus transactions as they + // don't have a transaction signer. if !params.AllowVoteWithoutEntity { return governance.ErrNotEligible } - // Default to an empty set of nodes so delegators without entities can vote. - default: - return fmt.Errorf("governance: failed to query entity: %w", err) + case false: + registryState := registryState.NewMutableState(ctx.State()) + submitterEntity, err := registryState.Entity(ctx, ctx.TxSigner()) + switch err { + case nil: + submitterNodes = submitterEntity.Nodes + case registryAPI.ErrNoSuchEntity: + if !params.AllowVoteWithoutEntity { + return governance.ErrNotEligible + } + // Default to an empty set of nodes so delegators without entities can vote. + default: + return fmt.Errorf("governance: failed to query entity: %w", err) + } } // Load current validator sets. diff --git a/go/consensus/cometbft/apps/roothash/finalization.go b/go/consensus/cometbft/apps/roothash/finalization.go index 47781c9ec49..93f647df3a6 100644 --- a/go/consensus/cometbft/apps/roothash/finalization.go +++ b/go/consensus/cometbft/apps/roothash/finalization.go @@ -179,10 +179,7 @@ func (app *Application) tryFinalizeRoundInsideTx( //nolint: gocyclo if err = app.removeRuntimeMessages(ctx, state, rtState.Runtime.ID, msgs, round); err != nil { return err } - msgEvents, err := app.processRuntimeMessages(ctx, rtState, sc.Commitment.Messages) - if err != nil { - return fmt.Errorf("failed to process runtime messages: %w", err) - } + msgEvents := app.processRuntimeMessages(ctx, rtState, sc.Commitment.Messages) // Compute good and bad entities. var ( diff --git a/go/consensus/cometbft/apps/roothash/messages.go b/go/consensus/cometbft/apps/roothash/messages.go index 3e0981b958e..eacd501f763 100644 --- a/go/consensus/cometbft/apps/roothash/messages.go +++ b/go/consensus/cometbft/apps/roothash/messages.go @@ -107,7 +107,7 @@ func (app *Application) processRuntimeMessages( ctx *tmapi.Context, rtState *roothash.RuntimeState, msgs []message.Message, -) ([]*roothash.MessageEvent, error) { +) []*roothash.MessageEvent { ctx = ctx.WithMessageExecution() defer ctx.Close() ctx = ctx.WithCallerAddress(staking.NewRuntimeAddress(rtState.Runtime.ID)) @@ -165,7 +165,7 @@ func (app *Application) processRuntimeMessages( Result: cbor.Marshal(result), }) } - return events, nil + return events } func (app *Application) doBeforeSchedule(ctx *tmapi.Context, msg any) (any, error) { diff --git a/go/consensus/cometbft/apps/roothash/transactions.go b/go/consensus/cometbft/apps/roothash/transactions.go index 24920755911..4866b8fc668 100644 --- a/go/consensus/cometbft/apps/roothash/transactions.go +++ b/go/consensus/cometbft/apps/roothash/transactions.go @@ -87,8 +87,8 @@ func (app *Application) executorCommit( msgCtx := ctx.WithSimulation() defer msgCtx.Close() - _, msgErr := app.processRuntimeMessages(msgCtx, rtState, msgs) - return msgErr + _ = app.processRuntimeMessages(msgCtx, rtState, msgs) + return nil } // Verify and add commitments to the pool.