@aztec/txe 0.0.1-commit.f295ac2 → 0.0.1-commit.f504929
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 +88 -54
- package/dest/oracle/interfaces.d.ts +29 -28
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +15 -15
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +16 -16
- package/dest/oracle/txe_oracle_top_level_context.d.ts +22 -23
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +125 -54
- package/dest/rpc_translator.d.ts +87 -81
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +287 -170
- package/dest/state_machine/archiver.d.ts +2 -2
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +7 -6
- package/dest/state_machine/dummy_p2p_client.d.ts +16 -12
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +28 -16
- package/dest/state_machine/index.d.ts +7 -7
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +31 -17
- package/dest/state_machine/mock_epoch_cache.d.ts +8 -6
- package/dest/state_machine/mock_epoch_cache.d.ts.map +1 -1
- package/dest/state_machine/mock_epoch_cache.js +9 -6
- package/dest/state_machine/synchronizer.d.ts +3 -3
- package/dest/state_machine/synchronizer.d.ts.map +1 -1
- package/dest/txe_session.d.ts +9 -6
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +86 -26
- package/dest/util/txe_public_contract_data_source.d.ts +2 -3
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +5 -22
- package/dest/utils/block_creation.d.ts +5 -5
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +7 -5
- package/package.json +15 -15
- package/src/index.ts +89 -52
- package/src/oracle/interfaces.ts +32 -31
- package/src/oracle/txe_oracle_public_context.ts +18 -20
- package/src/oracle/txe_oracle_top_level_context.ts +155 -102
- package/src/rpc_translator.ts +303 -177
- package/src/state_machine/archiver.ts +6 -8
- package/src/state_machine/dummy_p2p_client.ts +40 -22
- package/src/state_machine/index.ts +49 -19
- package/src/state_machine/mock_epoch_cache.ts +10 -11
- package/src/state_machine/synchronizer.ts +2 -2
- package/src/txe_session.ts +101 -85
- package/src/util/txe_public_contract_data_source.ts +10 -36
- package/src/utils/block_creation.ts +8 -6
- package/dest/util/txe_contract_store.d.ts +0 -12
- package/dest/util/txe_contract_store.d.ts.map +0 -1
- package/dest/util/txe_contract_store.js +0 -22
- package/src/util/txe_contract_store.ts +0 -36
package/src/index.ts
CHANGED
|
@@ -9,9 +9,12 @@ import { Fr } from '@aztec/aztec.js/fields';
|
|
|
9
9
|
import { PublicKeys, deriveKeys } from '@aztec/aztec.js/keys';
|
|
10
10
|
import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
11
11
|
import type { Logger } from '@aztec/foundation/log';
|
|
12
|
-
import {
|
|
12
|
+
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
13
|
+
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
13
14
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
15
|
+
import { ContractStore } from '@aztec/pxe/server';
|
|
14
16
|
import { computeArtifactHash } from '@aztec/stdlib/contract';
|
|
17
|
+
import type { ContractArtifactWithHash } from '@aztec/stdlib/contract';
|
|
15
18
|
import type { ApiSchemaFor } from '@aztec/stdlib/schemas';
|
|
16
19
|
import { zodFor } from '@aztec/stdlib/schemas';
|
|
17
20
|
|
|
@@ -29,22 +32,29 @@ import {
|
|
|
29
32
|
type ForeignCallResult,
|
|
30
33
|
ForeignCallResultSchema,
|
|
31
34
|
type ForeignCallSingle,
|
|
35
|
+
addressFromSingle,
|
|
32
36
|
fromArray,
|
|
33
37
|
fromSingle,
|
|
34
38
|
toSingle,
|
|
35
39
|
} from './util/encoding.js';
|
|
36
|
-
import type { ContractArtifactWithHash } from './util/txe_contract_store.js';
|
|
37
40
|
|
|
38
41
|
const sessions = new Map<number, TXESession>();
|
|
39
42
|
|
|
40
43
|
/*
|
|
41
44
|
* TXE typically has to load the same contract artifacts over and over again for multiple tests,
|
|
42
|
-
* so we cache them here to avoid
|
|
45
|
+
* so we cache them here to avoid loading from disk repeatedly.
|
|
46
|
+
*
|
|
47
|
+
* The in-flight map coalesces concurrent requests for the same cache key so that
|
|
48
|
+
* computeArtifactHash (very expensive) is only run once even under parallelism.
|
|
43
49
|
*/
|
|
44
50
|
const TXEArtifactsCache = new Map<
|
|
45
51
|
string,
|
|
46
52
|
{ artifact: ContractArtifactWithHash; instance: ContractInstanceWithAddress }
|
|
47
53
|
>();
|
|
54
|
+
const TXEArtifactsCacheInFlight = new Map<
|
|
55
|
+
string,
|
|
56
|
+
Promise<{ artifact: ContractArtifactWithHash; instance: ContractInstanceWithAddress }>
|
|
57
|
+
>();
|
|
48
58
|
|
|
49
59
|
type TXEForeignCallInput = {
|
|
50
60
|
session_id: number;
|
|
@@ -68,7 +78,7 @@ const TXEForeignCallInputSchema = zodFor<TXEForeignCallInput>()(
|
|
|
68
78
|
);
|
|
69
79
|
|
|
70
80
|
class TXEDispatcher {
|
|
71
|
-
private
|
|
81
|
+
private contractStore!: ContractStore;
|
|
72
82
|
|
|
73
83
|
constructor(private logger: Logger) {}
|
|
74
84
|
|
|
@@ -96,6 +106,8 @@ class TXEDispatcher {
|
|
|
96
106
|
|
|
97
107
|
const decodedArgs = fromArray(inputs[3] as ForeignCallArray);
|
|
98
108
|
const secret = fromSingle(inputs[4] as ForeignCallSingle);
|
|
109
|
+
const salt = fromSingle(inputs[5] as ForeignCallSingle);
|
|
110
|
+
const deployer = addressFromSingle(inputs[6] as ForeignCallSingle);
|
|
99
111
|
const publicKeys = secret.equals(Fr.ZERO) ? PublicKeys.default() : (await deriveKeys(secret)).publicKeys;
|
|
100
112
|
const publicKeysHash = await publicKeys.hash();
|
|
101
113
|
|
|
@@ -126,7 +138,7 @@ class TXEDispatcher {
|
|
|
126
138
|
|
|
127
139
|
const cacheKey = `${contractDirectory ?? ''}-${contractFilename}-${initializer}-${decodedArgs
|
|
128
140
|
.map(arg => arg.toString())
|
|
129
|
-
.join('-')}-${publicKeysHash}-${fileHash}`;
|
|
141
|
+
.join('-')}-${publicKeysHash}-${salt}-${deployer}-${fileHash}`;
|
|
130
142
|
|
|
131
143
|
let instance;
|
|
132
144
|
let artifact: ContractArtifactWithHash;
|
|
@@ -135,29 +147,36 @@ class TXEDispatcher {
|
|
|
135
147
|
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
136
148
|
({ artifact, instance } = TXEArtifactsCache.get(cacheKey)!);
|
|
137
149
|
} else {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
150
|
+
if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
|
|
151
|
+
this.logger.debug(`Loading compiled artifact ${artifactPath}`);
|
|
152
|
+
const compute = async () => {
|
|
153
|
+
const artifactJSON = JSON.parse(await readFile(artifactPath, 'utf-8')) as NoirCompiledContract;
|
|
154
|
+
const artifactWithoutHash = loadContractArtifact(artifactJSON);
|
|
155
|
+
const computedArtifact: ContractArtifactWithHash = {
|
|
156
|
+
...artifactWithoutHash,
|
|
157
|
+
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
158
|
+
// and the TXE contract data provider can cache it
|
|
159
|
+
artifactHash: await computeArtifactHash(artifactWithoutHash),
|
|
160
|
+
};
|
|
161
|
+
this.logger.debug(
|
|
162
|
+
`Deploy ${computedArtifact.name} with initializer ${initializer}(${decodedArgs}) and public keys hash ${publicKeysHash.toString()}`,
|
|
163
|
+
);
|
|
164
|
+
const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
|
|
165
|
+
constructorArgs: decodedArgs,
|
|
166
|
+
skipArgsDecoding: true,
|
|
167
|
+
salt,
|
|
168
|
+
publicKeys,
|
|
169
|
+
constructorArtifact: initializer ? initializer : undefined,
|
|
170
|
+
deployer,
|
|
171
|
+
});
|
|
172
|
+
const result = { artifact: computedArtifact, instance: computedInstance };
|
|
173
|
+
TXEArtifactsCache.set(cacheKey, result);
|
|
174
|
+
TXEArtifactsCacheInFlight.delete(cacheKey);
|
|
175
|
+
return result;
|
|
176
|
+
};
|
|
177
|
+
TXEArtifactsCacheInFlight.set(cacheKey, compute());
|
|
178
|
+
}
|
|
179
|
+
({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey)!);
|
|
161
180
|
}
|
|
162
181
|
|
|
163
182
|
inputs.splice(0, 1, artifact, instance, toSingle(secret));
|
|
@@ -175,23 +194,35 @@ class TXEDispatcher {
|
|
|
175
194
|
this.logger.debug(`Using cached artifact for ${cacheKey}`);
|
|
176
195
|
({ artifact, instance } = TXEArtifactsCache.get(cacheKey)!);
|
|
177
196
|
} else {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
197
|
+
if (!TXEArtifactsCacheInFlight.has(cacheKey)) {
|
|
198
|
+
const compute = async () => {
|
|
199
|
+
const keys = await deriveKeys(secret);
|
|
200
|
+
const args = [
|
|
201
|
+
keys.publicKeys.masterIncomingViewingPublicKey.x,
|
|
202
|
+
keys.publicKeys.masterIncomingViewingPublicKey.y,
|
|
203
|
+
];
|
|
204
|
+
const computedArtifact: ContractArtifactWithHash = {
|
|
205
|
+
...SchnorrAccountContractArtifact,
|
|
206
|
+
// Artifact hash is *very* expensive to compute, so we do it here once
|
|
207
|
+
// and the TXE contract data provider can cache it
|
|
208
|
+
artifactHash: await computeArtifactHash(SchnorrAccountContractArtifact),
|
|
209
|
+
};
|
|
210
|
+
const computedInstance = await getContractInstanceFromInstantiationParams(computedArtifact, {
|
|
211
|
+
constructorArgs: args,
|
|
212
|
+
skipArgsDecoding: true,
|
|
213
|
+
salt: Fr.ONE,
|
|
214
|
+
publicKeys: keys.publicKeys,
|
|
215
|
+
constructorArtifact: 'constructor',
|
|
216
|
+
deployer: AztecAddress.ZERO,
|
|
217
|
+
});
|
|
218
|
+
const result = { artifact: computedArtifact, instance: computedInstance };
|
|
219
|
+
TXEArtifactsCache.set(cacheKey, result);
|
|
220
|
+
TXEArtifactsCacheInFlight.delete(cacheKey);
|
|
221
|
+
return result;
|
|
222
|
+
};
|
|
223
|
+
TXEArtifactsCacheInFlight.set(cacheKey, compute());
|
|
224
|
+
}
|
|
225
|
+
({ artifact, instance } = await TXEArtifactsCacheInFlight.get(cacheKey)!);
|
|
195
226
|
}
|
|
196
227
|
|
|
197
228
|
inputs.splice(0, 0, artifact, instance);
|
|
@@ -204,20 +235,26 @@ class TXEDispatcher {
|
|
|
204
235
|
|
|
205
236
|
if (!sessions.has(sessionId)) {
|
|
206
237
|
this.logger.debug(`Creating new session ${sessionId}`);
|
|
207
|
-
if (!this.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
);
|
|
238
|
+
if (!this.contractStore) {
|
|
239
|
+
const kvStore = await openTmpStore('txe-contracts');
|
|
240
|
+
this.contractStore = new ContractStore(kvStore);
|
|
241
|
+
const provider = new BundledProtocolContractsProvider();
|
|
242
|
+
for (const name of protocolContractNames) {
|
|
243
|
+
const { instance, artifact } = await provider.getProtocolContractArtifact(name);
|
|
244
|
+
await this.contractStore.addContractArtifact(artifact);
|
|
245
|
+
await this.contractStore.addContractInstance(instance);
|
|
246
|
+
}
|
|
247
|
+
this.logger.debug('Registered protocol contracts in shared contract store');
|
|
211
248
|
}
|
|
212
|
-
sessions.set(sessionId, await TXESession.init(this.
|
|
249
|
+
sessions.set(sessionId, await TXESession.init(this.contractStore));
|
|
213
250
|
}
|
|
214
251
|
|
|
215
252
|
switch (functionName) {
|
|
216
|
-
case '
|
|
253
|
+
case 'aztec_txe_deploy': {
|
|
217
254
|
await this.#processDeployInputs(callData);
|
|
218
255
|
break;
|
|
219
256
|
}
|
|
220
|
-
case '
|
|
257
|
+
case 'aztec_txe_addAccount': {
|
|
221
258
|
await this.#processAddAccountInputs(callData);
|
|
222
259
|
break;
|
|
223
260
|
}
|
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,43 +44,44 @@ 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,
|
|
71
67
|
args: Fr[],
|
|
72
68
|
argsHash: Fr,
|
|
73
69
|
isStaticCall: boolean,
|
|
70
|
+
jobId: string,
|
|
74
71
|
): Promise<Fr[]>;
|
|
75
|
-
|
|
72
|
+
executeUtilityFunction(
|
|
76
73
|
targetContractAddress: AztecAddress,
|
|
77
74
|
functionSelector: FunctionSelector,
|
|
78
75
|
args: Fr[],
|
|
76
|
+
jobId: string,
|
|
79
77
|
): Promise<Fr[]>;
|
|
80
|
-
|
|
78
|
+
publicCallNewFlow(
|
|
81
79
|
from: AztecAddress,
|
|
82
80
|
targetContractAddress: AztecAddress,
|
|
83
81
|
calldata: Fr[],
|
|
84
82
|
isStaticCall: boolean,
|
|
85
83
|
): Promise<Fr[]>;
|
|
84
|
+
// TODO(F-335): Drop this from here as it's not a real oracle handler - it's only called from
|
|
85
|
+
// RPCTranslator::txeGetPrivateEvents and never from Noir.
|
|
86
|
+
syncContractNonOracleMethod(contractAddress: AztecAddress, scope: AztecAddress, jobId: string): Promise<void>;
|
|
86
87
|
}
|
|
@@ -3,7 +3,7 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type {
|
|
6
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
8
8
|
import {
|
|
9
9
|
MerkleTreeId,
|
|
@@ -39,57 +39,55 @@ 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
|
|
82
|
-
const nullifier = await siloNullifier(targetAddress, innerNullifier!);
|
|
83
|
-
|
|
81
|
+
async nullifierExists(siloedNullifier: Fr): Promise<boolean> {
|
|
84
82
|
const treeIndex = (
|
|
85
|
-
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [
|
|
83
|
+
await this.forkedWorldTrees.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, [siloedNullifier.toBuffer()])
|
|
86
84
|
)[0];
|
|
87
|
-
const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(
|
|
85
|
+
const transientIndex = this.transientSiloedNullifiers.find(n => n.equals(siloedNullifier));
|
|
88
86
|
|
|
89
87
|
return treeIndex !== undefined || transientIndex !== undefined;
|
|
90
88
|
}
|
|
91
89
|
|
|
92
|
-
async
|
|
90
|
+
async storageWrite(slot: Fr, value: Fr) {
|
|
93
91
|
this.logger.debug('AVM storage write', { slot, value });
|
|
94
92
|
|
|
95
93
|
const dataWrite = new PublicDataWrite(await computePublicDataTreeLeafSlot(this.contractAddress, slot), value);
|
|
@@ -101,8 +99,8 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
101
99
|
]);
|
|
102
100
|
}
|
|
103
101
|
|
|
104
|
-
async
|
|
105
|
-
const leafSlot = await computePublicDataTreeLeafSlot(
|
|
102
|
+
async storageRead(slot: Fr, contractAddress: AztecAddress): Promise<Fr> {
|
|
103
|
+
const leafSlot = await computePublicDataTreeLeafSlot(contractAddress, slot);
|
|
106
104
|
|
|
107
105
|
const lowLeafResult = await this.forkedWorldTrees.getPreviousValueIndex(
|
|
108
106
|
MerkleTreeId.PUBLIC_DATA_TREE,
|
|
@@ -119,12 +117,12 @@ export class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
119
117
|
)) as PublicDataTreeLeafPreimage
|
|
120
118
|
).leaf.value;
|
|
121
119
|
|
|
122
|
-
this.logger.debug('AVM storage read', { slot, value });
|
|
120
|
+
this.logger.debug('AVM storage read', { slot, contractAddress, value });
|
|
123
121
|
|
|
124
122
|
return value;
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
async close(): Promise<
|
|
125
|
+
async close(): Promise<L2Block> {
|
|
128
126
|
this.logger.debug('Exiting Public Context, building block with collected side effects', {
|
|
129
127
|
blockNumber: this.globalVariables.blockNumber,
|
|
130
128
|
});
|