diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 550e98ce172..94c664d0f11 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -922,28 +922,28 @@ class ArchiverStoreHelper } async addBlocks(blocks: L1Published[]): Promise { - return [ + const opResults = await Promise.all([ this.store.addLogs(blocks.map(block => block.data)), // Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them - ...(await Promise.all( - blocks.map(async block => { - const contractClassLogs = block.data.body.txEffects - .flatMap(txEffect => (txEffect ? [txEffect.contractClassLogs] : [])) - .flatMap(txLog => txLog.unrollLogs()); - // ContractInstanceDeployed event logs are broadcast in privateLogs. - const privateLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.privateLogs); - return ( - await Promise.all([ - this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Store), - this.#updateDeployedContractInstances(privateLogs, block.data.number, Operation.Store), - this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.data.number), - ]) - ).every(Boolean); - }), - )), + ...blocks.map(async block => { + const contractClassLogs = block.data.body.txEffects + .flatMap(txEffect => (txEffect ? [txEffect.contractClassLogs] : [])) + .flatMap(txLog => txLog.unrollLogs()); + // ContractInstanceDeployed event logs are broadcast in privateLogs. + const privateLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.privateLogs); + return ( + await Promise.all([ + this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Store), + this.#updateDeployedContractInstances(privateLogs, block.data.number, Operation.Store), + this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.data.number), + ]) + ).every(Boolean); + }), this.store.addNullifiers(blocks.map(block => block.data)), this.store.addBlocks(blocks), - ].every(Boolean); + ]); + + return opResults.every(Boolean); } async unwindBlocks(from: number, blocksToUnwind: number): Promise { @@ -966,9 +966,11 @@ class ArchiverStoreHelper const privateLogs = block.data.body.txEffects.flatMap(txEffect => txEffect.privateLogs); return ( - (await this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Delete)) && - (await this.#updateDeployedContractInstances(privateLogs, block.data.number, Operation.Delete)) - ); + await Promise.all([ + this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Delete), + this.#updateDeployedContractInstances(privateLogs, block.data.number, Operation.Delete), + ]) + ).every(Boolean); }), this.store.deleteLogs(blocks.map(b => b.data)), diff --git a/yarn-project/aztec.js/src/contract/deploy_method.ts b/yarn-project/aztec.js/src/contract/deploy_method.ts index 9b45db9b49c..869981308a7 100644 --- a/yarn-project/aztec.js/src/contract/deploy_method.ts +++ b/yarn-project/aztec.js/src/contract/deploy_method.ts @@ -89,6 +89,11 @@ export class DeployMethod extends Bas * it returns a promise for an array instead of a function call directly. */ public async request(options: DeployOptions = {}): Promise { + const deployment = await this.getDeploymentFunctionCalls(options); + + // NOTE: MEGA HACK. Remove with #10007 + // register the contract after generating deployment function calls in order to publicly register the class and (optioanlly) emit its bytecode + // // TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined? // Note that we need to run this registerContract here so it's available when computeFeeOptionsFromEstimatedGas // runs, since it needs the contract to have been registered in order to estimate gas for its initialization, @@ -97,7 +102,6 @@ export class DeployMethod extends Bas // once this tx has gone through. await this.wallet.registerContract({ artifact: this.artifact, instance: this.getInstance(options) }); - const deployment = await this.getDeploymentFunctionCalls(options); const bootstrap = await this.getInitializeFunctionCalls(options); if (deployment.calls.length + bootstrap.calls.length === 0) {