diff --git a/host/src/host/host.rs b/host/src/host/host.rs index fff6c7a8..136ab5ef 100644 --- a/host/src/host/host.rs +++ b/host/src/host/host.rs @@ -104,8 +104,15 @@ pub fn preflight( assert!(!blob_hashs.is_empty()); // Currently the protocol enforces the first blob hash to be used let blob_hash = blob_hashs[0]; + + let l2_chain_spec = get_network_spec(network); + let slot_id = block_time_to_block_slot( + l1_inclusion_block.header.timestamp.as_limbs()[0], + l2_chain_spec.genesis_time, + l2_chain_spec.seconds_per_slot, + )?; // Get the blob data for this block - let blobs = get_blob_data(&beacon_rpc_url.clone().unwrap(), l1_inclusion_block_no)?; + let blobs = get_blob_data(&beacon_rpc_url.clone().unwrap(), slot_id)?; assert!(!blobs.data.is_empty(), "blob data not available anymore"); // Get the blob data for the blob storing the tx list let tx_blobs: Vec = blobs @@ -203,6 +210,21 @@ pub fn preflight( }) } +// block_time_to_block_slot returns the slots of the given timestamp. +fn block_time_to_block_slot( + block_time: u64, + genesis_time: u64, + block_per_slot: u64, +) -> Result { + if block_time < genesis_time { + Err(anyhow::Error::msg( + "provided block_time precedes genesis time", + )) + } else { + Ok((block_time - genesis_time) / block_per_slot) + } +} + fn blob_to_bytes(blob_str: &str) -> Vec { match hex::decode(blob_str.to_lowercase().trim_start_matches("0x")) { Ok(b) => b, @@ -225,7 +247,8 @@ fn get_blob_data(beacon_rpc_url: &str, block_id: u64) -> Result = Lazy::new(|| ChainSpec { - chain_id: 167001, + chain_id: 167009, hard_forks: BTreeMap::from([ (SpecId::SHANGHAI, ForkCondition::Block(0)), (SpecId::CANCUN, ForkCondition::TBD), @@ -96,11 +100,13 @@ pub const TAIKO_A7_CHAIN_SPEC: Lazy = Lazy::new(|| ChainSpec { base_fee_max_decrease_denominator: uint!(8_U256), elasticity_multiplier: uint!(2_U256), }, - l1_contract: Some(Address::from_str("0xC069c3d2a9f2479F559AD34485698ad5199C555f").unwrap()), - l2_contract: Some(Address::from_str("0x1670010000000000000000000000000000010001").unwrap()), + l1_contract: Some(Address::from_str("0x79C9109b764609df928d16fC4a91e9081F7e87DB").unwrap()), + l2_contract: Some(Address::from_str("0x1670090000000000000000000000000000010001").unwrap()), sgx_verifier_address: Some( - Address::from_str("0x558E38a3286916934Cb63ced04558A52F7Ce67a9").unwrap(), + Address::from_str("0x532EFBf6D62720D0B2a2Bb9d11066E8588cAE6D9").unwrap(), ), + genesis_time: 1695902400u64, + seconds_per_slot: 12u64, }); pub fn get_network_spec(network: Network) -> ChainSpec { @@ -160,6 +166,8 @@ pub struct ChainSpec { pub l1_contract: Option
, pub l2_contract: Option
, pub sgx_verifier_address: Option
, + pub genesis_time: u64, + pub seconds_per_slot: u64, } impl ChainSpec { @@ -176,6 +184,8 @@ impl ChainSpec { l1_contract: None, l2_contract: None, sgx_verifier_address: None, + genesis_time: 0u64, + seconds_per_slot: 1u64, } } /// Returns the network chain ID. diff --git a/lib/src/protocol_instance.rs b/lib/src/protocol_instance.rs index e2ef08d7..79999454 100644 --- a/lib/src/protocol_instance.rs +++ b/lib/src/protocol_instance.rs @@ -109,7 +109,7 @@ pub fn assemble_protocol_instance( transition: Transition { parentHash: header.parent_hash, blockHash: header.hash(), - stateRoot: input.taiko.l1_header.state_root, + stateRoot: header.state_root, graffiti: input.taiko.prover_data.graffiti, }, block_metadata: BlockMetadata { diff --git a/prove_block.sh b/prove_block.sh index 08ba8c4d..838373f7 100755 --- a/prove_block.sh +++ b/prove_block.sh @@ -12,9 +12,11 @@ rangeEnd="$4" if [ "$chain" == "taiko_a6" ]; then l2Rpc="https://rpc.katla.taiko.xyz" l1Rpc="https://l1rpc.katla.taiko.xyz" + beaconRpc="https://l1beacon.hekla.taiko.xyz" elif [ "$chain" == "taiko_a7" ]; then - l2Rpc="https://rpc.internal.taiko.xyz" - l1Rpc="https://l1rpc.internal.taiko.xyz" + l2Rpc="https://rpc.hekla.taiko.xyz/" + l1Rpc="https://l1rpc.hekla.taiko.xyz/" + beaconRpc="https://l1beacon.hekla.taiko.xyz" else echo "Invalid chain name. Please use 'taiko_a6' or 'taiko_a7'." exit 1 @@ -59,7 +61,6 @@ if [ "$rangeEnd" == "" ]; then rangeEnd=$rangeStart fi -beaconRpc="https://l1beacon.internal.taiko.xyz" prover="0x70997970C51812dc3A010C7d01b50e0d17dc79C8" graffiti="8008500000000000000000000000000000000000000000000000000000000000"