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
1 change: 1 addition & 0 deletions .changelog/6523.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/consensus/cometbft/apps/governance: Ignore nodes when runtime votes
27 changes: 18 additions & 9 deletions go/consensus/cometbft/apps/governance/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 1 addition & 4 deletions go/consensus/cometbft/apps/roothash/finalization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions go/consensus/cometbft/apps/roothash/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions go/consensus/cometbft/apps/roothash/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading