Skip to content

send proposer set updates in x/staking EndBlocker ABCI validator updates#73

Merged
tqin7 merged 5 commits into
feature/proposer-set-reductionfrom
tq/proposer-set-abci-updates
Aug 5, 2025
Merged

send proposer set updates in x/staking EndBlocker ABCI validator updates#73
tqin7 merged 5 commits into
feature/proposer-set-reductionfrom
tq/proposer-set-abci-updates

Conversation

@tqin7
Copy link
Copy Markdown

@tqin7 tqin7 commented Aug 4, 2025

Description

in x/staking EndBlocker validator updates, include proposer set updates by setting CanPropose field of each validator update.

additionally introduced a flag in state SendFullProposerSetUpdate (which MsgSetProposers msg handler will set to true) and when true: x/staking EndBlocker will return validator updates for all validators (besides the ones that have power changes)


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • run make lint and make test
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

Comment thread x/staking/keeper/msg_server.go Outdated

// Set SendFullProposerSetAbciUpdate to true to trigger a full proposer set update
// in EndBlocker
if err := k.Keeper.SetSendFullProposerSetAbciUpdate(ctx, true); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Probably better to call this in keeper.SetProposers to guarantee atomicity?

Comment thread x/staking/keeper/proposer_set.go Outdated
return bz[0] == 1, nil
}

// SetSendFullProposerSetAbciUpdate sets whether a full proposer set ABCI update is needed
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment that we are ok with full send approach because CanPropose changes very infrequently

Comment thread go.sum
github.com/dvsekhvalnov/jose2go v1.6.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/dydxprotocol/cometbft v0.38.6-0.20241126215519-69cdde955fd0 h1:KBMuBNAE91SVeULnq2XBnmSDGeimI6aM1+YxlLb0yOI=
github.com/dydxprotocol/cometbft v0.38.6-0.20241126215519-69cdde955fd0/go.mod h1:XSQX1hQbr54qaJb4/5YNNZGXkAQHHa6bi/KMcN1SQ7w=
github.com/dydxprotocol/cometbft v0.38.6-0.20250731170939-ab5587555808 h1:k6zD9fZD4O4H2sMoBsW66uMyx+MtXDpmCqjmXtlG+38=
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is this pointing to and why doesn't the PR build?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this is pointing to the latest commit on comet's proposer set feature branch. build fails as it doesn't recognize CanPropose field but unit tests all are fine. will look into resolving it

Comment thread x/staking/keeper/val_state_change.go Outdated
updates = append(updates, validator.ABCIValidatorUpdate(powerReduction))
// update the validator set if power has changed or if a full proposer set update is needed
if !found || !bytes.Equal(oldPowerBytes, newPowerBytes) || sendFullProposerSetUpdate {
update := validator.ABCIValidatorUpdate(powerReduction)
Copy link
Copy Markdown

@northstar456 northstar456 Aug 4, 2025

Choose a reason for hiding this comment

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

ABCIValidatorUpdate not taking in CanUpdate isn't very clean considering it defaults canPropose to false. This reduces readability and opens up room for bugs.

Can we construct the update with CanUpdates, instead of updating the struct with update.CanPropose = .... below

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

good catch! did this for my proof of concept and forgot to change this to take in CanPropose as a parameter instead

Comment thread x/staking/keeper/val_state_change.go Outdated
}

updates = append(updates, validator.ABCIValidatorUpdateZero())
update := validator.ABCIValidatorUpdateZero()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same as above, instead of update.CanPropose = .... pass in the boolean to ABCIValidatorUpdateZero

}

// Check if we need to send a full proposer set update
sendFullProposerSetUpdate, err := k.GetSendFullProposerSetAbciUpdate(ctx)
Copy link
Copy Markdown

@northstar456 northstar456 Aug 4, 2025

Choose a reason for hiding this comment

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

Would it be easy to do another sanity check if sendFullProposerSetUpdate is true, that we have at least X validators with canPropose =true? Just trying to reduce possibilities for chain halting state changes as much as possible.

And since this is endblocker, if invariant check fails just log error and default to all validators being able to propose or sth

Wdyt?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

good idea! can be a good fail safe that we don't expect to hit

Comment thread x/staking/keeper/val_state_change.go Outdated
updates = append(updates, update)
}

// Set SendFullProposerSetAbciUpdate to `false` to avoid sending unnecessary validator updates.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is comment accurate? We are just marking "done" after emitting updates right

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yep we are just marking "done". i was trying to say that if we don't set this to false, we would keep sending full proposer set updates every block

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated the comment to make it clearer

@tqin7 tqin7 merged commit dcb542f into feature/proposer-set-reduction Aug 5, 2025
35 of 36 checks passed
@tqin7 tqin7 deleted the tq/proposer-set-abci-updates branch August 5, 2025 17:40
tqin7 added a commit that referenced this pull request Aug 5, 2025
* feat(proposer-set-reduction): Add proposer set state to x/staking (#71)

* add proposer set state to x/staking

* all validators are proposers when none is set and add more tests

* get and set entire proposers list instead of each individual proposer

* have a constant define min num of bonded in proposer set

* fix lint and better error name

* add gov msg that sets and query that reads proposer set (#72)

* add gov msg that sets and query that reads proposer set

* add comment on invariant checks

* send proposer set updates in x/staking EndBlocker ABCI validator updates (#73)

* send proposer set updates in x/staking EndBlocker ABCI validator updates

* set full update flag in SetProposers keeper method and set CanPropose when constructing validator updates

* update simapp's cometbft dependency

* update cometbft dependency of /tests

* add sanity check on full proposer set update

* use cometbft commit on main (#74)
pthmas pushed a commit to 01builders/dydx-cosmos-sdk that referenced this pull request Aug 8, 2025
* feat(proposer-set-reduction): Add proposer set state to x/staking (dydxprotocol#71)

* add proposer set state to x/staking

* all validators are proposers when none is set and add more tests

* get and set entire proposers list instead of each individual proposer

* have a constant define min num of bonded in proposer set

* fix lint and better error name

* add gov msg that sets and query that reads proposer set (dydxprotocol#72)

* add gov msg that sets and query that reads proposer set

* add comment on invariant checks

* send proposer set updates in x/staking EndBlocker ABCI validator updates (dydxprotocol#73)

* send proposer set updates in x/staking EndBlocker ABCI validator updates

* set full update flag in SetProposers keeper method and set CanPropose when constructing validator updates

* update simapp's cometbft dependency

* update cometbft dependency of /tests

* add sanity check on full proposer set update

* use cometbft commit on main (dydxprotocol#74)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants