@aztec/txe 0.70.0 → 0.72.1
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.map +1 -1
- package/dest/index.js +5 -3
- package/dest/node/txe_node.d.ts +16 -11
- package/dest/node/txe_node.d.ts.map +1 -1
- package/dest/node/txe_node.js +76 -48
- package/dest/oracle/txe_oracle.d.ts +14 -26
- package/dest/oracle/txe_oracle.d.ts.map +1 -1
- package/dest/oracle/txe_oracle.js +69 -71
- package/dest/txe_service/txe_service.d.ts +10 -14
- package/dest/txe_service/txe_service.d.ts.map +1 -1
- package/dest/txe_service/txe_service.js +23 -32
- package/package.json +14 -14
- package/src/index.ts +4 -2
- package/src/node/txe_node.ts +115 -63
- package/src/oracle/txe_oracle.ts +105 -80
- package/src/txe_service/txe_service.ts +39 -32
|
@@ -20,7 +20,7 @@ import { getCanonicalProtocolContract } from '@aztec/protocol-contracts/bundle';
|
|
|
20
20
|
import { enrichPublicSimulationError } from '@aztec/pxe';
|
|
21
21
|
import { type TypedOracle } from '@aztec/simulator/client';
|
|
22
22
|
import { HashedValuesCache } from '@aztec/simulator/server';
|
|
23
|
-
import {
|
|
23
|
+
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
24
24
|
import { MerkleTrees } from '@aztec/world-state';
|
|
25
25
|
|
|
26
26
|
import { TXE } from '../oracle/txe_oracle.js';
|
|
@@ -42,18 +42,18 @@ export class TXEService {
|
|
|
42
42
|
|
|
43
43
|
static async init(logger: Logger) {
|
|
44
44
|
const store = openTmpStore(true);
|
|
45
|
-
const trees = await MerkleTrees.new(store,
|
|
45
|
+
const trees = await MerkleTrees.new(store, getTelemetryClient(), logger);
|
|
46
46
|
const executionCache = new HashedValuesCache();
|
|
47
47
|
const keyStore = new KeyStore(store);
|
|
48
48
|
const txeDatabase = new TXEDatabase(store);
|
|
49
49
|
// Register protocol contracts.
|
|
50
50
|
for (const name of protocolContractNames) {
|
|
51
|
-
const { contractClass, instance, artifact } = getCanonicalProtocolContract(name);
|
|
51
|
+
const { contractClass, instance, artifact } = await getCanonicalProtocolContract(name);
|
|
52
52
|
await txeDatabase.addContractArtifact(contractClass.id, artifact);
|
|
53
53
|
await txeDatabase.addContractInstance(instance);
|
|
54
54
|
}
|
|
55
55
|
logger.debug(`TXE service initialized`);
|
|
56
|
-
const txe =
|
|
56
|
+
const txe = await TXE.create(logger, trees, executionCache, keyStore, txeDatabase);
|
|
57
57
|
const service = new TXEService(logger, txe);
|
|
58
58
|
await service.advanceBlocksBy(toSingle(new Fr(1n)));
|
|
59
59
|
return service;
|
|
@@ -95,8 +95,8 @@ export class TXEService {
|
|
|
95
95
|
return toForeignCallResult([]);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
deriveKeys(secret: ForeignCallSingle) {
|
|
99
|
-
const keys = (this.typedOracle as TXE).deriveKeys(fromSingle(secret));
|
|
98
|
+
async deriveKeys(secret: ForeignCallSingle) {
|
|
99
|
+
const keys = await (this.typedOracle as TXE).deriveKeys(fromSingle(secret));
|
|
100
100
|
return toForeignCallResult(keys.publicKeys.toFields().map(toSingle));
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -116,7 +116,7 @@ export class TXEService {
|
|
|
116
116
|
`Deploy ${artifact.name} with initializer ${initializerStr}(${decodedArgs}) and public keys hash ${publicKeysHashFr}`,
|
|
117
117
|
);
|
|
118
118
|
|
|
119
|
-
const instance = getContractInstanceFromDeployParams(artifact, {
|
|
119
|
+
const instance = await getContractInstanceFromDeployParams(artifact, {
|
|
120
120
|
constructorArgs: decodedArgs,
|
|
121
121
|
skipArgsDecoding: true,
|
|
122
122
|
salt: Fr.ONE,
|
|
@@ -177,10 +177,10 @@ export class TXEService {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
async addAccount(secret: ForeignCallSingle) {
|
|
180
|
-
const keys = (this.typedOracle as TXE).deriveKeys(fromSingle(secret));
|
|
180
|
+
const keys = await (this.typedOracle as TXE).deriveKeys(fromSingle(secret));
|
|
181
181
|
const args = [keys.publicKeys.masterIncomingViewingPublicKey.x, keys.publicKeys.masterIncomingViewingPublicKey.y];
|
|
182
182
|
const artifact = SchnorrAccountContractArtifact;
|
|
183
|
-
const instance = getContractInstanceFromDeployParams(artifact, {
|
|
183
|
+
const instance = await getContractInstanceFromDeployParams(artifact, {
|
|
184
184
|
constructorArgs: args,
|
|
185
185
|
skipArgsDecoding: true,
|
|
186
186
|
salt: Fr.ONE,
|
|
@@ -271,11 +271,6 @@ export class TXEService {
|
|
|
271
271
|
return toForeignCallResult([toSingle(new Fr(blockNumber))]);
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
async storeArrayInExecutionCache(args: ForeignCallArray) {
|
|
275
|
-
const hash = await this.typedOracle.storeArrayInExecutionCache(fromArray(args));
|
|
276
|
-
return toForeignCallResult([toSingle(hash)]);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
274
|
// Since the argument is a slice, noir automatically adds a length field to oracle call.
|
|
280
275
|
async storeInExecutionCache(_length: ForeignCallSingle, values: ForeignCallArray) {
|
|
281
276
|
const returnsHash = await this.typedOracle.storeInExecutionCache(fromArray(values));
|
|
@@ -588,37 +583,49 @@ export class TXEService {
|
|
|
588
583
|
return toForeignCallResult([]);
|
|
589
584
|
}
|
|
590
585
|
|
|
591
|
-
async
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
586
|
+
async dbStore(contractAddress: ForeignCallSingle, slot: ForeignCallSingle, values: ForeignCallArray) {
|
|
587
|
+
await this.typedOracle.dbStore(
|
|
588
|
+
AztecAddress.fromField(fromSingle(contractAddress)),
|
|
589
|
+
fromSingle(slot),
|
|
590
|
+
fromArray(values),
|
|
591
|
+
);
|
|
596
592
|
return toForeignCallResult([]);
|
|
597
593
|
}
|
|
598
594
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
* @param contract - The contract address.
|
|
602
|
-
* @param key - The key to load.
|
|
603
|
-
* @param tSize - The size of the serialized object to return.
|
|
604
|
-
* @returns The data found flag and the serialized object concatenated in one array.
|
|
605
|
-
*/
|
|
606
|
-
async load(contract: ForeignCallSingle, key: ForeignCallSingle, tSize: ForeignCallSingle) {
|
|
607
|
-
const processedContract = AztecAddress.fromField(fromSingle(contract));
|
|
608
|
-
const processedKey = fromSingle(key);
|
|
609
|
-
const values = await this.typedOracle.load(processedContract, processedKey);
|
|
595
|
+
async dbLoad(contractAddress: ForeignCallSingle, slot: ForeignCallSingle, tSize: ForeignCallSingle) {
|
|
596
|
+
const values = await this.typedOracle.dbLoad(AztecAddress.fromField(fromSingle(contractAddress)), fromSingle(slot));
|
|
610
597
|
// We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
|
|
611
598
|
// with two fields: `some` (a boolean) and `value` (a field array in this case).
|
|
612
599
|
if (values === null) {
|
|
613
600
|
// No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
|
|
614
|
-
|
|
615
|
-
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(processedTSize).fill(new Fr(0)))]);
|
|
601
|
+
return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(fromSingle(tSize).toNumber()).fill(new Fr(0)))]);
|
|
616
602
|
} else {
|
|
617
603
|
// Data was found so we set `some` to 1 and return it along with `value`.
|
|
618
604
|
return toForeignCallResult([toSingle(new Fr(1)), toArray(values)]);
|
|
619
605
|
}
|
|
620
606
|
}
|
|
621
607
|
|
|
608
|
+
async dbDelete(contractAddress: ForeignCallSingle, slot: ForeignCallSingle) {
|
|
609
|
+
await this.typedOracle.dbDelete(AztecAddress.fromField(fromSingle(contractAddress)), fromSingle(slot));
|
|
610
|
+
return toForeignCallResult([]);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
async dbCopy(
|
|
614
|
+
contractAddress: ForeignCallSingle,
|
|
615
|
+
srcSlot: ForeignCallSingle,
|
|
616
|
+
dstSlot: ForeignCallSingle,
|
|
617
|
+
numEntries: ForeignCallSingle,
|
|
618
|
+
) {
|
|
619
|
+
await this.typedOracle.dbCopy(
|
|
620
|
+
AztecAddress.fromField(fromSingle(contractAddress)),
|
|
621
|
+
fromSingle(srcSlot),
|
|
622
|
+
fromSingle(dstSlot),
|
|
623
|
+
fromSingle(numEntries).toNumber(),
|
|
624
|
+
);
|
|
625
|
+
|
|
626
|
+
return toForeignCallResult([]);
|
|
627
|
+
}
|
|
628
|
+
|
|
622
629
|
// AVM opcodes
|
|
623
630
|
|
|
624
631
|
avmOpcodeEmitUnencryptedLog(_message: ForeignCallArray) {
|