From d3fdf882960f24c66cd1f4bd83f423bca4128bd3 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Mon, 11 Sep 2023 17:45:14 +0000 Subject: [PATCH 1/2] Docs note around reading balances in cli guide. --- docs/docs/dev_docs/getting_started/cli.md | 4 ++-- .../acir-simulator/src/client/simulator.ts | 6 +++--- .../src/aztec_rpc_server/aztec_rpc_server.ts | 8 ++++---- yarn-project/aztec-sandbox/src/bin/index.ts | 4 +++- .../circuits.js/src/types/complete_address.ts | 2 +- .../end-to-end/src/cli_docs_sandbox.test.ts | 20 +++++++++++++------ 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/docs/docs/dev_docs/getting_started/cli.md b/docs/docs/dev_docs/getting_started/cli.md index d5681106936..aaa48fdc8e9 100644 --- a/docs/docs/dev_docs/getting_started/cli.md +++ b/docs/docs/dev_docs/getting_started/cli.md @@ -73,7 +73,7 @@ Let's double check that the accounts have been registered with the sandbox using #include_code get-accounts yarn-project/end-to-end/src/cli_docs_sandbox.test.ts bash -Save one of the printed accounts (not the one that you generated above) in an environment variable. We will use it later. +You will see a that a number of accounts exist that we did not create. The Sandbox initialises itself with 3 default accounts. Save one of the printed accounts (not the one that you generated above) in an environment variable. We will use it later. ```bash export ADDRESS2= @@ -118,7 +118,7 @@ The `call` command calls a read-only method on a contract, one that will not gen - `--contract-abi` - The abi of the contract we are calling. - `--contract-address` - The address of the deployed contract -As you can see from the result, this address has a balance of 1000000, as expected. +As you can see from the result, this address has a balance of 1000000, as expected. When using the Sandbox, you are able to query the balance of any account that has been created in the system, even the accounts created by default. You may wonder why this is, as you haven't provided the private keys for these accounts. The Sandbox contains a component known as the AztecRPCServer. When an account is created, this component stores the provided encryption private key and is able to read the account's private state meaning that the Sandbox can report the balance of any of it's accounts. More information about the account model can be found [here](../../concepts/foundation/accounts/main.md). ## Sending a Transaction diff --git a/yarn-project/acir-simulator/src/client/simulator.ts b/yarn-project/acir-simulator/src/client/simulator.ts index 5c4948b56e3..31e4e4f05dc 100644 --- a/yarn-project/acir-simulator/src/client/simulator.ts +++ b/yarn-project/acir-simulator/src/client/simulator.ts @@ -22,7 +22,7 @@ import { UnconstrainedFunctionExecution } from './unconstrained_execution.js'; * The ACIR simulator. */ export class AcirSimulator { - private static solver: WasmBlackBoxFunctionSolver; // ACVM's backend + private static solver: Promise; // ACVM's backend private log: DebugLogger; constructor(private db: DBOracle) { @@ -42,8 +42,8 @@ export class AcirSimulator { * * @returns ACVM WasmBlackBoxFunctionSolver */ - public static async getSolver(): Promise { - if (!this.solver) this.solver = await createBlackBoxSolver(); + public static getSolver(): Promise { + if (!this.solver) this.solver = createBlackBoxSolver(); return this.solver; } 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 9c21be42715..ce907b0f2fd 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 @@ -111,9 +111,9 @@ export class AztecRPCServer implements AztecRPC { const pubKey = this.keyStore.addAccount(privKey); this.synchroniser.addAccount(pubKey, this.keyStore); this.log.info(`Registered account ${completeAddress.address.toString()}`); - this.log.debug(`Registered ${completeAddress.toReadableString()}`); + this.log.debug(`Registered account\n ${completeAddress.toReadableString()}`); } else { - this.log.info(`Account "${completeAddress.address.toString()}" already registered.`); + this.log.info(`Account:\n "${completeAddress.address.toString()}"\n already registered.`); } } @@ -135,9 +135,9 @@ export class AztecRPCServer implements AztecRPC { public async registerRecipient(recipient: CompleteAddress): Promise { const wasAdded = await this.db.addCompleteAddress(recipient); if (wasAdded) { - this.log.info(`Added recipient: ${recipient.toReadableString()}`); + this.log.info(`Added recipient:\n ${recipient.toReadableString()}`); } else { - this.log.info(`Recipient "${recipient.toReadableString()}" already registered.`); + this.log.info(`Recipient:\n "${recipient.toReadableString()}"\n already registered.`); } } diff --git a/yarn-project/aztec-sandbox/src/bin/index.ts b/yarn-project/aztec-sandbox/src/bin/index.ts index f9ac88c3964..812666e2f5a 100644 --- a/yarn-project/aztec-sandbox/src/bin/index.ts +++ b/yarn-project/aztec-sandbox/src/bin/index.ts @@ -54,7 +54,9 @@ async function main() { accountStrings.push(` Public Key: ${completeAddress.publicKey.toString()}\n\n`); } } - logger.info(`${splash}\n${github}\n\n`.concat(...accountStrings).concat(`Aztec Sandbox is now ready for use!`)); + logger.info( + `${splash}\n${github}\n\n`.concat(...accountStrings).concat(`Aztec Sandbox v${version} is now ready for use!`), + ); } main().catch(err => { diff --git a/yarn-project/circuits.js/src/types/complete_address.ts b/yarn-project/circuits.js/src/types/complete_address.ts index 0e4020c2f15..77dfa19d159 100644 --- a/yarn-project/circuits.js/src/types/complete_address.ts +++ b/yarn-project/circuits.js/src/types/complete_address.ts @@ -67,7 +67,7 @@ export class CompleteAddress { * @returns A readable string representation of the complete address. */ public toReadableString(): string { - return `Address: ${this.address.toString()}, Public Key: ${this.publicKey.toString()}, Partial Address: ${this.partialAddress.toString()}`; + return ` Address: ${this.address.toString()}\n Public Key: ${this.publicKey.toString()}\n Partial Address: ${this.partialAddress.toString()}\n`; } /** diff --git a/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts b/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts index 9975f3addc4..c77869a4c5e 100644 --- a/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts +++ b/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts @@ -208,13 +208,21 @@ Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042e % aztec-cli get-accounts Accounts found: -Address: 0x20d3321707d53cebb168568e25c5c62a853ae1f0766d965e00d6f6c4eb05d599 -Public key: 0x02d18745eadddd496be95274367ee2cbf0bf667b81373fb6bed715c18814a09022907c273ec1c469fcc678738bd8efc3e9053fe1acbb11fa32da0d6881a1370e -Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042ed + Address: 0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d + Public Key: 0x27c20118733174347b8082f578a7d8fb84b3ad38be293715eee8119ee5cd8a6d0d6b7d8124b37359663e75bcd2756f544a93b821a06f8e33fba68cc8029794d9 + Partial Address: 0x1c6484e22441e5ca43bba53495d0cdc911da299150fde1191bcb330b64716ff9 -Address: 0x175310d40cd3412477db1c2a2188efd586b63d6830115fbb46c592a6303dbf6c -Public key: 0x08aad54f32f1b6621ee5f25267166e160147cd355a2dfc129fa646a651dd29471d814ac749c2cda831fcca361c830ba56db4b4bd5951d4953c81865d0ae0cbe7 -Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042ed + Address: 0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972 + Public Key: 0x08145e8e8d46f51cda8d4c9cad81920236366abeafb8d387002bad879a3e87a81570b04ac829e4c007141d856d5a36d3b9c464e0f3c1c99cdbadaa6bb93f3257 + Partial Address: 0x1833e53112953e6830a230cfc2895caed604f6395bbfafa730da26c5bf53c0a9 + + Address: 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b + Public Key: 0x13e6151ea8e7386a5e7c4c5221047bf73d0b1b7a2ad14d22b7f73e57c1fa00c614bc6da69da1b581b09ee6cdc195e5d58ae4dce01b63bbb744e58f03855a94dd + Partial Address: 0x30034aaf5d78821effa4827a132357110a49a4f37b6e384d884e233595bcf342 + + Address: 0x01b18c2044bbedd4a2e5f67cf6858370ccfb2b869b2000abe2f4ca12d9cc166e + Public Key: 0x240845f1179e3fbaa6ce587d44722b3452bbdaa11deb29553196b23534985d432b746bcf2f0e7046eb13f0ca0c4fedd027dc80b64384f50d6a14ad248faa941a + Partial Address: 0x03834845fc488d1454f195abe7d52b3393f6902eee080c90cd694c63572f7160 // docs:end:get-accounts `; From c51254d9f6886c5662e54684dd2964e22c6f0c22 Mon Sep 17 00:00:00 2001 From: PhilWindle Date: Tue, 12 Sep 2023 09:41:36 +0000 Subject: [PATCH 2/2] Revert simulator optimisation --- yarn-project/acir-simulator/src/client/simulator.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn-project/acir-simulator/src/client/simulator.ts b/yarn-project/acir-simulator/src/client/simulator.ts index 31e4e4f05dc..5c4948b56e3 100644 --- a/yarn-project/acir-simulator/src/client/simulator.ts +++ b/yarn-project/acir-simulator/src/client/simulator.ts @@ -22,7 +22,7 @@ import { UnconstrainedFunctionExecution } from './unconstrained_execution.js'; * The ACIR simulator. */ export class AcirSimulator { - private static solver: Promise; // ACVM's backend + private static solver: WasmBlackBoxFunctionSolver; // ACVM's backend private log: DebugLogger; constructor(private db: DBOracle) { @@ -42,8 +42,8 @@ export class AcirSimulator { * * @returns ACVM WasmBlackBoxFunctionSolver */ - public static getSolver(): Promise { - if (!this.solver) this.solver = createBlackBoxSolver(); + public static async getSolver(): Promise { + if (!this.solver) this.solver = await createBlackBoxSolver(); return this.solver; }