-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* introduce bitcoin prover * - check that l2 block da heder points to previous da header - implement send_transaction in bitcoin da * lint * review * fix udeps check * post merge fix
- Loading branch information
1 parent
bf131c8
commit fc6dfe0
Showing
17 changed files
with
162 additions
and
74 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[package] | ||
name = "citrea-bitcoin-prover" | ||
version = "0.3.0" | ||
edition = "2021" | ||
resolver = "2" | ||
|
||
[workspace] | ||
|
||
[dependencies] | ||
anyhow = "1.0.68" | ||
risc0-zkvm = { version = "0.21", default-features = false, features = ["std"] } | ||
risc0-zkvm-platform = "0.21" | ||
bitcoin-da = { path = "../../../../../crates/bitcoin-da", default-features = false } | ||
rollup-constants = { path = "../../../../rollup-constants" } | ||
citrea-stf = { path = "../../../../../crates/citrea-stf" } | ||
sov-risc0-adapter = { path = "../../../../../crates/sovereign-sdk/adapters/risc0" } | ||
sov-modules-api = { path = "../../../../../crates/sovereign-sdk/module-system/sov-modules-api", default-features = false } | ||
sov-state = { path = "../../../../../crates/sovereign-sdk/module-system/sov-state" } | ||
sov-modules-stf-blueprint = { path = "../../../../../crates/sovereign-sdk/module-system/sov-modules-stf-blueprint" } | ||
sov-rollup-interface = { path = "../../../../../crates/sovereign-sdk/rollup-interface" } | ||
# forcing cargo for this version or else chooses 3.1.1 and there is some dependency conflicts | ||
revm-primitives = { version = "=3.1.0", default-features = false } | ||
# forcing cargo for this version or else chooses 0.3.1 and there is some dependency conflicts | ||
alloy-trie = { version = "=0.3.0", default-features = false } | ||
|
||
[patch.crates-io] | ||
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" } | ||
ed25519-dalek = { git = "https://github.com/risc0/curve25519-dalek", tag = "curve25519-4.1.0-risczero.1" } | ||
crypto-bigint = { git = "https://github.com/risc0/RustCrypto-crypto-bigint", tag = "v0.5.2-risc0" } | ||
secp256k1_v027 = { package = "secp256k1", version = "0.27", git = "https://github.com/Sovereign-Labs/rust-secp256k1.git", branch = "risc0-compatible-0-27-0" } | ||
secp256k1_v028 = { package = "secp256k1", version = "0.28", git = "https://github.com/Sovereign-Labs/rust-secp256k1.git", branch = "risc0-compatible-0-28-2" } | ||
|
||
[profile.dev] | ||
opt-level = 3 | ||
|
||
[profile.dev.build-override] | ||
opt-level = 3 | ||
|
||
[profile.release] | ||
debug = 1 | ||
lto = true | ||
|
||
[profile.release.build-override] | ||
opt-level = 3 | ||
|
||
[features] | ||
bench = [ | ||
"sov-modules-api/bench", | ||
"sov-state/bench", | ||
"sov-modules-stf-blueprint/bench", | ||
] |
61 changes: 61 additions & 0 deletions
61
bin/citrea/provers/risc0/guest-bitcoin/src/bin/bitcoin_da.rs
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,61 @@ | ||
#![no_main] | ||
use bitcoin_da::spec::RollupParams; | ||
use bitcoin_da::verifier::BitcoinVerifier; | ||
|
||
use citrea_stf::runtime::Runtime; | ||
use citrea_stf::StfVerifier; | ||
#[cfg(feature = "bench")] | ||
use risc0_zkvm::guest::env; | ||
use rollup_constants::{DA_TX_ID_LEADING_ZEROS, ROLLUP_NAME}; | ||
use sov_modules_api::default_context::ZkDefaultContext; | ||
use sov_modules_stf_blueprint::StfBlueprint; | ||
use sov_risc0_adapter::guest::Risc0Guest; | ||
use sov_rollup_interface::da::DaVerifier; | ||
use sov_state::ZkStorage; | ||
|
||
#[cfg(feature = "bench")] | ||
fn report_bench_metrics(start_cycles: usize, end_cycles: usize) { | ||
let cycles_per_block = (end_cycles - start_cycles) as u64; | ||
let tuple = ("Cycles per block".to_string(), cycles_per_block); | ||
let mut serialized = Vec::new(); | ||
serialized.extend(tuple.0.as_bytes()); | ||
serialized.push(0); | ||
let size_bytes = tuple.1.to_ne_bytes(); | ||
serialized.extend(&size_bytes); | ||
|
||
// calculate the syscall name. | ||
let cycle_string = String::from("cycle_metrics\0"); | ||
let metrics_syscall_name = | ||
risc0_zkvm_platform::syscall::SyscallName::from_bytes_with_nul(cycle_string.as_ptr()); | ||
|
||
risc0_zkvm::guest::env::send_recv_slice::<u8, u8>(metrics_syscall_name, &serialized); | ||
} | ||
|
||
risc0_zkvm::guest::entry!(main); | ||
|
||
pub fn main() { | ||
let guest = Risc0Guest::new(); | ||
let storage = ZkStorage::new(); | ||
#[cfg(feature = "bench")] | ||
let start_cycles = env::cycle_count(); | ||
|
||
let stf: StfBlueprint<ZkDefaultContext, _, _, Runtime<_, _>> = StfBlueprint::new(); | ||
|
||
let stf_verifier = StfVerifier::new( | ||
stf, | ||
BitcoinVerifier::new(RollupParams { | ||
rollup_name: ROLLUP_NAME.to_string(), | ||
reveal_tx_id_prefix: DA_TX_ID_LEADING_ZEROS.to_vec(), | ||
}), | ||
); | ||
|
||
stf_verifier | ||
.run_sequencer_commitments_in_da_slot(guest, storage) | ||
.expect("Prover must be honest"); | ||
|
||
#[cfg(feature = "bench")] | ||
{ | ||
let end_cycles = env::cycle_count(); | ||
report_bench_metrics(start_cycles, end_cycles); | ||
} | ||
} |
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
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
Oops, something went wrong.