-
Notifications
You must be signed in to change notification settings - Fork 598
fix(txe): committing after txs #20714
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,7 +107,6 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| private senderAddressBookStore: SenderAddressBookStore, | ||
| private capsuleStore: CapsuleStore, | ||
| private privateEventStore: PrivateEventStore, | ||
| private jobId: string, | ||
| private nextBlockTimestamp: bigint, | ||
| private version: Fr, | ||
| private chainId: Fr, | ||
|
|
@@ -172,6 +171,25 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| return { txHash: txEffects.txHash, noteHashes: txEffects.noteHashes, nullifiers: txEffects.nullifiers }; | ||
| } | ||
|
|
||
| async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) { | ||
| if (contractAddress.equals(DEFAULT_ADDRESS)) { | ||
| this.logger.debug(`Skipping sync in txeGetPrivateEvents because the events correspond to the default address.`); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this exception needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because these tests work in top level context and have there address set to DEFAULT_ADDRESS. DEFAULT_ADDRESS is some kind of fake address and is set to the number of 42. This is pretty messy but a lot of TXE is pretty messy so would not bother with this now (and until we are sure that the current TXE model makes sense). |
||
| return; | ||
| } | ||
|
|
||
| const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader(); | ||
| await this.stateMachine.contractSyncService.ensureContractSynced( | ||
| contractAddress, | ||
| null, | ||
| async (call, execScopes) => { | ||
| await this.executeUtilityCall(call, execScopes, jobId); | ||
| }, | ||
| blockHeader, | ||
| jobId, | ||
| [scope], | ||
| ); | ||
| } | ||
|
|
||
| async txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) { | ||
| return ( | ||
| await this.privateEventStore.getPrivateEvents(selector, { | ||
|
|
@@ -285,6 +303,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| args: Fr[], | ||
| argsHash: Fr = Fr.zero(), | ||
| isStaticCall: boolean = false, | ||
| jobId: string, | ||
| ) { | ||
| this.logger.verbose( | ||
| `Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`, | ||
|
|
@@ -304,7 +323,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
|
|
||
| // Sync notes before executing private function to discover notes from previous transactions | ||
| const utilityExecutor = async (call: FunctionCall, execScopes: AccessScopes) => { | ||
| await this.executeUtilityCall(call, execScopes); | ||
| await this.executeUtilityCall(call, execScopes, jobId); | ||
| }; | ||
|
|
||
| const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader(); | ||
|
|
@@ -313,7 +332,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| functionSelector, | ||
| utilityExecutor, | ||
| blockHeader, | ||
| this.jobId, | ||
| jobId, | ||
| effectiveScopes, | ||
| ); | ||
|
|
||
|
|
@@ -360,7 +379,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| capsuleStore: this.capsuleStore, | ||
| privateEventStore: this.privateEventStore, | ||
| contractSyncService: this.stateMachine.contractSyncService, | ||
| jobId: this.jobId, | ||
| jobId, | ||
| totalPublicCalldataCount: 0, | ||
| sideEffectCounter: minRevertibleSideEffectCounter, | ||
| scopes: effectiveScopes, | ||
|
|
@@ -659,7 +678,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| return returnValues ?? []; | ||
| } | ||
|
|
||
| async txeExecuteUtilityFunction(targetContractAddress: AztecAddress, functionSelector: FunctionSelector, args: Fr[]) { | ||
| async txeExecuteUtilityFunction( | ||
| targetContractAddress: AztecAddress, | ||
| functionSelector: FunctionSelector, | ||
| args: Fr[], | ||
| jobId: string, | ||
| ) { | ||
| const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector); | ||
| if (!artifact) { | ||
| throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`); | ||
|
|
@@ -671,10 +695,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| targetContractAddress, | ||
| functionSelector, | ||
| async (call, execScopes) => { | ||
| await this.executeUtilityCall(call, execScopes); | ||
| await this.executeUtilityCall(call, execScopes, jobId); | ||
| }, | ||
| blockHeader, | ||
| this.jobId, | ||
| jobId, | ||
| 'ALL_SCOPES', | ||
| ); | ||
|
|
||
|
|
@@ -689,10 +713,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| returnTypes: [], | ||
| }); | ||
|
|
||
| return this.executeUtilityCall(call, 'ALL_SCOPES'); | ||
| return this.executeUtilityCall(call, 'ALL_SCOPES', jobId); | ||
| } | ||
|
|
||
| private async executeUtilityCall(call: FunctionCall, scopes: AccessScopes): Promise<Fr[]> { | ||
| private async executeUtilityCall(call: FunctionCall, scopes: AccessScopes, jobId: string): Promise<Fr[]> { | ||
| const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector); | ||
| if (entryPointArtifact.functionType !== FunctionType.UTILITY) { | ||
| throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`); | ||
|
|
@@ -719,7 +743,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl | |
| senderAddressBookStore: this.senderAddressBookStore, | ||
| capsuleStore: this.capsuleStore, | ||
| privateEventStore: this.privateEventStore, | ||
| jobId: this.jobId, | ||
| jobId, | ||
| scopes, | ||
| }); | ||
| const acirExecutionResult = await new WASMSimulator() | ||
|
|
||
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 needed this to be able to trigger contract sync from
txeGetPrivateEventsinRPCTranslator. It was not possible to do it fromtxeGetPrivateEventsinTXEOracleTopLevelContextbecause there we don't have access to the stateMachine and hence it's impossible to commit there after the sync is done.