-
Notifications
You must be signed in to change notification settings - Fork 310
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): initial external calls #4194
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
55 changes: 55 additions & 0 deletions
55
yarn-project/acir-simulator/src/avm/avm_execution_environment.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Fr } from '@aztec/foundation/fields'; | ||
|
||
import { initExecutionEnvironment } from './fixtures/index.js'; | ||
|
||
describe('Execution Environment', () => { | ||
const newAddress = new Fr(123456n); | ||
const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)]; | ||
|
||
it('New call should fork execution environment correctly', () => { | ||
const executionEnvironment = initExecutionEnvironment(); | ||
const newExecutionEnvironment = executionEnvironment.newCall(newAddress, calldata); | ||
|
||
allTheSameExcept(executionEnvironment, newExecutionEnvironment, { | ||
address: newAddress, | ||
storageAddress: newAddress, | ||
calldata, | ||
}); | ||
}); | ||
|
||
it('New delegate call should fork execution environment correctly', () => { | ||
const executionEnvironment = initExecutionEnvironment(); | ||
const newExecutionEnvironment = executionEnvironment.newDelegateCall(newAddress, calldata); | ||
|
||
allTheSameExcept(executionEnvironment, newExecutionEnvironment, { | ||
address: newAddress, | ||
isDelegateCall: true, | ||
calldata, | ||
}); | ||
}); | ||
|
||
it('New static call call should fork execution environment correctly', () => { | ||
const executionEnvironment = initExecutionEnvironment(); | ||
const newExecutionEnvironment = executionEnvironment.newStaticCall(newAddress, calldata); | ||
|
||
allTheSameExcept(executionEnvironment, newExecutionEnvironment, { | ||
address: newAddress, | ||
storageAddress: newAddress, | ||
isStaticCall: true, | ||
calldata, | ||
}); | ||
}); | ||
}); | ||
|
||
/** | ||
* Check all properties of one object are the same, except for the specified differentProperties | ||
*/ | ||
function allTheSameExcept(referenceObject: any, comparingObject: any, differentProperties: Record<string, any>): void { | ||
for (const key in referenceObject) { | ||
if (Object.keys(differentProperties).includes(key)) { | ||
expect(comparingObject[key]).toEqual(differentProperties[key]); | ||
} else { | ||
expect(comparingObject[key]).toEqual(referenceObject[key]); | ||
} | ||
} | ||
} |
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
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.
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.
I think the concepts of ExecutionEnvironment, Context, State, are getting a bit unclear to me. For example, a "context" in this line is actually a state:
aztec-packages/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts
Line 31 in 4027633
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.
On the same line, it's getting less clear what the "entry point" would be for a client. First I expected it to be the interpreter, but it needs some pre-processing so no.
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.
Ah the line above hangs from a pr where everything had different names, but were changed to line up with the yellow paper's definitions - I can rename the offending line.
The entry point would be instantiating a context, from the kernels function inputs, which will execute an interpreter.
Let me know if this model blows and we can get back to pen and paper