-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add execution environment with test construction fixtures
- Loading branch information
Showing
9 changed files
with
84 additions
and
73 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
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,40 +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 { ExecutionEnvironment } from '../avm_execution_environment.js'; | ||
import { AvmExecutionEnvironment } from '../avm_execution_environment.js'; | ||
|
||
export const initExecutionEnvironmentEmpty = (): ExecutionEnvironment => { | ||
return new ExecutionEnvironment( | ||
AztecAddress.zero(), | ||
AztecAddress.zero(), | ||
AztecAddress.zero(), | ||
AztecAddress.zero(), | ||
EthAddress.ZERO, | ||
Fr.zero(), | ||
Fr.zero(), | ||
Fr.zero(), | ||
Fr.zero(), | ||
false, | ||
false, | ||
[], | ||
); | ||
}; | ||
/** | ||
* 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[]; | ||
} | ||
|
||
export const initExecutionEnvironment = (contractAddress: AztecAddress): ExecutionEnvironment => { | ||
return new ExecutionEnvironment( | ||
contractAddress, | ||
contractAddress, | ||
AztecAddress.zero(), | ||
AztecAddress.zero(), | ||
EthAddress.ZERO, | ||
Fr.zero(), | ||
Fr.zero(), | ||
Fr.zero(), | ||
Fr.zero(), | ||
false, | ||
false, | ||
[], | ||
/** | ||
* 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
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