Skip to content

Commit 5dd9244

Browse files
benesjanaztec-bot
authored andcommitted
refactor: remove aztec dependency from aztec_sublib (#22033)
Reverting [bad decision of mine](#21533 (comment)) from a while ago. ## Summary - Copies the version oracle into `aztec_sublib` so it no longer depends on the `aztec` (aztecnr) crate - Removes the `aztec` dependency from `aztec_sublib/Nargo.toml` - Makes `aztec_sublib` fully independent, allowing it to be audited and versioned separately from aztecnr Resolves https://linear.app/aztec-labs/issue/F-466/extract-oracles-mod-specifically-for-aztec-sublib ## Test plan - [x] `nargo check --package fee_juice_contract` compiles successfully - [x] No remaining `aztec::` imports in aztec_sublib 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 7967002 commit 5dd9244

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

noir-projects/noir-contracts/contracts/protocol/aztec_sublib/Nargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ name = "aztec_sublib"
33
type = "lib"
44

55
[dependencies]
6-
aztec = { path = "../../../../aztec-nr/aztec" }
76
protocol_types = { path = "../../../../noir-protocol-circuits/crates/types" }

noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/oracle/mod.nr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ pub mod logs;
1616
// here from protocol_types.
1717
pub use protocol_types::logging;
1818

19-
// version oracle is defined in aztec-nr and re-exported here as re-defining versions is not practical.
20-
pub use aztec::oracle::version;
19+
pub mod version;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/// The ORACLE_VERSION constant is used to check that the oracle interface is in sync between PXE and Aztec.nr. We need
2+
/// to version the oracle interface to ensure that developers get a reasonable error message if they use incompatible
3+
/// versions of Aztec.nr and PXE. The TypeScript counterpart is in `oracle_version.ts`.
4+
///
5+
/// @dev Whenever a contract function or Noir test is run, the `aztec_utl_assertCompatibleOracleVersion` oracle is
6+
/// called and if the oracle version is incompatible an error is thrown.
7+
pub global ORACLE_VERSION: Field = 21;
8+
9+
/// Asserts that the version of the oracle is compatible with the version expected by the contract.
10+
pub fn assert_compatible_oracle_version() {
11+
// Safety: This oracle call returns nothing: we only call it to check Aztec.nr and Oracle interface versions are
12+
// compatible. It is therefore always safe to call.
13+
unsafe {
14+
assert_compatible_oracle_version_wrapper();
15+
}
16+
}
17+
18+
unconstrained fn assert_compatible_oracle_version_wrapper() {
19+
assert_compatible_oracle_version_oracle(ORACLE_VERSION);
20+
}
21+
22+
#[oracle(aztec_utl_assertCompatibleOracleVersion)]
23+
unconstrained fn assert_compatible_oracle_version_oracle(version: Field) {}
24+
25+
mod test {
26+
use super::{assert_compatible_oracle_version_oracle, ORACLE_VERSION};
27+
28+
#[test]
29+
unconstrained fn compatible_oracle_version() {
30+
assert_compatible_oracle_version_oracle(ORACLE_VERSION);
31+
}
32+
33+
#[test(should_fail_with = "Incompatible aztec cli version:")]
34+
unconstrained fn incompatible_oracle_version() {
35+
let arbitrary_incorrect_version = 318183437;
36+
assert_compatible_oracle_version_oracle(arbitrary_incorrect_version);
37+
}
38+
}

0 commit comments

Comments
 (0)