@aztec/txe 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +8 -6
- package/dest/oracle/interfaces.d.ts +31 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +13 -13
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +12 -12
- package/dest/oracle/txe_oracle_top_level_context.d.ts +27 -19
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +72 -42
- package/dest/rpc_translator.d.ts +128 -82
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +458 -170
- package/dest/state_machine/archiver.d.ts +3 -3
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +7 -8
- package/dest/state_machine/dummy_p2p_client.d.ts +3 -2
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +5 -2
- package/dest/state_machine/global_variable_builder.d.ts +9 -4
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +9 -3
- package/dest/state_machine/index.d.ts +4 -2
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +8 -4
- package/dest/state_machine/mock_epoch_cache.d.ts +18 -3
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +35 -2
- package/dest/state_machine/synchronizer.d.ts +5 -5
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/state_machine/synchronizer.js +3 -3
- package/dest/txe_session.d.ts +46 -1
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +86 -17
- package/dest/util/encoding.d.ts +71 -1
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +4 -0
- package/dest/util/txe_public_contract_data_source.d.ts +1 -1
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +1 -3
- package/package.json +15 -15
- package/src/index.ts +8 -5
- package/src/oracle/interfaces.ts +28 -32
- package/src/oracle/txe_oracle_public_context.ts +12 -12
- package/src/oracle/txe_oracle_top_level_context.ts +75 -46
- package/src/rpc_translator.ts +532 -204
- package/src/state_machine/archiver.ts +6 -5
- package/src/state_machine/dummy_p2p_client.ts +6 -2
- package/src/state_machine/global_variable_builder.ts +18 -3
- package/src/state_machine/index.ts +9 -2
- package/src/state_machine/mock_epoch_cache.ts +46 -3
- package/src/state_machine/synchronizer.ts +4 -4
- package/src/txe_session.ts +148 -17
- package/src/util/encoding.ts +5 -0
- package/src/util/txe_public_contract_data_source.ts +0 -2
package/src/oracle/interfaces.ts
CHANGED
|
@@ -24,18 +24,18 @@ import type { UInt64 } from '@aztec/stdlib/types';
|
|
|
24
24
|
export interface IAvmExecutionOracle {
|
|
25
25
|
isAvm: true;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
address(): Promise<AztecAddress>;
|
|
28
|
+
sender(): Promise<AztecAddress>;
|
|
29
|
+
blockNumber(): Promise<BlockNumber>;
|
|
30
|
+
timestamp(): Promise<bigint>;
|
|
31
|
+
isStaticCall(): Promise<boolean>;
|
|
32
|
+
chainId(): Promise<Fr>;
|
|
33
|
+
version(): Promise<Fr>;
|
|
34
|
+
emitNullifier(nullifier: Fr): Promise<void>;
|
|
35
|
+
emitNoteHash(noteHash: Fr): Promise<void>;
|
|
36
|
+
nullifierExists(siloedNullifier: Fr): Promise<boolean>;
|
|
37
|
+
storageWrite(slot: Fr, value: Fr): Promise<void>;
|
|
38
|
+
storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -44,27 +44,23 @@ export interface IAvmExecutionOracle {
|
|
|
44
44
|
export interface ITxeExecutionOracle {
|
|
45
45
|
isTxe: true;
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
): Promise<CompleteAddress>;
|
|
59
|
-
txeAddAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
|
|
60
|
-
txeGetLastBlockTimestamp(): Promise<bigint>;
|
|
61
|
-
txeGetLastTxEffects(): Promise<{
|
|
47
|
+
getDefaultAddress(): AztecAddress;
|
|
48
|
+
getNextBlockNumber(): Promise<BlockNumber>;
|
|
49
|
+
getNextBlockTimestamp(): Promise<UInt64>;
|
|
50
|
+
advanceBlocksBy(blocks: number): Promise<void>;
|
|
51
|
+
advanceTimestampBy(duration: UInt64): void;
|
|
52
|
+
deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, foreignSecret: Fr): Promise<void>;
|
|
53
|
+
createAccount(secret: Fr): Promise<CompleteAddress>;
|
|
54
|
+
addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr): Promise<CompleteAddress>;
|
|
55
|
+
addAuthWitness(address: AztecAddress, messageHash: Fr): Promise<void>;
|
|
56
|
+
getLastBlockTimestamp(): Promise<bigint>;
|
|
57
|
+
getLastTxEffects(): Promise<{
|
|
62
58
|
txHash: TxHash;
|
|
63
59
|
noteHashes: Fr[];
|
|
64
60
|
nullifiers: Fr[];
|
|
65
61
|
}>;
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
63
|
+
privateCallNewFlow(
|
|
68
64
|
from: AztecAddress,
|
|
69
65
|
targetContractAddress: AztecAddress,
|
|
70
66
|
functionSelector: FunctionSelector,
|
|
@@ -72,14 +68,14 @@ export interface ITxeExecutionOracle {
|
|
|
72
68
|
argsHash: Fr,
|
|
73
69
|
isStaticCall: boolean,
|
|
74
70
|
jobId: string,
|
|
75
|
-
): Promise<Fr[]>;
|
|
76
|
-
|
|
71
|
+
): Promise<{ returnValues: Fr[]; offchainEffects: Fr[][] }>;
|
|
72
|
+
executeUtilityFunction(
|
|
77
73
|
targetContractAddress: AztecAddress,
|
|
78
74
|
functionSelector: FunctionSelector,
|
|
79
75
|
args: Fr[],
|
|
80
76
|
jobId: string,
|
|
81
77
|
): Promise<Fr[]>;
|
|
82
|
-
|
|
78
|
+
publicCallNewFlow(
|
|
83
79
|
from: AztecAddress,
|
|
84
80
|
targetContractAddress: AztecAddress,
|
|
85
81
|
calldata: Fr[],
|
|
@@ -39,46 +39,46 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
address(): Promise<AztecAddress> {
|
|
43
43
|
return Promise.resolve(this.contractAddress);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
sender(): Promise<AztecAddress> {
|
|
47
47
|
return Promise.resolve(AztecAddress.ZERO); // todo: change?
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
blockNumber(): Promise<BlockNumber> {
|
|
51
51
|
return Promise.resolve(this.globalVariables.blockNumber);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
timestamp(): Promise<bigint> {
|
|
55
55
|
return Promise.resolve(this.globalVariables.timestamp);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
isStaticCall(): Promise<boolean> {
|
|
59
59
|
return Promise.resolve(false);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
chainId(): Promise<Fr> {
|
|
63
63
|
return Promise.resolve(this.globalVariables.chainId);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
version(): Promise<Fr> {
|
|
67
67
|
return Promise.resolve(this.globalVariables.version);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
async
|
|
70
|
+
async emitNullifier(nullifier: Fr) {
|
|
71
71
|
const siloedNullifier = await siloNullifier(this.contractAddress, nullifier);
|
|
72
72
|
this.transientSiloedNullifiers.push(siloedNullifier);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
async
|
|
75
|
+
async emitNoteHash(noteHash: Fr) {
|
|
76
76
|
const siloedNoteHash = await siloNoteHash(this.contractAddress, noteHash);
|
|
77
77
|
// TODO: make the note hash unique - they are only siloed right now
|
|
78
78
|
this.transientUniqueNoteHashes.push(siloedNoteHash);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
async
|
|
81
|
+
async nullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
82
82
|
const treeIndex = (
|
|
83
83
|
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
|
|
84
84
|
)[0];
|
|
@@ -87,7 +87,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
87
87
|
return treeIndex !== undefined || transientIndex !== undefined;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
async
|
|
90
|
+
async storageWrite(slot: Fr, value: Fr) {
|
|
91
91
|
this.logger.debug('AVM storage write', { slot, value });
|
|
92
92
|
|
|
93
93
|
const dataWrite = new PublicDataWrite(await computePublicDataTreeLeafSlot(this.contractAddress, slot), value);
|
|
@@ -99,7 +99,7 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
99
99
|
]);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
async
|
|
102
|
+
async storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
|
|
103
103
|
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
104
104
|
|
|
105
105
|
const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
DEFAULT_TEARDOWN_DA_GAS_LIMIT,
|
|
6
|
-
DEFAULT_TEARDOWN_L2_GAS_LIMIT,
|
|
3
|
+
MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
|
|
4
|
+
MAX_PROCESSABLE_L2_GAS,
|
|
7
5
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
8
6
|
} from '@aztec/constants';
|
|
9
7
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
@@ -12,13 +10,13 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
12
10
|
import { LogLevels, type Logger, applyStringFormatting, createLogger } from '@aztec/foundation/log';
|
|
13
11
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
14
12
|
import type { KeyStore } from '@aztec/key-store';
|
|
15
|
-
import type { AccessScopes } from '@aztec/pxe/client/lazy';
|
|
16
13
|
import {
|
|
17
14
|
AddressStore,
|
|
15
|
+
CapsuleService,
|
|
18
16
|
CapsuleStore,
|
|
19
17
|
type ContractStore,
|
|
20
18
|
NoteStore,
|
|
21
|
-
|
|
19
|
+
ORACLE_VERSION_MAJOR,
|
|
22
20
|
PrivateEventStore,
|
|
23
21
|
RecipientTaggingStore,
|
|
24
22
|
SenderAddressBookStore,
|
|
@@ -56,7 +54,13 @@ import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
|
56
54
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
57
55
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
58
56
|
import { type ContractInstanceWithAddress, computePartialAddress } from '@aztec/stdlib/contract';
|
|
59
|
-
import {
|
|
57
|
+
import {
|
|
58
|
+
FALLBACK_TEARDOWN_DA_GAS_LIMIT,
|
|
59
|
+
FALLBACK_TEARDOWN_L2_GAS_LIMIT,
|
|
60
|
+
Gas,
|
|
61
|
+
GasFees,
|
|
62
|
+
GasSettings,
|
|
63
|
+
} from '@aztec/stdlib/gas';
|
|
60
64
|
import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
61
65
|
import {
|
|
62
66
|
PartialPrivateTailPublicInputsForPublic,
|
|
@@ -116,22 +120,34 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
116
120
|
this.logger.debug('Entering Top Level Context');
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
private contractOracleVersion: { major: number; minor: number } | undefined;
|
|
124
|
+
|
|
125
|
+
assertCompatibleOracleVersion(major: number, minor: number): void {
|
|
126
|
+
if (major !== ORACLE_VERSION_MAJOR) {
|
|
127
|
+
const hint =
|
|
128
|
+
major > ORACLE_VERSION_MAJOR
|
|
129
|
+
? 'The contract was compiled with a newer version of Aztec.nr than this aztec cli version supports. Upgrade your aztec cli version to a compatible version.'
|
|
130
|
+
: 'The contract was compiled with an older version of Aztec.nr than this aztec cli version supports. Recompile the contract with a compatible version of Aztec.nr.';
|
|
121
131
|
throw new Error(
|
|
122
|
-
`Incompatible
|
|
132
|
+
`Incompatible aztec cli version: ${hint} See https://docs.aztec.network/errors/8 (expected oracle major version ${ORACLE_VERSION_MAJOR}, got ${major})`,
|
|
123
133
|
);
|
|
124
134
|
}
|
|
135
|
+
this.contractOracleVersion = { major, minor };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Prefixed with "nonOracleFunction" as it is not used as an oracle handler.
|
|
139
|
+
nonOracleFunctionGetContractOracleVersion(): { major: number; minor: number } | undefined {
|
|
140
|
+
return this.contractOracleVersion;
|
|
125
141
|
}
|
|
126
142
|
|
|
127
143
|
// This is typically only invoked in private contexts, but it is convenient to also have it in top-level for testing
|
|
128
144
|
// setup.
|
|
129
|
-
|
|
145
|
+
getRandomField(): Fr {
|
|
130
146
|
return Fr.random();
|
|
131
147
|
}
|
|
132
148
|
|
|
133
149
|
// We instruct users to debug contracts via this oracle, so it makes sense that they'd expect it to also work in tests
|
|
134
|
-
|
|
150
|
+
log(level: number, message: string, fields: Fr[]): Promise<void> {
|
|
135
151
|
if (!LogLevels[level]) {
|
|
136
152
|
throw new Error(`Invalid log level: ${level}`);
|
|
137
153
|
}
|
|
@@ -141,23 +157,23 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
141
157
|
return Promise.resolve();
|
|
142
158
|
}
|
|
143
159
|
|
|
144
|
-
|
|
160
|
+
getDefaultAddress(): AztecAddress {
|
|
145
161
|
return DEFAULT_ADDRESS;
|
|
146
162
|
}
|
|
147
163
|
|
|
148
|
-
async
|
|
164
|
+
async getNextBlockNumber(): Promise<BlockNumber> {
|
|
149
165
|
return BlockNumber((await this.getLastBlockNumber()) + 1);
|
|
150
166
|
}
|
|
151
167
|
|
|
152
|
-
|
|
168
|
+
getNextBlockTimestamp(): Promise<bigint> {
|
|
153
169
|
return Promise.resolve(this.nextBlockTimestamp);
|
|
154
170
|
}
|
|
155
171
|
|
|
156
|
-
async
|
|
172
|
+
async getLastBlockTimestamp() {
|
|
157
173
|
return (await this.stateMachine.node.getBlockHeader('latest'))!.globalVariables.timestamp;
|
|
158
174
|
}
|
|
159
175
|
|
|
160
|
-
async
|
|
176
|
+
async getLastTxEffects() {
|
|
161
177
|
const latestBlockNumber = await this.stateMachine.archiver.getBlockNumber();
|
|
162
178
|
const block = await this.stateMachine.archiver.getBlock(latestBlockNumber);
|
|
163
179
|
|
|
@@ -173,7 +189,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
173
189
|
|
|
174
190
|
async syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string) {
|
|
175
191
|
if (contractAddress.equals(DEFAULT_ADDRESS)) {
|
|
176
|
-
this.logger.debug(`Skipping sync in
|
|
192
|
+
this.logger.debug(`Skipping sync in getPrivateEvents because the events correspond to the default address.`);
|
|
177
193
|
return;
|
|
178
194
|
}
|
|
179
195
|
|
|
@@ -190,7 +206,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
190
206
|
);
|
|
191
207
|
}
|
|
192
208
|
|
|
193
|
-
async
|
|
209
|
+
async getPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress) {
|
|
194
210
|
return (
|
|
195
211
|
await this.privateEventStore.getPrivateEvents(selector, {
|
|
196
212
|
contractAddress,
|
|
@@ -201,7 +217,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
201
217
|
).map(e => e.packedEvent);
|
|
202
218
|
}
|
|
203
219
|
|
|
204
|
-
async
|
|
220
|
+
async advanceBlocksBy(blocks: number) {
|
|
205
221
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
206
222
|
|
|
207
223
|
for (let i = 0; i < blocks; i++) {
|
|
@@ -209,12 +225,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
209
225
|
}
|
|
210
226
|
}
|
|
211
227
|
|
|
212
|
-
|
|
228
|
+
advanceTimestampBy(duration: UInt64) {
|
|
213
229
|
this.logger.debug(`time traveling ${duration} seconds`);
|
|
214
230
|
this.nextBlockTimestamp += duration;
|
|
215
231
|
}
|
|
216
232
|
|
|
217
|
-
async
|
|
233
|
+
async deploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
218
234
|
// Emit deployment nullifier
|
|
219
235
|
await this.mineBlock({
|
|
220
236
|
nullifiers: [
|
|
@@ -226,7 +242,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
226
242
|
});
|
|
227
243
|
|
|
228
244
|
if (!secret.equals(Fr.ZERO)) {
|
|
229
|
-
await this.
|
|
245
|
+
await this.addAccount(artifact, instance, secret);
|
|
230
246
|
} else {
|
|
231
247
|
await this.contractStore.addContractInstance(instance);
|
|
232
248
|
await this.contractStore.addContractArtifact(artifact);
|
|
@@ -234,7 +250,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
234
250
|
}
|
|
235
251
|
}
|
|
236
252
|
|
|
237
|
-
async
|
|
253
|
+
async addAccount(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr) {
|
|
238
254
|
const partialAddress = await computePartialAddress(instance);
|
|
239
255
|
|
|
240
256
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
@@ -249,7 +265,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
249
265
|
return completeAddress;
|
|
250
266
|
}
|
|
251
267
|
|
|
252
|
-
async
|
|
268
|
+
async createAccount(secret: Fr) {
|
|
253
269
|
// This is a foot gun !
|
|
254
270
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
255
271
|
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
@@ -259,7 +275,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
259
275
|
return completeAddress;
|
|
260
276
|
}
|
|
261
277
|
|
|
262
|
-
async
|
|
278
|
+
async addAuthWitness(address: AztecAddress, messageHash: Fr) {
|
|
263
279
|
const account = await this.accountStore.getAccount(address);
|
|
264
280
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
265
281
|
|
|
@@ -272,7 +288,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
272
288
|
}
|
|
273
289
|
|
|
274
290
|
async mineBlock(options: { nullifiers?: Fr[] } = {}) {
|
|
275
|
-
const blockNumber = await this.
|
|
291
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
276
292
|
|
|
277
293
|
const txEffect = TxEffect.empty();
|
|
278
294
|
txEffect.nullifiers = [getSingleTxBlockRequestHash(blockNumber), ...(options.nullifiers ?? [])];
|
|
@@ -296,7 +312,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
296
312
|
await this.stateMachine.handleL2Block(block);
|
|
297
313
|
}
|
|
298
314
|
|
|
299
|
-
async
|
|
315
|
+
async privateCallNewFlow(
|
|
300
316
|
from: AztecAddress,
|
|
301
317
|
targetContractAddress: AztecAddress = AztecAddress.zero(),
|
|
302
318
|
functionSelector: FunctionSelector = FunctionSelector.empty(),
|
|
@@ -322,7 +338,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
322
338
|
const effectiveScopes = from.isZero() ? [] : [from];
|
|
323
339
|
|
|
324
340
|
// Sync notes before executing private function to discover notes from previous transactions
|
|
325
|
-
const utilityExecutor = async (call: FunctionCall, execScopes:
|
|
341
|
+
const utilityExecutor = async (call: FunctionCall, execScopes: AztecAddress[]) => {
|
|
326
342
|
await this.executeUtilityCall(call, execScopes, jobId);
|
|
327
343
|
};
|
|
328
344
|
|
|
@@ -336,12 +352,12 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
336
352
|
effectiveScopes,
|
|
337
353
|
);
|
|
338
354
|
|
|
339
|
-
const blockNumber = await this.
|
|
355
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
340
356
|
|
|
341
357
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
342
358
|
|
|
343
|
-
const gasLimits = new Gas(
|
|
344
|
-
const teardownGasLimits = new Gas(
|
|
359
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
360
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
345
361
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
346
362
|
|
|
347
363
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
@@ -376,7 +392,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
376
392
|
senderTaggingStore: this.senderTaggingStore,
|
|
377
393
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
378
394
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
379
|
-
|
|
395
|
+
capsuleService: new CapsuleService(this.capsuleStore, effectiveScopes),
|
|
380
396
|
privateEventStore: this.privateEventStore,
|
|
381
397
|
contractSyncService: this.stateMachine.contractSyncService,
|
|
382
398
|
jobId,
|
|
@@ -387,6 +403,8 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
387
403
|
// contract would perform, including setting senderForTags.
|
|
388
404
|
senderForTags: from,
|
|
389
405
|
simulator,
|
|
406
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
407
|
+
l2TipsStore: this.stateMachine.node,
|
|
390
408
|
});
|
|
391
409
|
|
|
392
410
|
// Note: This is a slight modification of simulator.run without any of the checks. Maybe we should modify simulator.run with a boolean value to skip checks.
|
|
@@ -409,7 +427,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
409
427
|
);
|
|
410
428
|
const publicFunctionsCalldata = await Promise.all(
|
|
411
429
|
publicCallRequests.map(async r => {
|
|
412
|
-
const calldata = await privateExecutionOracle.
|
|
430
|
+
const calldata = await privateExecutionOracle.getHashPreimage(r.calldataHash);
|
|
413
431
|
return new HashedValues(calldata, r.calldataHash);
|
|
414
432
|
}),
|
|
415
433
|
);
|
|
@@ -494,11 +512,17 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
494
512
|
}
|
|
495
513
|
}
|
|
496
514
|
|
|
515
|
+
// Walk the nested private-call tree and collect every offchain effect the transaction emitted.
|
|
516
|
+
// PXE stores these on each `PrivateCallExecutionResult` and they never reach TXE via the
|
|
517
|
+
// `aztec_utl_emitOffchainEffect` foreign-call path (that path only fires at the top-level), so
|
|
518
|
+
// we pull them out here and the RPC wrapper will hand them to `TXESession` for buffering.
|
|
519
|
+
const offchainEffects = collectNested([executionResult], r => r.offchainEffects.map(e => e.data));
|
|
520
|
+
|
|
497
521
|
if (isStaticCall) {
|
|
498
522
|
await checkpoint!.revert();
|
|
499
523
|
|
|
500
524
|
await forkedWorldTrees.close();
|
|
501
|
-
return executionResult.returnValues ?? [];
|
|
525
|
+
return { returnValues: executionResult.returnValues ?? [], offchainEffects };
|
|
502
526
|
}
|
|
503
527
|
|
|
504
528
|
const txEffect = TxEffect.empty();
|
|
@@ -520,10 +544,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
520
544
|
|
|
521
545
|
await forkedWorldTrees.close();
|
|
522
546
|
|
|
523
|
-
return executionResult.returnValues ?? [];
|
|
547
|
+
return { returnValues: executionResult.returnValues ?? [], offchainEffects };
|
|
524
548
|
}
|
|
525
549
|
|
|
526
|
-
async
|
|
550
|
+
async publicCallNewFlow(
|
|
527
551
|
from: AztecAddress,
|
|
528
552
|
targetContractAddress: AztecAddress,
|
|
529
553
|
calldata: Fr[],
|
|
@@ -533,11 +557,11 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
533
557
|
`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`,
|
|
534
558
|
);
|
|
535
559
|
|
|
536
|
-
const blockNumber = await this.
|
|
560
|
+
const blockNumber = await this.getNextBlockNumber();
|
|
537
561
|
|
|
538
|
-
const gasLimits = new Gas(
|
|
562
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
539
563
|
|
|
540
|
-
const teardownGasLimits = new Gas(
|
|
564
|
+
const teardownGasLimits = new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT);
|
|
541
565
|
|
|
542
566
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
543
567
|
|
|
@@ -678,7 +702,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
678
702
|
return returnValues ?? [];
|
|
679
703
|
}
|
|
680
704
|
|
|
681
|
-
async
|
|
705
|
+
async executeUtilityFunction(
|
|
682
706
|
targetContractAddress: AztecAddress,
|
|
683
707
|
functionSelector: FunctionSelector,
|
|
684
708
|
args: Fr[],
|
|
@@ -699,7 +723,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
699
723
|
},
|
|
700
724
|
blockHeader,
|
|
701
725
|
jobId,
|
|
702
|
-
|
|
726
|
+
await this.keyStore.getAccounts(),
|
|
703
727
|
);
|
|
704
728
|
|
|
705
729
|
const call = FunctionCall.from({
|
|
@@ -713,10 +737,10 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
713
737
|
returnTypes: [],
|
|
714
738
|
});
|
|
715
739
|
|
|
716
|
-
return this.executeUtilityCall(call,
|
|
740
|
+
return this.executeUtilityCall(call, await this.keyStore.getAccounts(), jobId);
|
|
717
741
|
}
|
|
718
742
|
|
|
719
|
-
private async executeUtilityCall(call: FunctionCall, scopes:
|
|
743
|
+
private async executeUtilityCall(call: FunctionCall, scopes: AztecAddress[], jobId: string): Promise<Fr[]> {
|
|
720
744
|
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
721
745
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
722
746
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
@@ -729,6 +753,7 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
729
753
|
|
|
730
754
|
try {
|
|
731
755
|
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
756
|
+
const simulator = new WASMSimulator();
|
|
732
757
|
const oracle = new UtilityExecutionOracle({
|
|
733
758
|
contractAddress: call.to,
|
|
734
759
|
authWitnesses: [],
|
|
@@ -741,12 +766,16 @@ export class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracl
|
|
|
741
766
|
aztecNode: this.stateMachine.node,
|
|
742
767
|
recipientTaggingStore: this.recipientTaggingStore,
|
|
743
768
|
senderAddressBookStore: this.senderAddressBookStore,
|
|
744
|
-
|
|
769
|
+
capsuleService: new CapsuleService(this.capsuleStore, scopes),
|
|
745
770
|
privateEventStore: this.privateEventStore,
|
|
771
|
+
messageContextService: this.stateMachine.messageContextService,
|
|
772
|
+
contractSyncService: this.stateMachine.contractSyncService,
|
|
773
|
+
l2TipsStore: this.stateMachine.node,
|
|
746
774
|
jobId,
|
|
747
775
|
scopes,
|
|
776
|
+
simulator,
|
|
748
777
|
});
|
|
749
|
-
const acirExecutionResult = await
|
|
778
|
+
const acirExecutionResult = await simulator
|
|
750
779
|
.executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback())
|
|
751
780
|
.catch((err: Error) => {
|
|
752
781
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|