Skip to content

Commit

Permalink
Add prev ship hash to telos EVM block
Browse files Browse the repository at this point in the history
  • Loading branch information
coa-telos committed Oct 2, 2024
1 parent a4ed288 commit d411d32
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion translator/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ pub enum DecodedRow {
#[derive(Clone)]
pub struct ProcessingEVMBlock {
pub block_num: u32,
block_hash: Checksum256,
pub block_hash: Checksum256,
pub prev_block_hash: Option<Checksum256>,
chain_id: u64,
result: GetBlocksResultV0,
signed_block: Option<SignedBlock>,
Expand All @@ -108,6 +109,8 @@ pub struct ProcessingEVMBlock {
pub struct TelosEVMBlock {
pub block_num: u32,
pub block_hash: B256,
pub ship_hash: String,
pub prev_ship_hash: Option<String>,
pub lib_num: u32,
pub lib_hash: String,
pub header: Header,
Expand Down Expand Up @@ -145,13 +148,15 @@ impl ProcessingEVMBlock {
chain_id: u64,
block_num: u32,
block_hash: Checksum256,
prev_block_hash: Option<Checksum256>,
lib_num: u32,
lib_hash: Checksum256,
result: GetBlocksResultV0,
) -> Self {
Self {
block_num,
block_hash,
prev_block_hash,
lib_num,
lib_hash,
chain_id,
Expand Down
3 changes: 3 additions & 0 deletions translator/src/tasks/final_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ pub async fn final_processor(
.collect(),
);

let prev_ship_hash = block.prev_block_hash.map(|hash| hash.as_string());
let completed_block = TelosEVMBlock {
block_num: evm_block_num,
block_hash,
ship_hash: block.block_hash.as_string(),
prev_ship_hash,
lib_num: block.lib_num,
lib_hash: block.lib_hash.as_string(),
transactions: block.transactions,
Expand Down
1 change: 1 addition & 0 deletions translator/src/tasks/raw_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub async fn raw_deserializer(
config.chain_id.0,
b.block_num,
b.block_id,
r.prev_block.as_ref().map(|b| b.block_id),
r.last_irreversible.block_num,
r.last_irreversible.block_id,
r.clone(),
Expand Down
1 change: 1 addition & 0 deletions translator/tests/block_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ async fn generate_block(
chain_id,
block_num,
block_pos.block_id,
None,
// Block is always final
block_num,
block_pos.block_id,
Expand Down
1 change: 1 addition & 0 deletions translator/tests/decode_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fn decode_block() {
1,
b.block_num,
Checksum256::default(),
None,
b.block_num,
Checksum256::default(),
r.clone(),
Expand Down

0 comments on commit d411d32

Please sign in to comment.