-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
274 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
yarn-project/acir-simulator/src/avm/avm_execution_environment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { GlobalVariables } from '@aztec/circuits.js'; | ||
import { AztecAddress } from '@aztec/foundation/aztec-address'; | ||
import { EthAddress } from '@aztec/foundation/eth-address'; | ||
import { Fr } from '@aztec/foundation/fields'; | ||
|
||
/** | ||
* Contains variables that remain constant during AVM execution | ||
* These variables are provided by the public kernel circuit | ||
*/ | ||
export class AvmExecutionEnvironment { | ||
constructor( | ||
/** - */ | ||
public readonly address: AztecAddress, | ||
/** - */ | ||
public readonly storageAddress: AztecAddress, | ||
/** - */ | ||
public readonly origin: AztecAddress, | ||
/** - */ | ||
public readonly sender: AztecAddress, | ||
/** - */ | ||
public readonly portal: EthAddress, | ||
/** - */ | ||
public readonly feePerL1Gas: Fr, | ||
/** - */ | ||
public readonly feePerL2Gas: Fr, | ||
/** - */ | ||
public readonly feePerDaGas: Fr, | ||
/** - */ | ||
public readonly contractCallDepth: Fr, | ||
/** - */ | ||
public readonly globals: GlobalVariables, | ||
/** - */ | ||
public readonly isStaticCall: boolean, | ||
/** - */ | ||
public readonly isDelegateCall: boolean, | ||
/** - */ | ||
public readonly calldata: Fr[], | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,60 @@ | ||
// Place large AVM text fixtures in here | ||
import { GlobalVariables } from '@aztec/circuits.js'; | ||
import { AztecAddress } from '@aztec/foundation/aztec-address'; | ||
import { EthAddress } from '@aztec/foundation/eth-address'; | ||
import { Fr } from '@aztec/foundation/fields'; | ||
|
||
import { AvmExecutionEnvironment } from '../avm_execution_environment.js'; | ||
|
||
/** | ||
* An interface that allows to override the default values of the AvmExecutionEnvironment | ||
*/ | ||
export interface AvmExecutionEnvironmentOverrides { | ||
/** - */ | ||
address?: AztecAddress; | ||
/** - */ | ||
storageAddress?: AztecAddress; | ||
/** - */ | ||
origin?: AztecAddress; | ||
/** - */ | ||
sender?: AztecAddress; | ||
/** - */ | ||
portal?: EthAddress; | ||
/** - */ | ||
feePerL1Gas?: Fr; | ||
/** - */ | ||
feePerL2Gas?: Fr; | ||
/** - */ | ||
feePerDaGas?: Fr; | ||
/** - */ | ||
contractCallDepth?: Fr; | ||
/** - */ | ||
globals?: GlobalVariables; | ||
/** - */ | ||
isStaticCall?: boolean; | ||
/** - */ | ||
isDelegateCall?: boolean; | ||
/** - */ | ||
calldata?: Fr[]; | ||
} | ||
|
||
/** | ||
* Create an empty instance of the Execution Environment where all values are zero, unless overriden in the overrides object | ||
*/ | ||
export function initExecutionEnvironment(overrides?: AvmExecutionEnvironmentOverrides): AvmExecutionEnvironment { | ||
return new AvmExecutionEnvironment( | ||
overrides?.address ?? AztecAddress.zero(), | ||
overrides?.storageAddress ?? AztecAddress.zero(), | ||
overrides?.origin ?? AztecAddress.zero(), | ||
overrides?.sender ?? AztecAddress.zero(), | ||
overrides?.portal ?? EthAddress.ZERO, | ||
overrides?.feePerL1Gas ?? Fr.zero(), | ||
overrides?.feePerL2Gas ?? Fr.zero(), | ||
overrides?.feePerDaGas ?? Fr.zero(), | ||
overrides?.contractCallDepth ?? Fr.zero(), | ||
overrides?.globals ?? GlobalVariables.empty(), | ||
overrides?.isStaticCall ?? false, | ||
overrides?.isDelegateCall ?? false, | ||
overrides?.calldata ?? [], | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
yarn-project/acir-simulator/src/avm/opcodes/arithmetic.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.