-
Notifications
You must be signed in to change notification settings - Fork 270
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
feat(avm): link up storage #4150
Merged
Merged
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8d06d9e
feat(avm): better field arithmetic
Maddiaa0 2c471d3
chore: test field division
Maddiaa0 688530a
chore: add div to opcodes list
Maddiaa0 8eb1ad7
fix: lint bb
Maddiaa0 d9b7747
chore: Add comments to mod inverse method
Maddiaa0 8550753
chore: remove commented import
Maddiaa0 e66d649
fix: fmr
Maddiaa0 b40f42c
fix: fmt
Maddiaa0 17a2005
feat(avm): link up storage
Maddiaa0 b61c95b
Merge branch 'master' into md/01-18-feat_avm_link_up_storage
Maddiaa0 4521d6d
feat: add execution environment with test construction fixtures
Maddiaa0 38dd382
Merge branch 'master' into md/01-18-feat_avm_link_up_storage
Maddiaa0 7fcc6cf
chore: add execution environment to merged tests
Maddiaa0 db1ca36
fix: fmt
Maddiaa0 cf375e4
Merge branch 'master' into md/01-18-feat_avm_link_up_storage
Maddiaa0 26a2315
chore: move calldata into execution environment
Maddiaa0 f2e66d6
Merge branch 'master' into md/01-18-feat_avm_link_up_storage
Maddiaa0 eb8be2b
Merge branch 'master' into md/01-18-feat_avm_link_up_storage
Maddiaa0 80b7fe4
Merge branch 'master' into md/01-18-feat_avm_link_up_storage
Maddiaa0 b2a4051
fix: post merge fix
Maddiaa0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calldata seems to be both here and in the environment, is that expected/needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In conversations with David I originally deemed that it should be separate from the execution environment, but the more I think about it, it fits the readonly nature of the rest of executionEnvironment, so i will move it in and push