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

fix(raiko): fix sp1 patches and update to ontake revm version #352

Closed
wants to merge 17 commits into from
513 changes: 402 additions & 111 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ reth-evm-ethereum = { git = "https://github.com/taikoxyz/taiko-reth.git", branch
reth-evm = { git = "https://github.com/taikoxyz/taiko-reth.git", branch = "v1.0.0-rc.2-taiko", default-features = false }
reth-rpc-types = { git = "https://github.com/taikoxyz/taiko-reth.git", branch = "v1.0.0-rc.2-taiko", default-features = false }
reth-revm = { git = "https://github.com/taikoxyz/taiko-reth.git", branch = "v1.0.0-rc.2-taiko", default-features = false }
reth-chainspec = { git = "https://github.com/taikoxyz/taiko-reth.git", branch = "v1.0.0-rc.2-taiko", default-features = false }
reth-chainspec = { git = "https://github.com/taikoxyz/taiko-reth.git", branch = "v1.0.0-rc.2-taiko", default-features = false, features = [
"taiko",
] }
reth-provider = { git = "https://github.com/taikoxyz/taiko-reth.git", branch = "v1.0.0-rc.2-taiko", default-features = false }

# risc zero
Expand All @@ -57,9 +59,12 @@ risc0-build = { version = "1.0.1" }
risc0-binfmt = { version = "1.0.1" }

# SP1
sp1-sdk = { version = "1.0.1" }
sp1-zkvm = { version = "1.0.1" }
sp1-helper = { version = "1.0.1" }
# sp1-sdk = { version = "1.0.1" }
# sp1-zkvm = { version = "1.0.1" }
# sp1-helper = { version = "1.0.1" }
sp1-sdk = { git = "https://github.com/succinctlabs/sp1", branch = "dev" }
sp1-zkvm = { git = "https://github.com/succinctlabs/sp1", branch = "dev" }
sp1-helper = { git = "https://github.com/succinctlabs/sp1", branch = "dev" }

# alloy
alloy-rlp = { version = "0.3.4", default-features = false }
Expand Down Expand Up @@ -134,7 +139,7 @@ utoipa-scalar = { version = "0.1.0", features = ["axum"] }
utoipa = { version = "4.2.0", features = ["axum_extras"] }
structopt = "0.3.24"
prometheus = { version = "0.13.3", features = ["process"] }
tokio = { version = "^1.23", features = ["full"] }
tokio = { version = "^1.39.3", features = ["full"] }
tokio-util = { version = "0.7.11" }
reqwest = { version = "0.11.22", features = ["json"] }
url = "2.5.0"
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARG BUILD_FLAGS=""

WORKDIR /opt/raiko
COPY . .
RUN cargo build --release ${BUILD_FLAGS} --features "sgx,risc0" --features "docker_build"
RUN cargo build --release ${BUILD_FLAGS} --features "sgx" --features "docker_build"

FROM gramineproject/gramine:1.6-jammy as runtime
ENV DEBIAN_FRONTEND=noninteractive
Expand Down
16 changes: 9 additions & 7 deletions core/src/provider/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ impl BlockDataProvider for RpcBlockDataProvider {
));
}

batch
.send()
.await
.map_err(|_| RaikoError::RPC("Error sending batch request".to_owned()))?;
batch.send().await.map_err(|e| {
RaikoError::RPC(format!(
"Error sending batch request for block {:?}: {e}",
blocks_to_fetch
))
})?;

