Skip to content

Commit

Permalink
feat(conductor)!: include sequencer block hash
Browse files Browse the repository at this point in the history
  • Loading branch information
joroshiba committed Feb 25, 2025
1 parent c248d71 commit 3ca47f5
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/astria-conductor/src/executor/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl Client {
prev_block_hash: Bytes,
transactions: Vec<Bytes>,
timestamp: Timestamp,
sequencer_block_hash: Bytes,
) -> eyre::Result<Block> {
use prost::Message;

Expand All @@ -132,6 +133,7 @@ impl Client {
prev_block_hash,
transactions,
timestamp: Some(timestamp),
sequencer_block_hash,
};
let response = tryhard::retry_fn(|| {
let mut client = self.inner.clone();
Expand Down
4 changes: 3 additions & 1 deletion crates/astria-conductor/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,16 +496,18 @@ impl Initialized {
block: ExecutableBlock,
) -> eyre::Result<Block> {
let ExecutableBlock {
hash,
transactions,
timestamp,
..
} = block;

let n_transactions = transactions.len();
let sequencer_block_hash = hash.as_bytes().to_vec().into();

let executed_block = self
.client
.execute_block_with_retry(parent_hash, transactions, timestamp)
.execute_block_with_retry(parent_hash, transactions, timestamp, sequencer_block_hash)
.await
.wrap_err("failed to run execute_block RPC")?;

Expand Down
11 changes: 11 additions & 0 deletions crates/astria-core/src/execution/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ pub struct Block {
parent_block_hash: Bytes,
/// Timestamp on the block, standardized to google protobuf standard.
timestamp: Timestamp,
/// The hash of the sequencer block that this block is derived from.
sequencer_block_hash: Bytes,
}

impl Block {
Expand All @@ -183,6 +185,11 @@ impl Block {
// effectively just a copy
self.timestamp.clone()
}

#[must_use]
pub fn sequencer_block_hash(&self) -> &Bytes {
&self.sequencer_block_hash
}
}

impl From<Block> for raw::Block {
Expand All @@ -201,6 +208,7 @@ impl Protobuf for Block {
hash,
parent_block_hash,
timestamp,
sequencer_block_hash,
} = raw;
// Cloning timestamp is effectively a copy because timestamp is just a (i32, i64) tuple
let timestamp = timestamp
Expand All @@ -212,6 +220,7 @@ impl Protobuf for Block {
hash: hash.clone(),
parent_block_hash: parent_block_hash.clone(),
timestamp,
sequencer_block_hash: sequencer_block_hash.clone(),
})
}

Expand All @@ -221,6 +230,7 @@ impl Protobuf for Block {
hash,
parent_block_hash,
timestamp,
sequencer_block_hash,
} = self;
Self::Raw {
number: *number,
Expand All @@ -229,6 +239,7 @@ impl Protobuf for Block {
// Cloning timestamp is effectively a copy because timestamp is just a (i32, i64)
// tuple
timestamp: Some(timestamp.clone()),
sequencer_block_hash: sequencer_block_hash.clone(),
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions crates/astria-core/src/generated/astria.execution.v1.rs

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

42 changes: 42 additions & 0 deletions crates/astria-core/src/generated/astria.execution.v1.serde.rs

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

4 changes: 4 additions & 0 deletions proto/executionapis/astria/execution/v1/execution.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ message Block {
bytes parent_block_hash = 3;
// Timestamp on the block, standardized to google protobuf standard.
google.protobuf.Timestamp timestamp = 4;
// The block hash of sequencer block this is derived from.
bytes sequencer_block_hash = 5;
}

// Fields which are indexed for finding blocks on a blockchain.
Expand Down Expand Up @@ -70,6 +72,8 @@ message ExecuteBlockRequest {
repeated astria.sequencerblock.v1.RollupData transactions = 2;
// Timestamp to be used for new block.
google.protobuf.Timestamp timestamp = 3;
// The hash of the sequencer block the transactions come from.
bytes sequencer_block_hash = 4;
}

// The CommitmentState holds the block at each stage of sequencer commitment
Expand Down

0 comments on commit 3ca47f5

Please sign in to comment.