From 7599ea970cd52fab590b94d4e6d5a38de9df1b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bene=C5=A1?= Date: Wed, 12 Jul 2023 16:44:16 +0200 Subject: [PATCH] Re-introducing txdao changes (#1037) * Revert "Revert "Remove to/from from txdao, replace with 'origin' (#1024)"" This reverts commit cd7d823d0e4ff7ba05abd8a403da30b42c27dba3. * test: updated snapshot --- .../cpp/src/aztec3/circuits/abis/tx_request.hpp | 2 +- yarn-project/aztec-cli/src/index.ts | 4 ++-- .../src/account_state/account_state.test.ts | 8 ++++---- .../aztec-rpc/src/account_state/account_state.ts | 7 ++----- .../src/aztec_rpc_server/aztec_rpc_server.ts | 8 +++----- yarn-project/aztec-rpc/src/database/database.ts | 2 +- yarn-project/aztec-rpc/src/database/memory_db.ts | 6 +++--- yarn-project/aztec-rpc/src/database/tx_dao.ts | 13 +++---------- .../aztec-rpc/src/synchroniser/synchroniser.ts | 4 ++-- .../src/examples/uniswap_trade_on_l1_from_l2.ts | 8 ++++---- .../src/examples/zk_token_contract.ts | 4 ++-- yarn-project/aztec.js/README.md | 2 +- .../aztec.js/src/contract/contract.test.ts | 4 ++-- .../src/contract/contract_function_interaction.ts | 4 ++-- .../contract_deployer/contract_deployer.test.ts | 2 +- .../kernel/__snapshots__/index.test.ts.snap | 2 +- .../end-to-end/src/cross_chain/test_harness.ts | 12 ++++++------ .../end-to-end/src/e2e_account_contract.test.ts | 12 ++++++------ .../src/e2e_cross_chain_messaging.test.ts | 2 +- .../end-to-end/src/e2e_deploy_contract.test.ts | 3 +-- .../end-to-end/src/e2e_nested_contract.test.ts | 14 +++++++------- .../end-to-end/src/e2e_p2p_network.test.ts | 4 ++-- .../src/e2e_public_cross_chain_messaging.test.ts | 2 +- .../src/e2e_public_token_contract.test.ts | 4 ++-- .../end-to-end/src/e2e_zk_token_contract.test.ts | 4 ++-- .../src/integration_archiver_l1_to_l2.test.ts | 2 +- .../src/uniswap_trade_on_l1_from_l2.test.ts | 4 ++-- yarn-project/types/src/tx/tx_receipt.ts | 9 ++------- 28 files changed, 67 insertions(+), 85 deletions(-) diff --git a/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp b/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp index 1a9ff0d7881..b67022aec44 100644 --- a/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp +++ b/circuits/cpp/src/aztec3/circuits/abis/tx_request.hpp @@ -82,7 +82,7 @@ template void write(std::vector& buf, TxRequest con template std::ostream& operator<<(std::ostream& os, TxRequest const& tx_request) { - return os << "from: " << tx_request.origin << "\n" + return os << "origin: " << tx_request.origin << "\n" << "function_data: " << tx_request.function_data << "\n" << "args_hash: " << tx_request.args_hash << "\n" << "tx_context: " << tx_request.tx_context << "\n"; diff --git a/yarn-project/aztec-cli/src/index.ts b/yarn-project/aztec-cli/src/index.ts index feee16f8afd..e25cff17f25 100644 --- a/yarn-project/aztec-cli/src/index.ts +++ b/yarn-project/aztec-cli/src/index.ts @@ -272,9 +272,9 @@ async function main() { const client = createAztecRpcClient(options.rpcUrl); const wallet = await getAccountWallet(client, Buffer.from(options.privateKey, 'hex'), accountCreationSalt); const contract = new Contract(contractAddress, contractAbi, wallet); - const from = (await wallet.getAccounts()).find(addr => addr.equals(wallet.getAddress())); + const origin = (await wallet.getAccounts()).find(addr => addr.equals(wallet.getAddress())); const tx = contract.methods[functionName](...functionArgs).send({ - from, + origin, }); await tx.isMined(); log('\nTX has been mined'); diff --git a/yarn-project/aztec-rpc/src/account_state/account_state.test.ts b/yarn-project/aztec-rpc/src/account_state/account_state.test.ts index fe8b50be407..c39a2eb8974 100644 --- a/yarn-project/aztec-rpc/src/account_state/account_state.test.ts +++ b/yarn-project/aztec-rpc/src/account_state/account_state.test.ts @@ -106,7 +106,7 @@ describe('Account State', () => { expect(txs).toEqual([ expect.objectContaining({ blockNumber: 1, - from: ownerAddress, + origin: ownerAddress, }), ]); expect(addNoteSpendingInfoBatchSpy).toHaveBeenCalledTimes(1); @@ -134,15 +134,15 @@ describe('Account State', () => { expect(txs).toEqual([ expect.objectContaining({ blockNumber: 2, - from: ownerAddress, + origin: ownerAddress, }), expect.objectContaining({ blockNumber: 5, - from: ownerAddress, + origin: ownerAddress, }), expect.objectContaining({ blockNumber: 5, - from: ownerAddress, + origin: ownerAddress, }), ]); expect(addNoteSpendingInfoBatchSpy).toHaveBeenCalledTimes(1); diff --git a/yarn-project/aztec-rpc/src/account_state/account_state.ts b/yarn-project/aztec-rpc/src/account_state/account_state.ts index 22abee0ca2f..00e604873aa 100644 --- a/yarn-project/aztec-rpc/src/account_state/account_state.ts +++ b/yarn-project/aztec-rpc/src/account_state/account_state.ts @@ -431,15 +431,12 @@ export class AccountState { const { newContractData } = blockContext.block.getTx(txIndex); const isContractDeployment = !newContractData[0].contractAddress.isZero(); const noteSpendingInfo = noteSpendingInfoDaos[j]; - const [to, contractAddress] = isContractDeployment - ? [undefined, noteSpendingInfo.contractAddress] - : [noteSpendingInfo.contractAddress, undefined]; + const contractAddress = isContractDeployment ? noteSpendingInfo.contractAddress : undefined; txDaos.push({ txHash, blockHash: blockContext.getBlockHash(), blockNumber: blockContext.block.number, - from: this.address, - to, + origin: this.address, contractAddress, error: '', }); diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts index 6e795e436ac..d0af805dc9e 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts @@ -218,8 +218,7 @@ export class AztecRPCServer implements AztecRPC { await this.db.addTx( TxDao.from({ txHash: await tx.getTxHash(), - from: account.getAddress(), - to: account.getAddress(), + origin: account.getAddress(), contractAddress: deployedContractAddress, }), ); @@ -270,8 +269,7 @@ export class AztecRPCServer implements AztecRPC { txHash: txHash, blockHash: localTx?.blockHash, blockNumber: localTx?.blockNumber, - from: localTx?.from, - to: localTx?.to, + origin: localTx?.origin, contractAddress: localTx?.contractAddress, error: '', }; @@ -294,7 +292,7 @@ export class AztecRPCServer implements AztecRPC { // if the transaction mined it will be removed from the pending pool and there is a race condition here as the synchroniser will not have the tx as mined yet, so it will appear dropped // until the synchroniser picks this up - const accountState = this.synchroniser.getAccount(localTx.from); + const accountState = this.synchroniser.getAccount(localTx.origin); if (accountState && !(await accountState?.isSynchronised())) { // there is a pending L2 block, which means the transaction will not be in the tx pool but may be awaiting mine on L1 return { diff --git a/yarn-project/aztec-rpc/src/database/database.ts b/yarn-project/aztec-rpc/src/database/database.ts index 4b23fee606b..7d74fee47af 100644 --- a/yarn-project/aztec-rpc/src/database/database.ts +++ b/yarn-project/aztec-rpc/src/database/database.ts @@ -39,7 +39,7 @@ export interface GetOptions { */ export interface Database extends ContractDatabase { getTx(txHash: TxHash): Promise; - getTxsByAddress(from: AztecAddress): Promise; + getTxsByAddress(origin: AztecAddress): Promise; addTx(tx: TxDao): Promise; addTxs(txs: TxDao[]): Promise; diff --git a/yarn-project/aztec-rpc/src/database/memory_db.ts b/yarn-project/aztec-rpc/src/database/memory_db.ts index 1fc17889806..931d0fa2937 100644 --- a/yarn-project/aztec-rpc/src/database/memory_db.ts +++ b/yarn-project/aztec-rpc/src/database/memory_db.ts @@ -55,11 +55,11 @@ export class MemoryDB extends MemoryContractDatabase implements Database { /** * Retrieve all transactions associated with a given AztecAddress. * - * @param from - The sender's address. + * @param origin - The sender's address. * @returns A Promise resolving to an array of TxDao objects associated with the sender. */ - public getTxsByAddress(from: AztecAddress) { - return Promise.resolve(this.txTable.filter(tx => tx.from.equals(from))); + public getTxsByAddress(origin: AztecAddress) { + return Promise.resolve(this.txTable.filter(tx => tx.origin.equals(origin))); } /** diff --git a/yarn-project/aztec-rpc/src/database/tx_dao.ts b/yarn-project/aztec-rpc/src/database/tx_dao.ts index 62f67f98aba..c51a3f15ca3 100644 --- a/yarn-project/aztec-rpc/src/database/tx_dao.ts +++ b/yarn-project/aztec-rpc/src/database/tx_dao.ts @@ -21,11 +21,7 @@ export class TxDao { /** * The sender's Aztec address. */ - public readonly from: AztecAddress, - /** - * The contract address involved in the transaction. Undefined if the transaction is for deployinig a new contract. - */ - public readonly to: AztecAddress | undefined, + public readonly origin: AztecAddress, /** * The address of the contract deployed by the transaction. Undefined if the transaction does not deploy a new contract. */ @@ -53,9 +49,7 @@ export class TxDao { /** The block number in which the transaction was included. */ blockNumber?: number | undefined; /** The sender's Aztec address. */ - from: AztecAddress; - /** The contract address involved in the transaction. Undefined if the transaction is for deployinig a new contract. */ - to: AztecAddress | undefined; + origin: AztecAddress; /** The address of the contract deployed by the transaction. Undefined if the transaction does not deploy a new contract. */ contractAddress: AztecAddress | undefined; /** Description of any error encountered during the transaction. */ @@ -67,8 +61,7 @@ export class TxDao { args.txHash, args.blockHash, args.blockNumber, - args.from, - args.to, + args.origin, args.contractAddress, args.error, args.contractBytecode, diff --git a/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts b/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts index a6a96b0e056..a2dbd78ed3c 100644 --- a/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts +++ b/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts @@ -236,9 +236,9 @@ export class Synchroniser { throw new Error(`Transaction ${txHash} not found in RPC database`); } - const account = this.getAccount(tx.from); + const account = this.getAccount(tx.origin); if (!account) { - throw new Error(`Unauthorised account: ${tx.from}`); + throw new Error(`Unauthorised account: ${tx.origin}`); } return tx; diff --git a/yarn-project/aztec-sandbox/src/examples/uniswap_trade_on_l1_from_l2.ts b/yarn-project/aztec-sandbox/src/examples/uniswap_trade_on_l1_from_l2.ts index cfe5a7ef3b2..f51ea0cc9cf 100644 --- a/yarn-project/aztec-sandbox/src/examples/uniswap_trade_on_l1_from_l2.ts +++ b/yarn-project/aztec-sandbox/src/examples/uniswap_trade_on_l1_from_l2.ts @@ -171,7 +171,7 @@ const transferWethOnL2 = async ( (await aztecRpcClient.getAccountPublicKey(ownerAddress)).toBigInts(), (await aztecRpcClient.getAccountPublicKey(receiver)).toBigInts(), ) - .send({ from: ownerAddress }); + .send({ origin: ownerAddress }); await transferTx.isMined(0, 0.5); const transferReceipt = await transferTx.getReceipt(); // expect(transferReceipt.status).toBe(TxStatus.MINED); @@ -240,7 +240,7 @@ async function main() { // Call the mint tokens function on the noir contract const consumptionTx = wethL2Contract.methods .mint(wethAmountToBridge, ownerPub, owner, messageKey, secret, ethAccount.toField()) - .send({ from: owner }); + .send({ origin: owner }); await consumptionTx.isMined(0, 0.5); const consumptionReceipt = await consumptionTx.getReceipt(); // expect(consumptionReceipt.status).toBe(TxStatus.MINED); @@ -275,7 +275,7 @@ async function main() { uniswapPortalAddress, ethAccount.toField(), ) - .send({ from: owner }); + .send({ origin: owner }); await withdrawTx.isMined(0, 0.5); const withdrawReceipt = await withdrawTx.getReceipt(); // expect(withdrawReceipt.status).toBe(TxStatus.MINED); @@ -326,7 +326,7 @@ async function main() { // Call the mint tokens function on the noir contract const daiMintTx = daiL2Contract.methods .mint(daiAmountToBridge, ownerPub, owner, depositDaiMessageKey, secret, ethAccount.toField()) - .send({ from: owner }); + .send({ origin: owner }); await daiMintTx.isMined(0, 0.5); const daiMintTxReceipt = await daiMintTx.getReceipt(); // expect(daiMintTxReceipt.status).toBe(TxStatus.MINED); diff --git a/yarn-project/aztec-sandbox/src/examples/zk_token_contract.ts b/yarn-project/aztec-sandbox/src/examples/zk_token_contract.ts index 706867f0d31..fce3bdba091 100644 --- a/yarn-project/aztec-sandbox/src/examples/zk_token_contract.ts +++ b/yarn-project/aztec-sandbox/src/examples/zk_token_contract.ts @@ -65,7 +65,7 @@ async function main() { // Mint more tokens logger(`Minting ${SECONDARY_AMOUNT} more coins`); - const mintTx = zkContract.methods.mint(SECONDARY_AMOUNT, ownerPubKeyPoint.toBigInts()).send({ from: ownerAddress }); + const mintTx = zkContract.methods.mint(SECONDARY_AMOUNT, ownerPubKeyPoint.toBigInts()).send({ origin: ownerAddress }); await mintTx.isMined(0, 0.5); const balanceAfterMint = await getBalance(zkContract, ownerPubKeyPoint, ownerAddress); logger(`Owner's balance is now: ${balanceAfterMint}`); @@ -74,7 +74,7 @@ async function main() { logger(`Transferring ${SECONDARY_AMOUNT} tokens from owner to another account.`); const transferTx = zkContract.methods .transfer(SECONDARY_AMOUNT, ownerPubKeyPoint.toBigInts(), address2PubKeyPoint.toBigInts()) - .send({ from: ownerAddress }); + .send({ origin: ownerAddress }); await transferTx.isMined(0, 0.5); const balanceAfterTransfer = await getBalance(zkContract, ownerPubKeyPoint, ownerAddress); const receiverBalance = await getBalance(zkContract, address2PubKeyPoint, address2); diff --git a/yarn-project/aztec.js/README.md b/yarn-project/aztec.js/README.md index 81459c49e48..0ba9cacb23c 100644 --- a/yarn-project/aztec.js/README.md +++ b/yarn-project/aztec.js/README.md @@ -26,7 +26,7 @@ import { Contract } from '@aztec/aztec.js'; const contract = new Contract(contractAddress, contractAbi, aztecRpcServer); const tx = contract.methods .transfer(amount, recipientAddress)) - .send({ from: senderAddress }); + .send({ origin: senderAddress }); await tx.isMined(); console.log(`Transferred ${amount} to ${recipientAddress}!`); ``` diff --git a/yarn-project/aztec.js/src/contract/contract.test.ts b/yarn-project/aztec.js/src/contract/contract.test.ts index 22dc7600b4e..cb81f2e509e 100644 --- a/yarn-project/aztec.js/src/contract/contract.test.ts +++ b/yarn-project/aztec.js/src/contract/contract.test.ts @@ -102,7 +102,7 @@ describe('Contract Class', () => { const param0 = 12; const param1 = 345n; const sentTx = fooContract.methods.bar(param0, param1).send({ - from: account, + origin: account, }); const txHash = await sentTx.getTxHash(); const receipt = await sentTx.getReceipt(); @@ -128,7 +128,7 @@ describe('Contract Class', () => { const fooContract = new Contract(contractAddress, defaultAbi, wallet); expect(() => fooContract.methods.qux().send({ - from: account, + origin: account, }), ).toThrow(); }); diff --git a/yarn-project/aztec.js/src/contract/contract_function_interaction.ts b/yarn-project/aztec.js/src/contract/contract_function_interaction.ts index adacbcea529..76655694d1a 100644 --- a/yarn-project/aztec.js/src/contract/contract_function_interaction.ts +++ b/yarn-project/aztec.js/src/contract/contract_function_interaction.ts @@ -13,7 +13,7 @@ export interface SendMethodOptions { /** * Sender's address initiating the transaction. */ - from?: AztecAddress; + origin?: AztecAddress; /** * The nonce representing the order of transactions sent by the address. */ @@ -60,7 +60,7 @@ export class ContractFunctionInteraction { throw new Error("Can't call `create` on an unconstrained function."); } if (!this.txRequest) { - const executionRequest = this.getExecutionRequest(this.contractAddress, options.from); + const executionRequest = this.getExecutionRequest(this.contractAddress, options.origin); const nodeInfo = await this.wallet.getNodeInfo(); const txContext = TxContext.empty(new Fr(nodeInfo.chainId), new Fr(nodeInfo.version)); const txRequest = await this.wallet.createAuthenticatedTxRequest([executionRequest], txContext); diff --git a/yarn-project/aztec.js/src/contract_deployer/contract_deployer.test.ts b/yarn-project/aztec.js/src/contract_deployer/contract_deployer.test.ts index 9d246ed0186..8fc8a57b296 100644 --- a/yarn-project/aztec.js/src/contract_deployer/contract_deployer.test.ts +++ b/yarn-project/aztec.js/src/contract_deployer/contract_deployer.test.ts @@ -43,7 +43,7 @@ describe.skip('Contract Deployer', () => { const sentTx = deployer.deploy(args[0], args[1]).send({ portalContract, contractAddressSalt, - from: account, + origin: account, }); const txHash = await sentTx.getTxHash(); const receipt = await sentTx.getReceipt(); diff --git a/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap index 9a29426a869..49abbe242c3 100644 --- a/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap +++ b/yarn-project/circuits.js/src/structs/kernel/__snapshots__/index.test.ts.snap @@ -273,7 +273,7 @@ vk_path: [ 0x1000 0x1001 0x1002 ] exports[`structs/kernel serializes and prints private_kernel_inputs_init 1`] = ` "tx_request: -from: 0x1 +origin: 0x1 function_data: function_selector: 257 is_private: 1 is_constructor: 1 diff --git a/yarn-project/end-to-end/src/cross_chain/test_harness.ts b/yarn-project/end-to-end/src/cross_chain/test_harness.ts index f64e795bfe9..38fa97cb03d 100644 --- a/yarn-project/end-to-end/src/cross_chain/test_harness.ts +++ b/yarn-project/end-to-end/src/cross_chain/test_harness.ts @@ -158,7 +158,7 @@ export class CrossChainTestHarness { (await this.aztecRpcServer.getAccountPublicKey(this.ownerAddress)).toBigInts(), (await this.aztecRpcServer.getAccountPublicKey(this.receiver)).toBigInts(), ) - .send({ from: this.accounts[0] }); + .send({ origin: this.accounts[0] }); await transferTx.isMined(0, 0.1); const transferReceipt = await transferTx.getReceipt(); @@ -171,7 +171,7 @@ export class CrossChainTestHarness { // Call the mint tokens function on the noir contract const consumptionTx = this.l2Contract.methods .mint(bridgeAmount, this.ownerPub, this.ownerAddress, messageKey, secret, this.ethAccount.toField()) - .send({ from: this.ownerAddress }); + .send({ origin: this.ownerAddress }); await consumptionTx.isMined(0, 0.1); const consumptionReceipt = await consumptionTx.getReceipt(); @@ -183,7 +183,7 @@ export class CrossChainTestHarness { // Call the mint tokens function on the noir contract const consumptionTx = this.l2Contract.methods .mintPublic(bridgeAmount, this.ownerAddress, messageKey, secret, this.ethAccount.toField()) - .send({ from: this.ownerAddress }); + .send({ origin: this.ownerAddress }); await consumptionTx.isMined(0, 0.1); const consumptionReceipt = await consumptionTx.getReceipt(); @@ -257,7 +257,7 @@ export class CrossChainTestHarness { async shieldFundsOnL2(shieldAmount: bigint, secretHash: Fr) { this.logger('Shielding funds on L2'); - const shieldTx = this.l2Contract.methods.shield(shieldAmount, secretHash).send({ from: this.ownerAddress }); + const shieldTx = this.l2Contract.methods.shield(shieldAmount, secretHash).send({ origin: this.ownerAddress }); await shieldTx.isMined(0, 0.1); const shieldReceipt = await shieldTx.getReceipt(); expect(shieldReceipt.status).toBe(TxStatus.MINED); @@ -267,7 +267,7 @@ export class CrossChainTestHarness { this.logger('Spending commitment in private call'); const privateTx = this.l2Contract.methods .redeemShield(shieldAmount, secret, this.ownerPub) - .send({ from: this.ownerAddress }); + .send({ origin: this.ownerAddress }); await privateTx.isMined(); const privateReceipt = await privateTx.getReceipt(); @@ -279,7 +279,7 @@ export class CrossChainTestHarness { this.logger('Unshielding tokens'); const unshieldTx = this.l2Contract.methods .unshieldTokens(unshieldAmount, this.ownerPub, this.ownerAddress.toField()) - .send({ from: this.ownerAddress }); + .send({ origin: this.ownerAddress }); await unshieldTx.isMined(); const unshieldReceipt = await unshieldTx.getReceipt(); diff --git a/yarn-project/end-to-end/src/e2e_account_contract.test.ts b/yarn-project/end-to-end/src/e2e_account_contract.test.ts index c212978af64..dcc290dad87 100644 --- a/yarn-project/end-to-end/src/e2e_account_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_account_contract.test.ts @@ -134,8 +134,8 @@ describe('e2e_account_contract', () => { await deployAll(); logger('Calling private function...'); - const tx1 = child.methods.value(42).send({ from: schnorrAccountContractAddress }); - const tx2 = childContractWithEcdsaSigning.methods.value(56).send({ from: ecdsaAccountContractAddress }); + const tx1 = child.methods.value(42).send({ origin: schnorrAccountContractAddress }); + const tx2 = childContractWithEcdsaSigning.methods.value(56).send({ origin: ecdsaAccountContractAddress }); const txs = [tx1, tx2]; @@ -151,8 +151,8 @@ describe('e2e_account_contract', () => { await deployAll(); logger('Calling public function...'); - const tx1 = child.methods.pubStoreValue(42).send({ from: schnorrAccountContractAddress }); - const tx2 = childContractWithEcdsaSigning.methods.pubStoreValue(15).send({ from: ecdsaAccountContractAddress }); + const tx1 = child.methods.pubStoreValue(42).send({ origin: schnorrAccountContractAddress }); + const tx2 = childContractWithEcdsaSigning.methods.pubStoreValue(15).send({ origin: ecdsaAccountContractAddress }); const txs = [tx1, tx2]; @@ -179,7 +179,7 @@ describe('e2e_account_contract', () => { await schnorrWallet.getAccountPublicKey(schnorrAccountContractAddress), schnorrWallet, ); - await expect(child.methods.value(42).simulate({ from: schnorrAccountContractAddress })).rejects.toThrowError( + await expect(child.methods.value(42).simulate({ origin: schnorrAccountContractAddress })).rejects.toThrowError( /could not satisfy all constraints/, ); }, 60_000); @@ -195,7 +195,7 @@ describe('e2e_account_contract', () => { ); logger('Deploying child contract...'); child = await deployChildContract(await ecdsaWallet.getAccountPublicKey(ecdsaAccountContractAddress), ecdsaWallet); - await expect(child.methods.value(42).simulate({ from: ecdsaAccountContractAddress })).rejects.toThrowError( + await expect(child.methods.value(42).simulate({ origin: ecdsaAccountContractAddress })).rejects.toThrowError( /could not satisfy all constraints/, ); }, 60_000); diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index d6b3b7c13db..4f4f7e917ad 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -73,7 +73,7 @@ describe('e2e_cross_chain_messaging', () => { logger('Send L2 tx to withdraw funds'); const withdrawTx = l2Contract.methods .withdraw(withdrawAmount, ownerPub, ethAccount, EthAddress.ZERO.toField()) - .send({ from: ownerAddress }); + .send({ origin: ownerAddress }); await withdrawTx.isMined(0, 0.1); const withdrawReceipt = await withdrawTx.getReceipt(); diff --git a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts index 026587fa6b2..a752c224b5d 100644 --- a/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_deploy_contract.test.ts @@ -33,8 +33,7 @@ describe('e2e_deploy_contract', () => { const receipt = await tx.getReceipt(); expect(receipt).toEqual( expect.objectContaining({ - from: accounts[0], - to: accounts[0], + origin: accounts[0], status: TxStatus.PENDING, error: '', }), diff --git a/yarn-project/end-to-end/src/e2e_nested_contract.test.ts b/yarn-project/end-to-end/src/e2e_nested_contract.test.ts index c2d63c10e41..3f1e72df19f 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_nested_contract.test.ts @@ -55,7 +55,7 @@ describe('e2e_nested_contract', () => { it('performs nested calls', async () => { const tx = parentContract.methods .entryPoint(childContract.address, Fr.fromBuffer(childContract.methods.value.selector)) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); @@ -66,7 +66,7 @@ describe('e2e_nested_contract', () => { it('performs public nested calls', async () => { const tx = parentContract.methods .pubEntryPoint(childContract.address, Fr.fromBuffer(childContract.methods.pubValue.selector), 42n) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); @@ -77,7 +77,7 @@ describe('e2e_nested_contract', () => { it('enqueues a single public call', async () => { const tx = parentContract.methods .enqueueCallToChild(childContract.address, Fr.fromBuffer(childContract.methods.pubStoreValue.selector), 42n) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); @@ -95,7 +95,7 @@ describe('e2e_nested_contract', () => { Fr.fromBuffer(childContract.methods.pubStoreValue.selector).value, 42n, ) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); @@ -111,7 +111,7 @@ describe('e2e_nested_contract', () => { Fr.fromBuffer(childContract.methods.pubStoreValue.selector), 42n, ) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); @@ -129,7 +129,7 @@ describe('e2e_nested_contract', () => { Fr.fromBuffer(childContract.methods.pubStoreValue.selector), 42n, ) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); @@ -148,7 +148,7 @@ describe('e2e_nested_contract', () => { Fr.fromBuffer(childContract.methods.pubStoreValue.selector).value, 42n, ) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); diff --git a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts index 0dc97f08f68..30478037fb1 100644 --- a/yarn-project/end-to-end/src/e2e_p2p_network.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p_network.test.ts @@ -123,12 +123,12 @@ describe('e2e_p2p_network', () => { const txs: SentTx[] = []; for (let i = 0; i < numTxs; i++) { const deployer = new ContractDeployer(TestContractAbi, aztecRpcServer); - const tx = deployer.deploy().send({ from: account, contractAddressSalt: Fr.random() }); + const tx = deployer.deploy().send({ origin: account, contractAddressSalt: Fr.random() }); logger(`Tx sent with hash ${await tx.getTxHash()}`); const receipt = await tx.getReceipt(); expect(receipt).toEqual( expect.objectContaining({ - from: account, + origin: account, status: TxStatus.PENDING, error: '', }), diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index 25ffd12b8b3..f0fd20b3516 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -65,7 +65,7 @@ describe('e2e_public_cross_chain_messaging', () => { logger('Send L2 tx to withdraw funds'); const withdrawTx = l2Contract.methods .withdrawPublic(withdrawAmount, ethAccount.toField(), EthAddress.ZERO.toField()) - .send({ from: ownerAddress }); + .send({ origin: ownerAddress }); await withdrawTx.isMined(0, 0.1); const withdrawReceipt = await withdrawTx.getReceipt(); diff --git a/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts index f6d2a87e362..c41c532b9bd 100644 --- a/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_token_contract.test.ts @@ -66,7 +66,7 @@ describe('e2e_public_token_contract', () => { const PK = await aztecRpcServer.getAccountPublicKey(recipient); - const tx = deployedContract.methods.mint(mintAmount, PK.toBigInts()).send({ from: recipient }); + const tx = deployedContract.methods.mint(mintAmount, PK.toBigInts()).send({ origin: recipient }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); @@ -87,7 +87,7 @@ describe('e2e_public_token_contract', () => { // Assemble two mint txs sequentially (no parallel calls to circuits!) and send them simultaneously const methods = times(3, () => deployedContract.methods.mint(mintAmount, PK.toBigInts())); - for (const method of methods) await method.simulate({ from: recipient }); + for (const method of methods) await method.simulate({ origin: recipient }); const txs = await Promise.all(methods.map(method => method.send())); // Check that all txs got mined in the same block diff --git a/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts index 5a3616acada..69fb1b3605c 100644 --- a/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_zk_token_contract.test.ts @@ -91,7 +91,7 @@ describe('e2e_zk_token_contract', () => { await expectsNumOfEncryptedLogsInTheLastBlockToBe(1); await expectUnencryptedLogsFromLastBlockToBe(['Balance set in constructor']); - const tx = deployedContract.methods.mint(mintAmount, ownerPublicKey).send({ from: owner }); + const tx = deployedContract.methods.mint(mintAmount, ownerPublicKey).send({ origin: owner }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); @@ -125,7 +125,7 @@ describe('e2e_zk_token_contract', () => { (await aztecRpcServer.getAccountPublicKey(owner)).toBigInts(), (await aztecRpcServer.getAccountPublicKey(receiver)).toBigInts(), ) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); await tx.isMined(0, 0.1); const receipt = await tx.getReceipt(); diff --git a/yarn-project/end-to-end/src/integration_archiver_l1_to_l2.test.ts b/yarn-project/end-to-end/src/integration_archiver_l1_to_l2.test.ts index 228628ee195..dd72821ac7a 100644 --- a/yarn-project/end-to-end/src/integration_archiver_l1_to_l2.test.ts +++ b/yarn-project/end-to-end/src/integration_archiver_l1_to_l2.test.ts @@ -126,7 +126,7 @@ describe('archiver integration with l1 to l2 messages', () => { (await aztecRpcServer.getAccountPublicKey(ownerAddress)).toBigInts(), (await aztecRpcServer.getAccountPublicKey(receiver)).toBigInts(), ) - .send({ from: accounts[0] }); + .send({ origin: accounts[0] }); expect((await archiver.getPendingL1ToL2Messages(10)).length).toEqual(0); expect(() => archiver.getConfirmedL1ToL2Message(Fr.ZERO)).toThrow(); diff --git a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts index e455473c69c..2d6fb06e241 100644 --- a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts @@ -199,12 +199,12 @@ describe('uniswap_trade_on_l1_from_l2', () => { uniswapPortalAddress, ethAccount.toField(), ) - .send({ from: ownerAddress }); + .send({ origin: ownerAddress }); await withdrawTx.isMined(0, 0.1); const withdrawReceipt = await withdrawTx.getReceipt(); expect(withdrawReceipt.status).toBe(TxStatus.MINED); - // check weth balance of owner on L2 (we first briedged `wethAmountToBridge` into L2 and now withdrew it!) + // check weth balance of owner on L2 (we first bridged `wethAmountToBridge` into L2 and now withdrew it!) await wethCrossChainHarness.expectBalanceOnL2(ownerAddress, initialBalance - transferAmount); // 5. Consume L2 to L1 message by calling uniswapPortal.swap() diff --git a/yarn-project/types/src/tx/tx_receipt.ts b/yarn-project/types/src/tx/tx_receipt.ts index 763f136a9b1..0092ca1077a 100644 --- a/yarn-project/types/src/tx/tx_receipt.ts +++ b/yarn-project/types/src/tx/tx_receipt.ts @@ -12,7 +12,7 @@ export enum TxStatus { /** * Represents a transaction receipt in the Aztec network. - * Contains essential information about the transaction including its status, sender, receiver, and associated addresses. + * Contains essential information about the transaction including its status, origin, and associated addresses. */ export interface TxReceipt { /** @@ -29,13 +29,8 @@ export interface TxReceipt { blockNumber?: number; /** * The sender's address. - * TODO: From and to are the same since we went full AA. We should unify these. */ - from?: AztecAddress; - /** - * The contract address for the transaction. - */ - to?: AztecAddress; + origin?: AztecAddress; /** * The deployed contract's address. */