@aztec/txe 0.70.0 → 0.71.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.
@@ -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 { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
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,7 +42,7 @@ 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, new NoopTelemetryClient(), logger);
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);
@@ -588,37 +588,49 @@ export class TXEService {
588
588
  return toForeignCallResult([]);
589
589
  }
590
590
 
591
- async store(contract: ForeignCallSingle, key: ForeignCallSingle, values: ForeignCallArray) {
592
- const processedContract = AztecAddress.fromField(fromSingle(contract));
593
- const processedKey = fromSingle(key);
594
- const processedValues = fromArray(values);
595
- await this.typedOracle.store(processedContract, processedKey, processedValues);
591
+ async dbStore(contractAddress: ForeignCallSingle, slot: ForeignCallSingle, values: ForeignCallArray) {
592
+ await this.typedOracle.dbStore(
593
+ AztecAddress.fromField(fromSingle(contractAddress)),
594
+ fromSingle(slot),
595
+ fromArray(values),
596
+ );
596
597
  return toForeignCallResult([]);
597
598
  }
598
599
 
599
- /**
600
- * Load data from pxe db.
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);
600
+ async dbLoad(contractAddress: ForeignCallSingle, slot: ForeignCallSingle, tSize: ForeignCallSingle) {
601
+ const values = await this.typedOracle.dbLoad(AztecAddress.fromField(fromSingle(contractAddress)), fromSingle(slot));
610
602
  // We are going to return a Noir Option struct to represent the possibility of null values. Options are a struct
611
603
  // with two fields: `some` (a boolean) and `value` (a field array in this case).
612
604
  if (values === null) {
613
605
  // No data was found so we set `some` to 0 and pad `value` with zeros get the correct return size.
614
- const processedTSize = fromSingle(tSize).toNumber();
615
- return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(processedTSize).fill(new Fr(0)))]);
606
+ return toForeignCallResult([toSingle(new Fr(0)), toArray(Array(fromSingle(tSize).toNumber()).fill(new Fr(0)))]);
616
607
  } else {
617
608
  // Data was found so we set `some` to 1 and return it along with `value`.
618
609
  return toForeignCallResult([toSingle(new Fr(1)), toArray(values)]);
619
610
  }
620
611
  }
621
612
 
613
+ async dbDelete(contractAddress: ForeignCallSingle, slot: ForeignCallSingle) {
614
+ await this.typedOracle.dbDelete(AztecAddress.fromField(fromSingle(contractAddress)), fromSingle(slot));
615
+ return toForeignCallResult([]);
616
+ }
617
+
618
+ async dbCopy(
619
+ contractAddress: ForeignCallSingle,
620
+ srcSlot: ForeignCallSingle,
621
+ dstSlot: ForeignCallSingle,
622
+ numEntries: ForeignCallSingle,
623
+ ) {
624
+ await this.typedOracle.dbCopy(
625
+ AztecAddress.fromField(fromSingle(contractAddress)),
626
+ fromSingle(srcSlot),
627
+ fromSingle(dstSlot),
628
+ fromSingle(numEntries).toNumber(),
629
+ );
630
+
631
+ return toForeignCallResult([]);
632
+ }
633
+
622
634
  // AVM opcodes
623
635
 
624
636
  avmOpcodeEmitUnencryptedLog(_message: ForeignCallArray) {