Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 20 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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ log.build.*
venv/
.venv/

*.pyc
.env*
log
*.patch
3 changes: 2 additions & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[default.extend-words]
consts = "consts"
Ba = "Ba"

[default.extend-identifiers]
consts = "consts"
consts = "consts"
2 changes: 0 additions & 2 deletions Dockerfile.zk
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ COPY --from=builder /opt/raiko/target/release/raiko-host /opt/raiko/bin/
# Copy the .env file with RISC0 and SP1 image IDs from builder stage
COPY --from=builder /opt/raiko/.env /opt/raiko/.env
# Include only the runtime guest ELF artifacts for SP1 and RISC0
COPY --from=builder /opt/raiko/provers/sp1/guest/elf/sp1-aggregation /opt/raiko/provers/sp1/elf/sp1-aggregation
COPY --from=builder /opt/raiko/provers/sp1/guest/elf/sp1-batch /opt/raiko/provers/sp1/elf/sp1-batch
COPY --from=builder /opt/raiko/provers/sp1/guest/elf/sp1-shasta-aggregation /opt/raiko/provers/sp1/elf/sp1-shasta-aggregation
COPY --from=builder /opt/raiko/provers/risc0/guest/target/riscv32im-risc0-zkvm-elf/release/boundless-aggregation.bin /opt/raiko/provers/risc0/elf/boundless-aggregation.bin
COPY --from=builder /opt/raiko/provers/risc0/guest/target/riscv32im-risc0-zkvm-elf/release/boundless-batch.bin /opt/raiko/provers/risc0/elf/boundless-batch.bin
COPY --from=builder /opt/raiko/provers/risc0/guest/target/riscv32im-risc0-zkvm-elf/release/boundless-shasta-aggregation.bin /opt/raiko/provers/risc0/elf/boundless-shasta-aggregation.bin

Expand Down
3 changes: 2 additions & 1 deletion ballot/src/poisson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl PoissionDrawer {
let mut last_draw_time = HashMap::new();

for (ptype, (_rate, per_day)) in config {
#[allow(clippy::clone_on_copy)]
per_day_limit.insert(ptype.clone(), per_day as usize);
let interval = if per_day == 0 {
0
Expand Down Expand Up @@ -60,7 +61,7 @@ impl PoissionDrawer {
.get(proof_type)
.cloned()
.unwrap_or_default();
let delta = now.signed_duration_since(&last_time).num_seconds();
let delta = now.signed_duration_since(last_time).num_seconds();
if delta <= 0 {
return false;
}
Expand Down
182 changes: 6 additions & 176 deletions core/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use alloy_primitives::{Address, B256};
use clap::Args;
use raiko_lib::{
input::{
shasta::Checkpoint, AggregationGuestInput, AggregationGuestOutput, BlobProofType,
GuestBatchInput, GuestBatchOutput, GuestInput, GuestOutput, ShastaAggregationGuestInput,
shasta::Checkpoint, AggregationGuestOutput, BlobProofType, GuestBatchInput,
GuestBatchOutput, GuestInput, GuestOutput, ShastaAggregationGuestInput,
},
proof_type::ProofType,
prover::{IdStore, IdWrite, Proof, ProofKey, Prover, ProverError},
Expand Down Expand Up @@ -209,51 +209,6 @@ pub async fn run_shasta_proposal_prover(
}
}

/// Run the prover driver depending on the proof type.
pub async fn aggregate_proofs(
proof_type: ProofType,
input: AggregationGuestInput,
output: &AggregationGuestOutput,
config: &Value,
store: Option<&mut dyn IdWrite>,
) -> RaikoResult<Proof> {
let proof = match proof_type {
ProofType::Native => NativeProver
.aggregate(input.clone(), output, config, store)
.await
.map_err(<ProverError as Into<RaikoError>>::into),
ProofType::Sp1 => {
#[cfg(feature = "sp1")]
return sp1_driver::Sp1Prover
.aggregate(input.clone(), output, config, store)
.await
.map_err(|e| e.into());
#[cfg(not(feature = "sp1"))]
Err(RaikoError::FeatureNotSupportedError(proof_type))
}
ProofType::Risc0 => {
#[cfg(feature = "risc0")]
return risc0_driver::Risc0Prover
.aggregate(input.clone(), output, config, store)
.await
.map_err(|e| e.into());
#[cfg(not(feature = "risc0"))]
Err(RaikoError::FeatureNotSupportedError(proof_type))
}
ProofType::Sgx | ProofType::SgxGeth => {
#[cfg(feature = "sgx")]
return sgx_prover::SgxProver::new(proof_type)
.aggregate(input.clone(), output, config, store)
.await
.map_err(|e| e.into());
#[cfg(not(feature = "sgx"))]
Err(RaikoError::FeatureNotSupportedError(proof_type))
}
}?;

Ok(proof)
}

pub async fn aggregate_shasta_proposals(
proof_type: ProofType,
input: ShastaAggregationGuestInput,
Expand Down Expand Up @@ -378,128 +333,6 @@ pub struct ProofRequest {
pub cached_event_data: Option<raiko_lib::input::BlockProposedFork>,
}

#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct BatchMetadata {
pub batch_id: u64,
pub l1_inclusion_block_number: u64,
}

impl std::str::FromStr for BatchMetadata {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let parts: Vec<&str> = s.split(':').collect();
if parts.len() != 2 {
return Err(anyhow::anyhow!(
"Invalid BatchMetadata format. Expected 'batch_id:l1_inclusion_block_number'"
));
}

let batch_id = parts[0]
.parse::<u64>()
.map_err(|_| anyhow::anyhow!("Invalid batch_id"))?;
let l1_inclusion_block_number = parts[1]
.parse::<u64>()
.map_err(|_| anyhow::anyhow!("Invalid l1_inclusion_block_number"))?;

Ok(Self {
batch_id,
l1_inclusion_block_number,
})
}
}

impl std::fmt::Display for BatchMetadata {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}:{}", self.batch_id, self.l1_inclusion_block_number)
}
}

#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct BatchProofRequest {
pub batches: Vec<BatchMetadata>,
pub aggregate: bool,
pub proof_type: ProofType,

pub network: String,
pub l1_network: String,
pub graffiti: B256,
#[serde_as(as = "DisplayFromStr")]
pub prover: Address,
pub blob_proof_type: BlobProofType,
#[serde(flatten)]
pub prover_args: ProverSpecificOpts,
}

