From a86127f454ee9c7a57076419520dbe1a47911655 Mon Sep 17 00:00:00 2001 From: smtmfft Date: Tue, 20 Feb 2024 09:29:56 +0000 Subject: [PATCH] add blob hash opt into taiko extra --- lib/src/taiko/host.rs | 48 +++++------------------------- lib/src/taiko/protocol_instance.rs | 4 ++- 2 files changed, 11 insertions(+), 41 deletions(-) diff --git a/lib/src/taiko/host.rs b/lib/src/taiko/host.rs index c905722c..ae0dffa1 100644 --- a/lib/src/taiko/host.rs +++ b/lib/src/taiko/host.rs @@ -1,10 +1,8 @@ -use alloy_sol_types::sol_data::FixedBytes; use anyhow::Result; use ethers_core::types::{Block, Transaction as EthersTransaction, H160, H256, U256}; use reqwest; use reth_primitives::eip4844::kzg_to_versioned_hash; use serde::Deserialize; -use sha2::{Digest, Sha256}; use tracing::info; use zeth_primitives::{ ethers::{from_ethers_h160, from_ethers_h256, from_ethers_u256}, @@ -30,6 +28,7 @@ pub struct TaikoExtra { pub l1_hash: B256, pub l1_height: u64, pub l2_tx_list: Vec, + pub tx_blob_hash: Option, pub prover: Address, pub graffiti: B256, pub l2_withdrawals: Vec, @@ -198,13 +197,11 @@ fn execute_data>( // KzgProof string `json:"kzg_proof"` // CommitmentInclusionProof []string // `json:"kzg_commitment_inclusion_proof"` } - -#[warn(dead_code)] #[derive(Clone, Debug, Deserialize)] struct GetBlobData { pub index: String, pub blob: String, - // pub signed_block_header: String, + // pub signed_block_header: SignedBeaconBlockHeader, // ignore for now pub kzg_commitment: String, pub kzg_proof: String, pub kzg_commitment_inclusion_proof: Vec, @@ -311,11 +308,11 @@ pub fn get_taiko_initial_data = blobs @@ -340,9 +335,9 @@ pub fn get_taiko_initial_data>(); let blob_data = decode_blob_data(&tx_blobs[0].blob); - blob_data.as_slice()[offset as usize..(offset + size) as usize].to_vec() + (blob_data.as_slice()[offset as usize..(offset + size) as usize].to_vec(), Some(from_ethers_h256(blob_hash))) } else { - l2_tx_list + (l2_tx_list, None) }; // 1. check l2 parent gas used @@ -374,6 +369,7 @@ pub fn get_taiko_initial_data Result { - let tx_list_hash = TxHash::from(keccak::keccak(extra.l2_tx_list.as_slice())); + let tx_list_hash = extra + .tx_blob_hash + .unwrap_or(TxHash::from(keccak::keccak(extra.l2_tx_list.as_slice()))); let deposits: Vec = extra .l2_withdrawals .iter()