@aztec/txe 0.80.0 → 0.81.0
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/node/txe_node.d.ts +7 -6
- package/dest/node/txe_node.d.ts.map +1 -1
- package/dest/node/txe_node.js +15 -34
- package/dest/oracle/txe_oracle.d.ts +4 -4
- package/dest/oracle/txe_oracle.d.ts.map +1 -1
- package/dest/oracle/txe_oracle.js +12 -7
- package/dest/txe_service/txe_service.d.ts +10 -1
- package/dest/txe_service/txe_service.d.ts.map +1 -1
- package/dest/txe_service/txe_service.js +37 -7
- package/dest/util/encoding.d.ts +14 -3
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/encoding.js +27 -8
- package/dest/util/txe_public_contract_data_source.d.ts +1 -2
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +0 -10
- package/dest/util/{txe_world_state_db.d.ts → txe_public_dbs.d.ts} +4 -5
- package/dest/util/txe_public_dbs.d.ts.map +1 -0
- package/dest/util/{txe_world_state_db.js → txe_public_dbs.js} +4 -4
- package/package.json +12 -12
- package/src/node/txe_node.ts +31 -54
- package/src/oracle/txe_oracle.ts +42 -22
- package/src/txe_service/txe_service.ts +60 -6
- package/src/util/encoding.ts +33 -8
- package/src/util/txe_public_contract_data_source.ts +0 -8
- package/src/util/{txe_world_state_db.ts → txe_public_dbs.ts} +4 -5
- package/dest/util/txe_world_state_db.d.ts.map +0 -1
package/dest/node/txe_node.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ARCHIVE_HEIGHT, L1_TO_L2_MSG_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, NULLIFIER_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import type { L1ContractAddresses } from '@aztec/ethereum';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
5
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import { type InBlock, L2Block, type L2BlockNumber, type L2Tips } from '@aztec/stdlib/block';
|
|
6
|
+
import { type InBlock, L2Block, type L2BlockNumber, type L2Tips, type PublishedL2Block } from '@aztec/stdlib/block';
|
|
7
7
|
import type { ContractClassPublic, ContractInstanceWithAddress, NodeInfo, ProtocolContractAddresses } from '@aztec/stdlib/contract';
|
|
8
8
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
9
9
|
import type { AztecNode, GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
@@ -60,11 +60,11 @@ export declare class TXENode implements AztecNode {
|
|
|
60
60
|
*/
|
|
61
61
|
setNullifiersIndexesWithBlock(blockNumber: number, nullifiers: Fr[]): void;
|
|
62
62
|
/**
|
|
63
|
-
* Adds
|
|
64
|
-
* @param blockNumber - The block number at which to add the
|
|
65
|
-
* @param privateLogs - The privateLogs that contain the
|
|
63
|
+
* Adds private logs to the txe node, given a block
|
|
64
|
+
* @param blockNumber - The block number at which to add the private logs.
|
|
65
|
+
* @param privateLogs - The privateLogs that contain the private logs to be added.
|
|
66
66
|
*/
|
|
67
|
-
|
|
67
|
+
addPrivateLogsByTags(blockNumber: number, privateLogs: PrivateLog[]): void;
|
|
68
68
|
/**
|
|
69
69
|
* Adds public logs to the txe node, given a block
|
|
70
70
|
* @param blockNumber - The block number at which to add the public logs.
|
|
@@ -192,6 +192,7 @@ export declare class TXENode implements AztecNode {
|
|
|
192
192
|
* @returns The blocks requested.
|
|
193
193
|
*/
|
|
194
194
|
getBlocks(_from: number, _limit: number): Promise<L2Block[]>;
|
|
195
|
+
getPublishedBlocks(_from: number, _limit: number): Promise<PublishedL2Block[]>;
|
|
195
196
|
/**
|
|
196
197
|
* Method to fetch the version of the package.
|
|
197
198
|
* @returns The node package version
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_node.d.ts","sourceRoot":"","sources":["../../src/node/txe_node.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"txe_node.d.ts","sourceRoot":"","sources":["../../src/node/txe_node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,OAAO,EACZ,OAAO,EAEP,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,mBAAmB,EACnB,2BAA2B,EAC3B,QAAQ,EACR,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACtH,OAAO,KAAK,EAEV,yBAAyB,EACzB,YAAY,EACZ,eAAe,EACf,oBAAoB,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,EACL,YAAY,EACZ,KAAK,0BAA0B,EAE/B,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,KAAK,sBAAsB,EAC3B,KAAK,EAAE,EACP,KAAK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;IAInE;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC;IAIrF,mGAAmG;IACnG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAI5C;;;;OAIG;IACH,gBAAgB,CAAC,cAAc,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE;;;OAGG;IACH,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;IAItC;;;;;OAKG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAIpE;;;;;;OAMG;IACH,0BAA0B,CACxB,YAAY,EAAE,aAAa,EAC3B,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAIlC;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IAIhC;;OAEG;IACH,uBAAuB,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAGzD"}
|
package/dest/node/txe_node.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
1
|
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -82,7 +81,7 @@ export class TXENode {
|
|
|
82
81
|
const parsedBlockNumber = blockNumber === 'latest' ? await this.getBlockNumber() : blockNumber;
|
|
83
82
|
const nullifiersInBlock = [];
|
|
84
83
|
for (const [key, val] of this.#blockNumberToNullifiers.entries()){
|
|
85
|
-
if (key
|
|
84
|
+
if (key <= parsedBlockNumber) {
|
|
86
85
|
nullifiersInBlock.push(...val);
|
|
87
86
|
}
|
|
88
87
|
}
|
|
@@ -105,18 +104,18 @@ export class TXENode {
|
|
|
105
104
|
this.#blockNumberToNullifiers.set(blockNumber, nullifiers);
|
|
106
105
|
}
|
|
107
106
|
/**
|
|
108
|
-
* Adds
|
|
109
|
-
* @param blockNumber - The block number at which to add the
|
|
110
|
-
* @param privateLogs - The privateLogs that contain the
|
|
111
|
-
*/
|
|
107
|
+
* Adds private logs to the txe node, given a block
|
|
108
|
+
* @param blockNumber - The block number at which to add the private logs.
|
|
109
|
+
* @param privateLogs - The privateLogs that contain the private logs to be added.
|
|
110
|
+
*/ addPrivateLogsByTags(blockNumber, privateLogs) {
|
|
112
111
|
privateLogs.forEach((log)=>{
|
|
113
112
|
const tag = log.fields[0];
|
|
113
|
+
this.#logger.verbose(`Found private log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
|
|
114
114
|
const currentLogs = this.#logsByTags.get(tag.toString()) ?? [];
|
|
115
|
-
const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber,
|
|
115
|
+
const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber, log);
|
|
116
116
|
currentLogs.push(scopedLog);
|
|
117
117
|
this.#logsByTags.set(tag.toString(), currentLogs);
|
|
118
118
|
});
|
|
119
|
-
// TODO: DISTINGUISH BETWEEN EVENT LOGS AND NOTE LOGS ?
|
|
120
119
|
this.#noteIndex += privateLogs.length;
|
|
121
120
|
}
|
|
122
121
|
/**
|
|
@@ -125,31 +124,10 @@ export class TXENode {
|
|
|
125
124
|
* @param publicLogs - The public logs to be added.
|
|
126
125
|
*/ addPublicLogsByTags(blockNumber, publicLogs) {
|
|
127
126
|
publicLogs.forEach((log)=>{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// See macros/note/mod/ and see how finalization_log[0] is constructed, to understand this monstrosity. (It wasn't me).
|
|
131
|
-
// Search the codebase for "disgusting encoding" to see other hardcoded instances of this encoding, that you might need to change if you ever find yourself here.
|
|
132
|
-
if (!firstFieldBuf.subarray(0, 27).equals(Buffer.alloc(27)) || firstFieldBuf[29] !== 0) {
|
|
133
|
-
// See parseLogFromPublic - the first field of a tagged log is 5 bytes structured:
|
|
134
|
-
// [ publicLen[0], publicLen[1], 0, privateLen[0], privateLen[1]]
|
|
135
|
-
this.#logger.warn(`Skipping public log with invalid first field: ${log.log[0]}`);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
// Check that the length values line up with the log contents
|
|
139
|
-
const publicValuesLength = firstFieldBuf.subarray(-5).readUint16BE();
|
|
140
|
-
const privateValuesLength = firstFieldBuf.subarray(-5).readUint16BE(3);
|
|
141
|
-
// Add 1 for the first field holding lengths
|
|
142
|
-
const totalLogLength = 1 + publicValuesLength + privateValuesLength;
|
|
143
|
-
// Note that zeroes can be valid log values, so we can only assert that we do not go over the given length
|
|
144
|
-
if (totalLogLength > PUBLIC_LOG_DATA_SIZE_IN_FIELDS || log.log.slice(totalLogLength).find((f)=>!f.isZero())) {
|
|
145
|
-
this.#logger.warn(`Skipping invalid tagged public log with first field: ${log.log[0]}`);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
// The first elt stores lengths => tag is in fields[1]
|
|
149
|
-
const tag = log.log[1];
|
|
150
|
-
this.#logger.verbose(`Found tagged public log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
|
|
127
|
+
const tag = log.log[0];
|
|
128
|
+
this.#logger.verbose(`Found public log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
|
|
151
129
|
const currentLogs = this.#logsByTags.get(tag.toString()) ?? [];
|
|
152
|
-
const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber,
|
|
130
|
+
const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber, log);
|
|
153
131
|
currentLogs.push(scopedLog);
|
|
154
132
|
this.#logsByTags.set(tag.toString(), currentLogs);
|
|
155
133
|
});
|
|
@@ -160,8 +138,8 @@ export class TXENode {
|
|
|
160
138
|
* @returns For each received tag, an array of matching logs and metadata (e.g. tx hash) is returned. An empty
|
|
161
139
|
array implies no logs match that tag.
|
|
162
140
|
*/ getLogsByTags(tags) {
|
|
163
|
-
const
|
|
164
|
-
return Promise.resolve(
|
|
141
|
+
const logs = tags.map((tag)=>this.#logsByTags.get(tag.toString()) ?? []);
|
|
142
|
+
return Promise.resolve(logs);
|
|
165
143
|
}
|
|
166
144
|
/**
|
|
167
145
|
* Returns the tips of the L2 chain.
|
|
@@ -298,6 +276,9 @@ export class TXENode {
|
|
|
298
276
|
*/ getBlocks(_from, _limit) {
|
|
299
277
|
throw new Error('TXE Node method getBlocks not implemented');
|
|
300
278
|
}
|
|
279
|
+
getPublishedBlocks(_from, _limit) {
|
|
280
|
+
throw new Error('TXE Node method getPublishedBlocks not implemented');
|
|
281
|
+
}
|
|
301
282
|
/**
|
|
302
283
|
* Method to fetch the version of the package.
|
|
303
284
|
* @returns The node package version
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { type L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
4
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import { Fr, Point } from '@aztec/foundation/fields';
|
|
5
5
|
import { type Logger } from '@aztec/foundation/log';
|
|
6
6
|
import { KeyStore } from '@aztec/key-store';
|
|
7
7
|
import type { AztecAsyncKVStore } from '@aztec/kv-store';
|
|
@@ -15,8 +15,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
15
15
|
import type { ContractInstance, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
16
16
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
17
17
|
import { type KeyValidationRequest, PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
18
|
-
import { ContractClassLog, LogWithTxData } from '@aztec/stdlib/logs';
|
|
19
|
-
import { IndexedTaggingSecret, type PrivateLog, type PublicLog } from '@aztec/stdlib/logs';
|
|
18
|
+
import { ContractClassLog, IndexedTaggingSecret, LogWithTxData, type PrivateLog, type PublicLog } from '@aztec/stdlib/logs';
|
|
20
19
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
21
20
|
import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
|
|
22
21
|
import { BlockHeader } from '@aztec/stdlib/tx';
|
|
@@ -133,7 +132,7 @@ export declare class TXE implements TypedOracle {
|
|
|
133
132
|
incrementAppTaggingSecretIndexAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<void>;
|
|
134
133
|
getIndexedTaggingSecretAsSender(sender: AztecAddress, recipient: AztecAddress): Promise<IndexedTaggingSecret>;
|
|
135
134
|
syncNotes(): Promise<void>;
|
|
136
|
-
deliverNote(
|
|
135
|
+
deliverNote(contractAddress: AztecAddress, storageSlot: Fr, nonce: Fr, content: Fr[], noteHash: Fr, nullifier: Fr, txHash: Fr, recipient: AztecAddress): Promise<void>;
|
|
137
136
|
getLogByTag(tag: Fr): Promise<LogWithTxData | null>;
|
|
138
137
|
avmOpcodeCall(targetContractAddress: AztecAddress, args: Fr[], isStaticCall: boolean): Promise<PublicTxResult>;
|
|
139
138
|
avmOpcodeSuccessCopy(): boolean;
|
|
@@ -148,5 +147,6 @@ export declare class TXE implements TypedOracle {
|
|
|
148
147
|
deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void>;
|
|
149
148
|
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void>;
|
|
150
149
|
aes128Decrypt(ciphertext: Buffer, iv: Buffer, symKey: Buffer): Promise<Buffer>;
|
|
150
|
+
getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point>;
|
|
151
151
|
}
|
|
152
152
|
//# sourceMappingURL=txe_oracle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_oracle.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_oracle.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,KAAK,wBAAwB,EAS9B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"txe_oracle.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_oracle.ts"],"names":[],"mappings":";;AACA,OAAO,EACL,KAAK,wBAAwB,EAS9B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,KAAK,MAAM,EAAyB,MAAM,uBAAuB,CAAC;AAE3E,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACL,mBAAmB,EAGnB,oBAAoB,EAMrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,QAAQ,EAEb,KAAK,WAAW,EAOjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAGL,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,gBAAgB,EAChB,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAA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I,CAAC;IAQvG,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK9E,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;CAGrE"}
|
|
@@ -9,7 +9,7 @@ import { KeyStore } from '@aztec/key-store';
|
|
|
9
9
|
import { AddressDataProvider, AuthWitnessDataProvider, CapsuleDataProvider, ContractDataProvider, NoteDataProvider, PXEOracleInterface, SyncDataProvider, TaggingDataProvider, enrichPublicSimulationError } from '@aztec/pxe/server';
|
|
10
10
|
import { ExecutionNoteCache, HashedValuesCache, Oracle, WASMSimulator, extractCallStack, extractPrivateCircuitPublicInputs, pickNotes, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
|
|
11
11
|
import { createTxForPublicCalls } from '@aztec/simulator/public/fixtures';
|
|
12
|
-
import { ExecutionError, PublicTxSimulator, createSimulationError, resolveAssertionMessageFromError } from '@aztec/simulator/server';
|
|
12
|
+
import { ExecutionError, PublicContractsDB, PublicTxSimulator, createSimulationError, resolveAssertionMessageFromError } from '@aztec/simulator/server';
|
|
13
13
|
import { FunctionSelector, countArgumentsSize } from '@aztec/stdlib/abi';
|
|
14
14
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
15
15
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
@@ -26,7 +26,7 @@ import { ForkCheckpoint, NativeWorldStateService } from '@aztec/world-state/nati
|
|
|
26
26
|
import { TXENode } from '../node/txe_node.js';
|
|
27
27
|
import { TXEAccountDataProvider } from '../util/txe_account_data_provider.js';
|
|
28
28
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
29
|
-
import {
|
|
29
|
+
import { TXEPublicTreesDB } from '../util/txe_public_dbs.js';
|
|
30
30
|
export class TXE {
|
|
31
31
|
logger;
|
|
32
32
|
keyStore;
|
|
@@ -509,7 +509,7 @@ export class TXE {
|
|
|
509
509
|
}
|
|
510
510
|
await this.node.setTxEffect(blockNumber, new TxHash(new Fr(blockNumber)), txEffect);
|
|
511
511
|
this.node.setNullifiersIndexesWithBlock(blockNumber, txEffect.nullifiers);
|
|
512
|
-
this.node.
|
|
512
|
+
this.node.addPrivateLogsByTags(this.blockNumber, this.privateLogs);
|
|
513
513
|
this.node.addPublicLogsByTags(this.blockNumber, this.publicLogs);
|
|
514
514
|
const stateReference = await fork.getStateReference();
|
|
515
515
|
const archiveInfo = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
@@ -635,7 +635,9 @@ export class TXE {
|
|
|
635
635
|
// See note at revert below.
|
|
636
636
|
const checkpoint = await ForkCheckpoint.new(db);
|
|
637
637
|
try {
|
|
638
|
-
const
|
|
638
|
+
const treesDB = new TXEPublicTreesDB(db, this);
|
|
639
|
+
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(this));
|
|
640
|
+
const simulator = new PublicTxSimulator(treesDB, contractsDB, globalVariables, /*doMerkleOperations=*/ true);
|
|
639
641
|
const { usedTxRequestHashForNonces } = this.noteCache.finish();
|
|
640
642
|
const firstNullifier = usedTxRequestHashForNonces ? this.getTxRequestHash() : this.noteCache.getAllNullifiers()[0];
|
|
641
643
|
// When setting up a teardown call, we tell it that
|
|
@@ -719,13 +721,13 @@ export class TXE {
|
|
|
719
721
|
async syncNotes() {
|
|
720
722
|
const taggedLogsByRecipient = await this.pxeOracleInterface.syncTaggedLogs(this.contractAddress, await this.getBlockNumber(), undefined);
|
|
721
723
|
for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()){
|
|
722
|
-
await this.pxeOracleInterface.processTaggedLogs(taggedLogs, AztecAddress.fromString(recipient));
|
|
724
|
+
await this.pxeOracleInterface.processTaggedLogs(this.contractAddress, taggedLogs, AztecAddress.fromString(recipient));
|
|
723
725
|
}
|
|
724
726
|
await this.pxeOracleInterface.removeNullifiedNotes(this.contractAddress);
|
|
725
727
|
return Promise.resolve();
|
|
726
728
|
}
|
|
727
|
-
deliverNote(
|
|
728
|
-
|
|
729
|
+
async deliverNote(contractAddress, storageSlot, nonce, content, noteHash, nullifier, txHash, recipient) {
|
|
730
|
+
await this.pxeOracleInterface.deliverNote(contractAddress, storageSlot, nonce, content, noteHash, nullifier, txHash, recipient);
|
|
729
731
|
}
|
|
730
732
|
async getLogByTag(tag) {
|
|
731
733
|
return await this.pxeOracleInterface.getLogByTag(tag);
|
|
@@ -831,4 +833,7 @@ export class TXE {
|
|
|
831
833
|
const aes128 = new Aes128();
|
|
832
834
|
return aes128.decryptBufferCBC(ciphertext, iv, symKey);
|
|
833
835
|
}
|
|
836
|
+
getSharedSecret(address, ephPk) {
|
|
837
|
+
return this.pxeOracleInterface.getSharedSecret(address, ephPk);
|
|
838
|
+
}
|
|
834
839
|
}
|
|
@@ -133,6 +133,12 @@ export declare class TXEService {
|
|
|
133
133
|
syncNotes(): Promise<{
|
|
134
134
|
values: (string | ForeignCallArray)[];
|
|
135
135
|
}>;
|
|
136
|
+
deliverNote(contractAddress: ForeignCallSingle, storageSlot: ForeignCallSingle, nonce: ForeignCallSingle, content: ForeignCallArray, contentLength: ForeignCallSingle, noteHash: ForeignCallSingle, nullifier: ForeignCallSingle, txHash: ForeignCallSingle, recipient: ForeignCallSingle): Promise<{
|
|
137
|
+
values: (string | ForeignCallArray)[];
|
|
138
|
+
}>;
|
|
139
|
+
getLogByTag(tag: ForeignCallSingle): Promise<{
|
|
140
|
+
values: (string | ForeignCallArray)[];
|
|
141
|
+
}>;
|
|
136
142
|
storeCapsule(contractAddress: ForeignCallSingle, slot: ForeignCallSingle, capsule: ForeignCallArray): Promise<{
|
|
137
143
|
values: (string | ForeignCallArray)[];
|
|
138
144
|
}>;
|
|
@@ -145,7 +151,10 @@ export declare class TXEService {
|
|
|
145
151
|
copyCapsule(contractAddress: ForeignCallSingle, srcSlot: ForeignCallSingle, dstSlot: ForeignCallSingle, numEntries: ForeignCallSingle): Promise<{
|
|
146
152
|
values: (string | ForeignCallArray)[];
|
|
147
153
|
}>;
|
|
148
|
-
aes128Decrypt(
|
|
154
|
+
aes128Decrypt(ciphertextBVecStorage: ForeignCallArray, ciphertextLength: ForeignCallSingle, iv: ForeignCallArray, symKey: ForeignCallArray): Promise<{
|
|
155
|
+
values: (string | ForeignCallArray)[];
|
|
156
|
+
}>;
|
|
157
|
+
getSharedSecret(address: ForeignCallSingle, ephPk: ForeignCallArray): Promise<{
|
|
149
158
|
values: (string | ForeignCallArray)[];
|
|
150
159
|
}>;
|
|
151
160
|
avmOpcodeEmitUnencryptedLog(_message: ForeignCallArray): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_service.d.ts","sourceRoot":"","sources":["../../src/txe_service/txe_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,2BAA2B,
|
|
1
|
+
{"version":3,"file":"txe_service.d.ts","sourceRoot":"","sources":["../../src/txe_service/txe_service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,2BAA2B,EAAa,MAAM,iBAAiB,CAAC;AAE9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,KAAK,gBAAgB,EAAkC,MAAM,mBAAmB,CAAC;AAU1F,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EAYvB,MAAM,qBAAqB,CAAC;AAG7B,qBAAa,UAAU;IACT,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,WAAW;gBAAnC,MAAM,EAAE,MAAM,EAAU,WAAW,EAAE,WAAW;WAEvD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;IAWjE,uBAAuB,CAAC,WAAW,EA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ACvB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,gBAAgB;;;IAyBxB,oBAAoB;;;CAIrB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/aztec.js';
|
|
1
|
+
import { Fr, Point } from '@aztec/aztec.js';
|
|
2
2
|
import { DEPLOYER_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
3
3
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
4
4
|
import { enrichPublicSimulationError } from '@aztec/pxe/server';
|
|
@@ -8,9 +8,10 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
8
8
|
import { computePartialAddress } from '@aztec/stdlib/contract';
|
|
9
9
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
10
10
|
import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/stdlib/hash';
|
|
11
|
+
import { LogWithTxData } from '@aztec/stdlib/logs';
|
|
11
12
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
12
13
|
import { TXE } from '../oracle/txe_oracle.js';
|
|
13
|
-
import { addressFromSingle, arrayToBoundedVec, bufferToU8Array, fromArray, fromSingle, fromUintArray, toArray, toForeignCallResult, toSingle } from '../util/encoding.js';
|
|
14
|
+
import { addressFromSingle, arrayToBoundedVec, bufferToU8Array, fromArray, fromSingle, fromUintArray, fromUintBoundedVec, toArray, toForeignCallResult, toSingle, toSingleOrArray } from '../util/encoding.js';
|
|
14
15
|
import { ExpectedFailureError } from '../util/expected_failure_error.js';
|
|
15
16
|
export class TXEService {
|
|
16
17
|
logger;
|
|
@@ -394,6 +395,26 @@ export class TXEService {
|
|
|
394
395
|
await this.typedOracle.syncNotes();
|
|
395
396
|
return toForeignCallResult([]);
|
|
396
397
|
}
|
|
398
|
+
async deliverNote(contractAddress, storageSlot, nonce, content, contentLength, noteHash, nullifier, txHash, recipient) {
|
|
399
|
+
await this.typedOracle.deliverNote(AztecAddress.fromField(fromSingle(contractAddress)), fromSingle(storageSlot), fromSingle(nonce), fromArray(content.slice(0, Number(BigInt(contentLength)))), fromSingle(noteHash), fromSingle(nullifier), fromSingle(txHash), AztecAddress.fromField(fromSingle(recipient)));
|
|
400
|
+
return toForeignCallResult([
|
|
401
|
+
toSingle(Fr.ONE)
|
|
402
|
+
]);
|
|
403
|
+
}
|
|
404
|
+
async getLogByTag(tag) {
|
|
405
|
+
const log = await this.typedOracle.getLogByTag(fromSingle(tag));
|
|
406
|
+
if (log == null) {
|
|
407
|
+
return toForeignCallResult([
|
|
408
|
+
toSingle(Fr.ZERO),
|
|
409
|
+
...LogWithTxData.noirSerializationOfEmpty().map(toSingleOrArray)
|
|
410
|
+
]);
|
|
411
|
+
} else {
|
|
412
|
+
return toForeignCallResult([
|
|
413
|
+
toSingle(Fr.ONE),
|
|
414
|
+
...log.toNoirSerialization().map(toSingleOrArray)
|
|
415
|
+
]);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
397
418
|
async storeCapsule(contractAddress, slot, capsule) {
|
|
398
419
|
await this.typedOracle.storeCapsule(AztecAddress.fromField(fromSingle(contractAddress)), fromSingle(slot), fromArray(capsule));
|
|
399
420
|
return toForeignCallResult([]);
|
|
@@ -424,13 +445,22 @@ export class TXEService {
|
|
|
424
445
|
await this.typedOracle.copyCapsule(AztecAddress.fromField(fromSingle(contractAddress)), fromSingle(srcSlot), fromSingle(dstSlot), fromSingle(numEntries).toNumber());
|
|
425
446
|
return toForeignCallResult([]);
|
|
426
447
|
}
|
|
427
|
-
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
428
|
-
|
|
429
|
-
|
|
448
|
+
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
449
|
+
// The compiler didn't throw an error, so it took me a while to learn of the existence of this file, and that I need
|
|
450
|
+
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
451
|
+
// existence of a txe_oracle method?
|
|
452
|
+
async aes128Decrypt(ciphertextBVecStorage, ciphertextLength, iv, symKey) {
|
|
453
|
+
const ciphertext = fromUintBoundedVec(ciphertextBVecStorage, ciphertextLength, 8);
|
|
430
454
|
const ivBuffer = fromUintArray(iv, 8);
|
|
431
455
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
432
|
-
const plaintextBuffer = await this.typedOracle.aes128Decrypt(
|
|
433
|
-
return toForeignCallResult(arrayToBoundedVec(bufferToU8Array(plaintextBuffer),
|
|
456
|
+
const plaintextBuffer = await this.typedOracle.aes128Decrypt(ciphertext, ivBuffer, symKeyBuffer);
|
|
457
|
+
return toForeignCallResult(arrayToBoundedVec(bufferToU8Array(plaintextBuffer), ciphertextBVecStorage.length));
|
|
458
|
+
}
|
|
459
|
+
async getSharedSecret(address, ephPk) {
|
|
460
|
+
const secret = await this.typedOracle.getSharedSecret(AztecAddress.fromField(fromSingle(address)), Point.fromFields(fromArray(ephPk)));
|
|
461
|
+
return toForeignCallResult([
|
|
462
|
+
toArray(secret.toFields())
|
|
463
|
+
]);
|
|
434
464
|
}
|
|
435
465
|
// AVM opcodes
|
|
436
466
|
avmOpcodeEmitUnencryptedLog(_message) {
|
package/dest/util/encoding.d.ts
CHANGED
|
@@ -17,21 +17,32 @@ export declare function fromArray(obj: ForeignCallArray): Fr[];
|
|
|
17
17
|
/**
|
|
18
18
|
* Converts an array of Noir unsigned integers to a single tightly-packed buffer.
|
|
19
19
|
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
20
|
-
* @returns
|
|
20
|
+
* @returns A buffer where each byte is correctly represented as a single byte in the buffer.
|
|
21
21
|
*/
|
|
22
22
|
export declare function fromUintArray(obj: ForeignCallArray, uintBitSize: number): Buffer;
|
|
23
|
+
/**
|
|
24
|
+
* Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
|
|
25
|
+
* translated as two separate ForeignCallArray and ForeignCallSingle values (an array and a single field).
|
|
26
|
+
*
|
|
27
|
+
* @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
|
|
28
|
+
* @param length The length of the BoundedVec (i.e. BoundedVec::len())
|
|
29
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
30
|
+
* @returns A buffer containing the unsigned integers tightly packed
|
|
31
|
+
*/
|
|
32
|
+
export declare function fromUintBoundedVec(storage: ForeignCallArray, length: ForeignCallSingle, uintBitSize: number): Buffer;
|
|
23
33
|
export declare function toSingle(obj: Fr | AztecAddress): ForeignCallSingle;
|
|
24
34
|
export declare function toArray(objs: Fr[]): ForeignCallArray;
|
|
35
|
+
export declare function toSingleOrArray(value: Fr | Fr[]): string | string[];
|
|
25
36
|
export declare function bufferToU8Array(buffer: Buffer): ForeignCallArray;
|
|
26
37
|
/**
|
|
27
38
|
* Converts a ForeignCallArray into a tuple which represents a nr BoundedVec.
|
|
28
39
|
* If the input array is shorter than the maxLen, it pads the result with zeros,
|
|
29
40
|
* so that nr can correctly coerce this result into a BoundedVec.
|
|
30
|
-
* @param array
|
|
41
|
+
* @param bVecStorage - The array underlying the BoundedVec.
|
|
31
42
|
* @param maxLen - the max length of the BoundedVec.
|
|
32
43
|
* @returns a tuple representing a BoundedVec.
|
|
33
44
|
*/
|
|
34
|
-
export declare function arrayToBoundedVec(
|
|
45
|
+
export declare function arrayToBoundedVec(bVecStorage: ForeignCallArray, maxLen: number): [ForeignCallArray, ForeignCallSingle];
|
|
35
46
|
export declare function toForeignCallResult(obj: (ForeignCallSingle | ForeignCallArray)[]): {
|
|
36
47
|
values: (string | ForeignCallArray)[];
|
|
37
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/util/encoding.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,mBAAmB,CAA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EAAE,iBAAiB,CAAC,CAYvC;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,EAAE;;EAEhF;AAED,eAAO,MAAM,uBAAuB,aAAa,CAAC;AAElD,eAAO,MAAM,sBAAsB,iCAAsB,CAAC;AAE1D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEjC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC"}
|
package/dest/util/encoding.js
CHANGED
|
@@ -16,7 +16,7 @@ export function fromArray(obj) {
|
|
|
16
16
|
/**
|
|
17
17
|
* Converts an array of Noir unsigned integers to a single tightly-packed buffer.
|
|
18
18
|
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
19
|
-
* @returns
|
|
19
|
+
* @returns A buffer where each byte is correctly represented as a single byte in the buffer.
|
|
20
20
|
*/ export function fromUintArray(obj, uintBitSize) {
|
|
21
21
|
if (uintBitSize % 8 !== 0) {
|
|
22
22
|
throw new Error(`u${uintBitSize} is not a supported type in Noir`);
|
|
@@ -24,12 +24,31 @@ export function fromArray(obj) {
|
|
|
24
24
|
const uintByteSize = uintBitSize / 8;
|
|
25
25
|
return Buffer.concat(obj.map((str)=>hexToBuffer(str).slice(-uintByteSize)));
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
|
|
29
|
+
* translated as two separate ForeignCallArray and ForeignCallSingle values (an array and a single field).
|
|
30
|
+
*
|
|
31
|
+
* @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
|
|
32
|
+
* @param length The length of the BoundedVec (i.e. BoundedVec::len())
|
|
33
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
34
|
+
* @returns A buffer containing the unsigned integers tightly packed
|
|
35
|
+
*/ export function fromUintBoundedVec(storage, length, uintBitSize) {
|
|
36
|
+
if (uintBitSize % 8 !== 0) {
|
|
37
|
+
throw new Error(`u${uintBitSize} is not a supported type in Noir`);
|
|
38
|
+
}
|
|
39
|
+
const uintByteSize = uintBitSize / 8;
|
|
40
|
+
const boundedStorage = storage.slice(0, fromSingle(length).toNumber());
|
|
41
|
+
return Buffer.concat(boundedStorage.map((str)=>hexToBuffer(str).slice(-uintByteSize)));
|
|
42
|
+
}
|
|
27
43
|
export function toSingle(obj) {
|
|
28
44
|
return obj.toString().slice(2);
|
|
29
45
|
}
|
|
30
46
|
export function toArray(objs) {
|
|
31
47
|
return objs.map((obj)=>obj.toString());
|
|
32
48
|
}
|
|
49
|
+
export function toSingleOrArray(value) {
|
|
50
|
+
return Array.isArray(value) ? value.map(toSingle) : toSingle(value);
|
|
51
|
+
}
|
|
33
52
|
export function bufferToU8Array(buffer) {
|
|
34
53
|
return toArray(Array.from(buffer).map((byte)=>new Fr(byte)));
|
|
35
54
|
}
|
|
@@ -37,19 +56,19 @@ export function bufferToU8Array(buffer) {
|
|
|
37
56
|
* Converts a ForeignCallArray into a tuple which represents a nr BoundedVec.
|
|
38
57
|
* If the input array is shorter than the maxLen, it pads the result with zeros,
|
|
39
58
|
* so that nr can correctly coerce this result into a BoundedVec.
|
|
40
|
-
* @param array
|
|
59
|
+
* @param bVecStorage - The array underlying the BoundedVec.
|
|
41
60
|
* @param maxLen - the max length of the BoundedVec.
|
|
42
61
|
* @returns a tuple representing a BoundedVec.
|
|
43
|
-
*/ export function arrayToBoundedVec(
|
|
44
|
-
if (
|
|
45
|
-
throw new Error(`Array of length ${
|
|
62
|
+
*/ export function arrayToBoundedVec(bVecStorage, maxLen) {
|
|
63
|
+
if (bVecStorage.length > maxLen) {
|
|
64
|
+
throw new Error(`Array of length ${bVecStorage.length} larger than maxLen ${maxLen}`);
|
|
46
65
|
}
|
|
47
|
-
const lengthDiff = maxLen -
|
|
66
|
+
const lengthDiff = maxLen - bVecStorage.length;
|
|
48
67
|
// We pad the array to the maxLen of the BoundedVec.
|
|
49
68
|
const zeroPaddingArray = toArray(Array(lengthDiff).fill(new Fr(0)));
|
|
50
69
|
// These variable names match with the BoundedVec members in nr:
|
|
51
|
-
const storage =
|
|
52
|
-
const len = toSingle(new Fr(
|
|
70
|
+
const storage = bVecStorage.concat(zeroPaddingArray);
|
|
71
|
+
const len = toSingle(new Fr(bVecStorage.length));
|
|
53
72
|
return [
|
|
54
73
|
storage,
|
|
55
74
|
len
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress
|
|
4
|
+
import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
import type { TXE } from '../oracle/txe_oracle.js';
|
|
6
6
|
export declare class TXEPublicContractDataSource implements ContractDataSource {
|
|
7
7
|
private txeOracle;
|
|
8
8
|
constructor(txeOracle: TXE);
|
|
9
|
-
getPublicFunction(address: AztecAddress, selector: FunctionSelector): Promise<PublicFunction | undefined>;
|
|
10
9
|
getBlockNumber(): Promise<number>;
|
|
11
10
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
12
11
|
getBytecodeCommitment(id: Fr): Promise<Fr | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_public_contract_data_source.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_contract_data_source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC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;IAK1F,gBAAgB,CAAC,cAAc,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CAIrE"}
|
|
@@ -8,16 +8,6 @@ export class TXEPublicContractDataSource {
|
|
|
8
8
|
constructor(txeOracle){
|
|
9
9
|
this.txeOracle = txeOracle;
|
|
10
10
|
}
|
|
11
|
-
async getPublicFunction(address, selector) {
|
|
12
|
-
const bytecode = await this.txeOracle.getContractDataProvider().getBytecode(address, selector);
|
|
13
|
-
if (!bytecode) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
bytecode,
|
|
18
|
-
selector
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
11
|
getBlockNumber() {
|
|
22
12
|
return this.txeOracle.getBlockNumber();
|
|
23
13
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import {
|
|
2
|
+
import { PublicTreesDB } from '@aztec/simulator/server';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
5
4
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
6
5
|
import type { TXE } from '../oracle/txe_oracle.js';
|
|
7
|
-
export declare class
|
|
6
|
+
export declare class TXEPublicTreesDB extends PublicTreesDB {
|
|
8
7
|
private merkleDb;
|
|
9
8
|
private txe;
|
|
10
|
-
constructor(merkleDb: MerkleTreeWriteOperations,
|
|
9
|
+
constructor(merkleDb: MerkleTreeWriteOperations, txe: TXE);
|
|
11
10
|
storageRead(contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
12
11
|
storageWrite(contract: AztecAddress, slot: Fr, newValue: Fr): Promise<void>;
|
|
13
12
|
}
|
|
14
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=txe_public_dbs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txe_public_dbs.d.ts","sourceRoot":"","sources":["../../src/util/txe_public_dbs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAEnD,qBAAa,gBAAiB,SAAQ,aAAa;IACrC,OAAO,CAAC,QAAQ;IAA6B,OAAO,CAAC,GAAG;gBAAhD,QAAQ,EAAE,yBAAyB,EAAU,GAAG,EAAE,GAAG;IAI1D,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;IAgB1D,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAK3F"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import {
|
|
2
|
+
import { PublicTreesDB } from '@aztec/simulator/server';
|
|
3
3
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
4
4
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
5
5
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
6
|
-
export class
|
|
6
|
+
export class TXEPublicTreesDB extends PublicTreesDB {
|
|
7
7
|
merkleDb;
|
|
8
8
|
txe;
|
|
9
|
-
constructor(merkleDb,
|
|
10
|
-
super(merkleDb
|
|
9
|
+
constructor(merkleDb, txe){
|
|
10
|
+
super(merkleDb), this.merkleDb = merkleDb, this.txe = txe;
|
|
11
11
|
}
|
|
12
12
|
async storageRead(contract, slot) {
|
|
13
13
|
const leafSlot = (await computePublicDataTreeLeafSlot(contract, slot)).toBigInt();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/txe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": "./dest/index.js",
|
|
6
6
|
"bin": "./dest/bin/index.js",
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aztec/accounts": "0.
|
|
63
|
-
"@aztec/aztec.js": "0.
|
|
64
|
-
"@aztec/constants": "0.
|
|
65
|
-
"@aztec/foundation": "0.
|
|
66
|
-
"@aztec/key-store": "0.
|
|
67
|
-
"@aztec/kv-store": "0.
|
|
68
|
-
"@aztec/protocol-contracts": "0.
|
|
69
|
-
"@aztec/pxe": "0.
|
|
70
|
-
"@aztec/simulator": "0.
|
|
71
|
-
"@aztec/stdlib": "0.
|
|
72
|
-
"@aztec/world-state": "0.
|
|
62
|
+
"@aztec/accounts": "0.81.0",
|
|
63
|
+
"@aztec/aztec.js": "0.81.0",
|
|
64
|
+
"@aztec/constants": "0.81.0",
|
|
65
|
+
"@aztec/foundation": "0.81.0",
|
|
66
|
+
"@aztec/key-store": "0.81.0",
|
|
67
|
+
"@aztec/kv-store": "0.81.0",
|
|
68
|
+
"@aztec/protocol-contracts": "0.81.0",
|
|
69
|
+
"@aztec/pxe": "0.81.0",
|
|
70
|
+
"@aztec/simulator": "0.81.0",
|
|
71
|
+
"@aztec/stdlib": "0.81.0",
|
|
72
|
+
"@aztec/world-state": "0.81.0",
|
|
73
73
|
"zod": "^3.23.8"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
package/src/node/txe_node.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
PUBLIC_LOG_DATA_SIZE_IN_FIELDS,
|
|
1
|
+
import type {
|
|
2
|
+
ARCHIVE_HEIGHT,
|
|
3
|
+
L1_TO_L2_MSG_TREE_HEIGHT,
|
|
4
|
+
NOTE_HASH_TREE_HEIGHT,
|
|
5
|
+
NULLIFIER_TREE_HEIGHT,
|
|
6
|
+
PUBLIC_DATA_TREE_HEIGHT,
|
|
8
7
|
} from '@aztec/constants';
|
|
9
8
|
import type { L1ContractAddresses } from '@aztec/ethereum';
|
|
10
9
|
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
@@ -12,7 +11,14 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
12
11
|
import { createLogger } from '@aztec/foundation/log';
|
|
13
12
|
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
14
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
type InBlock,
|
|
16
|
+
L2Block,
|
|
17
|
+
L2BlockHash,
|
|
18
|
+
type L2BlockNumber,
|
|
19
|
+
type L2Tips,
|
|
20
|
+
type PublishedL2Block,
|
|
21
|
+
} from '@aztec/stdlib/block';
|
|
16
22
|
import type {
|
|
17
23
|
ContractClassPublic,
|
|
18
24
|
ContractInstanceWithAddress,
|
|
@@ -139,7 +145,7 @@ export class TXENode implements AztecNode {
|
|
|
139
145
|
|
|
140
146
|
const nullifiersInBlock: Fr[] = [];
|
|
141
147
|
for (const [key, val] of this.#blockNumberToNullifiers.entries()) {
|
|
142
|
-
if (key
|
|
148
|
+
if (key <= parsedBlockNumber) {
|
|
143
149
|
nullifiersInBlock.push(...val);
|
|
144
150
|
}
|
|
145
151
|
}
|
|
@@ -170,26 +176,21 @@ export class TXENode implements AztecNode {
|
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
/**
|
|
173
|
-
* Adds
|
|
174
|
-
* @param blockNumber - The block number at which to add the
|
|
175
|
-
* @param privateLogs - The privateLogs that contain the
|
|
179
|
+
* Adds private logs to the txe node, given a block
|
|
180
|
+
* @param blockNumber - The block number at which to add the private logs.
|
|
181
|
+
* @param privateLogs - The privateLogs that contain the private logs to be added.
|
|
176
182
|
*/
|
|
177
|
-
|
|
183
|
+
addPrivateLogsByTags(blockNumber: number, privateLogs: PrivateLog[]) {
|
|
178
184
|
privateLogs.forEach(log => {
|
|
179
185
|
const tag = log.fields[0];
|
|
186
|
+
this.#logger.verbose(`Found private log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
|
|
187
|
+
|
|
180
188
|
const currentLogs = this.#logsByTags.get(tag.toString()) ?? [];
|
|
181
|
-
const scopedLog = new TxScopedL2Log(
|
|
182
|
-
new TxHash(new Fr(blockNumber)),
|
|
183
|
-
this.#noteIndex,
|
|
184
|
-
blockNumber,
|
|
185
|
-
false,
|
|
186
|
-
log.toBuffer(),
|
|
187
|
-
);
|
|
189
|
+
const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber, log);
|
|
188
190
|
currentLogs.push(scopedLog);
|
|
189
191
|
this.#logsByTags.set(tag.toString(), currentLogs);
|
|
190
192
|
});
|
|
191
193
|
|
|
192
|
-
// TODO: DISTINGUISH BETWEEN EVENT LOGS AND NOTE LOGS ?
|
|
193
194
|
this.#noteIndex += privateLogs.length;
|
|
194
195
|
}
|
|
195
196
|
|
|
@@ -200,39 +201,11 @@ export class TXENode implements AztecNode {
|
|
|
200
201
|
*/
|
|
201
202
|
addPublicLogsByTags(blockNumber: number, publicLogs: PublicLog[]) {
|
|
202
203
|
publicLogs.forEach(log => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// See macros/note/mod/ and see how finalization_log[0] is constructed, to understand this monstrosity. (It wasn't me).
|
|
206
|
-
// Search the codebase for "disgusting encoding" to see other hardcoded instances of this encoding, that you might need to change if you ever find yourself here.
|
|
207
|
-
if (!firstFieldBuf.subarray(0, 27).equals(Buffer.alloc(27)) || firstFieldBuf[29] !== 0) {
|
|
208
|
-
// See parseLogFromPublic - the first field of a tagged log is 5 bytes structured:
|
|
209
|
-
// [ publicLen[0], publicLen[1], 0, privateLen[0], privateLen[1]]
|
|
210
|
-
this.#logger.warn(`Skipping public log with invalid first field: ${log.log[0]}`);
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
// Check that the length values line up with the log contents
|
|
214
|
-
const publicValuesLength = firstFieldBuf.subarray(-5).readUint16BE();
|
|
215
|
-
const privateValuesLength = firstFieldBuf.subarray(-5).readUint16BE(3);
|
|
216
|
-
// Add 1 for the first field holding lengths
|
|
217
|
-
const totalLogLength = 1 + publicValuesLength + privateValuesLength;
|
|
218
|
-
// Note that zeroes can be valid log values, so we can only assert that we do not go over the given length
|
|
219
|
-
if (totalLogLength > PUBLIC_LOG_DATA_SIZE_IN_FIELDS || log.log.slice(totalLogLength).find(f => !f.isZero())) {
|
|
220
|
-
this.#logger.warn(`Skipping invalid tagged public log with first field: ${log.log[0]}`);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
// The first elt stores lengths => tag is in fields[1]
|
|
224
|
-
const tag = log.log[1];
|
|
225
|
-
|
|
226
|
-
this.#logger.verbose(`Found tagged public log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
|
|
204
|
+
const tag = log.log[0];
|
|
205
|
+
this.#logger.verbose(`Found public log with tag ${tag.toString()} in block ${this.getBlockNumber()}`);
|
|
227
206
|
|
|
228
207
|
const currentLogs = this.#logsByTags.get(tag.toString()) ?? [];
|
|
229
|
-
const scopedLog = new TxScopedL2Log(
|
|
230
|
-
new TxHash(new Fr(blockNumber)),
|
|
231
|
-
this.#noteIndex,
|
|
232
|
-
blockNumber,
|
|
233
|
-
true,
|
|
234
|
-
log.toBuffer(),
|
|
235
|
-
);
|
|
208
|
+
const scopedLog = new TxScopedL2Log(new TxHash(new Fr(blockNumber)), this.#noteIndex, blockNumber, log);
|
|
236
209
|
|
|
237
210
|
currentLogs.push(scopedLog);
|
|
238
211
|
this.#logsByTags.set(tag.toString(), currentLogs);
|
|
@@ -245,9 +218,9 @@ export class TXENode implements AztecNode {
|
|
|
245
218
|
array implies no logs match that tag.
|
|
246
219
|
*/
|
|
247
220
|
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
|
|
248
|
-
const
|
|
221
|
+
const logs = tags.map(tag => this.#logsByTags.get(tag.toString()) ?? []);
|
|
249
222
|
|
|
250
|
-
return Promise.resolve(
|
|
223
|
+
return Promise.resolve(logs);
|
|
251
224
|
}
|
|
252
225
|
|
|
253
226
|
/**
|
|
@@ -450,6 +423,10 @@ export class TXENode implements AztecNode {
|
|
|
450
423
|
throw new Error('TXE Node method getBlocks not implemented');
|
|
451
424
|
}
|
|
452
425
|
|
|
426
|
+
getPublishedBlocks(_from: number, _limit: number): Promise<PublishedL2Block[]> {
|
|
427
|
+
throw new Error('TXE Node method getPublishedBlocks not implemented');
|
|
428
|
+
}
|
|
429
|
+
|
|
453
430
|
/**
|
|
454
431
|
* Method to fetch the version of the package.
|
|
455
432
|
* @returns The node package version
|
package/src/oracle/txe_oracle.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from '@aztec/constants';
|
|
13
13
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
14
14
|
import { Aes128, Schnorr, poseidon2Hash } from '@aztec/foundation/crypto';
|
|
15
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
15
|
+
import { Fr, Point } from '@aztec/foundation/fields';
|
|
16
16
|
import { type Logger, applyStringFormatting } from '@aztec/foundation/log';
|
|
17
17
|
import { Timer } from '@aztec/foundation/timer';
|
|
18
18
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
import { createTxForPublicCalls } from '@aztec/simulator/public/fixtures';
|
|
47
47
|
import {
|
|
48
48
|
ExecutionError,
|
|
49
|
+
PublicContractsDB,
|
|
49
50
|
type PublicTxResult,
|
|
50
51
|
PublicTxSimulator,
|
|
51
52
|
createSimulationError,
|
|
@@ -74,8 +75,13 @@ import {
|
|
|
74
75
|
import type { MerkleTreeReadOperations, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
75
76
|
import { type KeyValidationRequest, PrivateContextInputs } from '@aztec/stdlib/kernel';
|
|
76
77
|
import { deriveKeys } from '@aztec/stdlib/keys';
|
|
77
|
-
import {
|
|
78
|
-
|
|
78
|
+
import {
|
|
79
|
+
ContractClassLog,
|
|
80
|
+
IndexedTaggingSecret,
|
|
81
|
+
LogWithTxData,
|
|
82
|
+
type PrivateLog,
|
|
83
|
+
type PublicLog,
|
|
84
|
+
} from '@aztec/stdlib/logs';
|
|
79
85
|
import type { NoteStatus } from '@aztec/stdlib/note';
|
|
80
86
|
import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
81
87
|
import {
|
|
@@ -99,7 +105,7 @@ import { ForkCheckpoint, NativeWorldStateService } from '@aztec/world-state/nati
|
|
|
99
105
|
import { TXENode } from '../node/txe_node.js';
|
|
100
106
|
import { TXEAccountDataProvider } from '../util/txe_account_data_provider.js';
|
|
101
107
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
102
|
-
import {
|
|
108
|
+
import { TXEPublicTreesDB } from '../util/txe_public_dbs.js';
|
|
103
109
|
|
|
104
110
|
export class TXE implements TypedOracle {
|
|
105
111
|
private blockNumber = 1;
|
|
@@ -753,7 +759,7 @@ export class TXE implements TypedOracle {
|
|
|
753
759
|
|
|
754
760
|
await this.node.setTxEffect(blockNumber, new TxHash(new Fr(blockNumber)), txEffect);
|
|
755
761
|
this.node.setNullifiersIndexesWithBlock(blockNumber, txEffect.nullifiers);
|
|
756
|
-
this.node.
|
|
762
|
+
this.node.addPrivateLogsByTags(this.blockNumber, this.privateLogs);
|
|
757
763
|
this.node.addPublicLogsByTags(this.blockNumber, this.publicLogs);
|
|
758
764
|
|
|
759
765
|
const stateReference = await fork.getStateReference();
|
|
@@ -935,12 +941,9 @@ export class TXE implements TypedOracle {
|
|
|
935
941
|
// See note at revert below.
|
|
936
942
|
const checkpoint = await ForkCheckpoint.new(db);
|
|
937
943
|
try {
|
|
938
|
-
const
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
globalVariables,
|
|
942
|
-
/*doMerkleOperations=*/ true,
|
|
943
|
-
);
|
|
944
|
+
const treesDB = new TXEPublicTreesDB(db, this);
|
|
945
|
+
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(this));
|
|
946
|
+
const simulator = new PublicTxSimulator(treesDB, contractsDB, globalVariables, /*doMerkleOperations=*/ true);
|
|
944
947
|
|
|
945
948
|
const { usedTxRequestHashForNonces } = this.noteCache.finish();
|
|
946
949
|
const firstNullifier = usedTxRequestHashForNonces
|
|
@@ -1088,7 +1091,11 @@ export class TXE implements TypedOracle {
|
|
|
1088
1091
|
);
|
|
1089
1092
|
|
|
1090
1093
|
for (const [recipient, taggedLogs] of taggedLogsByRecipient.entries()) {
|
|
1091
|
-
await this.pxeOracleInterface.processTaggedLogs(
|
|
1094
|
+
await this.pxeOracleInterface.processTaggedLogs(
|
|
1095
|
+
this.contractAddress,
|
|
1096
|
+
taggedLogs,
|
|
1097
|
+
AztecAddress.fromString(recipient),
|
|
1098
|
+
);
|
|
1092
1099
|
}
|
|
1093
1100
|
|
|
1094
1101
|
await this.pxeOracleInterface.removeNullifiedNotes(this.contractAddress);
|
|
@@ -1096,17 +1103,26 @@ export class TXE implements TypedOracle {
|
|
|
1096
1103
|
return Promise.resolve();
|
|
1097
1104
|
}
|
|
1098
1105
|
|
|
1099
|
-
deliverNote(
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1106
|
+
public async deliverNote(
|
|
1107
|
+
contractAddress: AztecAddress,
|
|
1108
|
+
storageSlot: Fr,
|
|
1109
|
+
nonce: Fr,
|
|
1110
|
+
content: Fr[],
|
|
1111
|
+
noteHash: Fr,
|
|
1112
|
+
nullifier: Fr,
|
|
1113
|
+
txHash: Fr,
|
|
1114
|
+
recipient: AztecAddress,
|
|
1108
1115
|
): Promise<void> {
|
|
1109
|
-
|
|
1116
|
+
await this.pxeOracleInterface.deliverNote(
|
|
1117
|
+
contractAddress,
|
|
1118
|
+
storageSlot,
|
|
1119
|
+
nonce,
|
|
1120
|
+
content,
|
|
1121
|
+
noteHash,
|
|
1122
|
+
nullifier,
|
|
1123
|
+
txHash,
|
|
1124
|
+
recipient,
|
|
1125
|
+
);
|
|
1110
1126
|
}
|
|
1111
1127
|
|
|
1112
1128
|
async getLogByTag(tag: Fr): Promise<LogWithTxData | null> {
|
|
@@ -1240,4 +1256,8 @@ export class TXE implements TypedOracle {
|
|
|
1240
1256
|
const aes128 = new Aes128();
|
|
1241
1257
|
return aes128.decryptBufferCBC(ciphertext, iv, symKey);
|
|
1242
1258
|
}
|
|
1259
|
+
|
|
1260
|
+
getSharedSecret(address: AztecAddress, ephPk: Point): Promise<Point> {
|
|
1261
|
+
return this.pxeOracleInterface.getSharedSecret(address, ephPk);
|
|
1262
|
+
}
|
|
1243
1263
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ContractInstanceWithAddress, Fr } from '@aztec/aztec.js';
|
|
1
|
+
import { type ContractInstanceWithAddress, Fr, Point } from '@aztec/aztec.js';
|
|
2
2
|
import { DEPLOYER_CONTRACT_ADDRESS } from '@aztec/constants';
|
|
3
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
|
|
@@ -11,6 +11,7 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
11
11
|
import { computePartialAddress } from '@aztec/stdlib/contract';
|
|
12
12
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
13
13
|
import { computePublicDataTreeLeafSlot, siloNullifier } from '@aztec/stdlib/hash';
|
|
14
|
+
import { LogWithTxData } from '@aztec/stdlib/logs';
|
|
14
15
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
15
16
|
|
|
16
17
|
import { TXE } from '../oracle/txe_oracle.js';
|
|
@@ -23,9 +24,11 @@ import {
|
|
|
23
24
|
fromArray,
|
|
24
25
|
fromSingle,
|
|
25
26
|
fromUintArray,
|
|
27
|
+
fromUintBoundedVec,
|
|
26
28
|
toArray,
|
|
27
29
|
toForeignCallResult,
|
|
28
30
|
toSingle,
|
|
31
|
+
toSingleOrArray,
|
|
29
32
|
} from '../util/encoding.js';
|
|
30
33
|
import { ExpectedFailureError } from '../util/expected_failure_error.js';
|
|
31
34
|
|
|
@@ -521,6 +524,41 @@ export class TXEService {
|
|
|
521
524
|
return toForeignCallResult([]);
|
|
522
525
|
}
|
|
523
526
|
|
|
527
|
+
public async deliverNote(
|
|
528
|
+
contractAddress: ForeignCallSingle,
|
|
529
|
+
storageSlot: ForeignCallSingle,
|
|
530
|
+
nonce: ForeignCallSingle,
|
|
531
|
+
content: ForeignCallArray,
|
|
532
|
+
contentLength: ForeignCallSingle,
|
|
533
|
+
noteHash: ForeignCallSingle,
|
|
534
|
+
nullifier: ForeignCallSingle,
|
|
535
|
+
txHash: ForeignCallSingle,
|
|
536
|
+
recipient: ForeignCallSingle,
|
|
537
|
+
) {
|
|
538
|
+
await this.typedOracle.deliverNote(
|
|
539
|
+
AztecAddress.fromField(fromSingle(contractAddress)),
|
|
540
|
+
fromSingle(storageSlot),
|
|
541
|
+
fromSingle(nonce),
|
|
542
|
+
fromArray(content.slice(0, Number(BigInt(contentLength)))),
|
|
543
|
+
fromSingle(noteHash),
|
|
544
|
+
fromSingle(nullifier),
|
|
545
|
+
fromSingle(txHash),
|
|
546
|
+
AztecAddress.fromField(fromSingle(recipient)),
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
return toForeignCallResult([toSingle(Fr.ONE)]);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
async getLogByTag(tag: ForeignCallSingle) {
|
|
553
|
+
const log = await this.typedOracle.getLogByTag(fromSingle(tag));
|
|
554
|
+
|
|
555
|
+
if (log == null) {
|
|
556
|
+
return toForeignCallResult([toSingle(Fr.ZERO), ...LogWithTxData.noirSerializationOfEmpty().map(toSingleOrArray)]);
|
|
557
|
+
} else {
|
|
558
|
+
return toForeignCallResult([toSingle(Fr.ONE), ...log.toNoirSerialization().map(toSingleOrArray)]);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
524
562
|
async storeCapsule(contractAddress: ForeignCallSingle, slot: ForeignCallSingle, capsule: ForeignCallArray) {
|
|
525
563
|
await this.typedOracle.storeCapsule(
|
|
526
564
|
AztecAddress.fromField(fromSingle(contractAddress)),
|
|
@@ -567,15 +605,31 @@ export class TXEService {
|
|
|
567
605
|
return toForeignCallResult([]);
|
|
568
606
|
}
|
|
569
607
|
|
|
570
|
-
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
571
|
-
|
|
572
|
-
|
|
608
|
+
// TODO: I forgot to add a corresponding function here, when I introduced an oracle method to txe_oracle.ts.
|
|
609
|
+
// The compiler didn't throw an error, so it took me a while to learn of the existence of this file, and that I need
|
|
610
|
+
// to implement this function here. Isn't there a way to programmatically identify that this is missing, given the
|
|
611
|
+
// existence of a txe_oracle method?
|
|
612
|
+
async aes128Decrypt(
|
|
613
|
+
ciphertextBVecStorage: ForeignCallArray,
|
|
614
|
+
ciphertextLength: ForeignCallSingle,
|
|
615
|
+
iv: ForeignCallArray,
|
|
616
|
+
symKey: ForeignCallArray,
|
|
617
|
+
) {
|
|
618
|
+
const ciphertext = fromUintBoundedVec(ciphertextBVecStorage, ciphertextLength, 8);
|
|
573
619
|
const ivBuffer = fromUintArray(iv, 8);
|
|
574
620
|
const symKeyBuffer = fromUintArray(symKey, 8);
|
|
575
621
|
|
|
576
|
-
const plaintextBuffer = await this.typedOracle.aes128Decrypt(
|
|
622
|
+
const plaintextBuffer = await this.typedOracle.aes128Decrypt(ciphertext, ivBuffer, symKeyBuffer);
|
|
623
|
+
|
|
624
|
+
return toForeignCallResult(arrayToBoundedVec(bufferToU8Array(plaintextBuffer), ciphertextBVecStorage.length));
|
|
625
|
+
}
|
|
577
626
|
|
|
578
|
-
|
|
627
|
+
async getSharedSecret(address: ForeignCallSingle, ephPk: ForeignCallArray) {
|
|
628
|
+
const secret = await this.typedOracle.getSharedSecret(
|
|
629
|
+
AztecAddress.fromField(fromSingle(address)),
|
|
630
|
+
Point.fromFields(fromArray(ephPk)),
|
|
631
|
+
);
|
|
632
|
+
return toForeignCallResult([toArray(secret.toFields())]);
|
|
579
633
|
}
|
|
580
634
|
|
|
581
635
|
// AVM opcodes
|
package/src/util/encoding.ts
CHANGED
|
@@ -31,7 +31,7 @@ export function fromArray(obj: ForeignCallArray) {
|
|
|
31
31
|
/**
|
|
32
32
|
* Converts an array of Noir unsigned integers to a single tightly-packed buffer.
|
|
33
33
|
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
34
|
-
* @returns
|
|
34
|
+
* @returns A buffer where each byte is correctly represented as a single byte in the buffer.
|
|
35
35
|
*/
|
|
36
36
|
export function fromUintArray(obj: ForeignCallArray, uintBitSize: number): Buffer {
|
|
37
37
|
if (uintBitSize % 8 !== 0) {
|
|
@@ -41,6 +41,24 @@ export function fromUintArray(obj: ForeignCallArray, uintBitSize: number): Buffe
|
|
|
41
41
|
return Buffer.concat(obj.map(str => hexToBuffer(str).slice(-uintByteSize)));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Converts a Noir BoundedVec of unsigned integers into a Buffer. Note that BoundedVecs are structs, and therefore
|
|
46
|
+
* translated as two separate ForeignCallArray and ForeignCallSingle values (an array and a single field).
|
|
47
|
+
*
|
|
48
|
+
* @param storage The array with the BoundedVec's storage (i.e. BoundedVec::storage())
|
|
49
|
+
* @param length The length of the BoundedVec (i.e. BoundedVec::len())
|
|
50
|
+
* @param uintBitSize If it's an array of Noir u8's, put `8`, etc.
|
|
51
|
+
* @returns A buffer containing the unsigned integers tightly packed
|
|
52
|
+
*/
|
|
53
|
+
export function fromUintBoundedVec(storage: ForeignCallArray, length: ForeignCallSingle, uintBitSize: number): Buffer {
|
|
54
|
+
if (uintBitSize % 8 !== 0) {
|
|
55
|
+
throw new Error(`u${uintBitSize} is not a supported type in Noir`);
|
|
56
|
+
}
|
|
57
|
+
const uintByteSize = uintBitSize / 8;
|
|
58
|
+
const boundedStorage = storage.slice(0, fromSingle(length).toNumber());
|
|
59
|
+
return Buffer.concat(boundedStorage.map(str => hexToBuffer(str).slice(-uintByteSize)));
|
|
60
|
+
}
|
|
61
|
+
|
|
44
62
|
export function toSingle(obj: Fr | AztecAddress): ForeignCallSingle {
|
|
45
63
|
return obj.toString().slice(2);
|
|
46
64
|
}
|
|
@@ -49,6 +67,10 @@ export function toArray(objs: Fr[]): ForeignCallArray {
|
|
|
49
67
|
return objs.map(obj => obj.toString());
|
|
50
68
|
}
|
|
51
69
|
|
|
70
|
+
export function toSingleOrArray(value: Fr | Fr[]) {
|
|
71
|
+
return Array.isArray(value) ? value.map(toSingle) : toSingle(value);
|
|
72
|
+
}
|
|
73
|
+
|
|
52
74
|
export function bufferToU8Array(buffer: Buffer): ForeignCallArray {
|
|
53
75
|
return toArray(Array.from(buffer).map(byte => new Fr(byte)));
|
|
54
76
|
}
|
|
@@ -57,21 +79,24 @@ export function bufferToU8Array(buffer: Buffer): ForeignCallArray {
|
|
|
57
79
|
* Converts a ForeignCallArray into a tuple which represents a nr BoundedVec.
|
|
58
80
|
* If the input array is shorter than the maxLen, it pads the result with zeros,
|
|
59
81
|
* so that nr can correctly coerce this result into a BoundedVec.
|
|
60
|
-
* @param array
|
|
82
|
+
* @param bVecStorage - The array underlying the BoundedVec.
|
|
61
83
|
* @param maxLen - the max length of the BoundedVec.
|
|
62
84
|
* @returns a tuple representing a BoundedVec.
|
|
63
85
|
*/
|
|
64
|
-
export function arrayToBoundedVec(
|
|
65
|
-
|
|
66
|
-
|
|
86
|
+
export function arrayToBoundedVec(
|
|
87
|
+
bVecStorage: ForeignCallArray,
|
|
88
|
+
maxLen: number,
|
|
89
|
+
): [ForeignCallArray, ForeignCallSingle] {
|
|
90
|
+
if (bVecStorage.length > maxLen) {
|
|
91
|
+
throw new Error(`Array of length ${bVecStorage.length} larger than maxLen ${maxLen}`);
|
|
67
92
|
}
|
|
68
|
-
const lengthDiff = maxLen -
|
|
93
|
+
const lengthDiff = maxLen - bVecStorage.length;
|
|
69
94
|
// We pad the array to the maxLen of the BoundedVec.
|
|
70
95
|
const zeroPaddingArray = toArray(Array(lengthDiff).fill(new Fr(0)));
|
|
71
96
|
|
|
72
97
|
// These variable names match with the BoundedVec members in nr:
|
|
73
|
-
const storage =
|
|
74
|
-
const len = toSingle(new Fr(
|
|
98
|
+
const storage = bVecStorage.concat(zeroPaddingArray);
|
|
99
|
+
const len = toSingle(new Fr(bVecStorage.length));
|
|
75
100
|
return [storage, len];
|
|
76
101
|
}
|
|
77
102
|
|
|
@@ -16,14 +16,6 @@ import type { TXE } from '../oracle/txe_oracle.js';
|
|
|
16
16
|
export class TXEPublicContractDataSource implements ContractDataSource {
|
|
17
17
|
constructor(private txeOracle: TXE) {}
|
|
18
18
|
|
|
19
|
-
async getPublicFunction(address: AztecAddress, selector: FunctionSelector): Promise<PublicFunction | undefined> {
|
|
20
|
-
const bytecode = await this.txeOracle.getContractDataProvider().getBytecode(address, selector);
|
|
21
|
-
if (!bytecode) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
return { bytecode, selector };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
getBlockNumber(): Promise<number> {
|
|
28
20
|
return this.txeOracle.getBlockNumber();
|
|
29
21
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import {
|
|
2
|
+
import { PublicTreesDB } from '@aztec/simulator/server';
|
|
3
3
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
4
4
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
6
5
|
import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
|
|
7
6
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
8
7
|
import { MerkleTreeId, type PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
|
|
9
8
|
|
|
10
9
|
import type { TXE } from '../oracle/txe_oracle.js';
|
|
11
10
|
|
|
12
|
-
export class
|
|
13
|
-
constructor(private merkleDb: MerkleTreeWriteOperations,
|
|
14
|
-
super(merkleDb
|
|
11
|
+
export class TXEPublicTreesDB extends PublicTreesDB {
|
|
12
|
+
constructor(private merkleDb: MerkleTreeWriteOperations, private txe: TXE) {
|
|
13
|
+
super(merkleDb);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
override async storageRead(contract: AztecAddress, slot: Fr): Promise<Fr> {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"txe_world_state_db.d.ts","sourceRoot":"","sources":["../../src/util/txe_world_state_db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAGjF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAEnD,qBAAa,eAAgB,SAAQ,YAAY;IACnC,OAAO,CAAC,QAAQ;IAA6D,OAAO,CAAC,GAAG;gBAAhF,QAAQ,EAAE,yBAAyB,EAAE,UAAU,EAAE,kBAAkB,EAAU,GAAG,EAAE,GAAG;IAI1F,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;IAgB1D,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAK3F"}
|