Skip to content

Commit

Permalink
Restore short-prefix behind cargo flag (#1554)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfldde authored Dec 4, 2024
1 parent 5d1eee6 commit b610149
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nightly_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ native = [
]
testing = [
"native",
"short-prefix",
]
short-prefix = []
23 changes: 10 additions & 13 deletions crates/primitives/src/constants.rs
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -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;
1 change: 1 addition & 0 deletions guests/risc0/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ methods = [

[features]
bench = []
short-prefix = []
3 changes: 3 additions & 0 deletions guests/risc0/batch-proof-bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions guests/risc0/batch-proof-mock/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions guests/risc0/batch-proof-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ 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 }
sov-modules-api = { path = "../../../crates/sovereign-sdk/module-system/sov-modules-api", default-features = false }
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" }
Expand Down
7 changes: 6 additions & 1 deletion guests/risc0/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 3 additions & 0 deletions guests/risc0/light-client-proof-bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
3 changes: 3 additions & 0 deletions guests/risc0/light-client-proof-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit b610149

Please sign in to comment.