Skip to content

Commit

Permalink
chore: add apps & fee support to AVM simulator and AVM bb-prover tests (
Browse files Browse the repository at this point in the history
#11323)

Adds the following test helper classes:
- SimpleContractDataSource: fulfills ContractDataSource interface in a
minimal way to work with isolated AVM tests
- BaseAvmSimulationTester: provides a similar interface to
ContractDataSource, but adding contracts also performs contract address
nullifier insertions and includes helpers for contract initialization
(useful for constructor calls).
- AvmSimulationTester: extends Base* and exposes a function to
`simulateCall`. Uses a parent state manager to maintain state between
enqueued calls.
- PublicTxSimulationTester: extends Base* and exposes a function to
`simulateTx`. Commits state to trees to maintain state between txs.
- AvmProvingTester (& v2): extends a `PublicTxSimulationTester` and
exposes a function to `simProveVerify` a tx
  • Loading branch information
dbanks12 authored Jan 28, 2025
1 parent ba969fc commit a836786
Show file tree
Hide file tree
Showing 29 changed files with 1,944 additions and 925 deletions.
4 changes: 3 additions & 1 deletion barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ void AvmTraceBuilder::pay_fee()
// TS equivalent:
// computeFeePayerBalanceStorageSlot(fee_payer);
std::vector<FF> slot_hash_inputs = { FEE_JUICE_BALANCES_SLOT, public_inputs.fee_payer };
const auto balance_slot = poseidon2_trace_builder.poseidon2_hash(slot_hash_inputs, clk, Poseidon2Caller::SILO);
// TODO: do constrained slot derivations!
// const auto balance_slot = poseidon2_trace_builder.poseidon2_hash(slot_hash_inputs, clk, Poseidon2Caller::SILO);
const auto balance_slot = Poseidon2::hash(slot_hash_inputs);

// ** Read the balance before fee payment **
// TS equivalent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,14 @@ contract AvmTest {
* be optimized away.
************************************************************************/
#[public]
fn bulk_testing(args_field: [Field; 10], args_u8: [u8; 10]) {
fn bulk_testing(
args_field: [Field; 10],
args_u8: [u8; 10],
get_instance_for_address: AztecAddress,
expected_deployer: AztecAddress,
expected_class_id: ContractClassId,
expected_initialization_hash: Field,
) {
dep::aztec::oracle::debug_log::debug_log("set_storage_single");
set_storage_single(30);
dep::aztec::oracle::debug_log::debug_log("set_storage_list");
Expand All @@ -692,9 +699,12 @@ contract AvmTest {
dep::aztec::oracle::debug_log::debug_log("pedersen_hash_with_index");
let _ = pedersen_hash_with_index(args_field);
dep::aztec::oracle::debug_log::debug_log("test_get_contract_instance");
// address should match yarn-project/simulator/src/public/fixtures/index.ts's
// MockedAvmTestContractDataSource.otherContractInstance
test_get_contract_instance(AztecAddress::from_field(0x4444));
test_get_contract_instance_matches(
get_instance_for_address,
expected_deployer,
expected_class_id,
expected_initialization_hash,
);
dep::aztec::oracle::debug_log::debug_log("get_address");
let _ = get_address();
dep::aztec::oracle::debug_log::debug_log("get_sender");
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/bb-prover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
"devDependencies": {
"@aztec/ethereum": "workspace:^",
"@aztec/kv-store": "workspace:^",
"@aztec/noir-contracts.js": "workspace:^",
"@aztec/protocol-contracts": "workspace:^",
"@aztec/types": "workspace:^",
"@jest/globals": "^29.5.0",
"@types/jest": "^29.5.0",
Expand Down
Loading

1 comment on commit a836786

@AztecBot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.05.

Benchmark suite Current: a836786 Previous: 06a7633 Ratio
wasmClientIVCBench/Full/6 85003.30465 ms/iter 74230.485303 ms/iter 1.15
commit(t) 3785113714 ns/iter 3322489726 ns/iter 1.14

This comment was automatically generated by workflow using github-action-benchmark.

CC: @ludamad @codygunton

Please sign in to comment.