Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sequencer): Add new validator update action #1679

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

ethanoroshiba
Copy link
Contributor

@ethanoroshiba ethanoroshiba commented Oct 17, 2024

Summary

Added new action ValidatorUpdateV2, which houses the same functionality as ValidatorUpdate but now includes a name field.

Background

Previously, validator names were not stored app-side, and names could only be set in CometBFT genesis.

Changes

  • Added ValidatorUpdateV2 action to protos and core.
  • Restricted validator name to 32 characters when converting from on-wire format.
  • Added ValidatorNames struct, which contains address <> name key-value pairs.
  • Added storage keys, value impls, snapshots, and state read/write methods for ValidatorNames.
  • Added new ABCI query for validator name, accepting address as a parameter.
  • Edited ValidatorSet to use insert instead of push_update so that it doesn't imply any ordering.

Testing

  • Snapshot tests added for new VALIDATOR_NAMES storage key
  • Unit tests for new state read/write methods
  • Unit tests that new ABCI query works as expected
  • Unit test for ABCI query router to validator_name_request.
  • App execution test for ValidatorUpdateV2.
  • Added ValidatorUpdateV2 to app_execute_transaction_with_every_action.

Related Issues

closes #1590

@github-actions github-actions bot added proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate labels Oct 17, 2024
crates/astria-sequencer/src/authority/query.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/authority/mod.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/authority/query.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/authority/query.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/authority/query.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/authority/query.rs Outdated Show resolved Hide resolved
crates/astria-sequencer/src/authority/query.rs Outdated Show resolved Hide resolved
@ethanoroshiba ethanoroshiba changed the title feat(sequencer)!: Add new validator update action feat(sequencer): Add new validator update action Oct 29, 2024
power,
name,
} = value;
if name.len() > MAX_VALIDATOR_NAME_LENGTH {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we explicitly check against chars(), or is 32 bytes fine?


#[derive(Debug, PartialEq, Eq)]
#[cfg_attr(test, derive(Clone))]
pub(crate) struct ValidatorNames(BTreeMap<[u8; ADDRESS_LEN], String>);
Copy link
Collaborator

@noot noot Nov 4, 2024

Choose a reason for hiding this comment

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

would prefer to store each validator name in a separate storage entry so we don't have to fetch every single validator name just to update one name. then to get all the names, you can use a prefix iterator to return a stream, as all validator names will be stored after one prefix (eg. keys are of the form valname/<address> where valname is the storage prefix).

see example here:

fn allowed_fee_assets(&self) -> AllowedFeeAssetsStream<Self::PrefixKeysStream> {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this catch! Done in a7a64af

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proto pertaining to the Astria Protobuf spec sequencer pertaining to the astria-sequencer crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(sequencer): updates of validator names
4 participants