Skip to content

Commit

Permalink
(core, sequencer)!: generate serde traits impls for all protocol prot…
Browse files Browse the repository at this point in the history
…obufs (#1260)

## Summary
This patch ensures extends our generated serde `Deserialize` and
`Serialize` trait implementations to all protobuf messages defined in
`astria.protocol`.

## Background
So far the protocol-specs did not have serde traits generated, but these
are necessary to write out bridge-withdrawer actions as JSON.

A side-effect of this patch is that all of
`proto/protocolapis/astria_vendored` is now also commited to the
repository (they were previously filtered). Very likely this is not
desired but should be addressed in a followup. It is not clear to the
author of this patch in how far these types might be necessary.

## Changes
- Generate serde `Deserialize` and `Serialize` impls for Rust types
generated from `astria.protocol` and `astria_vendored` protobufs
- Use a vendored `astria_vendored::tendermint::abci::ValidatorUpdate`
instead of `tendermint_proto`: `[email protected]` does not yet
have serde impls for its types, which blocks us from having an easy way
to use `pbjson` generated serde impls
- Introduce a new `ValidatorUpdate` action to replace
`tendermint::validator::Update` to transform to/from the vendored
protobuf type (again necessary to implement serde and foreign type
restrictions)
- Update sequencer to use  the new `ValidatorUpdate` type

## Testing
All tests have been upgraded and still pass. Specifically, ingestion of
validator updates happens through cometbft, which were already tested
end-to-end.

## Breaking Changelist
- Marked as breaking even though none of the breaking change tests are
affected: the serialization shape of the validator updates has changed.
As they are commited to state using json, this should be breaking.
  • Loading branch information
SuperFluffy authored Jul 11, 2024
1 parent 69db1bd commit 5757558
Show file tree
Hide file tree
Showing 35 changed files with 5,804 additions and 215 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions crates/astria-cli/src/commands/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use astria_core::{
InitBridgeAccountAction,
SudoAddressChangeAction,
TransferAction,
ValidatorUpdate,
},
TransactionParams,
UnsignedTransaction,
},
};
use astria_sequencer_client::{
tendermint,
tendermint_rpc::endpoint,
Client,
HttpClient,
Expand Down Expand Up @@ -421,13 +421,14 @@ pub(crate) async fn sudo_address_change(args: &SudoAddressChangeArgs) -> eyre::R
/// * If the http client cannot be created
/// * If the transaction failed to be submitted
pub(crate) async fn validator_update(args: &ValidatorUpdateArgs) -> eyre::Result<()> {
let public_key_raw = hex::decode(args.validator_public_key.as_str())
.wrap_err("failed to decode public key into bytes")?;
let pub_key = tendermint::PublicKey::from_raw_ed25519(&public_key_raw)
.expect("failed to parse public key from parsed bytes");
let validator_update = tendermint::validator::Update {
pub_key,
power: args.power.into(),
let verification_key = astria_core::crypto::VerificationKey::try_from(
&*hex::decode(&args.validator_public_key)
.wrap_err("failed to decode public key bytes from argument")?,
)
.wrap_err("failed to construct public key from bytes")?;
let validator_update = ValidatorUpdate {
power: args.power,
verification_key,
};

let res = submit_transaction(
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-core/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl From<[u8; 32]> for SigningKey {
}

/// An Ed25519 verification key.
#[derive(Clone)]
#[derive(Clone, Copy)]
pub struct VerificationKey {
key: Ed25519VerificationKey,
}
Expand Down
186 changes: 186 additions & 0 deletions crates/astria-core/src/generated/astria.composer.v1alpha1.serde.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5757558

Please sign in to comment.