From 7fda4fe452f6e33bc1a08a1c244bf895686592be Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 13 Nov 2024 16:13:37 +0000 Subject: [PATCH 1/3] chore: nuking ancient redundant test --- .../token_bridge_public_to_private.test.ts | 59 ------------------- yarn-project/yarn.lock | 1 + 2 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts deleted file mode 100644 index 0b065456ecb..00000000000 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging/token_bridge_public_to_private.test.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Fr } from '@aztec/circuits.js'; - -import { CrossChainMessagingTest } from './cross_chain_messaging_test.js'; - -// TODO(benesjan): this test seems quite redundant. Nuke? -describe('e2e_cross_chain_messaging token_bridge_public_to_private', () => { - const t = new CrossChainMessagingTest('token_bridge_public_to_private'); - - let { crossChainTestHarness, ethAccount, aztecNode, ownerAddress } = t; - - beforeEach(async () => { - await t.applyBaseSnapshots(); - await t.setup(); - // Have to destructure again to ensure we have latest refs. - ({ crossChainTestHarness } = t); - - ethAccount = crossChainTestHarness.ethAccount; - aztecNode = crossChainTestHarness.aztecNode; - ownerAddress = crossChainTestHarness.ownerAddress; - }, 300_000); - - afterEach(async () => { - await t.teardown(); - }); - - it('Milestone 5.4: Should be able to create a commitment in a public function and spend in a private function', async () => { - const l1TokenBalance = 1000000n; - const bridgeAmount = 100n; - const shieldAmount = 50n; - - await crossChainTestHarness.mintTokensOnL1(l1TokenBalance); - const claim = await crossChainTestHarness.sendTokensToPortalPublic(bridgeAmount); - const msgHash = Fr.fromString(claim.messageHash); - expect(await crossChainTestHarness.getL1BalanceOf(ethAccount)).toEqual(l1TokenBalance - bridgeAmount); - - await crossChainTestHarness.makeMessageConsumable(msgHash); - - // Check message leaf index matches - const maybeIndexAndPath = await aztecNode.getL1ToL2MessageMembershipWitness('latest', msgHash); - expect(maybeIndexAndPath).toBeDefined(); - const messageLeafIndex = maybeIndexAndPath![0]; - expect(messageLeafIndex).toEqual(claim.messageLeafIndex); - - await crossChainTestHarness.consumeMessageOnAztecAndMintPublicly(claim); - await crossChainTestHarness.expectPublicBalanceOnL2(ownerAddress, bridgeAmount); - - // Create the commitment to be spent in the private domain - await crossChainTestHarness.transferToPrivateOnL2(shieldAmount); - - // Create the transaction spending the commitment - await crossChainTestHarness.expectPublicBalanceOnL2(ownerAddress, bridgeAmount - shieldAmount); - await crossChainTestHarness.expectPrivateBalanceOnL2(ownerAddress, shieldAmount); - - // Transfer to public the tokens again, sending them to the same account, however this can be any account. - await crossChainTestHarness.transferToPublicOnL2(shieldAmount); - await crossChainTestHarness.expectPublicBalanceOnL2(ownerAddress, bridgeAmount); - await crossChainTestHarness.expectPrivateBalanceOnL2(ownerAddress, 0n); - }); -}); diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 15bdd54a182..449d4424f8e 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -3512,6 +3512,7 @@ __metadata: "@noir-lang/acvm_js": 0.54.0 "@noir-lang/noirc_abi": 0.38.0 "@noir-lang/types": 0.38.0 + checksum: 99cdc1f1e352d45a8968261dc7f1d68d58b5bca8177e25c610667eb60954436356c56852e6a23fbf69ddb8db9b92494736438c0852f4702d33e8d0e981e60552 languageName: node linkType: hard From 685a57025e7b0b52b5ede824c2850d61a85ebb57 Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 13 Nov 2024 16:23:27 +0000 Subject: [PATCH 2/3] doc fix --- .../advanced/token_bridge/1_depositing_to_aztec.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md b/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md index 955e16f2799..cb426b2ef98 100644 --- a/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md +++ b/docs/docs/tutorials/codealong/contract_tutorials/advanced/token_bridge/1_depositing_to_aztec.md @@ -79,7 +79,6 @@ Let’s do the similar for the private flow: Here we want to send a message to mint tokens privately on Aztec! Some key differences from the previous method are: - The content hash uses a different function name - `mint_to_private`. This is done to make it easy to separate concerns. If the contentHash between the public and private message was the same, then an attacker could consume a private message publicly! -- Since we want to mint tokens privately, we shouldn’t specify a `to` Aztec address (remember that Ethereum is completely public). Instead, we will use a secret hash - `secretHashForRedeemingMintedNotes`. Only he who knows the preimage to the secret hash can actually mint the notes. This is similar to the mechanism we use for message consumption on L2 - Like with the public flow, we move the user’s funds to the portal - We now send the message to the inbox with the `recipient` (the sister contract on L2 along with the version of aztec the message is intended for) and the `secretHashForL2MessageConsumption` (such that on L2, the consumption of the message can be private). From ad37c8d457bfe2054b5b29de6d397870bc4a8d8a Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 13 Nov 2024 16:26:15 +0000 Subject: [PATCH 3/3] fix --- .../noir-contracts/contracts/token_contract/src/main.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fd1b5180159..b1edf3c0c41 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -556,7 +556,7 @@ contract Token { ) { let token = Token::at(context.this_address()); - // We prepare the transfer. + // We prepare the partial note to which we'll "send" the minted amount. let hiding_point_slot = _prepare_transfer_to_private(from, to, &mut context, storage); // At last we finalize the mint. Usage of the `unsafe` method here is safe because we set the `from`