#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct BatchProofRequestOpt {
// Required fields
pub batches: Vec<BatchMetadata>,
pub aggregate: Option<bool>,
pub proof_type: String,

// Optional fields, if not provided, the default values will be used
pub network: Option<String>,
pub l1_network: Option<String>,
pub graffiti: Option<String>,
pub prover: Option<String>,
pub blob_proof_type: Option<String>,
#[serde(flatten)]
pub prover_args: Option<ProverSpecificOpts>,
}

impl TryFrom<BatchProofRequestOpt> for BatchProofRequest {
type Error = RaikoError;

fn try_from(value: BatchProofRequestOpt) -> Result<Self, Self::Error> {
Ok(Self {
batches: value.batches,
aggregate: value.aggregate.unwrap_or(false),
proof_type: value
.proof_type
.parse()
.map_err(|_| RaikoError::InvalidRequestConfig("Invalid proof_type".to_string()))?,

network: value.network.ok_or(RaikoError::InvalidRequestConfig(
"Missing network".to_string(),
))?,
l1_network: value.l1_network.ok_or(RaikoError::InvalidRequestConfig(
"Missing l1_network".to_string(),
))?,
graffiti: value
.graffiti
.ok_or(RaikoError::InvalidRequestConfig(
"Missing graffiti".to_string(),
))?
.parse()
.map_err(|_| RaikoError::InvalidRequestConfig("Invalid graffiti".to_string()))?,
prover: value
.prover
.ok_or(RaikoError::InvalidRequestConfig(
"Missing prover".to_string(),
))?
.parse()
.map_err(|_| RaikoError::InvalidRequestConfig("Invalid prover".to_string()))?,
blob_proof_type: value
.blob_proof_type
.unwrap_or("proof_of_equivalence".to_string())
.parse()
.map_err(|_| {
RaikoError::InvalidRequestConfig("Invalid blob_proof_type".to_string())
})?,
prover_args: value
.prover_args
.ok_or(RaikoError::InvalidRequestConfig(
"Missing prover_args".to_string(),
))?
.into(),
})
}
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)]
pub struct ShastaProposalCheckpoint {
pub block_number: u64,
Expand All @@ -510,7 +343,7 @@ pub struct ShastaProposalCheckpoint {
impl From<ShastaProposalCheckpoint> for Checkpoint {
fn from(value: ShastaProposalCheckpoint) -> Self {
Checkpoint {
blockNumber: value.block_number.into(),
blockNumber: value.block_number,
blockHash: value.block_hash,
stateRoot: value.state_root,
}
Expand Down Expand Up @@ -606,12 +439,9 @@ impl TryFrom<ShastaProofRequestOpt> for ShastaProofRequest {
.map_err(|_| {
RaikoError::InvalidRequestConfig("Invalid blob_proof_type".to_string())
})?,
prover_args: value
.prover_args
.ok_or(RaikoError::InvalidRequestConfig(
"Missing prover_args".to_string(),
))?
.into(),
prover_args: value.prover_args.ok_or(RaikoError::InvalidRequestConfig(
"Missing prover_args".to_string(),
))?,
})
}
}
Expand Down
Loading
Loading