Skip to content

Commit db5b6b1

Browse files
authored
feat: merge-train/fairies (#21103)
BEGIN_COMMIT_OVERRIDE chore: remove prefund env var in non local networks (#21095) feat: aztec new supporting multiple contract crates (#21007) feat!: Expose offchain effects when simulating/sending txs (#20563) chore: exclude auto-generated dirs from VS Code search (#20881) feat: improve oracle name prefixes (#21101) fix(pxe): correct contract class log DA gas metering from +2 to +1 (#21102) chore: remove stale aes comments (#21133) chore: add warning on invalid recipients (#21134) feat: mask ciphertext fields with Poseidon2-derived values (#21009) END_COMMIT_OVERRIDE
2 parents f2bbd11 + 95f961c commit db5b6b1

264 files changed

Lines changed: 3234 additions & 1994 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,53 @@
148148
},
149149
"solidity.formatter": "forge",
150150
"search.exclude": {
151+
// Package managers / dependencies
151152
"**/.yarn": true,
152153
"**/.yalc": true,
153154
"**/node_modules": true,
154155
"**/.pnp.*": true,
155-
"**/msgpack-c/**": true
156+
"**/l1-contracts/lib/**": true,
157+
"**/barretenberg/sol/lib/**": true,
158+
"**/msgpack-c/**": true,
159+
160+
// Build outputs
161+
"**/dest/**": true,
162+
"**/dist/**": true,
163+
"**/target/**": true,
164+
"**/build/**": true,
165+
"**/out/**": true,
166+
"**/artifacts/**": true,
167+
"**/generated/**": true,
168+
169+
// Caches
170+
"**/.cache/**": true,
171+
"**/.cache-loader/**": true,
172+
"**/.docusaurus/**": true,
173+
"**/.tsbuildinfo": true,
174+
"**/tsconfig.tsbuildinfo": true,
175+
"**/.eslintcache": true,
176+
177+
// Docs: versioned/generated content
178+
"**/docs/developer_versioned_docs/**": true,
179+
"**/docs/network_versioned_docs/**": true,
180+
"**/docs/network_versioned_sidebars/**": true,
181+
"**/docs/processed-docs/**": true,
182+
"**/docs/processed-docs-cache/**": true,
183+
"**/docs/static/**": true,
184+
"**/docs/build/**": true,
185+
"**/barretenberg/docs/versioned_docs/**": true,
186+
"**/barretenberg/docs/versioned_sidebars/**": true,
187+
"**/barretenberg/docs/static/**": true,
188+
"**/barretenberg/docs/build/**": true,
189+
"**/noir/noir-repo/docs/versioned_docs/**": true,
190+
"**/noir/noir-repo/docs/versioned_sidebars/**": true,
191+
192+
// C++/Rust build
193+
"**/barretenberg/cpp/build*/**": true,
194+
"**/barretenberg/cpp/src/wasi-sdk*/**": true,
195+
"**/cmake-build-*/**": true,
196+
"**/bench-out/**": true,
197+
"**/coverage/**": true
156198
},
157199
"[terraform]": {
158200
"editor.defaultFormatter": "hashicorp.terraform"

avm-transpiler/src/transpile.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -538,38 +538,38 @@ fn handle_foreign_call(
538538
inputs: &[ValueOrArray],
539539
) {
540540
match function {
541-
"avmOpcodeCall" => handle_external_call(avm_instrs, destinations, inputs, AvmOpcode::CALL),
542-
"avmOpcodeStaticCall" => {
541+
"aztec_avm_call" => handle_external_call(avm_instrs, destinations, inputs, AvmOpcode::CALL),
542+
"aztec_avm_staticCall" => {
543543
handle_external_call(avm_instrs, destinations, inputs, AvmOpcode::STATICCALL);
544544
}
545-
"avmOpcodeEmitPublicLog" => {
545+
"aztec_avm_emitPublicLog" => {
546546
handle_emit_public_log(avm_instrs, destinations, inputs);
547547
}
548-
"avmOpcodeNoteHashExists" => handle_note_hash_exists(avm_instrs, destinations, inputs),
549-
"avmOpcodeEmitNoteHash" | "avmOpcodeEmitNullifier" => handle_emit_note_hash_or_nullifier(
550-
function == "avmOpcodeEmitNullifier",
548+
"aztec_avm_noteHashExists" => handle_note_hash_exists(avm_instrs, destinations, inputs),
549+
"aztec_avm_emitNoteHash" | "aztec_avm_emitNullifier" => handle_emit_note_hash_or_nullifier(
550+
function == "aztec_avm_emitNullifier",
551551
avm_instrs,
552552
destinations,
553553
inputs,
554554
),
555-
"avmOpcodeNullifierExists" => handle_nullifier_exists(avm_instrs, destinations, inputs),
556-
"avmOpcodeL1ToL2MsgExists" => handle_l1_to_l2_msg_exists(avm_instrs, destinations, inputs),
557-
"avmOpcodeSendL2ToL1Msg" => handle_send_l2_to_l1_msg(avm_instrs, destinations, inputs),
558-
"avmOpcodeCalldataCopy" => handle_calldata_copy(avm_instrs, destinations, inputs),
559-
"avmOpcodeSuccessCopy" => handle_success_copy(avm_instrs, destinations, inputs),
560-
"avmOpcodeReturndataSize" => handle_returndata_size(avm_instrs, destinations, inputs),
561-
"avmOpcodeReturndataCopy" => handle_returndata_copy(avm_instrs, destinations, inputs),
562-
"avmOpcodeReturn" => handle_return(avm_instrs, destinations, inputs),
563-
"avmOpcodeRevert" => handle_revert(avm_instrs, destinations, inputs),
564-
"avmOpcodeStorageRead" => handle_storage_read(avm_instrs, destinations, inputs),
565-
"avmOpcodeStorageWrite" => handle_storage_write(avm_instrs, destinations, inputs),
566-
"utilityLog" => handle_debug_log(avm_instrs, destinations, inputs),
555+
"aztec_avm_nullifierExists" => handle_nullifier_exists(avm_instrs, destinations, inputs),
556+
"aztec_avm_l1ToL2MsgExists" => handle_l1_to_l2_msg_exists(avm_instrs, destinations, inputs),
557+
"aztec_avm_sendL2ToL1Msg" => handle_send_l2_to_l1_msg(avm_instrs, destinations, inputs),
558+
"aztec_avm_calldataCopy" => handle_calldata_copy(avm_instrs, destinations, inputs),
559+
"aztec_avm_successCopy" => handle_success_copy(avm_instrs, destinations, inputs),
560+
"aztec_avm_returndataSize" => handle_returndata_size(avm_instrs, destinations, inputs),
561+
"aztec_avm_returndataCopy" => handle_returndata_copy(avm_instrs, destinations, inputs),
562+
"aztec_avm_return" => handle_return(avm_instrs, destinations, inputs),
563+
"aztec_avm_revert" => handle_revert(avm_instrs, destinations, inputs),
564+
"aztec_avm_storageRead" => handle_storage_read(avm_instrs, destinations, inputs),
565+
"aztec_avm_storageWrite" => handle_storage_write(avm_instrs, destinations, inputs),
566+
"aztec_utl_log" => handle_debug_log(avm_instrs, destinations, inputs),
567567
// Getters.
568568
_ if inputs.is_empty() && destinations.len() == 1 => {
569569
handle_getter_instruction(avm_instrs, function, destinations, inputs);
570570
}
571571
// Get contract instance variations.
572-
_ if function.starts_with("avmOpcodeGetContractInstance") => {
572+
_ if function.starts_with("aztec_avm_getContractInstance") => {
573573
handle_get_contract_instance(avm_instrs, function, destinations, inputs);
574574
}
575575
// Anything else.
@@ -580,7 +580,7 @@ fn handle_foreign_call(
580580
/// Handle an AVM CALL
581581
/// (an external 'call' brillig foreign call was encountered)
582582
/// Adds the new instruction to the avm instructions list.
583-
// #[oracle(avmOpcodeCall)]
583+
// #[oracle(aztec_avm_call)]
584584
// unconstrained fn call_opcode<let N: u32>(
585585
// l2_gas_allocation: u32,
586586
// da_gas_allocation: u32,
@@ -947,18 +947,18 @@ fn handle_getter_instruction(
947947
};
948948

949949
let var_idx = match function {
950-
"avmOpcodeAddress" => EnvironmentVariable::ADDRESS,
951-
"avmOpcodeSender" => EnvironmentVariable::SENDER,
952-
"avmOpcodeMinFeePerL2Gas" => EnvironmentVariable::MINFEEPERL2GAS,
953-
"avmOpcodeMinFeePerDaGas" => EnvironmentVariable::MINFEEPERDAGAS,
954-
"avmOpcodeTransactionFee" => EnvironmentVariable::TRANSACTIONFEE,
955-
"avmOpcodeChainId" => EnvironmentVariable::CHAINID,
956-
"avmOpcodeVersion" => EnvironmentVariable::VERSION,
957-
"avmOpcodeBlockNumber" => EnvironmentVariable::BLOCKNUMBER,
958-
"avmOpcodeTimestamp" => EnvironmentVariable::TIMESTAMP,
959-
"avmOpcodeL2GasLeft" => EnvironmentVariable::L2GASLEFT,
960-
"avmOpcodeDaGasLeft" => EnvironmentVariable::DAGASLEFT,
961-
"avmOpcodeIsStaticCall" => EnvironmentVariable::ISSTATICCALL,
950+
"aztec_avm_address" => EnvironmentVariable::ADDRESS,
951+
"aztec_avm_sender" => EnvironmentVariable::SENDER,
952+
"aztec_avm_minFeePerL2Gas" => EnvironmentVariable::MINFEEPERL2GAS,
953+
"aztec_avm_minFeePerDaGas" => EnvironmentVariable::MINFEEPERDAGAS,
954+
"aztec_avm_transactionFee" => EnvironmentVariable::TRANSACTIONFEE,
955+
"aztec_avm_chainId" => EnvironmentVariable::CHAINID,
956+
"aztec_avm_version" => EnvironmentVariable::VERSION,
957+
"aztec_avm_blockNumber" => EnvironmentVariable::BLOCKNUMBER,
958+
"aztec_avm_timestamp" => EnvironmentVariable::TIMESTAMP,
959+
"aztec_avm_l2GasLeft" => EnvironmentVariable::L2GASLEFT,
960+
"aztec_avm_daGasLeft" => EnvironmentVariable::DAGASLEFT,
961+
"aztec_avm_isStaticCall" => EnvironmentVariable::ISSTATICCALL,
962962
_ => panic!("Transpiler doesn't know how to process getter {:?}", function),
963963
};
964964

@@ -1348,7 +1348,7 @@ fn handle_debug_log(
13481348
) {
13491349
// We need to handle two flavors here:
13501350
//
1351-
// #[oracle(utilityLog)]
1351+
// #[oracle(aztec_utl_log)]
13521352
// unconstrained fn log_oracle<let M: u32, let N: u32>(
13531353
// log_level: u8,
13541354
// msg: str<M>,
@@ -1358,7 +1358,7 @@ fn handle_debug_log(
13581358
//
13591359
// and
13601360
//
1361-
//#[oracle(utilityLog)]
1361+
//#[oracle(aztec_utl_log)]
13621362
// unconstrained fn log_slice_oracle<let M: u32>(log_level: u8, msg: str<M>, args: [Field]) {}
13631363
//
13641364
// Luckily, these two flavors have both 4 arguments, since noir inserts a length field for slices before the slice.
@@ -1420,7 +1420,7 @@ fn handle_debug_log(
14201420
});
14211421
}
14221422

1423-
// #[oracle(avmOpcodeCalldataCopy)]
1423+
// #[oracle(aztec_avm_calldataCopy)]
14241424
// unconstrained fn calldata_copy_opcode<let N: u32>(cdoffset: Field) -> [Field; N] {}
14251425
fn handle_calldata_copy(
14261426
avm_instrs: &mut Vec<AvmInstruction>,
@@ -1463,7 +1463,7 @@ fn handle_calldata_copy(
14631463
});
14641464
}
14651465

1466-
// #[oracle(avmOpcodeReturndataSize)]
1466+
// #[oracle(aztec_avm_returndataSize)]
14671467
// unconstrained fn returndata_size_opcode() -> u32 {}
14681468
fn handle_returndata_size(
14691469
avm_instrs: &mut Vec<AvmInstruction>,
@@ -1488,7 +1488,7 @@ fn handle_returndata_size(
14881488
});
14891489
}
14901490

1491-
// #[oracle(avmOpcodeReturndataCopy)]
1491+
// #[oracle(aztec_avm_returndataCopy)]
14921492
// unconstrained fn returndata_copy_opcode(rdoffset: u32, copy_size: u32) -> [Field] {}
14931493
fn handle_returndata_copy(
14941494
avm_instrs: &mut Vec<AvmInstruction>,
@@ -1546,7 +1546,7 @@ fn handle_returndata_copy(
15461546
]);
15471547
}
15481548

1549-
// #[oracle(avmOpcodeReturn)]
1549+
// #[oracle(aztec_avm_return)]
15501550
// unconstrained fn return_opcode<let N: u32>(returndata: [Field; N]) {}
15511551
fn handle_return(
15521552
avm_instrs: &mut Vec<AvmInstruction>,
@@ -1565,7 +1565,7 @@ fn handle_return(
15651565
generate_return_instruction(avm_instrs, &return_data_offset, &return_data_size);
15661566
}
15671567

1568-
// #[oracle(avmOpcodeRevert)]
1568+
// #[oracle(aztec_avm_revert)]
15691569
// unconstrained fn revert_opcode(revertdata: [Field]) {}
15701570
fn handle_revert(
15711571
avm_instrs: &mut Vec<AvmInstruction>,
@@ -1640,9 +1640,9 @@ fn handle_get_contract_instance(
16401640
assert_eq!(destinations.len(), 1);
16411641

16421642
let member_idx = match function {
1643-
"avmOpcodeGetContractInstanceDeployer" => ContractInstanceMember::DEPLOYER,
1644-
"avmOpcodeGetContractInstanceClassId" => ContractInstanceMember::CLASS_ID,
1645-
"avmOpcodeGetContractInstanceInitializationHash" => ContractInstanceMember::INIT_HASH,
1643+
"aztec_avm_getContractInstanceDeployer" => ContractInstanceMember::DEPLOYER,
1644+
"aztec_avm_getContractInstanceClassId" => ContractInstanceMember::CLASS_ID,
1645+
"aztec_avm_getContractInstanceInitializationHash" => ContractInstanceMember::INIT_HASH,
16461646
_ => panic!("Transpiler doesn't know how to process function {:?}", function),
16471647
};
16481648

@@ -1767,7 +1767,7 @@ fn tag_from_bit_size(bit_size: BitSize) -> AvmTypeTag {
17671767
}
17681768
}
17691769

1770-
/// #[oracle(avmOpcodeSuccessCopy)]
1770+
/// #[oracle(aztec_avm_successCopy)]
17711771
/// unconstrained fn success_copy_opcode() -> bool {}
17721772
fn handle_success_copy(
17731773
avm_instrs: &mut Vec<AvmInstruction>,

aztec-up/test/counter_contract.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@ set -euo pipefail
44
export LOG_LEVEL=silent
55

66
# Execute commands as per: https://docs.aztec.network/tutorials/codealong/contract_tutorials/counter_contract
7-
aztec new counter_contract
7+
aztec new counter
88

99
# Verify workspace structure
10-
if [ ! -f counter_contract/Nargo.toml ]; then
10+
if [ ! -f counter/Nargo.toml ]; then
1111
echo "Failed to create workspace Nargo.toml."
1212
exit 1
1313
fi
14-
if [ ! -f counter_contract/contract/Nargo.toml ] || [ ! -f counter_contract/contract/src/main.nr ]; then
14+
if [ ! -f counter/counter_contract/Nargo.toml ] || [ ! -f counter/counter_contract/src/main.nr ]; then
1515
echo "Failed to create contract crate."
1616
exit 1
1717
fi
18-
if [ ! -f counter_contract/test/Nargo.toml ] || [ ! -f counter_contract/test/src/lib.nr ]; then
18+
if [ ! -f counter/counter_test/Nargo.toml ] || [ ! -f counter/counter_test/src/lib.nr ]; then
1919
echo "Failed to create test crate."
2020
exit 1
2121
fi
2222

23-
# Check counter_contract dir is owned by ubuntu.
24-
if [ "$(stat -c %U counter_contract)" != "ubuntu" ]; then
25-
echo "counter_contract dir is not owned by ubuntu."
23+
# Check counter dir is owned by ubuntu.
24+
if [ "$(stat -c %U counter)" != "ubuntu" ]; then
25+
echo "counter dir is not owned by ubuntu."
2626
exit 1
2727
fi
2828

2929
# "Write" our contract over the scaffold.
30-
cp -Rf ./aztec-packages/noir-projects/noir-contracts/contracts/test/counter_contract/* counter_contract/
31-
cd counter_contract
32-
sed -i 's|\.\./\.\./\.\./\.\./\.\./|/home/ubuntu/aztec-packages/noir-projects/|g' contract/Nargo.toml test/Nargo.toml
30+
cp -Rf ./aztec-packages/noir-projects/noir-contracts/contracts/test/counter/* counter/
31+
cd counter
32+
sed -i 's|\.\./\.\./\.\./\.\./\.\./|/home/ubuntu/aztec-packages/noir-projects/|g' counter_contract/Nargo.toml counter_test/Nargo.toml
3333

3434
# Compile the contract.
3535
aztec compile
3636
# Codegen
37-
aztec codegen -o contract/src/artifacts target
38-
if [ ! -d contract/src/artifacts ]; then
37+
aztec codegen -o counter_contract/src/artifacts target
38+
if [ ! -d counter_contract/src/artifacts ]; then
3939
echo "Failed to codegen TypeScript."
4040
exit 1
4141
fi

aztec-up/test/default_scaffold.sh

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,65 @@
22
set -euo pipefail
33

44
# Tests that the default scaffold generated by `aztec new` compiles and passes its tests without any modifications.
5-
# This catches regressions in the template files produced by setup_workspace.sh (e.g. syntax errors, stale imports,
6-
# or API changes in aztec-nr) that would otherwise go unnoticed until a user runs `aztec new` themselves.
5+
# Also tests that a second contract can be added to the workspace with `aztec new`.
76

87
export LOG_LEVEL=silent
98

10-
aztec new my_contract
9+
aztec new my_workspace
1110

12-
# Verify workspace structure.
13-
if [ ! -f my_contract/Nargo.toml ]; then
11+
# Verify workspace structure with named crate directories.
12+
if [ ! -f my_workspace/Nargo.toml ]; then
1413
echo "Failed to create workspace Nargo.toml."
1514
exit 1
1615
fi
17-
if [ ! -f my_contract/contract/Nargo.toml ] || [ ! -f my_contract/contract/src/main.nr ]; then
16+
if [ ! -f my_workspace/my_workspace_contract/Nargo.toml ] || [ ! -f my_workspace/my_workspace_contract/src/main.nr ]; then
1817
echo "Failed to create contract crate."
1918
exit 1
2019
fi
21-
if [ ! -f my_contract/test/Nargo.toml ] || [ ! -f my_contract/test/src/lib.nr ]; then
20+
if [ ! -f my_workspace/my_workspace_test/Nargo.toml ] || [ ! -f my_workspace/my_workspace_test/src/lib.nr ]; then
2221
echo "Failed to create test crate."
2322
exit 1
2423
fi
2524

26-
cd my_contract
25+
cd my_workspace
2726

2827
# This is unfortunate as it makes the test worse but in CI setting the aztec version is 0.0.1 which doesn't exist as
2928
# a remote git tag, so we need to rewrite dependencies to use local aztec-nr.
30-
sed -i 's|aztec = .*git.*AztecProtocol/aztec-nr.*|aztec = { path="/home/ubuntu/aztec-packages/noir-projects/aztec-nr/aztec" }|' contract/Nargo.toml test/Nargo.toml
29+
sed -i 's|aztec = .*git.*AztecProtocol/aztec-nr.*|aztec = { path="/home/ubuntu/aztec-packages/noir-projects/aztec-nr/aztec" }|' \
30+
my_workspace_contract/Nargo.toml my_workspace_test/Nargo.toml
3131

3232
# Compile the default scaffold contract.
3333
aztec compile
3434

3535
# Run the default scaffold tests.
3636
aztec test
37+
38+
# --- Test adding a second contract to the workspace ---
39+
aztec new token
40+
41+
# Verify token crates were created.
42+
if [ ! -f token_contract/Nargo.toml ] || [ ! -f token_contract/src/main.nr ]; then
43+
echo "Failed to create token contract crate."
44+
exit 1
45+
fi
46+
if [ ! -f token_test/Nargo.toml ] || [ ! -f token_test/src/lib.nr ]; then
47+
echo "Failed to create token test crate."
48+
exit 1
49+
fi
50+
51+
# Verify workspace Nargo.toml contains all four members.
52+
if ! grep -q '"my_workspace_contract"' Nargo.toml || \
53+
! grep -q '"my_workspace_test"' Nargo.toml || \
54+
! grep -q '"token_contract"' Nargo.toml || \
55+
! grep -q '"token_test"' Nargo.toml; then
56+
echo "Workspace Nargo.toml does not contain all expected members."
57+
exit 1
58+
fi
59+
60+
# Rewrite aztec deps for token crates too.
61+
sed -i 's|aztec = .*git.*AztecProtocol/aztec-nr.*|aztec = { path="/home/ubuntu/aztec-packages/noir-projects/aztec-nr/aztec" }|' \
62+
token_contract/Nargo.toml token_test/Nargo.toml
63+
64+
# Compile and test the full workspace (both contracts).
65+
aztec compile
66+
aztec test

boxes/boxes/react/src/hooks/useContract.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export function useContract() {
2424
contractAddressSalt: salt,
2525
});
2626

27-
const contract = await toast.promise(deploymentPromise, {
27+
const { contract } = await toast.promise(deploymentPromise, {
2828
pending: 'Deploying contract...',
2929
success: {
30-
render: ({ data }) => `Address: ${data.address}`,
30+
render: ({ data }) => `Address: ${data.contract.address}`,
3131
},
3232
error: 'Error deploying contract',
3333
});

boxes/boxes/react/src/hooks/useNumber.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export function useNumber({ contract }: { contract: Contract }) {
1111

1212
setWait(true);
1313
const defaultAccountAddress = deployerEnv.getDefaultAccountAddress();
14-
const viewTxReceipt = await contract!.methods
14+
const { result } = await contract!.methods
1515
.getNumber(defaultAccountAddress)
1616
.simulate({ from: defaultAccountAddress });
17-
toast(`Number is: ${viewTxReceipt.value}`);
17+
toast(`Number is: ${result}`);
1818
setWait(false);
1919
};
2020

boxes/boxes/vanilla/app/embedded-wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class EmbeddedWallet extends EmbeddedWalletBase {
162162
wait: { timeout: 120 },
163163
};
164164

165-
const receipt = await deployMethod.send(deployOpts);
165+
const { receipt } = await deployMethod.send(deployOpts);
166166

167167
logger.info('Account deployed', receipt);
168168

0 commit comments

Comments
 (0)