Skip to content

Commit

Permalink
update conductor, tests to work with pbjson
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperFluffy committed Mar 23, 2024
1 parent 8651ba2 commit 0a592f3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
7 changes: 5 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/astria-conductor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ config = { package = "astria-config", path = "../astria-config", features = [
"tests",
] }
insta = { version = "1.36.1", features = ["json"] }
chrono = "0.4.35"

[build-dependencies]
astria-build-info = { path = "../astria-build-info", features = ["build"] }
2 changes: 1 addition & 1 deletion crates/astria-conductor/src/executor/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use astria_eyre::eyre::{
WrapErr as _,
};
use bytes::Bytes;
use prost_types::Timestamp;
use pbjson_types::Timestamp;
use tonic::transport::Channel;
use tracing::instrument;

Expand Down
12 changes: 6 additions & 6 deletions crates/astria-conductor/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use bytes::Bytes;
use celestia_client::celestia_types::Height as CelestiaHeight;
use sequencer_client::tendermint::{
block::Height as SequencerHeight,
Time,
Time as TendermintTime,
};
use tokio::{
select,
Expand Down Expand Up @@ -518,7 +518,7 @@ enum Update {
struct ExecutableBlock {
hash: [u8; 32],
height: SequencerHeight,
timestamp: prost_types::Timestamp,
timestamp: pbjson_types::Timestamp,
transactions: Vec<Vec<u8>>,
}

Expand All @@ -530,7 +530,7 @@ impl ExecutableBlock {
transactions,
..
} = block;
let timestamp = convert_tendermint_to_prost_timestamp(header.time);
let timestamp = convert_tendermint_time_to_protobuf_timestamp(header.time);
Self {
hash: block_hash,
height: header.height,
Expand All @@ -542,7 +542,7 @@ impl ExecutableBlock {
fn from_sequencer(block: FilteredSequencerBlock, id: RollupId) -> Self {
let hash = block.block_hash();
let height = block.height();
let timestamp = convert_tendermint_to_prost_timestamp(block.cometbft_header().time);
let timestamp = convert_tendermint_time_to_protobuf_timestamp(block.cometbft_header().time);
let FilteredSequencerBlockParts {
mut rollup_transactions,
..
Expand All @@ -561,12 +561,12 @@ impl ExecutableBlock {
}

/// Converts a [`tendermint::Time`] to a [`prost_types::Timestamp`].
fn convert_tendermint_to_prost_timestamp(value: Time) -> prost_types::Timestamp {
fn convert_tendermint_time_to_protobuf_timestamp(value: TendermintTime) -> pbjson_types::Timestamp {
let sequencer_client::tendermint_proto::google::protobuf::Timestamp {
seconds,
nanos,
} = value.into();
prost_types::Timestamp {
pbjson_types::Timestamp {
seconds,
nanos,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-conductor/src/executor/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ mod tests {
generated::execution::v1alpha2 as raw,
Protobuf as _,
};
use prost_types::Timestamp;
use pbjson_types::Timestamp;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions crates/astria-conductor/src/executor/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn make_genesis_block() -> raw::Block {
number: 0,
hash: GENESIS_HASH,
parent_block_hash: GENESIS_HASH,
timestamp: Some(std::time::SystemTime::now().into()),
timestamp: Some(chrono::Utc::now().into()),
}
}

Expand Down Expand Up @@ -556,7 +556,7 @@ fn make_block(number: u32) -> raw::Block {
number,
hash: Bytes::from_static(&[0u8; 32]),
parent_block_hash: Bytes::from_static(&[0u8; 32]),
timestamp: Some(prost_types::Timestamp {
timestamp: Some(pbjson_types::Timestamp {
seconds: 0,
nanos: 0,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ source: crates/astria-conductor/src/sequencer/reporting.rs
expression: ReportRollups(block.rollup_transactions())
---
{
"2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a": 2,
"4545454545454545454545454545454545454545454545454545454545454545": 1
"KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKio=": 2,
"RUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUU=": 1
}

0 comments on commit 0a592f3

Please sign in to comment.