let mut blocks = Vec::with_capacity(max_batch_size);
// Collect the data from the batch
Expand Down Expand Up @@ -132,7 +134,7 @@ impl BlockDataProvider for RpcBlockDataProvider {
batch
.send()
.await
.map_err(|_| RaikoError::RPC("Error sending batch request".to_owned()))?;
.map_err(|e| RaikoError::RPC(format!("Error sending batch request {e}")))?;

let mut accounts = vec![];
// Collect the data from the batch
Expand Down Expand Up @@ -197,7 +199,7 @@ impl BlockDataProvider for RpcBlockDataProvider {
batch
.send()
.await
.map_err(|_| RaikoError::RPC("Error sending batch request".to_owned()))?;
.map_err(|e| RaikoError::RPC(format!("Error sending batch request {e}")))?;

let mut values = Vec::with_capacity(max_batch_size);
// Collect the data from the batch
Expand Down Expand Up @@ -299,7 +301,7 @@ impl BlockDataProvider for RpcBlockDataProvider {
batch
.send()
.await
.map_err(|_| RaikoError::RPC("Error sending batch request".to_owned()))?;
.map_err(|e| RaikoError::RPC(format!("Error sending batch request {e}")))?;

// Collect the data from the batch
for request in requests {
Expand Down
10 changes: 5 additions & 5 deletions host/config/chain_spec_list_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"l1_contract": null,
"l2_contract": null,
"rpc": "https://rpc.ankr.com/eth",
"rpc": "https://ethereum-rpc.publicnode.com",
"beacon_rpc": "https://ethereum-beacon-api.publicnode.com",
"verifier_address": {
"SGX":"0x532efbf6d62720d0b2a2bb9d11066e8588cae6d9",
Expand Down Expand Up @@ -73,9 +73,9 @@
{
"name": "taiko_a7",
"chain_id": 167009,
"max_spec_id": "SHANGHAI",
"max_spec_id": "HEKLA",
"hard_forks": {
"SHANGHAI": {
"HEKLA": {
"Block": 0
},
"CANCUN": "TBD"
Expand All @@ -102,9 +102,9 @@
{
"name": "taiko_mainnet",
"chain_id": 167000,
"max_spec_id": "SHANGHAI",
"max_spec_id": "HEKLA",
"hard_forks": {
"SHANGHAI": {
"HEKLA": {
"Block": 0
},
"CANCUN": "TBD"
Expand Down
4 changes: 2 additions & 2 deletions host/config/chain_spec_list_devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
{
"name": "taiko_dev",
"chain_id": 167001,
"max_spec_id": "SHANGHAI",
"max_spec_id": "HEKLA",
"hard_forks": {
"SHANGHAI": {
"HEKLA": {
"Block": 0
},
"CANCUN": "TBD"
Expand Down
11 changes: 7 additions & 4 deletions host/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,18 @@ impl ProofActor {
pub async fn run_task(&mut self, proof_request: ProofRequest, _permit: OwnedSemaphorePermit) {
let cancel_token = CancellationToken::new();

let Ok((chain_id, blockhash)) = get_task_data(
let res = get_task_data(
&proof_request.network,
proof_request.block_number,
&self.chain_specs,
)
.await
else {
error!("Could not get task data for {proof_request:?}");
.await;
if let Err(e) = res {
error!("Could not get task data for {proof_request:?}: {e}");
return;
}
let Ok((chain_id, blockhash)) = res else {
unreachable!();
};

let key = TaskDescriptor::from((
Expand Down
10 changes: 8 additions & 2 deletions lib/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use reth_primitives::revm_primitives::{
Account, AccountInfo, AccountStatus, Bytecode, Bytes, HashMap,
};
use reth_primitives::{Address, BlockWithSenders, Header, B256, KECCAK_EMPTY, U256};
use tracing::debug;
use tracing::{debug, error};

pub fn calculate_block_header(input: &GuestInput) -> Header {
let cycle_tracker = CycleTracker::start("initialize_database");
Expand Down Expand Up @@ -116,6 +116,7 @@ impl<DB: Database<Error = ProviderError> + DatabaseCommit + OptimisticDatabase>
l1_header: self.input.taiko.l1_header.clone(),
parent_header: self.input.parent_header.clone(),
l2_contract: self.input.chain_spec.l2_contract.unwrap_or_default(),
..Default::default()
})
.optimistic(optimistic);
let BlockExecutionOutput {
Expand All @@ -125,7 +126,12 @@ impl<DB: Database<Error = ProviderError> + DatabaseCommit + OptimisticDatabase>
gas_used: _,
db: full_state,
valid_transaction_indices,
} = executor.execute((&block, total_difficulty).into())?;
} = executor
.execute((&block, total_difficulty).into())
.map_err(|e| {
error!("Error executing block: {:?}", e);
e
})?;
// Filter out the valid transactions so that the header checks only take these into account
block.body = valid_transaction_indices
.iter()
Expand Down
8 changes: 8 additions & 0 deletions lib/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ mod tests {
);
}

#[test]
fn revm_taiko_a7_spec_id() {
let taiko_a7_spec = SupportedChainSpecs::default()
.get_chain_spec(&Network::TaikoA7.to_string())
.unwrap();
assert_eq!(taiko_a7_spec.spec_id(1, 0), Some(SpecId::HEKLA));
}

#[ignore]
#[test]
fn serde_chain_spec() {
Expand Down
2 changes: 1 addition & 1 deletion provers/risc0/driver/src/methods/risc0_guest.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub const RISC0_GUEST_ELF: &[u8] =
include_bytes!("../../../guest/target/riscv32im-risc0-zkvm-elf/release/risc0-guest");
pub const RISC0_GUEST_ID: [u32; 8] = [
585002223, 1554547443, 2264904673, 1125944276, 2810284811, 2386551270, 1177567941, 3875681569,
3081612924, 3607021821, 3447357908, 4021531326, 181386186, 1121032291, 3850993439, 1990175839,
];
Loading
Loading