Skip to content

Commit

Permalink
feat(raiko): remove A6 support (#200)
Browse files Browse the repository at this point in the history
* remove a6 support

* ci openapi deployment fix

* hopefully fix pages deployment

* fix test compile
  • Loading branch information
Brechtpd authored May 14, 2024
1 parent 5ede08c commit 250b9ea
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 189 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/openapi-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ concurrency:
jobs:
deploy-docs:
name: Generate OpenAPI docs
runs-on: ubuntu-latest
environment:
name: github-pages
name: ${{ (github.ref == 'refs/heads/main') && 'github-pages' || 'test-environment' }}
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest

steps:
- name: Checkout
Expand All @@ -36,13 +36,16 @@ jobs:
run: ./script/generate-docs.sh

- name: Setup Pages
if: github.ref == 'refs/heads/main'
uses: actions/configure-pages@v3

- name: Upload artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v2
with:
path: './openapi'
path: './openapi'

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
id: deployment
uses: actions/deploy-pages@v2
38 changes: 13 additions & 25 deletions host/src/preflight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use raiko_lib::{
builder::{
prepare::TaikoHeaderPrepStrategy, BlockBuilder, OptimisticDatabase, TkoTxExecStrategy,
},
consts::{ChainSpec, Network},
consts::ChainSpec,
input::{
decode_anchor, proposeBlockCall, taiko_a6::BlockProposed as TestnetBlockProposed,
BlockProposed, GuestInput, TaikoGuestInput, TaikoProverData,
decode_anchor, proposeBlockCall, BlockProposed, GuestInput, TaikoGuestInput,
TaikoProverData,
},
utils::{generate_transactions, to_header, zlib_compress_data},
Measurement,
Expand Down Expand Up @@ -476,16 +476,8 @@ async fn get_block_proposed_event(
bail!("No L1 contract address in the chain spec");
};

let Some(network) = chain_spec.network() else {
bail!("No network in the chain spec");
};

// Get the event signature (value can differ between chains)
let event_signature = if network == Network::TaikoA6 {
TestnetBlockProposed::SIGNATURE_HASH
} else {
BlockProposed::SIGNATURE_HASH
};
let event_signature = BlockProposed::SIGNATURE_HASH;
// Setup the filter to get the relevant events
let filter = Filter::new()
.address(l1_address)
Expand All @@ -504,24 +496,17 @@ async fn get_block_proposed_event(
) else {
bail!("Could not create log")
};
let (block_id, data) = if network == Network::TaikoA6 {
let event = TestnetBlockProposed::decode_log(&log_struct, false)
.map_err(|_| HostError::Anyhow(anyhow!("Could not decode tesstnet log")))?;
(event.blockId, event.data.into())
} else {
let event = BlockProposed::decode_log(&log_struct, false)
.map_err(|_| HostError::Anyhow(anyhow!("Could not decode log")))?;
(event.blockId, event.data)
};
if block_id == raiko_primitives::U256::from(l2_block_number) {
let event = BlockProposed::decode_log(&log_struct, false)
.map_err(|_| HostError::Anyhow(anyhow!("Could not decode log")))?;
if event.blockId == raiko_primitives::U256::from(l2_block_number) {
let Some(log_tx_hash) = log.transaction_hash else {
bail!("No transaction hash in the log")
};
let tx = provider
.get_transaction_by_hash(log_tx_hash)
.await
.expect("Could not find the propose tx");
return Ok((tx, data));
return Ok((tx, event.data));
}
}
bail!("No BlockProposed event found for block {l2_block_number}");
Expand Down Expand Up @@ -638,7 +623,10 @@ fn from_block_tx(tx: &AlloyRpcTransaction) -> HostResult<TxEnvelope> {
#[cfg(test)]
mod test {
use ethers_core::types::Transaction;
use raiko_lib::{consts::get_network_spec, utils::decode_transactions};
use raiko_lib::{
consts::{get_network_spec, Network},
utils::decode_transactions,
};
use raiko_primitives::{eip4844::parse_kzg_trusted_setup, kzg::KzgSettings};

use super::*;
Expand Down Expand Up @@ -877,7 +865,7 @@ mod test {
#[ignore]
#[test]
fn test_slot_block_num_mapping() {
let chain_spec = get_network_spec(Network::TaikoA6);
let chain_spec = get_network_spec(Network::TaikoA7);
let expected_slot = 1000u64;
let second_per_slot = 12u64;
let block_time = chain_spec.genesis_time + expected_slot * second_per_slot;
Expand Down
31 changes: 0 additions & 31 deletions lib/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,6 @@ lazy_static! {
is_taiko: false,
};

/// The Taiko A6 specification.
pub static ref TAIKO_A6_CHAIN_SPEC: ChainSpec = ChainSpec {
name: Network::TaikoA6.to_string(),
chain_id: 167008,
max_spec_id: SpecId::SHANGHAI,
hard_forks: BTreeMap::from([
(SpecId::SHANGHAI, ForkCondition::Block(0)),
(SpecId::CANCUN, ForkCondition::TBD),
]),
eip_1559_constants: Eip1559Constants {
base_fee_change_denominator: uint!(8_U256),
base_fee_max_increase_denominator: uint!(8_U256),
base_fee_max_decrease_denominator: uint!(8_U256),
elasticity_multiplier: uint!(2_U256),
},
l1_contract: Some(Address::from_str("0xB20BB9105e007Bd3E0F73d63D4D3dA2c8f736b77").unwrap()),
l2_contract: Some(Address::from_str("0x1670080000000000000000000000000000010001").unwrap()),
sgx_verifier_address: Some(
Address::from_str("0x558E38a3286916934Cb63ced04558A52F7Ce67a9").unwrap(),
),
genesis_time: 0u64,
seconds_per_slot: 1u64,
is_taiko: true,
};

/// The Taiko A7 specification.
pub static ref TAIKO_A7_CHAIN_SPEC: ChainSpec = ChainSpec {
name: Network::TaikoA7.to_string(),
Expand Down Expand Up @@ -151,7 +126,6 @@ pub fn get_network_spec(network: Network) -> ChainSpec {
match network {
Network::Ethereum => ETH_MAINNET_CHAIN_SPEC.clone(),
Network::Holesky => ETH_HOLESKY_CHAIN_SPEC.clone(),
Network::TaikoA6 => TAIKO_A6_CHAIN_SPEC.clone(),
Network::TaikoA7 => TAIKO_A7_CHAIN_SPEC.clone(),
}
}
Expand Down Expand Up @@ -286,8 +260,6 @@ pub enum Network {
Ethereum,
/// Ethereum testnet holesky
Holesky,
/// Taiko A6 tesnet
TaikoA6,
/// Taiko A7 tesnet
TaikoA7,
}
Expand All @@ -299,7 +271,6 @@ impl FromStr for Network {
match s.to_lowercase().as_str() {
"ethereum" => Ok(Network::Ethereum),
"holesky" => Ok(Network::Holesky),
"taiko_a6" => Ok(Network::TaikoA6),
"taiko_a7" => Ok(Network::TaikoA7),
#[allow(clippy::needless_return)]
_ => bail!("Unknown network"),
Expand All @@ -312,7 +283,6 @@ impl Display for Network {
f.write_str(match self {
Network::Ethereum => "ethereum",
Network::Holesky => "holesky",
Network::TaikoA6 => "taiko_a6",
Network::TaikoA7 => "taiko_a7",
})
}
Expand All @@ -323,7 +293,6 @@ impl Network {
match self {
Network::Ethereum => false,
Network::Holesky => false,
Network::TaikoA6 => true,
Network::TaikoA7 => true,
}
}
Expand Down
125 changes: 0 additions & 125 deletions lib/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,131 +205,6 @@ sol! {
function proveBlock(uint64 blockId, bytes calldata input) {}
}

pub mod taiko_a6 {
use alloy_sol_types::sol;
use serde::{Deserialize, Serialize};

sol! {
#[derive(Debug, Default, Deserialize, Serialize)]
struct EthDeposit {
address recipient;
uint96 amount;
uint64 id;
}

#[derive(Debug, Default, Deserialize, Serialize)]
struct BlockMetadata {
bytes32 l1Hash; // slot 1
bytes32 difficulty; // slot 2
bytes32 blobHash; //or txListHash (if Blob not yet supported), // slot 3
bytes32 extraData; // slot 4
bytes32 depositsHash; // slot 5
address coinbase; // L2 coinbase, // slot 6
uint64 id;
uint32 gasLimit;
uint64 timestamp; // slot 7
uint64 l1Height;
uint24 txListByteOffset;
uint24 txListByteSize;
uint16 minTier;
bool blobUsed;
bytes32 parentMetaHash; // slot 8
}

#[derive(Debug, Default, Deserialize, Serialize)]
struct BlockParams {
address assignedProver;
address coinbase;
bytes32 extraData;
bytes32 blobHash;
uint24 txListByteOffset;
uint24 txListByteSize;
bool cacheBlobForReuse;
bytes32 parentMetaHash;
HookCall[] hookCalls;
}

#[derive(Debug, Default, Deserialize, Serialize)]
struct HookCall {
address hook;
bytes data;
}

#[derive(Debug)]
struct Transition {
bytes32 parentHash;
bytes32 blockHash;
bytes32 signalRoot;
bytes32 graffiti;
}

#[derive(Debug, Default, Deserialize, Serialize)]
event BlockProposed(
uint256 indexed blockId,
address indexed assignedProver,
uint96 livenessBond,
BlockMetadata meta,
EthDeposit[] depositsProcessed
);

#[derive(Debug)]
struct TierProof {
uint16 tier;
bytes data;
}

#[derive(Debug)]
function proposeBlock(
bytes calldata params,
bytes calldata txList
)
{}

function proveBlock(uint64 blockId, bytes calldata input) {}
}
}

impl From<taiko_a6::EthDeposit> for EthDeposit {
fn from(item: taiko_a6::EthDeposit) -> Self {
EthDeposit {
recipient: item.recipient,
amount: item.amount,
id: item.id,
}
}
}

impl From<taiko_a6::BlockProposed> for BlockProposed {
fn from(item: taiko_a6::BlockProposed) -> Self {
BlockProposed {
blockId: item.blockId,
assignedProver: item.assignedProver,
livenessBond: item.livenessBond,
meta: BlockMetadata {
l1Hash: item.meta.l1Hash,
difficulty: item.meta.difficulty,
blobHash: item.meta.blobHash,
extraData: item.meta.extraData,
depositsHash: item.meta.depositsHash,
coinbase: item.meta.coinbase,
id: item.meta.id,
gasLimit: item.meta.gasLimit,
timestamp: item.meta.timestamp,
l1Height: item.meta.l1Height,
minTier: item.meta.minTier,
blobUsed: item.meta.blobUsed,
parentMetaHash: item.meta.parentMetaHash,
..Default::default()
},
depositsProcessed: item
.depositsProcessed
.iter()
.map(|v| v.clone().into())
.collect(),
}
}
}

#[cfg(feature = "std")]
use std::path::Path;

Expand Down
6 changes: 1 addition & 5 deletions script/prove-block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ if [ "$chain" == "ethereum" ]; then
rpc="https://rpc.ankr.com/eth"
elif [ "$chain" == "holesky" ]; then
rpc="https://ethereum-holesky-rpc.publicnode.com"
elif [ "$chain" == "taiko_a6" ]; then
rpc="https://rpc.katla.taiko.xyz"
l1Rpc="https://ethereum-holesky-rpc.publicnode.com"
beaconRpc="https://l1beacon.hekla.taiko.xyz"
elif [ "$chain" == "taiko_a7" ]; then
rpc="https://rpc.hekla.taiko.xyz"
l1Rpc="https://ethereum-holesky-rpc.publicnode.com"
beaconRpc="https://eth-holesky-beacon.public.blastapi.io"
else
echo "Invalid chain name. Please use 'ethereum', 'taiko_a6' or 'taiko_a7'."
echo "Invalid chain name. Please use 'ethereum', 'holesky' or 'taiko_a7'."
exit 1
fi

Expand Down

0 comments on commit 250b9ea

Please sign in to comment.