From cf61d0fb99701dc6ad7995aba8bcb68f6e34984f Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:58:15 +0000 Subject: [PATCH 1/3] feat: remove unused header in public executor --- yarn-project/simulator/src/avm/avm_execution_environment.ts | 4 +--- yarn-project/simulator/src/avm/avm_simulator.test.ts | 1 - yarn-project/simulator/src/avm/fixtures/index.ts | 3 +-- yarn-project/simulator/src/public/executor.ts | 5 +---- yarn-project/simulator/src/public/public_processor.ts | 2 +- 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/yarn-project/simulator/src/avm/avm_execution_environment.ts b/yarn-project/simulator/src/avm/avm_execution_environment.ts index 9e067710bdad..36592fd7a036 100644 --- a/yarn-project/simulator/src/avm/avm_execution_environment.ts +++ b/yarn-project/simulator/src/avm/avm_execution_environment.ts @@ -1,4 +1,4 @@ -import { FunctionSelector, type GlobalVariables, type Header } from '@aztec/circuits.js'; +import { FunctionSelector, type GlobalVariables } from '@aztec/circuits.js'; import { type AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -14,7 +14,6 @@ export class AvmExecutionEnvironment { public readonly functionSelector: FunctionSelector, // may be temporary (#7224) public readonly contractCallDepth: Fr, public readonly transactionFee: Fr, - public readonly header: Header, public readonly globals: GlobalVariables, public readonly isStaticCall: boolean, public readonly isDelegateCall: boolean, @@ -35,7 +34,6 @@ export class AvmExecutionEnvironment { functionSelector, this.contractCallDepth.add(Fr.ONE), this.transactionFee, - this.header, this.globals, isStaticCall, isDelegateCall, diff --git a/yarn-project/simulator/src/avm/avm_simulator.test.ts b/yarn-project/simulator/src/avm/avm_simulator.test.ts index a5dac0b30356..03078a1b713a 100644 --- a/yarn-project/simulator/src/avm/avm_simulator.test.ts +++ b/yarn-project/simulator/src/avm/avm_simulator.test.ts @@ -819,7 +819,6 @@ describe('AVM simulator: transpiled Noir contracts', () => { /*nestedEnvironment=*/ expect.objectContaining({ sender: environment.address, // sender is top-level call contractCallDepth: new Fr(1), // top call is depth 0, nested is depth 1 - header: environment.header, // just confirming that nested env looks roughly right globals: environment.globals, // just confirming that nested env looks roughly right isStaticCall: isStaticCall, // TODO(7121): can't check calldata like this since it is modified on environment construction diff --git a/yarn-project/simulator/src/avm/fixtures/index.ts b/yarn-project/simulator/src/avm/fixtures/index.ts index 9d8e2183322d..084767f03170 100644 --- a/yarn-project/simulator/src/avm/fixtures/index.ts +++ b/yarn-project/simulator/src/avm/fixtures/index.ts @@ -1,5 +1,5 @@ import { isNoirCallStackUnresolved } from '@aztec/circuit-types'; -import { GasFees, GlobalVariables, Header } from '@aztec/circuits.js'; +import { GasFees, GlobalVariables } from '@aztec/circuits.js'; import { FunctionSelector, getFunctionDebugMetadata } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; @@ -63,7 +63,6 @@ export function initExecutionEnvironment(overrides?: Partial Date: Thu, 3 Oct 2024 10:58:30 +0000 Subject: [PATCH 2/3] fmt --- yarn-project/simulator/src/public/executor.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/yarn-project/simulator/src/public/executor.ts b/yarn-project/simulator/src/public/executor.ts index 5ed64ec717a8..3f99b0368027 100644 --- a/yarn-project/simulator/src/public/executor.ts +++ b/yarn-project/simulator/src/public/executor.ts @@ -1,6 +1,6 @@ import { type PublicExecutionRequest } from '@aztec/circuit-types'; import { type AvmSimulationStats } from '@aztec/circuit-types/stats'; -import { Fr, Gas, type GlobalVariables, type Header, type Nullifier, type TxContext } from '@aztec/circuits.js'; +import { Fr, Gas, type GlobalVariables, type Nullifier, type TxContext } from '@aztec/circuits.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { Timer } from '@aztec/foundation/timer'; import { type TelemetryClient } from '@aztec/telemetry-client'; @@ -61,11 +61,7 @@ export class PublicExecutor { pendingSiloedNullifiers.map(n => n.value), ); - const avmExecutionEnv = createAvmExecutionEnvironment( - executionRequest, - globalVariables, - transactionFee, - ); + const avmExecutionEnv = createAvmExecutionEnvironment(executionRequest, globalVariables, transactionFee); const avmMachineState = new AvmMachineState(availableGas); const avmContext = new AvmContext(avmPersistableState, avmExecutionEnv, avmMachineState); From d08fc27f04948f8626571eca4413f3ec7b772667 Mon Sep 17 00:00:00 2001 From: Maddiaa0 <47148561+Maddiaa0@users.noreply.github.com> Date: Thu, 3 Oct 2024 11:48:46 +0000 Subject: [PATCH 3/3] fix: txe --- yarn-project/txe/src/oracle/txe_oracle.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index 6bd3aef063ed..32791a806b88 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -679,24 +679,14 @@ export class TXE implements TypedOracle { return `${artifact.name}:${f.name}`; } - async executePublicFunction( - targetContractAddress: AztecAddress, - args: Fr[], - callContext: CallContext, - counter: number, - ) { - const header = Header.empty(); - header.state = await this.trees.getStateReference(true); - header.globalVariables.blockNumber = new Fr(await this.getBlockNumber()); - + executePublicFunction(targetContractAddress: AztecAddress, args: Fr[], callContext: CallContext, counter: number) { const executor = new PublicExecutor( new TXEWorldStateDB(this.trees.asLatest(), new TXEPublicContractDataSource(this)), - header, new NoopTelemetryClient(), ); const execution = new PublicExecutionRequest(targetContractAddress, callContext, args); - return executor.simulate( + const executionResult = executor.simulate( execution, GlobalVariables.empty(), Gas.test(), @@ -705,6 +695,7 @@ export class TXE implements TypedOracle { /* transactionFee */ Fr.ONE, counter, ); + return Promise.resolve(executionResult); } async avmOpcodeCall(