-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prover types to make SDK feature complete.
- Loading branch information
Showing
5 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
use alloy_primitives::B256; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub mod base64 { | ||
use base64::prelude::*; | ||
use serde::{Deserialize, Deserializer, Serialize, Serializer}; | ||
|
||
/// serialize bytes as base64 | ||
pub fn serialize<S>(data: &[u8], s: S) -> Result<S::Ok, S::Error> | ||
where | ||
S: Serializer, | ||
{ | ||
String::serialize(&BASE64_STANDARD.encode(data), s) | ||
} | ||
|
||
/// deserialize base64 to bytes | ||
pub fn deserialize<'de, D>(d: D) -> Result<Vec<u8>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
let s = String::deserialize(d)?; | ||
BASE64_STANDARD | ||
.decode(s.as_bytes()) | ||
.map_err(serde::de::Error::custom) | ||
} | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct ChunkTaskDetail { | ||
pub block_hashes: Vec<B256>, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize)] | ||
pub struct BundleTaskDetail { | ||
pub batch_proofs: Vec<BatchProof>, | ||
} | ||
|
||
#[derive(Debug, Clone, Deserialize, Serialize)] | ||
pub struct SubCircuitRowUsage { | ||
pub name: String, | ||
pub row_number: usize, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Deserialize, Serialize)] | ||
pub struct ChunkProof { | ||
#[serde(with = "base64")] | ||
pub protocol: Vec<u8>, | ||
#[serde(flatten)] | ||
pub proof: Proof, | ||
pub chunk_info: ChunkInfo, | ||
#[serde(default)] | ||
pub row_usages: Vec<SubCircuitRowUsage>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct BatchProof { | ||
#[serde(with = "base64")] | ||
pub protocol: Vec<u8>, | ||
#[serde(flatten)] | ||
proof: Proof, | ||
pub batch_hash: B256, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct BundleProof { | ||
#[serde(flatten)] | ||
on_chain_proof: Proof, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Deserialize, Serialize)] | ||
pub struct Proof { | ||
#[serde(with = "base64")] | ||
proof: Vec<u8>, | ||
#[serde(with = "base64")] | ||
instances: Vec<u8>, | ||
#[serde(with = "base64")] | ||
vk: Vec<u8>, | ||
pub git_version: Option<String>, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Deserialize, Serialize)] | ||
pub struct ChunkInfo { | ||
/// Chain identifier | ||
pub chain_id: u64, | ||
/// state root before this chunk | ||
pub prev_state_root: B256, | ||
/// state root after this chunk | ||
pub post_state_root: B256, | ||
/// the withdraw root after this chunk | ||
pub withdraw_root: B256, | ||
/// the data hash of this chunk | ||
pub data_hash: B256, | ||
/// Flattened L2 tx bytes (RLP-signed) in this chunk. | ||
#[serde(with = "base64")] | ||
pub tx_bytes: Vec<u8>, | ||
/// if the chunk is a padded chunk | ||
pub is_padding: bool, | ||
} |