fix: template init was not using up-to-date dependencies#1008
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe changes implement commit-hash-aware template initialization by extracting the template repository's git commit hash and using it to rewrite template dependencies to point to specific commits. Additionally, BFV parameter handling is abstracted through a new parameter-set type, and test coverage is expanded with table-driven tests. Changes
Sequence DiagramsequenceDiagram
participant User
participant Init as init (lib.rs)
participant Git as git.rs
participant Copy as copy.rs
participant Template as templates/*
User->>Init: init_template()
Init->>Copy: download_and_copy_template()
Copy->>Template: copy files with local paths
Init->>Git: get_commit_hash(TEMP_DIR)
Git-->>Init: commit_hash
Init->>Init: apply filters to rewrite deps<br/>(e3-program-server, etc.)<br/>with git+rev = commit_hash
Init-->>User: "Template downloaded<br/>with commit hash '...'"
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
templates/default/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
crates/fs/src/fs.rs(1 hunks)crates/init/src/copy.rs(1 hunks)crates/init/src/git.rs(1 hunks)crates/init/src/lib.rs(2 hunks)templates/default/Cargo.toml(1 hunks)templates/default/program/src/lib.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2025-08-25T10:28:56.174Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 657
File: Cargo.toml:32-34
Timestamp: 2025-08-25T10:28:56.174Z
Learning: The examples/CRISP directory has its own Cargo.toml workspace configuration with members like "server", "wasm-crypto", "program/core", "program/client", etc. The root workspace intentionally excludes "examples/CRISP/server", "examples/CRISP/program", and "examples/CRISP/wasm-crypto" to prevent double workspace membership, which is the correct approach for self-contained example workspaces.
Applied to files:
templates/default/Cargo.tomlcrates/init/src/lib.rs
📚 Learning: 2024-10-22T02:36:01.448Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/data/Cargo.toml:0-0
Timestamp: 2024-10-22T02:36:01.448Z
Learning: In `packages/ciphernode/data/Cargo.toml`, `actix-rt` is only used in tests and should remain in `[dev-dependencies]`.
Applied to files:
templates/default/Cargo.toml
📚 Learning: 2024-10-08T19:45:18.209Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 107
File: packages/ciphernode/sortition/src/distance.rs:1-1
Timestamp: 2024-10-08T19:45:18.209Z
Learning: In `packages/ciphernode/core/src/events.rs`, the import statements use the correct and updated `alloy::primitives` module.
Applied to files:
templates/default/Cargo.tomltemplates/default/program/src/lib.rs
📚 Learning: 2025-11-05T14:12:57.814Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 963
File: examples/CRISP/client/package.json:25-25
Timestamp: 2025-11-05T14:12:57.814Z
Learning: In the Enclave/CRISP codebase, `enclave-e3/sdk` and `crisp-e3/sdk` are different packages: `enclave-e3/sdk` is the general Enclave SDK, while `crisp-e3/sdk` is the CRISP-specific SDK. The CRISP client (`examples/CRISP/client`) intentionally depends on `enclave-e3/sdk`, not `crisp-e3/sdk`.
Applied to files:
templates/default/Cargo.toml
📚 Learning: 2024-10-28T12:00:09.010Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/enclave/src/commands/wallet/set.rs:17-23
Timestamp: 2024-10-28T12:00:09.010Z
Learning: In the `enclave` package of the `ciphernode` project, prefer using `println!` over logging macros like `error!` from the `tracing` crate for error output in CLI commands.
Applied to files:
templates/default/Cargo.toml
📚 Learning: 2025-05-07T15:18:20.056Z
Learnt from: 0xjei
Repo: gnosisguild/enclave PR: 388
File: packages/commons/src/bfv/mod.rs:38-48
Timestamp: 2025-05-07T15:18:20.056Z
Learning: The `build_bfv_params` and related functions in the commons BFV utilities intentionally use panic for error handling as a temporary solution. The team plans to refactor these to use proper Result-based error handling in the future.
Applied to files:
templates/default/program/src/lib.rs
📚 Learning: 2024-10-22T02:10:34.864Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:82-83
Timestamp: 2024-10-22T02:10:34.864Z
Learning: In the file `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs`, when reviewing test functions like `generate_pk_share`, minor performance optimizations (e.g., minimizing mutex locks) are not a priority.
Applied to files:
templates/default/program/src/lib.rs
📚 Learning: 2025-11-08T01:31:47.484Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 969
File: packages/enclave-sdk/src/enclave-sdk.ts:101-103
Timestamp: 2025-11-08T01:31:47.484Z
Learning: In packages/enclave-sdk/src/enclave-sdk.ts, the TRBFV protocol parameter setup is intentionally incomplete as of PR #969. The constructor sets BFV_THRESHOLD parameters for TRBFV, but the encryption methods (encryptNumber, encryptVector, encryptNumberAndGenInputs, encryptVectorAndGenInputs) intentionally only support BFV and will throw "Protocol not supported" for TRBFV until future implementation is completed.
Applied to files:
templates/default/program/src/lib.rs
📚 Learning: 2024-10-23T01:59:42.967Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:274-274
Timestamp: 2024-10-23T01:59:42.967Z
Learning: In the `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs` file and other test files within this project, hardcoding `CIPHERNODE_SECRET` is acceptable for testing purposes.
Applied to files:
templates/default/program/src/lib.rs
📚 Learning: 2024-10-08T19:45:18.209Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 133
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:137-139
Timestamp: 2024-10-08T19:45:18.209Z
Learning: In `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs`, using the same RNG instance `rng_test` for generating multiple key shares without advancing its state is acceptable.
Applied to files:
templates/default/program/src/lib.rs
🧬 Code graph analysis (2)
crates/init/src/lib.rs (2)
crates/init/src/git.rs (1)
get_commit_hash(138-158)crates/init/src/copy.rs (1)
new(21-27)
templates/default/program/src/lib.rs (2)
crates/bfv-helpers/src/lib.rs (2)
build_bfv_params_arc(266-288)encode_bfv_params(302-316)crates/trbfv/src/trbfv_config.rs (1)
params(34-36)
🔇 Additional comments (6)
crates/fs/src/fs.rs (2)
299-307: Good refactoring to table-driven tests.The introduction of a local
TestCasestruct and the table-driven test approach improves test maintainability and makes it easy to add new test scenarios.
327-352: Well-structured test execution loop.The test execution properly isolates each test case with a fresh filesystem instance, uses unique file paths, and includes helpful assertion messages. The implementation follows Rust testing best practices.
crates/init/src/copy.rs (1)
48-48: LGTM!The simplification to use
filter.glob_patterndirectly is correct. The test coverage at lines 94-229 validates that glob patterns like**/*/package.jsonproperly match nested files under the destination path.templates/default/Cargo.toml (1)
12-14: LGTM - Correct use of local paths for template development.These local path dependencies enable testing the template within the monorepo. The init process (crates/init/src/lib.rs lines 120-134) will rewrite these to git URLs with specific commit hashes when users run
enclave init.templates/default/program/src/lib.rs (1)
29-30: LGTM - Improved parameter abstraction.The refactor from tuple access to structured
BfvParamSetimproves type safety and readability. The signature change tobuild_bfv_params_arccorrectly adds theerror1_varianceparameter, matching the implementation in crates/bfv-helpers/src/lib.rs:265-287.Also applies to: 41-47
crates/init/src/git.rs (1)
138-158: LGTM - Well-implemented git commit hash retrieval.The function correctly:
- Uses
git rev-parse HEADto get the commit hash- Provides contextual error messages
- Validates exit status before processing output
- Trims the trailing newline from git's output
The implementation follows the same patterns as other git helper functions in this file.
enclave initCargo.tomlSummary by CodeRabbit
New Features
Tests
Chores