Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unused header in public executor #8990

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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,
Expand All @@ -35,7 +34,6 @@ export class AvmExecutionEnvironment {
functionSelector,
this.contractCallDepth.add(Fr.ONE),
this.transactionFee,
this.header,
this.globals,
isStaticCall,
isDelegateCall,
Expand Down
1 change: 0 additions & 1 deletion yarn-project/simulator/src/avm/avm_simulator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions yarn-project/simulator/src/avm/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -63,7 +63,6 @@ export function initExecutionEnvironment(overrides?: Partial<AvmExecutionEnviron
overrides?.functionSelector ?? FunctionSelector.empty(),
overrides?.contractCallDepth ?? Fr.zero(),
overrides?.transactionFee ?? Fr.zero(),
overrides?.header ?? Header.empty(),
overrides?.globals ?? GlobalVariables.empty(),
overrides?.isStaticCall ?? false,
overrides?.isDelegateCall ?? false,
Expand Down
13 changes: 3 additions & 10 deletions yarn-project/simulator/src/public/executor.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,7 +21,7 @@ import { PublicSideEffectTrace } from './side_effect_trace.js';
export class PublicExecutor {
metrics: ExecutorMetrics;

constructor(private readonly worldStateDB: WorldStateDB, private readonly header: Header, client: TelemetryClient) {
constructor(private readonly worldStateDB: WorldStateDB, client: TelemetryClient) {
this.metrics = new ExecutorMetrics(client, 'PublicExecutor');
}

Expand Down Expand Up @@ -61,12 +61,7 @@ export class PublicExecutor {
pendingSiloedNullifiers.map(n => n.value),
);

const avmExecutionEnv = createAvmExecutionEnvironment(
executionRequest,
this.header,
globalVariables,
transactionFee,
);
const avmExecutionEnv = createAvmExecutionEnvironment(executionRequest, globalVariables, transactionFee);

const avmMachineState = new AvmMachineState(availableGas);
const avmContext = new AvmContext(avmPersistableState, avmExecutionEnv, avmMachineState);
Expand Down Expand Up @@ -120,7 +115,6 @@ export class PublicExecutor {
*/
function createAvmExecutionEnvironment(
executionRequest: PublicExecutionRequest,
header: Header,
globalVariables: GlobalVariables,
transactionFee: Fr,
): AvmExecutionEnvironment {
Expand All @@ -131,7 +125,6 @@ function createAvmExecutionEnvironment(
executionRequest.callContext.functionSelector,
/*contractCallDepth=*/ Fr.zero(),
transactionFee,
header,
globalVariables,
executionRequest.callContext.isStaticCall,
executionRequest.callContext.isDelegateCall,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/simulator/src/public/public_processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class PublicProcessorFactory {
const historicalHeader = maybeHistoricalHeader ?? merkleTree.getInitialHeader();

const worldStateDB = new WorldStateDB(merkleTree, this.contractDataSource);
const publicExecutor = new PublicExecutor(worldStateDB, historicalHeader, telemetryClient);
const publicExecutor = new PublicExecutor(worldStateDB, telemetryClient);
const publicKernelSimulator = new RealPublicKernelCircuitSimulator(this.simulator);

return PublicProcessor.create(
Expand Down
15 changes: 3 additions & 12 deletions yarn-project/txe/src/oracle/txe_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -705,6 +695,7 @@ export class TXE implements TypedOracle {
/* transactionFee */ Fr.ONE,
counter,
);
return Promise.resolve(executionResult);
}

async avmOpcodeCall(
Expand Down
Loading