diff --git a/.github/workflows/nightly_build_push.yml b/.github/workflows/nightly_build_push.yml index da2148c95d..486b307bce 100644 --- a/.github/workflows/nightly_build_push.yml +++ b/.github/workflows/nightly_build_push.yml @@ -35,11 +35,11 @@ jobs: - name: Build Project run: | - cargo build --release + cargo build --features short-prefix - name: Copy binary to build-push/nightly run: | - cp target/release/citrea docker/build-push/nightly/citrea + cp target/debug/citrea docker/build-push/nightly/citrea chmod +x docker/build-push/nightly/citrea - name: Set up Docker Buildx diff --git a/Makefile b/Makefile index 58f4c54cad..50172cf869 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ EF_TESTS_URL := https://github.com/chainwayxyz/ef-tests/archive/develop.tar.gz EF_TESTS_DIR := crates/evm/ethereum-tests CITREA_E2E_TEST_BINARY := $(CURDIR)/target/debug/citrea PARALLEL_PROOF_LIMIT := 1 +TEST_FEATURES := --features short-prefix .PHONY: help @@ -21,6 +22,10 @@ build-sp1: build: ## Build the project @cargo build +.PHONY: build-test +build-test: ## Build the project + @cargo build $(TEST_FEATURES) + build-release: build-risc0 build-sp1 ## Build the project in release mode @cargo build --release @@ -44,7 +49,7 @@ clean-all: clean clean-node clean-txs test-legacy: ## Runs test suite with output from tests printed @cargo test -- --nocapture -Zunstable-options --report-time -test: build $(EF_TESTS_DIR) ## Runs test suite using next test +test: build-test $(EF_TESTS_DIR) ## Runs test suite using next test RISC0_DEV_MODE=1 cargo nextest run --workspace --all-features --no-fail-fast $(filter-out $@,$(MAKECMDGOALS)) install-dev-tools: ## Installs all necessary cargo helpers @@ -98,7 +103,7 @@ find-unused-deps: ## Prints unused dependencies for project. Note: requires nigh find-flaky-tests: ## Runs tests over and over to find if there's flaky tests flaky-finder -j16 -r320 --continue "cargo test -- --nocapture" -coverage: build $(EF_TESTS_DIR) ## Coverage in lcov format +coverage: build-test $(EF_TESTS_DIR) ## Coverage in lcov format cargo llvm-cov --locked --lcov --output-path lcov.info nextest --workspace --all-features coverage-html: ## Coverage in HTML format diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 0a4755dc90..b19b5b4d5a 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -32,4 +32,6 @@ native = [ ] testing = [ "native", + "short-prefix", ] +short-prefix = [] diff --git a/crates/primitives/src/constants.rs b/crates/primitives/src/constants.rs index 2f511f9d16..276685f7b8 100644 --- a/crates/primitives/src/constants.rs +++ b/crates/primitives/src/constants.rs @@ -1,19 +1,13 @@ -#[cfg_attr(feature = "testing", allow(dead_code))] -const fn get_max_txbody_size() -> usize { - #[cfg(feature = "testing")] - { - 39700 - } - #[cfg(not(feature = "testing"))] - { - 397000 - } -} - /// Prefix for the reveal transaction ids - batch proof namespace. +#[cfg(feature = "short-prefix")] +pub const TO_BATCH_PROOF_PREFIX: &[u8] = &[1]; +#[cfg(not(feature = "short-prefix"))] pub const TO_BATCH_PROOF_PREFIX: &[u8] = &[1, 1]; /// Prefix for the reveal transaction ids - light client namespace. +#[cfg(feature = "short-prefix")] +pub const TO_LIGHT_CLIENT_PREFIX: &[u8] = &[2]; +#[cfg(not(feature = "short-prefix"))] pub const TO_LIGHT_CLIENT_PREFIX: &[u8] = &[2, 2]; pub const TEST_PRIVATE_KEY: &str = @@ -22,4 +16,7 @@ pub const TEST_PRIVATE_KEY: &str = pub const MIN_BASE_FEE_PER_GAS: u128 = 10_000_000; // 0.01 gwei /// Maximum size of a bitcoin transaction body in bytes -pub const MAX_TXBODY_SIZE: usize = get_max_txbody_size(); +#[cfg(feature = "testing")] +pub const MAX_TXBODY_SIZE: usize = 39700; +#[cfg(not(feature = "testing"))] +pub const MAX_TXBODY_SIZE: usize = 397000; diff --git a/guests/risc0/Cargo.toml b/guests/risc0/Cargo.toml index 4bd1365e3c..f8027b5b3f 100644 --- a/guests/risc0/Cargo.toml +++ b/guests/risc0/Cargo.toml @@ -19,3 +19,4 @@ methods = [ [features] bench = [] +short-prefix = [] diff --git a/guests/risc0/batch-proof-bitcoin/Cargo.toml b/guests/risc0/batch-proof-bitcoin/Cargo.toml index e162d64fac..920816b381 100644 --- a/guests/risc0/batch-proof-bitcoin/Cargo.toml +++ b/guests/risc0/batch-proof-bitcoin/Cargo.toml @@ -20,6 +20,9 @@ sov-modules-stf-blueprint = { path = "../../../crates/sovereign-sdk/module-syste sov-rollup-interface = { path = "../../../crates/sovereign-sdk/rollup-interface" } sov-state = { path = "../../../crates/sovereign-sdk/module-system/sov-state" } +[features] +short-prefix = ["citrea-primitives/short-prefix"] + [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.2-risczero.0" } diff --git a/guests/risc0/batch-proof-mock/Cargo.lock b/guests/risc0/batch-proof-mock/Cargo.lock index 09a1772f61..73a13003f5 100644 --- a/guests/risc0/batch-proof-mock/Cargo.lock +++ b/guests/risc0/batch-proof-mock/Cargo.lock @@ -554,6 +554,7 @@ name = "batch-proof-mock" version = "0.5.0-rc.1" dependencies = [ "anyhow", + "citrea-primitives", "citrea-risc0-adapter", "citrea-stf", "risc0-zkvm", diff --git a/guests/risc0/batch-proof-mock/Cargo.toml b/guests/risc0/batch-proof-mock/Cargo.toml index e179d74180..ccd1972be3 100644 --- a/guests/risc0/batch-proof-mock/Cargo.toml +++ b/guests/risc0/batch-proof-mock/Cargo.toml @@ -11,6 +11,7 @@ risc0-zkvm = { version = "1.1.3", default-features = false } risc0-zkvm-platform = { version = "1.1.3" } anyhow = "1.0" +citrea-primitives = { path = "../../../crates/primitives" } citrea-risc0-adapter = { path = "../../../crates/risc0" } citrea-stf = { path = "../../../crates/citrea-stf" } sov-mock-da = { path = "../../../crates/sovereign-sdk/adapters/mock-da", default-features = false } @@ -18,6 +19,9 @@ sov-modules-api = { path = "../../../crates/sovereign-sdk/module-system/sov-modu sov-modules-stf-blueprint = { path = "../../../crates/sovereign-sdk/module-system/sov-modules-stf-blueprint" } sov-state = { path = "../../../crates/sovereign-sdk/module-system/sov-state" } +[features] +short-prefix = ["citrea-primitives/short-prefix"] + [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.2-risczero.0" } diff --git a/guests/risc0/build.rs b/guests/risc0/build.rs index 530d162203..a6fa804461 100644 --- a/guests/risc0/build.rs +++ b/guests/risc0/build.rs @@ -48,7 +48,12 @@ fn main() { fn get_guest_options() -> HashMap<&'static str, risc0_build::GuestOptions> { let mut guest_pkg_to_options = HashMap::new(); - let features = vec![]; + + let mut features = Vec::new(); + + if std::env::var("CARGO_FEATURE_SHORT_PREFIX").is_ok() { + features.push("short-prefix".to_string()); + } let use_docker = if std::env::var("REPR_GUEST_BUILD").is_ok() { let this_package_dir = std::env!("CARGO_MANIFEST_DIR"); diff --git a/guests/risc0/light-client-proof-bitcoin/Cargo.toml b/guests/risc0/light-client-proof-bitcoin/Cargo.toml index 52a857c916..d5ac261b7c 100644 --- a/guests/risc0/light-client-proof-bitcoin/Cargo.toml +++ b/guests/risc0/light-client-proof-bitcoin/Cargo.toml @@ -20,6 +20,9 @@ sov-modules-stf-blueprint = { path = "../../../crates/sovereign-sdk/module-syste sov-rollup-interface = { path = "../../../crates/sovereign-sdk/rollup-interface" } sov-state = { path = "../../../crates/sovereign-sdk/module-system/sov-state" } +[features] +short-prefix = ["citrea-primitives/short-prefix"] + [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.2-risczero.0" } diff --git a/guests/risc0/light-client-proof-mock/Cargo.toml b/guests/risc0/light-client-proof-mock/Cargo.toml index 4517317cc8..25f76b58eb 100644 --- a/guests/risc0/light-client-proof-mock/Cargo.toml +++ b/guests/risc0/light-client-proof-mock/Cargo.toml @@ -21,6 +21,9 @@ sov-modules-stf-blueprint = { path = "../../../crates/sovereign-sdk/module-syste sov-rollup-interface = { path = "../../../crates/sovereign-sdk/rollup-interface" } sov-state = { path = "../../../crates/sovereign-sdk/module-system/sov-state" } +[features] +short-prefix = ["citrea-primitives/short-prefix"] + [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.2-risczero.0" }