Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(raiko): multi blocks in one proposal tx #403

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions core/src/preflight/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,19 @@ pub async fn prepare_taiko_chain_input(

// Fetch the tx data from either calldata or blobdata
let (tx_data, blob_commitment, blob_proof) = if block_proposed.blob_used() {
let expected_blob_hash = block_proposed.blob_hash();
let blob_hashes = proposal_tx.blob_versioned_hashes.unwrap_or_default();
// Get the blob hashes attached to the propose tx and make sure the expected blob hash is in there
require(
blob_hashes.contains(&expected_blob_hash),
&format!(
"Proposal blobs hash mismatch: {:?} not in {:?}",
expected_blob_hash, blob_hashes
),
)?;

get_tx_data(
proposal_tx.blob_versioned_hashes,
expected_blob_hash,
l1_inclusion_header.timestamp,
l1_chain_spec,
&blob_proof_type,
Expand Down Expand Up @@ -187,17 +198,12 @@ pub async fn prepare_taiko_chain_input(
}

pub async fn get_tx_data(
blob_versioned_hashes: Option<Vec<B256>>,
blob_hash: B256,
timestamp: u64,
chain_spec: &ChainSpec,
blob_proof_type: &BlobProofType,
) -> RaikoResult<(Vec<u8>, Option<Vec<u8>>, Option<Vec<u8>>)> {
debug!("blob active");
// Get the blob hashes attached to the propose tx
let blob_hashes = blob_versioned_hashes.unwrap_or_default();
require(!blob_hashes.is_empty(), "blob hashes are empty")?;
// Currently the protocol enforces the first blob hash to be used
let blob_hash = blob_hashes[0];
debug!("get tx from hash blob: {blob_hash:?}");
// Get the blob data for this block
let slot_id = block_time_to_block_slot(
timestamp,
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ services:
- L1_NETWORK=${L1_NETWORK}
- NETWORK=${NETWORK}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
- RUST_LOG=${RUST_LOG:-info}
# you can use your own PCCS host
#- PCCS_HOST=host.docker.internal:8081
# use the host's network to connect to the PCCS
Expand Down
1 change: 1 addition & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash

exec 2>&1
set -xeo pipefail

export IN_CONTAINER=1
Expand Down
4 changes: 3 additions & 1 deletion host/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use tracing_subscriber::FmtSubscriber;
#[tokio::main]
async fn main() -> HostResult<()> {
dotenv::dotenv().ok();
env_logger::init();
env_logger::Builder::from_default_env()
.target(env_logger::Target::Stdout)
.init();
let state = ProverState::init()?;
let _guard = subscribe_log(
&state.opts.log_path,
Expand Down
8 changes: 8 additions & 0 deletions lib/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ impl BlockProposedFork {
_ => None,
}
}

pub fn blob_hash(&self) -> B256 {
match self {
BlockProposedFork::Hekla(block) => block.meta.blobHash,
BlockProposedFork::Ontake(block) => block.meta.blobHash,
_ => B256::default(),
}
}
}

#[serde_as]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/protocol_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::{
},
CycleTracker,
};
use log::{debug, info};
use reth_evm_ethereum::taiko::ANCHOR_GAS_LIMIT;
use tracing::{debug, info};

#[derive(Debug, Clone)]
pub enum BlockMetaDataFork {
Expand Down
6 changes: 5 additions & 1 deletion lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy_rlp::Decodable;
use anyhow::Result;
use libflate::zlib::{Decoder as zlibDecoder, Encoder as zlibEncoder};
use reth_primitives::TransactionSigned;
use tracing::{error, warn};
use tracing::{debug, error, warn};

use crate::consts::{ChainSpec, Network};
use crate::input::BlockProposedFork;
Expand All @@ -31,6 +31,10 @@ fn unzip_tx_list_from_data_buf(
blob_slice_param: Option<(usize, usize)>,
tx_list_data_buf: &[u8],
) -> Vec<u8> {
debug!(
"unzip_tx_list_from_data_buf(is_blob_data: {is_blob_data}, tx_list_data_buf.len: {:?}, blob_slice_param: {blob_slice_param:?})",
tx_list_data_buf.len()
);
#[allow(clippy::collapsible_else_if)]
if chain_spec.is_taiko() {
// taiko has some limitations to be aligned with taiko-client
Expand Down
Loading