diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index 283595c8ead..7f4b29b5feb 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -103,7 +103,7 @@ library Constants { uint256 internal constant DEPLOYER_CONTRACT_ADDRESS = 0x02f1337e8c79dd0247ccbde85241ad65ee991ae283a63479e095e51f0abbc7e3; uint256 internal constant GAS_TOKEN_ADDRESS = - 0x03d751d1a8655b35b0d0c8d74e35219104fe0b011bd262ee26e6c6a5c557c801; + 0x2271d994fae5e4279485ca23d5c2408f408155676cd31d487d127bae206d026f; uint256 internal constant AZTEC_ADDRESS_LENGTH = 1; uint256 internal constant GAS_FEES_LENGTH = 2; uint256 internal constant GAS_LENGTH = 2; diff --git a/noir-projects/noir-contracts/Nargo.toml b/noir-projects/noir-contracts/Nargo.toml index 12fbe295874..141e5925a00 100644 --- a/noir-projects/noir-contracts/Nargo.toml +++ b/noir-projects/noir-contracts/Nargo.toml @@ -39,7 +39,6 @@ members = [ "contracts/token_blacklist_contract", "contracts/token_bridge_contract", "contracts/uniswap_contract", - "contracts/reader_contract", "contracts/multi_call_entrypoint_contract", "contracts/static_child_contract", "contracts/static_parent_contract" diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index c25a2b0fa56..cb633e0dec3 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -42,18 +42,6 @@ contract AvmTest { /************************************************************************ * Storage ************************************************************************/ - unconstrained fn view_storage_single() -> pub Field { - storage.single.read() - } - - unconstrained fn view_storage_list() -> pub [Field; 2] { - storage.list.read().serialize() - } - - unconstrained fn view_storage_map(address: AztecAddress) -> pub u32 { - storage.map.at(address).read() - } - #[aztec(public)] fn set_storage_single(a: Field) { storage.single.write(a); diff --git a/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr index 9556d683e83..d3fc4b5520a 100644 --- a/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/gas_token_contract/src/main.nr @@ -71,13 +71,16 @@ contract GasToken { } #[aztec(public)] + #[aztec(view)] fn check_balance(fee_limit: Field) { let fee_limit = U128::from_integer(fee_limit); assert(storage.balances.at(context.msg_sender()).read() >= fee_limit, "Balance too low"); } // utility function for testing - unconstrained fn balance_of_public(owner: AztecAddress) -> pub Field { + #[aztec(public)] + #[aztec(view)] + fn balance_of_public(owner: AztecAddress) -> pub Field { storage.balances.at(owner).read().to_field() } } diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr index 79314a807e8..2a7eac34721 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -1,4 +1,5 @@ mod asset; +mod position; mod interest_math; mod helpers; @@ -14,6 +15,7 @@ contract Lending { use dep::aztec::context::{PublicContext, gas::GasOpts}; use crate::asset::Asset; + use crate::position::Position; use crate::interest_math::compute_multiplier; use crate::helpers::{covered_by_collateral, DebtReturn, debt_updates, debt_value, compute_identifier}; use dep::token::Token; @@ -29,12 +31,6 @@ contract Lending { static_debt: Map>, // abusing keys very heavily } - struct Position { - collateral: Field, - static_debt: Field, - debt: Field, - } - // Constructs the contract. #[aztec(private)] #[aztec(initializer)] @@ -269,11 +265,15 @@ contract Lending { storage.static_debt.at(owner).write(debt_returns.static_debt.to_integer()); } - unconstrained fn get_asset(asset_id: Field) -> pub Asset { + #[aztec(public)] + #[aztec(view)] + fn get_asset(asset_id: Field) -> pub Asset { storage.assets.at(asset_id).read() } - unconstrained fn get_position(owner: AztecAddress) -> pub Position { + #[aztec(public)] + #[aztec(view)] + fn get_position(owner: AztecAddress) -> pub Position { let collateral = storage.collateral.at(owner).read(); let static_debt = storage.static_debt.at(owner).read(); let asset: Asset = storage.assets.at(0).read(); @@ -284,7 +284,9 @@ contract Lending { Position { collateral, static_debt, debt } } - unconstrained fn get_assets() -> pub [AztecAddress; 2] { + #[aztec(public)] + #[aztec(view)] + fn get_assets() -> pub [AztecAddress; 2] { [storage.collateral_asset.read(), storage.stable_coin.read()] } } diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/position.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/position.nr new file mode 100644 index 00000000000..080f977e9c0 --- /dev/null +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/position.nr @@ -0,0 +1,30 @@ +use dep::aztec::prelude::AztecAddress; +use dep::aztec::protocol_types::traits::{Deserialize, Serialize}; + +struct Position { + collateral: Field, + static_debt: Field, + debt: Field, +} + +global POSITION_SERIALIZED_LEN: Field = 3; + +impl Serialize for Position { + fn serialize(position: Position) -> [Field; POSITION_SERIALIZED_LEN] { + [ + position.collateral.to_field(), + position.static_debt.to_field(), + position.debt.to_field(), + ] + } +} + +impl Deserialize for Position { + fn deserialize(fields: [Field; POSITION_SERIALIZED_LEN]) -> Position { + Position { + collateral: fields[0], + static_debt: fields[1], + debt: fields[2], + } + } +} diff --git a/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr b/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr index 5b0c32b4ac7..3c919579009 100644 --- a/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr @@ -21,8 +21,4 @@ contract PriceFeed { fn get_price(asset_id: Field) -> Asset { storage.assets.at(asset_id).read() } - - unconstrained fn fetch_price(asset_id: Field) -> pub Asset { - storage.assets.at(asset_id).read() - } } diff --git a/noir-projects/noir-contracts/contracts/reader_contract/Nargo.toml b/noir-projects/noir-contracts/contracts/reader_contract/Nargo.toml deleted file mode 100644 index 8ae3ed01400..00000000000 --- a/noir-projects/noir-contracts/contracts/reader_contract/Nargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "reader_contract" -authors = [""] -compiler_version = ">=0.25.0" -type = "contract" - -[dependencies] -aztec = { path = "../../../aztec-nr/aztec" } -compressed_string = { path = "../../../aztec-nr/compressed-string" } diff --git a/noir-projects/noir-contracts/contracts/reader_contract/src/main.nr b/noir-projects/noir-contracts/contracts/reader_contract/src/main.nr deleted file mode 100644 index 4dc3734e87a..00000000000 --- a/noir-projects/noir-contracts/contracts/reader_contract/src/main.nr +++ /dev/null @@ -1,71 +0,0 @@ -contract Reader { - use dep::aztec::prelude::{AztecAddress, FunctionSelector, Deserialize}; - - use dep::aztec::context::gas::GasOpts; - - use dep::compressed_string::FieldCompressedString; - - #[aztec(private)] - fn constructor() {} - - #[aztec(public)] - fn check_name_public(who: AztecAddress, what: str<31>) { - let selector = FunctionSelector::from_signature("public_get_name()"); - let name: FieldCompressedString = context.call_public_function(who, selector, &[], GasOpts::default()).deserialize_into(); - let _what = FieldCompressedString::from_string(what); - assert(name.is_eq(_what)); - } - - #[aztec(private)] - fn check_name_private(who: AztecAddress, what: str<31>) { - let selector = FunctionSelector::from_signature("private_get_name()"); - let name: FieldCompressedString = context.call_private_function_no_args(who, selector).unpack_into(); - let _what = FieldCompressedString::from_string(what); - assert(name.is_eq(_what)); - } - - unconstrained fn get_name(who: AztecAddress) -> pub str<6> { - // We cannot yet call an unconstrained function from another - "Reader" - } - - #[aztec(public)] - fn check_symbol_public(who: AztecAddress, what: str<31>) { - let selector = FunctionSelector::from_signature("public_get_symbol()"); - let symbol: FieldCompressedString = context.call_public_function(who, selector, &[], GasOpts::default()).deserialize_into(); - let _what = FieldCompressedString::from_string(what); - assert(symbol.is_eq(_what)); - } - - #[aztec(private)] - fn check_symbol_private(who: AztecAddress, what: str<31>) { - let selector = FunctionSelector::from_signature("private_get_symbol()"); - let symbol: FieldCompressedString = context.call_private_function_no_args(who, selector).unpack_into(); - let _what = FieldCompressedString::from_string(what); - assert(symbol.is_eq(_what)); - } - - unconstrained fn get_symbol(who: AztecAddress) -> pub str<3> { - // We cannot yet call an unconstrained function from another - "RDR" - } - - #[aztec(public)] - fn check_decimals_public(who: AztecAddress, what: u8) { - let selector = FunctionSelector::from_signature("public_get_decimals()"); - let ret: u8 = context.call_public_function(who, selector, &[], GasOpts::default()).deserialize_into(); - assert(ret == what); - } - - #[aztec(private)] - fn check_decimals_private(who: AztecAddress, what: u8) { - let selector = FunctionSelector::from_signature("private_get_decimals()"); - let result: u8 = context.call_private_function_no_args(who, selector).unpack_into(); - assert(result == what); - } - - unconstrained fn get_decimals(who: AztecAddress) -> pub u8 { - // We cannot yet call an unconstrained function from another - 18 - } -} diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index 6d3932038f8..6963a03e0d7 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -93,7 +93,10 @@ contract StatefulTest { balance_utils::get_balance(owner_balance) } - unconstrained fn get_public_value(owner: AztecAddress) -> pub Field { + #[aztec(public)] + #[aztec(noinitcheck)] + #[aztec(view)] + fn get_public_value(owner: AztecAddress) -> pub Field { storage.public_values.at(owner).read() } } diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index f2e54e26133..e8cbba3054d 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -40,6 +40,19 @@ contract TokenBlacklist { } #[aztec(public)] + #[aztec(view)] + fn total_supply() -> pub Field { + storage.total_supply.read().to_field() + } + + #[aztec(public)] + #[aztec(view)] + fn balance_of_public(owner: AztecAddress) -> pub Field { + storage.public_balances.at(owner).read().to_field() + } + + #[aztec(public)] + #[aztec(view)] fn get_roles(user: AztecAddress) -> UserFlags { storage.roles.at(user).get_current_value_in_public() } @@ -182,8 +195,7 @@ contract TokenBlacklist { storage.balances.sub(from, U128::from_integer(amount)); - let selector = FunctionSelector::from_signature("_increase_public_balance((Field),Field)"); - context.call_public_function(context.this_address(), selector, [to.to_field(), amount]); + TokenBlacklist::at(context.this_address())._increase_public_balance(to, amount).enqueue(&mut context); } // docs:start:transfer_private @@ -218,8 +230,7 @@ contract TokenBlacklist { storage.balances.sub(from, U128::from_integer(amount)); - let selector = FunctionSelector::from_signature("_reduce_total_supply(Field)"); - context.call_public_function(context.this_address(), selector, [amount]); + TokenBlacklist::at(context.this_address())._reduce_total_supply(amount).enqueue(&mut context); } /// Internal /// @@ -241,15 +252,7 @@ contract TokenBlacklist { /// Unconstrained /// - unconstrained fn total_supply() -> pub Field { - storage.total_supply.read().to_field() - } - unconstrained fn balance_of_private(owner: AztecAddress) -> pub Field { storage.balances.balance_of(owner).to_field() } - - unconstrained fn balance_of_public(owner: AztecAddress) -> pub Field { - storage.public_balances.at(owner).read().to_field() - } } diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr index e503e3f691a..06de11e96cb 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr @@ -98,11 +98,7 @@ contract TokenBridge { // `mint_private` on token is public. So we call an internal public function // which then calls the public method on the token contract. // Since the secret_hash is passed, no secret is leaked. - context.call_public_function( - context.this_address(), - FunctionSelector::from_signature("_call_mint_on_token(Field,Field)"), - [amount, secret_hash_for_redeeming_minted_notes] - ); + TokenBridge::at(context.this_address())._call_mint_on_token(amount, secret_hash_for_redeeming_minted_notes).enqueue(&mut context); } // docs:end:claim_private @@ -123,11 +119,7 @@ contract TokenBridge { // docs:start:call_assert_token_is_same // Assert that user provided token address is same as seen in storage. - context.call_public_function( - context.this_address(), - FunctionSelector::from_signature("_assert_token_is_same((Field))"), - [token.to_field()] - ); + TokenBridge::at(context.this_address())._assert_token_is_same(token).enqueue(&mut context); // docs:end:call_assert_token_is_same // Burn tokens @@ -135,23 +127,14 @@ contract TokenBridge { } /// docs:end:exit_to_l1_private - // View function that is callable by other contracts. - // Unconstrained can't be called by others since it isn't safe. // docs:start:get_token #[aztec(public)] + #[aztec(view)] fn get_token() -> AztecAddress { storage.token.read() } // docs:end:get_token - // /// Unconstrained /// - - // docs:start:read_token - unconstrained fn token() -> pub AztecAddress { - storage.token.read() - } - // docs:end:read_token - // docs:start:call_mint_on_token // This is a public call as we need to read from public storage. // Also, note that user hashes their secret in private and only sends the hash in public diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index 09f69cca44e..e3a158868bc 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -76,39 +76,32 @@ contract Token { } // docs:end:set_admin - unconstrained fn un_get_name() -> pub [u8; 31] { - storage.name.read_public().to_bytes() - } - #[aztec(public)] + #[aztec(view)] fn public_get_name() -> pub FieldCompressedString { storage.name.read_public() } #[aztec(private)] + #[aztec(view)] fn private_get_name() -> pub FieldCompressedString { storage.name.read_private() } - unconstrained fn un_get_symbol() -> pub [u8; 31] { - storage.symbol.read_public().to_bytes() - } - #[aztec(public)] + #[aztec(view)] fn public_get_symbol() -> pub FieldCompressedString { storage.symbol.read_public() } #[aztec(private)] + #[aztec(view)] fn private_get_symbol() -> pub FieldCompressedString { storage.symbol.read_private() } - unconstrained fn un_get_decimals() -> pub u8 { - storage.decimals.read_public() - } - #[aztec(public)] + #[aztec(view)] fn public_get_decimals() -> pub u8 { // docs:start:read_decimals_public storage.decimals.read_public() @@ -116,12 +109,45 @@ contract Token { } #[aztec(private)] + #[aztec(view)] fn private_get_decimals() -> pub u8 { // docs:start:read_decimals_private storage.decimals.read_private() // docs:end:read_decimals_private } + // docs:start:admin + #[aztec(public)] + #[aztec(view)] + fn admin() -> Field { + storage.admin.read().to_field() + } + // docs:end:admin + + // docs:start:is_minter + #[aztec(public)] + #[aztec(view)] + fn is_minter(minter: AztecAddress) -> bool { + storage.minters.at(minter).read() + } + // docs:end:is_minter + + // docs:start:total_supply + #[aztec(public)] + #[aztec(view)] + fn total_supply() -> Field { + storage.total_supply.read().to_integer() + } + // docs:end:total_supply + + // docs:start:balance_of_public + #[aztec(public)] + #[aztec(view)] + fn balance_of_public(owner: AztecAddress) -> Field { + storage.public_balances.at(owner).read().to_integer() + } + // docs:end:balance_of_public + // docs:start:set_minter #[aztec(public)] fn set_minter(minter: AztecAddress, approve: bool) { @@ -192,7 +218,7 @@ contract Token { let from_balance = storage.public_balances.at(from).read().sub(amount); let pending_shields = storage.pending_shields; - let mut note = TransparentNote::new(amount.to_integer(), secret_hash); + let mut note = TransparentNote::new(amount.to_field(), secret_hash); storage.public_balances.at(from).write(from_balance); pending_shields.insert_from_public(&mut note); @@ -332,34 +358,10 @@ contract Token { /// Unconstrained /// - // docs:start:admin - unconstrained fn admin() -> pub Field { - storage.admin.read().to_field() - } - // docs:end:admin - - // docs:start:is_minter - unconstrained fn is_minter(minter: AztecAddress) -> pub bool { - storage.minters.at(minter).read() - } - // docs:end:is_minter - - // docs:start:total_supply - unconstrained fn total_supply() -> pub Field { - storage.total_supply.read().to_integer() - } - // docs:end:total_supply - // docs:start:balance_of_private unconstrained fn balance_of_private(owner: AztecAddress) -> pub Field { - storage.balances.balance_of(owner).to_integer() + storage.balances.balance_of(owner).to_field() } // docs:end:balance_of_private - - // docs:start:balance_of_public - unconstrained fn balance_of_public(owner: AztecAddress) -> pub Field { - storage.public_balances.at(owner).read().to_integer() - } - // docs:end:balance_of_public } // docs:end:token_all diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 125f67b6837..4298295827f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -143,7 +143,7 @@ global FIXED_DA_GAS: u32 = 512; // CANONICAL CONTRACT ADDRESSES global CANONICAL_KEY_REGISTRY_ADDRESS = 0x1585e564a60e6ec974bc151b62705292ebfc75c33341986a47fd9749cedb567e; global DEPLOYER_CONTRACT_ADDRESS = 0x02f1337e8c79dd0247ccbde85241ad65ee991ae283a63479e095e51f0abbc7e3; -global GAS_TOKEN_ADDRESS = 0x03d751d1a8655b35b0d0c8d74e35219104fe0b011bd262ee26e6c6a5c557c801; +global GAS_TOKEN_ADDRESS = 0x2271d994fae5e4279485ca23d5c2408f408155676cd31d487d127bae206d026f; // LENGTH OF STRUCTS SERIALIZED TO FIELDS global AZTEC_ADDRESS_LENGTH = 1; diff --git a/yarn-project/aztec.js/src/contract/batch_call.ts b/yarn-project/aztec.js/src/contract/batch_call.ts index 22ea99b0931..d2f1f6c9cd1 100644 --- a/yarn-project/aztec.js/src/contract/batch_call.ts +++ b/yarn-project/aztec.js/src/contract/batch_call.ts @@ -37,10 +37,18 @@ export class BatchCall extends BaseContractInteraction { */ public async simulate(options: SimulateMethodOptions = {}): Promise { const { calls, unconstrained } = this.calls.reduce<{ + /** + * Keep track of the number of private calls to retrieve the return values + */ + privateIndex: 0; + /** + * Keep track of the number of private calls to retrieve the return values + */ + publicIndex: 0; /** * The public and private function calls in the batch */ - calls: [FunctionCall, number][]; + calls: [FunctionCall, number, number][]; /** * The unconstrained function calls in the batch. */ @@ -50,29 +58,35 @@ export class BatchCall extends BaseContractInteraction { if (current.type === FunctionType.UNCONSTRAINED) { acc.unconstrained.push([current, index]); } else { - acc.calls.push([current, index]); + acc.calls.push([ + current, + index, + current.type === FunctionType.PRIVATE ? acc.privateIndex++ : acc.publicIndex++, + ]); } return acc; }, - { calls: [], unconstrained: [] }, - ); - - const unconstrainedCalls = await Promise.all( - unconstrained.map(async indexedCall => { - const call = indexedCall[0]; - return [await this.wallet.simulateUnconstrained(call.name, call.args, call.to, options?.from), indexedCall[1]]; - }), + { calls: [], unconstrained: [], publicIndex: 0, privateIndex: 0 }, ); const txRequest = await this.wallet.createTxExecutionRequest({ calls: calls.map(indexedCall => indexedCall[0]) }); - const simulatedTx = await this.wallet.simulateTx(txRequest, true, options?.from); + + const unconstrainedCalls = unconstrained.map(async indexedCall => { + const call = indexedCall[0]; + return [await this.wallet.simulateUnconstrained(call.name, call.args, call.to, options?.from), indexedCall[1]]; + }); + + const [unconstrainedResults, simulatedTx] = await Promise.all([ + Promise.all(unconstrainedCalls), + this.wallet.simulateTx(txRequest, true, options?.from), + ]); const results: any[] = []; - unconstrainedCalls.forEach(([result, index]) => { + unconstrainedResults.forEach(([result, index]) => { results[index] = result; }); - calls.forEach(([call, callIndex], resultIndex) => { + calls.forEach(([call, callIndex, resultIndex]) => { // As account entrypoints are private, for private functions we retrieve the return values from the first nested call // since we're interested in the first set of values AFTER the account entrypoint // For public functions we retrieve the first values directly from the public output. diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index a957aca21eb..7bbdd32cf05 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -86,7 +86,7 @@ export const DA_GAS_PER_BYTE = 16; export const FIXED_DA_GAS = 512; export const CANONICAL_KEY_REGISTRY_ADDRESS = 0x1585e564a60e6ec974bc151b62705292ebfc75c33341986a47fd9749cedb567en; export const DEPLOYER_CONTRACT_ADDRESS = 0x02f1337e8c79dd0247ccbde85241ad65ee991ae283a63479e095e51f0abbc7e3n; -export const GAS_TOKEN_ADDRESS = 0x03d751d1a8655b35b0d0c8d74e35219104fe0b011bd262ee26e6c6a5c557c801n; +export const GAS_TOKEN_ADDRESS = 0x2271d994fae5e4279485ca23d5c2408f408155676cd31d487d127bae206d026fn; export const AZTEC_ADDRESS_LENGTH = 1; export const GAS_FEES_LENGTH = 2; export const GAS_LENGTH = 2; diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 7eeb24251f9..b4c138967f7 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -66,6 +66,7 @@ "koa": "^2.14.2", "koa-static": "^5.0.0", "levelup": "^5.1.1", + "lodash.chunk": "^4.2.0", "lodash.compact": "^3.0.1", "lodash.every": "^4.6.0", "memdown": "^6.1.1", @@ -89,6 +90,7 @@ "devDependencies": { "@jest/globals": "^29.5.0", "@types/jest": "^29.5.0", + "@types/lodash.chunk": "^4.2.9", "concurrently": "^7.6.0", "jest": "^29.5.0", "jest-extended": "^4.0.2", diff --git a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts b/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts index b191f526468..d5d3881e7e3 100644 --- a/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts +++ b/yarn-project/end-to-end/src/e2e_avm_simulator.test.ts @@ -70,14 +70,14 @@ describe('e2e_avm_simulator', () => { describe('Storage', () => { it('Modifies storage (Field)', async () => { await avmContract.methods.set_storage_single(20n).send().wait(); - expect(await avmContract.methods.view_storage_single().simulate()).toEqual(20n); + expect(await avmContract.methods.read_storage_single().simulate()).toEqual(20n); }); it('Modifies storage (Map)', async () => { const address = AztecAddress.fromBigInt(9090n); await avmContract.methods.set_storage_map(address, 100).send().wait(); await avmContract.methods.add_storage_map(address, 100).send().wait(); - expect(await avmContract.methods.view_storage_map(address).simulate()).toEqual(200n); + expect(await avmContract.methods.read_storage_map(address).simulate()).toEqual(200n); }); it('Preserves storage across enqueued public calls', async () => { @@ -90,7 +90,7 @@ describe('e2e_avm_simulator', () => { .send() .wait(); // On a separate tx, we check the result. - expect(await avmContract.methods.view_storage_map(address).simulate()).toEqual(200n); + expect(await avmContract.methods.read_storage_map(address).simulate()).toEqual(200n); }); }); diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/access_control.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/access_control.test.ts index 4c1400caffe..6dfac5a88e5 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/access_control.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/access_control.test.ts @@ -4,10 +4,12 @@ import { BlacklistTokenContractTest, Role } from './blacklist_token_contract_tes describe('e2e_blacklist_token_contract access control', () => { const t = new BlacklistTokenContractTest('access_control'); + let { wallets } = t; beforeAll(async () => { await t.applyBaseSnapshots(); await t.setup(); + ({ wallets } = t); }); afterAll(async () => { @@ -15,7 +17,7 @@ describe('e2e_blacklist_token_contract access control', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('grant mint permission to the admin', async () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts index 05ca22f844f..865a5321322 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/burn.test.ts @@ -21,7 +21,7 @@ describe('e2e_blacklist_token_contract burn', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); describe('public', () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts index ab535e3e61a..e2979d99107 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/minting.test.ts @@ -21,11 +21,11 @@ describe('e2e_blacklist_token_contract mint', () => { }); beforeEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); describe('Public', () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts index d5dfbe462e9..ef289f6ffb9 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/shielding.test.ts @@ -20,7 +20,7 @@ describe('e2e_blacklist_token_contract shield + redeem_shield', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); const secret = Fr.random(); @@ -38,7 +38,7 @@ describe('e2e_blacklist_token_contract shield + redeem_shield', () => { const receipt = await asset.methods.shield(wallets[0].getAddress(), amount, secretHash, 0).send().wait(); tokenSim.shield(wallets[0].getAddress(), amount); - await tokenSim.check(); + await t.tokenSim.check(wallets[0]); // Redeem it await t.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); @@ -60,7 +60,7 @@ describe('e2e_blacklist_token_contract shield + redeem_shield', () => { const receipt = await action.send().wait(); tokenSim.shield(wallets[0].getAddress(), amount); - await tokenSim.check(); + await t.tokenSim.check(wallets[0]); // Check that replaying the shield should fail! const txReplay = asset diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts index e69813b6fed..cfee467902a 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_private.test.ts @@ -21,7 +21,7 @@ describe('e2e_blacklist_token_contract transfer private', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('transfer less than balance', async () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts index 0b9fd846376..8b2ac023d0e 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/transfer_public.test.ts @@ -21,7 +21,7 @@ describe('e2e_blacklist_token_contract transfer public', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('transfer less than balance', async () => { diff --git a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts index 224a26b5f0f..346a3ebba3f 100644 --- a/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_blacklist_token_contract/unshielding.test.ts @@ -21,7 +21,7 @@ describe('e2e_blacklist_token_contract unshielding', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('on behalf of self', async () => { diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index 8ffb4dac434..98a3ae7854f 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -82,7 +82,7 @@ describe('e2e_lending_contract', () => { afterAll(() => teardown()); afterEach(async () => { - await lendingSim.check(); + await lendingSim.check(wallet); }); it('Mint assets for later usage', async () => { diff --git a/yarn-project/end-to-end/src/e2e_prover/e2e_prover.test.ts b/yarn-project/end-to-end/src/e2e_prover/e2e_prover.test.ts index 33c763d4248..ace44568c50 100644 --- a/yarn-project/end-to-end/src/e2e_prover/e2e_prover.test.ts +++ b/yarn-project/end-to-end/src/e2e_prover/e2e_prover.test.ts @@ -13,14 +13,14 @@ async function verifyProof(circuitType: ClientProtocolArtifact, tx: Tx, proofCre describe('full_prover', () => { const t = new FullProverTest('full_prover'); - let { provenAssets, accounts, tokenSim, logger, proofCreator } = t; + let { provenAssets, accounts, tokenSim, logger, proofCreator, wallets } = t; beforeAll(async () => { await t.applyBaseSnapshots(); await t.applyMintSnapshot(); await t.setup(); await t.deployVerifier(); - ({ provenAssets, accounts, tokenSim, logger, proofCreator } = t); + ({ provenAssets, accounts, tokenSim, logger, proofCreator, wallets } = t); }); afterAll(async () => { @@ -28,7 +28,7 @@ describe('full_prover', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it( diff --git a/yarn-project/end-to-end/src/e2e_token_contract/access_control.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/access_control.test.ts index 8efc7d88277..72e3155ab62 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/access_control.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/access_control.test.ts @@ -2,10 +2,12 @@ import { TokenContractTest } from './token_contract_test.js'; describe('e2e_token_contract access control', () => { const t = new TokenContractTest('access_control'); + let { wallets } = t; beforeAll(async () => { await t.applyBaseSnapshots(); await t.setup(); + ({ wallets } = t); }); afterAll(async () => { @@ -13,7 +15,7 @@ describe('e2e_token_contract access control', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('Set admin', async () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts index bfe3406329c..ed605ac6956 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/burn.test.ts @@ -20,7 +20,7 @@ describe('e2e_token_contract burn', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); describe('public', () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts index 7a833d6a157..c093b5b05dc 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/minting.test.ts @@ -18,7 +18,7 @@ describe('e2e_token_contract minting', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); describe('Public', () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/reading_constants.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/reading_constants.test.ts index 3ef4c97c474..e4fbc22e35c 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/reading_constants.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/reading_constants.test.ts @@ -1,12 +1,14 @@ -import { ReaderContract } from '@aztec/noir-contracts.js'; +import { Fr } from '@aztec/circuits.js'; import { TokenContractTest } from './token_contract_test.js'; -const toString = (val: bigint[]) => { +const toString = ({ value }: { value: bigint }) => { + const vals: number[] = Array.from(new Fr(value).toBuffer()); + let str = ''; - for (let i = 0; i < val.length; i++) { - if (val[i] != 0n) { - str += String.fromCharCode(Number(val[i])); + for (let i = 0; i < vals.length; i++) { + if (vals[i] != 0) { + str += String.fromCharCode(Number(vals[i])); } } return str; @@ -15,28 +17,13 @@ const toString = (val: bigint[]) => { describe('e2e_token_contract reading constants', () => { const t = new TokenContractTest('reading_constants'); const { TOKEN_DECIMALS, TOKEN_NAME, TOKEN_SYMBOL } = TokenContractTest; - // Do not destructure anything mutable. - const { logger } = t; - let reader: ReaderContract; + let { wallets } = t; beforeAll(async () => { await t.applyBaseSnapshots(); - - await t.snapshot( - 'reading_constants', - async () => { - logger.verbose('Deploying ReaderContract...'); - const reader = await ReaderContract.deploy(t.wallets[0]).send().deployed(); - logger.verbose(`Deployed ReaderContract to ${reader.address}.`); - return { readerAddress: reader.address }; - }, - async ({ readerAddress }) => { - reader = await ReaderContract.at(readerAddress, t.wallets[0]); - logger.verbose(`Reader contract restored to ${readerAddress}.`); - }, - ); - await t.setup(); + + ({ wallets } = t); }); afterAll(async () => { @@ -46,68 +33,36 @@ describe('e2e_token_contract reading constants', () => { beforeEach(async () => {}); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('check name private', async () => { - const name = toString(await t.asset.methods.un_get_name().simulate()); + const name = toString(await t.asset.methods.private_get_name().simulate()); expect(name).toBe(TOKEN_NAME); - - await reader.methods.check_name_private(t.asset.address, TOKEN_NAME).send().wait(); - await expect(reader.methods.check_name_private(t.asset.address, 'WRONG_NAME').simulate()).rejects.toThrow( - 'name.is_eq(_what)', - ); }); it('check name public', async () => { - const name = toString(await t.asset.methods.un_get_name().simulate()); + const name = toString(await t.asset.methods.public_get_name().simulate()); expect(name).toBe(TOKEN_NAME); - - await reader.methods.check_name_public(t.asset.address, TOKEN_NAME).send().wait(); - await expect(reader.methods.check_name_public(t.asset.address, 'WRONG_NAME').simulate()).rejects.toThrow( - 'name.is_eq(_what)', - ); }); it('check symbol private', async () => { - const sym = toString(await t.asset.methods.un_get_symbol().simulate()); + const sym = toString(await t.asset.methods.private_get_symbol().simulate()); expect(sym).toBe(TOKEN_SYMBOL); - - await reader.methods.check_symbol_private(t.asset.address, TOKEN_SYMBOL).send().wait(); - - await expect(reader.methods.check_symbol_private(t.asset.address, 'WRONG_SYMBOL').simulate()).rejects.toThrow( - "'symbol.is_eq(_what)'", - ); }); it('check symbol public', async () => { - const sym = toString(await t.asset.methods.un_get_symbol().simulate()); + const sym = toString(await t.asset.methods.public_get_symbol().simulate()); expect(sym).toBe(TOKEN_SYMBOL); - - await reader.methods.check_symbol_public(t.asset.address, TOKEN_SYMBOL).send().wait(); - - await expect(reader.methods.check_symbol_public(t.asset.address, 'WRONG_SYMBOL').simulate()).rejects.toThrow( - "'symbol.is_eq(_what)'", - ); }); it('check decimals private', async () => { - const dec = await t.asset.methods.un_get_decimals().simulate(); + const dec = await t.asset.methods.private_get_decimals().simulate(); expect(dec).toBe(TOKEN_DECIMALS); - - await reader.methods.check_decimals_private(t.asset.address, TOKEN_DECIMALS).send().wait(); - - await expect(reader.methods.check_decimals_private(t.asset.address, 99).simulate()).rejects.toThrow( - "Cannot satisfy constraint 'result == what'", - ); }); it('check decimals public', async () => { - const dec = await t.asset.methods.un_get_decimals().simulate(); + const dec = await t.asset.methods.public_get_decimals().simulate(); expect(dec).toBe(TOKEN_DECIMALS); - - await reader.methods.check_decimals_public(t.asset.address, TOKEN_DECIMALS).send().wait(); - - await expect(reader.methods.check_decimals_public(t.asset.address, 99).simulate()).rejects.toThrow("'ret == what'"); }); }); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts index 93ab4e44870..2438f1554db 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/shielding.test.ts @@ -23,7 +23,7 @@ describe('e2e_token_contract shield + redeem shield', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('on behalf of self', async () => { @@ -34,7 +34,7 @@ describe('e2e_token_contract shield + redeem shield', () => { const receipt = await asset.methods.shield(accounts[0].address, amount, secretHash, 0).send().wait(); tokenSim.shield(accounts[0].address, amount); - await tokenSim.check(); + await tokenSim.check(wallets[0]); // Redeem it await t.addPendingShieldNoteToPXE(0, amount, secretHash, receipt.txHash); @@ -56,7 +56,7 @@ describe('e2e_token_contract shield + redeem shield', () => { const receipt = await action.send().wait(); tokenSim.shield(accounts[0].address, amount); - await tokenSim.check(); + await tokenSim.check(wallets[0]); // Check that replaying the shield should fail! const txReplay = asset.withWallet(wallets[1]).methods.shield(accounts[0].address, amount, secretHash, nonce).send(); diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts index fb5394567dc..647cd6e013b 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer_private.test.ts @@ -19,7 +19,7 @@ describe('e2e_token_contract transfer private', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('transfer less than balance', async () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts index cb352c57df2..037c3ce29d9 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/transfer_public.test.ts @@ -20,7 +20,7 @@ describe('e2e_token_contract transfer public', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('transfer less than balance', async () => { diff --git a/yarn-project/end-to-end/src/e2e_token_contract/unshielding.test.ts b/yarn-project/end-to-end/src/e2e_token_contract/unshielding.test.ts index d52b3ce214e..3dc03f2ece7 100644 --- a/yarn-project/end-to-end/src/e2e_token_contract/unshielding.test.ts +++ b/yarn-project/end-to-end/src/e2e_token_contract/unshielding.test.ts @@ -20,7 +20,7 @@ describe('e2e_token_contract unshielding', () => { }); afterEach(async () => { - await t.tokenSim.check(); + await t.tokenSim.check(wallets[0]); }); it('on behalf of self', async () => { diff --git a/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts b/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts index 994d41e7d21..7adf0e29ac4 100644 --- a/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts +++ b/yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts @@ -107,7 +107,7 @@ export async function deployAndInitializeTokenAndBridgeContracts( throw new Error(`Token admin is not ${owner}`); } - if (!(await bridge.methods.token().simulate()).equals(token.address)) { + if (!(await bridge.methods.get_token().simulate()).equals(token.address)) { throw new Error(`Bridge token is not ${token.address}`); } diff --git a/yarn-project/end-to-end/src/simulators/lending_simulator.ts b/yarn-project/end-to-end/src/simulators/lending_simulator.ts index 95805f00421..b9bea8c7a36 100644 --- a/yarn-project/end-to-end/src/simulators/lending_simulator.ts +++ b/yarn-project/end-to-end/src/simulators/lending_simulator.ts @@ -1,5 +1,5 @@ // Convenience struct to hold an account's address and secret that can easily be passed around. -import { type AztecAddress, type CheatCodes, Fr } from '@aztec/aztec.js'; +import { type AztecAddress, type CheatCodes, Fr, type Wallet } from '@aztec/aztec.js'; import { pedersenHash } from '@aztec/foundation/crypto'; import { type LendingContract } from '@aztec/noir-contracts.js/Lending'; @@ -154,10 +154,10 @@ export class LendingSimulator { this.mintedOutside += amount; } - async check() { + async check(wallet: Wallet) { // Run checks on both underlying assets - await this.collateralAsset.check(); - await this.stableCoin.check(); + await this.collateralAsset.check(wallet); + await this.stableCoin.check(wallet); // Check that total collateral equals total holdings by contract. const totalCollateral = Object.values(this.collateral).reduce((a, b) => new Fr(a.value + b.value), Fr.ZERO); diff --git a/yarn-project/end-to-end/src/simulators/token_simulator.ts b/yarn-project/end-to-end/src/simulators/token_simulator.ts index 1cfd44eb6f4..b9ef2a88101 100644 --- a/yarn-project/end-to-end/src/simulators/token_simulator.ts +++ b/yarn-project/end-to-end/src/simulators/token_simulator.ts @@ -1,7 +1,9 @@ /* eslint-disable jsdoc/require-jsdoc */ -import { type AztecAddress, type DebugLogger } from '@aztec/aztec.js'; +import { type AztecAddress, BatchCall, type DebugLogger, type Wallet } from '@aztec/aztec.js'; import { type TokenContract } from '@aztec/noir-contracts.js/Token'; +import chunk from 'lodash.chunk'; + export class TokenSimulator { private balancesPrivate: Map = new Map(); private balancePublic: Map = new Map(); @@ -80,15 +82,23 @@ export class TokenSimulator { return this.balancesPrivate.get(address.toString()) || 0n; } - public async check() { - expect(await this.token.methods.total_supply().simulate()).toEqual(this.totalSupply); - - // Check that all our public matches + public async check(wallet: Wallet) { + const calls = [this.token.methods.total_supply().request()]; for (const address of this.accounts) { - const actualPublicBalance = await this.token.methods.balance_of_public(address).simulate(); - expect(actualPublicBalance).toEqual(this.balanceOfPublic(address)); - const actualPrivateBalance = await this.token.methods.balance_of_private({ address }).simulate(); - expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address)); + calls.push(this.token.methods.balance_of_public(address).request()); + calls.push(this.token.methods.balance_of_private(address).request()); + } + + const batchedCalls = chunk(calls, 4); + + const results = (await Promise.all(batchedCalls.map(batch => new BatchCall(wallet, batch).simulate()))).flat(); + + expect(results[0]).toEqual(this.totalSupply); + + // Check that all our balances match + for (let i = 0; i < this.accounts.length; i++) { + expect(results[i * 2 + 1]).toEqual(this.balanceOfPublic(this.accounts[i])); + expect(results[i * 2 + 2]).toEqual(this.balanceOfPrivate(this.accounts[i])); } } } diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 171e126da42..3da39b2f7d9 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -386,6 +386,7 @@ __metadata: "@types/koa": ^2.13.9 "@types/koa-static": ^4.0.2 "@types/levelup": ^5.1.2 + "@types/lodash.chunk": ^4.2.9 "@types/lodash.every": ^4.6.7 "@types/memdown": ^3.0.3 "@types/node": ^18.7.23 @@ -402,6 +403,7 @@ __metadata: koa: ^2.14.2 koa-static: ^5.0.0 levelup: ^5.1.1 + lodash.chunk: ^4.2.0 lodash.compact: ^3.0.1 lodash.every: ^4.6.0 memdown: ^6.1.1