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 validator update with name action #1608

Closed
wants to merge 6 commits into from

Conversation

ethanoroshiba
Copy link
Contributor

@ethanoroshiba ethanoroshiba commented Oct 1, 2024

Summary

Added ValidatorUpdateWithName action which wraps a ValidatorUpdate and has an additional field for the validator name to be stored app side.

Background

Validator names could previously only be set in the CometBFT genesis, this is meant to give us a way to set validator names app-side.

Changes

  • Added ValidatorUpdateWithName action to proto, core, and sequencer.
  • Implemented app-side storage for the validator names corresponding to their address.
  • Added ABCI query for validator name.

Testing

  • Added unit test for ValidatorUpdateWithName action.
  • Added 3 unit tests for validator_name_request ABCI query.
  • Added ValidatorUpdateWithName to app_execute_transaction_with_every_action_snapshot

Breaking Changelist

  • Backwards compatible, but added new action.
  • Added new action to snapshot test with every action, breaking this snapshot test.

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 1, 2024
@@ -33,6 +33,7 @@ pub enum Action {
Sequence(SequenceAction),
Transfer(TransferAction),
ValidatorUpdate(ValidatorUpdate),
ValidatorUpdateWithName(ValidatorUpdateWithName),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Open to calling this action something else if people would like. Maybe something like NamedValidatorUpdate

Comment on lines +145 to +148
#[instrument(skip_all)]
fn clear_validator_names(&mut self) {
self.delete(VALIDATOR_NAMES_KEY.to_string());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this is unused - can it be removed?

fn put_validator_names(&mut self, validator_names: BTreeMap<String, String>) -> Result<()> {
self.put_raw(
VALIDATOR_NAMES_KEY.to_string(),
serde_json::to_vec(&validator_names).wrap_err("failed to serialize validator names")?,
Copy link
Contributor

Choose a reason for hiding this comment

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

We're now using Borsh to encode everything in storage. Could you update this to follow the approach taken for other types please?

This will involve creating a new type in authority::storage like:

#[derive(Debug, BorshSerialize, BorshDeserialize)]
pub(in crate::authority) struct ValidatorName<'a>(Cow<'a, str>);

See the implementation for AddressPrefix for example.

This new type should then be included as a variant in authority::storage::ValueImpl.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we have a new unit test for the added putter/getter please?

}
};

match validator_names.get(&hex::encode(address.address_bytes())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid hex-encoding the addresses in this collection?

@Fraser999 Fraser999 deleted the ENG-883/validator_name_update branch November 19, 2024 15:18
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
2 participants