Skip to content

Commit

Permalink
feat(core): add Protobuf for FilteredSequencerBlock
Browse files Browse the repository at this point in the history
this is non-breaking, because
FilteredSequencerBlock retains its inherent
methods and only gets an additional trait impl.
  • Loading branch information
SuperFluffy committed Jan 7, 2025
1 parent bc95a28 commit 556bb15
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions crates/astria-core/src/sequencerblock/v1/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use bytes::Bytes;
use indexmap::IndexMap;
use sha2::Sha256;
use tendermint::{
account,
Time,
account,
};

use super::{
Expand All @@ -24,22 +24,22 @@ use super::{
raw,
};
use crate::{
Protobuf,
primitive::v1::{
asset,
derive_merkle_tree_from_rollup_txs,
Address,
AddressError,
IncorrectRollupIdLength,
RollupId,
TransactionId,
TransactionIdError,
asset,
derive_merkle_tree_from_rollup_txs,
},
protocol::transaction::v1::{
action,
Transaction,
TransactionError,
action,
},
Protobuf as _,
};

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -938,14 +938,11 @@ impl SequencerBlock {
let proof = rollup_transaction_tree
.construct_proof(i)
.expect("the proof must exist because the tree was derived with the same leaf");
rollup_transactions.insert(
rollup_transactions.insert(rollup_id, RollupTransactions {
rollup_id,
RollupTransactions {
rollup_id,
transactions: data, // TODO: rename this field?
proof,
},
);
transactions: data, // TODO: rename this field?
proof,
});
}
rollup_transactions.sort_unstable_keys();

Expand Down Expand Up @@ -1368,6 +1365,27 @@ impl FilteredSequencerBlock {
}
}

impl Protobuf for FilteredSequencerBlock {
type Error = FilteredSequencerBlockError;
type Raw = raw::FilteredSequencerBlock;

fn try_from_raw_ref(raw: &Self::Raw) -> Result<Self, Self::Error> {
Self::try_from_raw(raw.clone())
}

fn to_raw(&self) -> Self::Raw {
self.clone().into_raw()
}

fn try_from_raw(raw: Self::Raw) -> Result<Self, Self::Error> {
Self::try_from_raw(raw)
}

fn into_raw(self) -> Self::Raw {
self.into_raw()
}
}

#[derive(Debug, thiserror::Error)]
#[error(transparent)]
pub struct FilteredSequencerBlockError(FilteredSequencerBlockErrorKind);
Expand Down

0 comments on commit 556bb15

Please sign in to comment.