@aztec/txe 3.0.0-rc.5 → 4.0.0-nightly.20260107
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/constants.d.ts +3 -0
- package/dest/constants.d.ts.map +1 -0
- package/dest/constants.js +2 -0
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -2
- package/dest/oracle/interfaces.d.ts +4 -2
- package/dest/oracle/interfaces.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.d.ts +2 -2
- package/dest/oracle/txe_oracle_public_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_public_context.js +3 -5
- package/dest/oracle/txe_oracle_top_level_context.d.ts +18 -10
- package/dest/oracle/txe_oracle_top_level_context.d.ts.map +1 -1
- package/dest/oracle/txe_oracle_top_level_context.js +83 -52
- package/dest/rpc_translator.d.ts +9 -3
- package/dest/rpc_translator.d.ts.map +1 -1
- package/dest/rpc_translator.js +33 -3
- package/dest/state_machine/archiver.d.ts +19 -7
- package/dest/state_machine/archiver.d.ts.map +1 -1
- package/dest/state_machine/archiver.js +93 -15
- package/dest/state_machine/dummy_p2p_client.d.ts +1 -1
- package/dest/state_machine/dummy_p2p_client.d.ts.map +1 -1
- package/dest/state_machine/dummy_p2p_client.js +3 -1
- package/dest/state_machine/global_variable_builder.d.ts +3 -2
- package/dest/state_machine/global_variable_builder.d.ts.map +1 -1
- package/dest/state_machine/global_variable_builder.js +12 -0
- package/dest/state_machine/index.d.ts +5 -5
- package/dest/state_machine/index.d.ts.map +1 -1
- package/dest/state_machine/index.js +13 -19
- package/dest/txe_session.d.ts +15 -9
- package/dest/txe_session.d.ts.map +1 -1
- package/dest/txe_session.js +72 -42
- package/dest/util/encoding.d.ts +601 -2
- package/dest/util/encoding.d.ts.map +1 -1
- package/dest/util/txe_account_store.d.ts +10 -0
- package/dest/util/txe_account_store.d.ts.map +1 -0
- package/dest/util/{txe_account_data_provider.js → txe_account_store.js} +1 -1
- package/dest/util/txe_contract_store.d.ts +12 -0
- package/dest/util/txe_contract_store.d.ts.map +1 -0
- package/dest/util/{txe_contract_data_provider.js → txe_contract_store.js} +3 -3
- package/dest/util/txe_public_contract_data_source.d.ts +4 -4
- package/dest/util/txe_public_contract_data_source.d.ts.map +1 -1
- package/dest/util/txe_public_contract_data_source.js +10 -10
- package/dest/utils/block_creation.d.ts +16 -2
- package/dest/utils/block_creation.d.ts.map +1 -1
- package/dest/utils/block_creation.js +22 -1
- package/package.json +15 -15
- package/src/constants.ts +3 -0
- package/src/index.ts +15 -12
- package/src/oracle/interfaces.ts +3 -1
- package/src/oracle/txe_oracle_public_context.ts +3 -8
- package/src/oracle/txe_oracle_top_level_context.ts +125 -76
- package/src/rpc_translator.ts +45 -3
- package/src/state_machine/archiver.ts +119 -21
- package/src/state_machine/dummy_p2p_client.ts +3 -1
- package/src/state_machine/global_variable_builder.ts +18 -1
- package/src/state_machine/index.ts +18 -17
- package/src/txe_session.ts +157 -69
- package/src/util/{txe_account_data_provider.ts → txe_account_store.ts} +1 -1
- package/src/util/{txe_contract_data_provider.ts → txe_contract_store.ts} +3 -3
- package/src/util/txe_public_contract_data_source.ts +9 -9
- package/src/utils/block_creation.ts +31 -1
- package/dest/util/txe_account_data_provider.d.ts +0 -10
- package/dest/util/txe_account_data_provider.d.ts.map +0 -1
- package/dest/util/txe_contract_data_provider.d.ts +0 -12
- package/dest/util/txe_contract_data_provider.d.ts.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
export declare const DEFAULT_ADDRESS: AztecAddress;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uc3RhbnRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUUzRCxlQUFPLE1BQU0sZUFBZSxjQUE4QixDQUFDIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,eAAO,MAAM,eAAe,cAA8B,CAAC"}
|
package/dest/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import type { Logger } from '@aztec/foundation/log';
|
|
|
5
5
|
* @returns A TXE RPC server.
|
|
6
6
|
*/
|
|
7
7
|
export declare function createTXERpcServer(logger: Logger): import("@aztec/foundation/json-rpc/server").SafeJsonRpcServer;
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFVQSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQWdPcEQ7Ozs7R0FJRztBQUNILHdCQUFnQixrQkFBa0IsQ0FBQyxNQUFNLEVBQUUsTUFBTSxpRUFJaEQifQ==
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAgOpD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,iEAIhD"}
|
package/dest/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createSafeJsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
|
8
8
|
import { protocolContractNames } from '@aztec/protocol-contracts';
|
|
9
9
|
import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
|
|
10
10
|
import { computeArtifactHash } from '@aztec/stdlib/contract';
|
|
11
|
+
import { zodFor } from '@aztec/stdlib/schemas';
|
|
11
12
|
import { createHash } from 'crypto';
|
|
12
13
|
import { createReadStream } from 'fs';
|
|
13
14
|
import { readFile, readdir } from 'fs/promises';
|
|
@@ -20,7 +21,7 @@ const sessions = new Map();
|
|
|
20
21
|
* TXE typically has to load the same contract artifacts over and over again for multiple tests,
|
|
21
22
|
* so we cache them here to avoid both loading them from disk repeatedly and computing their artifact hashes
|
|
22
23
|
*/ const TXEArtifactsCache = new Map();
|
|
23
|
-
const TXEForeignCallInputSchema = z.object({
|
|
24
|
+
const TXEForeignCallInputSchema = zodFor()(z.object({
|
|
24
25
|
// eslint-disable-next-line camelcase
|
|
25
26
|
session_id: z.number().int().nonnegative(),
|
|
26
27
|
function: z.string(),
|
|
@@ -29,7 +30,7 @@ const TXEForeignCallInputSchema = z.object({
|
|
|
29
30
|
// eslint-disable-next-line camelcase
|
|
30
31
|
package_name: z.string(),
|
|
31
32
|
inputs: ForeignCallArgsSchema
|
|
32
|
-
});
|
|
33
|
+
}));
|
|
33
34
|
class TXEDispatcher {
|
|
34
35
|
logger;
|
|
35
36
|
protocolContracts;
|
|
@@ -4,7 +4,7 @@ import type { ContractInstanceWithAddress } from '@aztec/aztec.js/contracts';
|
|
|
4
4
|
import { TxHash } from '@aztec/aztec.js/tx';
|
|
5
5
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
6
6
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
7
|
-
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
|
+
import type { EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
|
|
8
8
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
9
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
10
10
|
/**
|
|
@@ -34,6 +34,7 @@ export interface IAvmExecutionOracle {
|
|
|
34
34
|
*/
|
|
35
35
|
export interface ITxeExecutionOracle {
|
|
36
36
|
isTxe: true;
|
|
37
|
+
txeGetDefaultAddress(): AztecAddress;
|
|
37
38
|
txeGetNextBlockNumber(): Promise<BlockNumber>;
|
|
38
39
|
txeGetNextBlockTimestamp(): Promise<UInt64>;
|
|
39
40
|
txeAdvanceBlocksBy(blocks: number): Promise<void>;
|
|
@@ -48,8 +49,9 @@ export interface ITxeExecutionOracle {
|
|
|
48
49
|
noteHashes: Fr[];
|
|
49
50
|
nullifiers: Fr[];
|
|
50
51
|
}>;
|
|
52
|
+
txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
51
53
|
txePrivateCallNewFlow(from: AztecAddress, targetContractAddress: AztecAddress, functionSelector: FunctionSelector, args: Fr[], argsHash: Fr, isStaticCall: boolean): Promise<Fr[]>;
|
|
52
54
|
txeSimulateUtilityFunction(targetContractAddress: AztecAddress, functionSelector: FunctionSelector, args: Fr[]): Promise<Fr[]>;
|
|
53
55
|
txePublicCallNewFlow(from: AztecAddress, targetContractAddress: AztecAddress, calldata: Fr[], isStaticCall: boolean): Promise<Fr[]>;
|
|
54
56
|
}
|
|
55
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
57
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29yYWNsZS9pbnRlcmZhY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJ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RUFBRSxFQUFFLEVBQUUsR0FDVCxPQUFPLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQztJQUNqQixvQkFBb0IsQ0FDbEIsSUFBSSxFQUFFLFlBQVksRUFDbEIscUJBQXFCLEVBQUUsWUFBWSxFQUNuQyxRQUFRLEVBQUUsRUFBRSxFQUFFLEVBQ2QsWUFBWSxFQUFFLE9BQU8sR0FDcEIsT0FBTyxDQUFDLEVBQUUsRUFBRSxDQUFDLENBQUM7Q0FDbEIifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/oracle/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/oracle/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;A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E,GACT,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IACjB,oBAAoB,CAClB,IAAI,EAAE,YAAY,EAClB,qBAAqB,EAAE,YAAY,EACnC,QAAQ,EAAE,EAAE,EAAE,EACd,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;CAClB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { L2Block } from '@aztec/stdlib/block';
|
|
4
|
+
import type { L2Block } from '@aztec/stdlib/block';
|
|
5
5
|
import { type MerkleTreeWriteOperations } from '@aztec/stdlib/trees';
|
|
6
6
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
7
7
|
import type { IAvmExecutionOracle } from './interfaces.js';
|
|
@@ -31,4 +31,4 @@ export declare class TXEOraclePublicContext implements IAvmExecutionOracle {
|
|
|
31
31
|
close(): Promise<L2Block>;
|
|
32
32
|
private makeTxEffect;
|
|
33
33
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX29yYWNsZV9wdWJsaWNfY29udGV4dC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29yYWNsZS90eGVfb3JhY2xlX3B1YmxpY19jb250ZXh0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM5RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFHcEQsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQzNELE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5QjtJQUVELGdCQUFnQixJQUFJLE9BQU8sQ0FBQyxFQUFFLENBQUMsQ0FFOUI7SUFFSyxzQkFBc0IsQ0FBQyxTQUFTLEVBQUUsRUFBRSxpQkFHekM7SUFFSyxxQkFBcUIsQ0FBQyxRQUFRLEVBQUUsRUFBRSxpQkFJdkM7SUFFSyx3QkFBd0IsQ0FBQyxjQUFjLEVBQUUsRUFBRSxFQUFFLGFBQWEsRUFBRSxZQUFZLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQVNoRztJQUVLLHFCQUFxQixDQUFDLElBQUksRUFBRSxFQUFFLEVBQUUsS0FBSyxFQUFFLEVBQUUsaUJBVTlDO0lBRUssb0JBQW9CLENBQUMsSUFBSSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsRUFBRSxDQUFDLENBcUJoRDtJQUVLLEtBQUssSUFBSSxPQUFPLENBQUMsT0FBTyxDQUFDLENBa0I5QjtJQUVELE9BQU8sQ0FBQyxZQUFZO0NBYXJCIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_oracle_public_context.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_oracle_public_context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,
|
|
1
|
+
{"version":3,"file":"txe_oracle_public_context.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_oracle_public_context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC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,GAAG,OAAO,CAAC,EAAE,CAAC,CAqBhD;IAEK,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAkB9B;IAED,OAAO,CAAC,YAAY;CAarB"}
|
|
@@ -2,12 +2,10 @@ import { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { PublicDataWrite } from '@aztec/stdlib/avm';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
6
5
|
import { computePublicDataTreeLeafSlot, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
|
|
7
|
-
import { makeAppendOnlyTreeSnapshot } from '@aztec/stdlib/testing';
|
|
8
6
|
import { MerkleTreeId, PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
9
7
|
import { TxEffect, TxHash } from '@aztec/stdlib/tx';
|
|
10
|
-
import { insertTxEffectIntoWorldTrees,
|
|
8
|
+
import { insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
11
9
|
export class TXEOraclePublicContext {
|
|
12
10
|
contractAddress;
|
|
13
11
|
forkedWorldTrees;
|
|
@@ -99,9 +97,9 @@ export class TXEOraclePublicContext {
|
|
|
99
97
|
});
|
|
100
98
|
const txEffect = this.makeTxEffect();
|
|
101
99
|
await insertTxEffectIntoWorldTrees(txEffect, this.forkedWorldTrees);
|
|
102
|
-
const block =
|
|
100
|
+
const block = await makeTXEBlock(this.forkedWorldTrees, this.globalVariables, [
|
|
103
101
|
txEffect
|
|
104
|
-
])
|
|
102
|
+
]);
|
|
105
103
|
await this.forkedWorldTrees.close();
|
|
106
104
|
this.logger.debug('Exited PublicContext with built block', {
|
|
107
105
|
blockNumber: block.number,
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { KeyStore } from '@aztec/key-store';
|
|
4
|
-
import {
|
|
4
|
+
import { AddressStore, CapsuleStore, NoteStore, PrivateEventStore, RecipientTaggingStore, SenderAddressBookStore, SenderTaggingStore } from '@aztec/pxe/server';
|
|
5
5
|
import { type IMiscOracle } from '@aztec/pxe/simulator';
|
|
6
|
-
import { type ContractArtifact, FunctionSelector } from '@aztec/stdlib/abi';
|
|
6
|
+
import { type ContractArtifact, EventSelector, FunctionSelector } from '@aztec/stdlib/abi';
|
|
7
7
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
8
8
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
9
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
10
10
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
11
11
|
import type { UInt64 } from '@aztec/stdlib/types';
|
|
12
12
|
import type { TXEStateMachine } from '../state_machine/index.js';
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
13
|
+
import type { TXEAccountStore } from '../util/txe_account_store.js';
|
|
14
|
+
import type { TXEContractStore } from '../util/txe_contract_store.js';
|
|
15
15
|
import type { ITxeExecutionOracle } from './interfaces.js';
|
|
16
16
|
export declare class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecutionOracle {
|
|
17
17
|
private stateMachine;
|
|
18
|
-
private
|
|
18
|
+
private contractStore;
|
|
19
|
+
private noteStore;
|
|
19
20
|
private keyStore;
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private
|
|
21
|
+
private addressStore;
|
|
22
|
+
private accountStore;
|
|
23
|
+
private senderTaggingStore;
|
|
24
|
+
private recipientTaggingStore;
|
|
25
|
+
private senderAddressBookStore;
|
|
26
|
+
private capsuleStore;
|
|
27
|
+
private privateEventStore;
|
|
23
28
|
private nextBlockTimestamp;
|
|
24
29
|
private version;
|
|
25
30
|
private chainId;
|
|
@@ -27,10 +32,11 @@ export declare class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecut
|
|
|
27
32
|
isMisc: true;
|
|
28
33
|
isTxe: true;
|
|
29
34
|
private logger;
|
|
30
|
-
constructor(stateMachine: TXEStateMachine,
|
|
35
|
+
constructor(stateMachine: TXEStateMachine, contractStore: TXEContractStore, noteStore: NoteStore, keyStore: KeyStore, addressStore: AddressStore, accountStore: TXEAccountStore, senderTaggingStore: SenderTaggingStore, recipientTaggingStore: RecipientTaggingStore, senderAddressBookStore: SenderAddressBookStore, capsuleStore: CapsuleStore, privateEventStore: PrivateEventStore, nextBlockTimestamp: bigint, version: Fr, chainId: Fr, authwits: Map<string, AuthWitness>);
|
|
31
36
|
utilityAssertCompatibleOracleVersion(version: number): void;
|
|
32
37
|
utilityGetRandomField(): Fr;
|
|
33
38
|
utilityDebugLog(level: number, message: string, fields: Fr[]): void;
|
|
39
|
+
txeGetDefaultAddress(): AztecAddress;
|
|
34
40
|
txeGetNextBlockNumber(): Promise<BlockNumber>;
|
|
35
41
|
txeGetNextBlockTimestamp(): Promise<bigint>;
|
|
36
42
|
txeGetLastBlockTimestamp(): Promise<bigint>;
|
|
@@ -39,6 +45,7 @@ export declare class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecut
|
|
|
39
45
|
noteHashes: Fr[];
|
|
40
46
|
nullifiers: Fr[];
|
|
41
47
|
}>;
|
|
48
|
+
txeGetPrivateEvents(selector: EventSelector, contractAddress: AztecAddress, scope: AztecAddress): Promise<Fr[][]>;
|
|
42
49
|
txeAdvanceBlocksBy(blocks: number): Promise<void>;
|
|
43
50
|
txeAdvanceTimestampBy(duration: UInt64): void;
|
|
44
51
|
txeDeploy(artifact: ContractArtifact, instance: ContractInstanceWithAddress, secret: Fr): Promise<void>;
|
|
@@ -51,7 +58,8 @@ export declare class TXEOracleTopLevelContext implements IMiscOracle, ITxeExecut
|
|
|
51
58
|
txePrivateCallNewFlow(from: AztecAddress, targetContractAddress: AztecAddress | undefined, functionSelector: FunctionSelector | undefined, args: Fr[], argsHash?: Fr, isStaticCall?: boolean): Promise<Fr[]>;
|
|
52
59
|
txePublicCallNewFlow(from: AztecAddress, targetContractAddress: AztecAddress, calldata: Fr[], isStaticCall: boolean): Promise<Fr[]>;
|
|
53
60
|
txeSimulateUtilityFunction(targetContractAddress: AztecAddress, functionSelector: FunctionSelector, args: Fr[]): Promise<Fr[]>;
|
|
61
|
+
private executeUtilityCall;
|
|
54
62
|
close(): [bigint, Map<string, AuthWitness>];
|
|
55
63
|
private getLastBlockNumber;
|
|
56
64
|
}
|
|
57
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
65
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhlX29yYWNsZV90b3BfbGV2ZWxfY29udGV4dC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL29yYWNsZS90eGVfb3JhY2xlX3RvcF9sZXZlbF9jb250ZXh0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUU5RCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFHcEQsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDakQsT0FBTyxFQUNMLFlBQVksRUFDWixZQUFZLEVBQ1osU0FBUyxFQUVULGlCQUFpQixFQUNqQixxQkFBcUIsRUFDckIsc0JBQXNCLEVBQ3RCLGtCQUFrQixFQUVuQixNQUFNLG1CQUFtQixDQUFDO0FBQzNCLE9BQU8sRUFJTCxLQUFLLFdBQVcsRUFNakIsTUFBTSxzQkFBc0IsQ0FBQztBQWdCOUIsT0FBTyxFQUFFLEtBQUssZ0JBQWdCLEVBQUUsYUFBYSxFQUFnQixnQkFBZ0IsRUFBZ0IsTUFBTSxtQkFBbUIsQ0FBQztBQUN2SCxPQUFPLEVBQUUsV0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sRUFBRSxpQkF3Qlg7WUFFYSxrQkFBa0I7SUFtRGhDLEtBQUssSUFBSSxDQUFDLE1BQU0sRUFBRSxHQUFHLENBQUMsTUFBTSxFQUFFLFdBQVcsQ0FBQyxDQUFDLENBRzFDO1lBRWEsa0JBQWtCO0NBSWpDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"txe_oracle_top_level_context.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_oracle_top_level_context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"txe_oracle_top_level_context.d.ts","sourceRoot":"","sources":["../../src/oracle/txe_oracle_top_level_context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAGpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EAET,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAEnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,WAAW,EAMjB,MAAM,sBAAsB,CAAC;AAgB9B,OAAO,EAAE,KAAK,gBAAgB,EAAE,aAAa,EAAgB,gBAAgB,EAAgB,MAAM,mBAAmB,CAAC;AACvH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,2BAA2B,EAAyB,MAAM,wBAAwB,CAAC;AAYjG,OAAO,EASL,MAAM,EAE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EACnC,QAAQ,EAAE,EAAE,EAAE,EACd,YAAY,EAAE,OAAO,iBAyItB;IAEK,0BAA0B,CAC9B,qBAAqB,EAAE,YAAY,EACnC,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,EAAE,EAAE,EAAE,iBAwBX;YAEa,kBAAkB;IAmDhC,KAAK,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAG1C;YAEa,kBAAkB;CAIjC"}
|
|
@@ -8,29 +8,34 @@ import { ORACLE_VERSION, enrichPublicSimulationError } from '@aztec/pxe/server';
|
|
|
8
8
|
import { ExecutionNoteCache, ExecutionTaggingIndexCache, HashedValuesCache, Oracle, PrivateExecutionOracle, UtilityExecutionOracle, executePrivateFunction, generateSimulatedProvingResult } from '@aztec/pxe/simulator';
|
|
9
9
|
import { ExecutionError, WASMSimulator, createSimulationError, extractCallStack, resolveAssertionMessageFromError, toACVMWitness, witnessMapToFields } from '@aztec/simulator/client';
|
|
10
10
|
import { CppPublicTxSimulator, GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor } from '@aztec/simulator/server';
|
|
11
|
-
import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
11
|
+
import { FunctionCall, FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
|
|
12
12
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
13
13
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
14
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
16
15
|
import { computePartialAddress } from '@aztec/stdlib/contract';
|
|
17
16
|
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
18
17
|
import { computeCalldataHash, computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
|
|
19
18
|
import { PartialPrivateTailPublicInputsForPublic, PrivateKernelTailCircuitPublicInputs, PrivateToPublicAccumulatedData, PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
20
19
|
import { ChonkProof } from '@aztec/stdlib/proofs';
|
|
21
|
-
import {
|
|
20
|
+
import { makeGlobalVariables } from '@aztec/stdlib/testing';
|
|
22
21
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
23
22
|
import { CallContext, HashedValues, PrivateExecutionResult, Tx, TxConstantData, TxContext, TxEffect, TxHash, collectNested } from '@aztec/stdlib/tx';
|
|
24
23
|
import { ForkCheckpoint } from '@aztec/world-state';
|
|
24
|
+
import { DEFAULT_ADDRESS } from '../constants.js';
|
|
25
25
|
import { TXEPublicContractDataSource } from '../util/txe_public_contract_data_source.js';
|
|
26
|
-
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees,
|
|
26
|
+
import { getSingleTxBlockRequestHash, insertTxEffectIntoWorldTrees, makeTXEBlock } from '../utils/block_creation.js';
|
|
27
27
|
export class TXEOracleTopLevelContext {
|
|
28
28
|
stateMachine;
|
|
29
|
-
|
|
29
|
+
contractStore;
|
|
30
|
+
noteStore;
|
|
30
31
|
keyStore;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
addressStore;
|
|
33
|
+
accountStore;
|
|
34
|
+
senderTaggingStore;
|
|
35
|
+
recipientTaggingStore;
|
|
36
|
+
senderAddressBookStore;
|
|
37
|
+
capsuleStore;
|
|
38
|
+
privateEventStore;
|
|
34
39
|
nextBlockTimestamp;
|
|
35
40
|
version;
|
|
36
41
|
chainId;
|
|
@@ -38,13 +43,18 @@ export class TXEOracleTopLevelContext {
|
|
|
38
43
|
isMisc;
|
|
39
44
|
isTxe;
|
|
40
45
|
logger;
|
|
41
|
-
constructor(stateMachine,
|
|
46
|
+
constructor(stateMachine, contractStore, noteStore, keyStore, addressStore, accountStore, senderTaggingStore, recipientTaggingStore, senderAddressBookStore, capsuleStore, privateEventStore, nextBlockTimestamp, version, chainId, authwits){
|
|
42
47
|
this.stateMachine = stateMachine;
|
|
43
|
-
this.
|
|
48
|
+
this.contractStore = contractStore;
|
|
49
|
+
this.noteStore = noteStore;
|
|
44
50
|
this.keyStore = keyStore;
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
51
|
+
this.addressStore = addressStore;
|
|
52
|
+
this.accountStore = accountStore;
|
|
53
|
+
this.senderTaggingStore = senderTaggingStore;
|
|
54
|
+
this.recipientTaggingStore = recipientTaggingStore;
|
|
55
|
+
this.senderAddressBookStore = senderAddressBookStore;
|
|
56
|
+
this.capsuleStore = capsuleStore;
|
|
57
|
+
this.privateEventStore = privateEventStore;
|
|
48
58
|
this.nextBlockTimestamp = nextBlockTimestamp;
|
|
49
59
|
this.version = version;
|
|
50
60
|
this.chainId = chainId;
|
|
@@ -74,6 +84,9 @@ export class TXEOracleTopLevelContext {
|
|
|
74
84
|
module: `${this.logger.module}:debug_log`
|
|
75
85
|
});
|
|
76
86
|
}
|
|
87
|
+
txeGetDefaultAddress() {
|
|
88
|
+
return DEFAULT_ADDRESS;
|
|
89
|
+
}
|
|
77
90
|
async txeGetNextBlockNumber() {
|
|
78
91
|
return BlockNumber(await this.getLastBlockNumber() + 1);
|
|
79
92
|
}
|
|
@@ -84,7 +97,7 @@ export class TXEOracleTopLevelContext {
|
|
|
84
97
|
return (await this.stateMachine.node.getBlockHeader('latest')).globalVariables.timestamp;
|
|
85
98
|
}
|
|
86
99
|
async txeGetLastTxEffects() {
|
|
87
|
-
const block = await this.stateMachine.archiver.
|
|
100
|
+
const block = await this.stateMachine.archiver.getL2Block('latest');
|
|
88
101
|
if (block.body.txEffects.length != 1) {
|
|
89
102
|
// Note that calls like env.mine() will result in blocks with no transactions, hitting this
|
|
90
103
|
throw new Error(`Expected a single transaction in the last block, found ${block.body.txEffects.length}`);
|
|
@@ -96,6 +109,16 @@ export class TXEOracleTopLevelContext {
|
|
|
96
109
|
nullifiers: txEffects.nullifiers
|
|
97
110
|
};
|
|
98
111
|
}
|
|
112
|
+
async txeGetPrivateEvents(selector, contractAddress, scope) {
|
|
113
|
+
return (await this.privateEventStore.getPrivateEvents(selector, {
|
|
114
|
+
contractAddress,
|
|
115
|
+
scopes: [
|
|
116
|
+
scope
|
|
117
|
+
],
|
|
118
|
+
fromBlock: 0,
|
|
119
|
+
toBlock: await this.getLastBlockNumber() + 1
|
|
120
|
+
})).map((e)=>e.packedEvent);
|
|
121
|
+
}
|
|
99
122
|
async txeAdvanceBlocksBy(blocks) {
|
|
100
123
|
this.logger.debug(`time traveling ${blocks} blocks`);
|
|
101
124
|
for(let i = 0; i < blocks; i++){
|
|
@@ -116,32 +139,32 @@ export class TXEOracleTopLevelContext {
|
|
|
116
139
|
if (!secret.equals(Fr.ZERO)) {
|
|
117
140
|
await this.txeAddAccount(artifact, instance, secret);
|
|
118
141
|
} else {
|
|
119
|
-
await this.
|
|
120
|
-
await this.
|
|
142
|
+
await this.contractStore.addContractInstance(instance);
|
|
143
|
+
await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
|
|
121
144
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
122
145
|
}
|
|
123
146
|
}
|
|
124
147
|
async txeAddAccount(artifact, instance, secret) {
|
|
125
148
|
const partialAddress = await computePartialAddress(instance);
|
|
126
149
|
this.logger.debug(`Deployed ${artifact.name} at ${instance.address}`);
|
|
127
|
-
await this.
|
|
128
|
-
await this.
|
|
150
|
+
await this.contractStore.addContractInstance(instance);
|
|
151
|
+
await this.contractStore.addContractArtifact(instance.currentContractClassId, artifact);
|
|
129
152
|
const completeAddress = await this.keyStore.addAccount(secret, partialAddress);
|
|
130
|
-
await this.
|
|
131
|
-
await this.
|
|
153
|
+
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
154
|
+
await this.addressStore.addCompleteAddress(completeAddress);
|
|
132
155
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
133
156
|
return completeAddress;
|
|
134
157
|
}
|
|
135
158
|
async txeCreateAccount(secret) {
|
|
136
|
-
// This is a
|
|
159
|
+
// This is a foot gun !
|
|
137
160
|
const completeAddress = await this.keyStore.addAccount(secret, secret);
|
|
138
|
-
await this.
|
|
139
|
-
await this.
|
|
161
|
+
await this.accountStore.setAccount(completeAddress.address, completeAddress);
|
|
162
|
+
await this.addressStore.addCompleteAddress(completeAddress);
|
|
140
163
|
this.logger.debug(`Created account ${completeAddress.address}`);
|
|
141
164
|
return completeAddress;
|
|
142
165
|
}
|
|
143
166
|
async txeAddAuthWitness(address, messageHash) {
|
|
144
|
-
const account = await this.
|
|
167
|
+
const account = await this.accountStore.getAccount(address);
|
|
145
168
|
const privateKey = await this.keyStore.getMasterSecretKey(account.publicKeys.masterIncomingViewingPublicKey);
|
|
146
169
|
const schnorr = new Schnorr();
|
|
147
170
|
const signature = await schnorr.constructSignature(messageHash.toBuffer(), privateKey);
|
|
@@ -160,39 +183,45 @@ export class TXEOracleTopLevelContext {
|
|
|
160
183
|
txEffect.txHash = new TxHash(new Fr(blockNumber));
|
|
161
184
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
162
185
|
await insertTxEffectIntoWorldTrees(txEffect, forkedWorldTrees);
|
|
163
|
-
const
|
|
186
|
+
const globals = makeGlobalVariables(undefined, {
|
|
164
187
|
blockNumber,
|
|
165
188
|
timestamp: this.nextBlockTimestamp,
|
|
166
189
|
version: this.version,
|
|
167
190
|
chainId: this.chainId
|
|
168
|
-
})
|
|
191
|
+
});
|
|
192
|
+
const block = await makeTXEBlock(forkedWorldTrees, globals, [
|
|
169
193
|
txEffect
|
|
170
|
-
])
|
|
194
|
+
]);
|
|
171
195
|
await forkedWorldTrees.close();
|
|
172
196
|
this.logger.info(`Created block ${blockNumber} with timestamp ${block.header.globalVariables.timestamp}`);
|
|
173
197
|
await this.stateMachine.handleL2Block(block);
|
|
174
198
|
}
|
|
175
199
|
async txePrivateCallNewFlow(from, targetContractAddress = AztecAddress.zero(), functionSelector = FunctionSelector.empty(), args, argsHash = Fr.zero(), isStaticCall = false) {
|
|
176
|
-
this.logger.verbose(`Executing external function ${await this.
|
|
177
|
-
const artifact = await this.
|
|
200
|
+
this.logger.verbose(`Executing external function ${await this.contractStore.getDebugFunctionName(targetContractAddress, functionSelector)}@${targetContractAddress} isStaticCall=${isStaticCall}`);
|
|
201
|
+
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
178
202
|
if (!artifact) {
|
|
179
203
|
const message = functionSelector.equals(await FunctionSelector.fromSignature('verify_private_authwit(Field)')) ? 'Found no account contract artifact for a private authwit check - use `create_contract_account` instead of `create_light_account` for authwit support.' : 'Function Artifact does not exist';
|
|
180
204
|
throw new Error(message);
|
|
181
205
|
}
|
|
206
|
+
// Sync notes before executing private function to discover notes from previous transactions
|
|
207
|
+
const utilityExecutor = async (call)=>{
|
|
208
|
+
await this.executeUtilityCall(call);
|
|
209
|
+
};
|
|
210
|
+
await this.contractStore.syncPrivateState(targetContractAddress, functionSelector, utilityExecutor);
|
|
182
211
|
const blockNumber = await this.txeGetNextBlockNumber();
|
|
183
212
|
const callContext = new CallContext(from, targetContractAddress, functionSelector, isStaticCall);
|
|
184
213
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
185
214
|
const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
|
|
186
215
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
187
216
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
188
|
-
const blockHeader = await this.
|
|
217
|
+
const blockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
189
218
|
const protocolNullifier = await computeProtocolNullifier(getSingleTxBlockRequestHash(blockNumber));
|
|
190
219
|
const noteCache = new ExecutionNoteCache(protocolNullifier);
|
|
191
220
|
const taggingIndexCache = new ExecutionTaggingIndexCache();
|
|
192
221
|
const simulator = new WASMSimulator();
|
|
193
|
-
const privateExecutionOracle = new PrivateExecutionOracle(argsHash, txContext, callContext, /** Header of a block whose state is used during private execution (not the block the transaction is included in). */ blockHeader, /** List of transient auth witnesses to be used during this simulation */ Array.from(this.authwits.values()), /** List of transient auth witnesses to be used during this simulation */ [], HashedValuesCache.create([
|
|
222
|
+
const privateExecutionOracle = new PrivateExecutionOracle(argsHash, txContext, callContext, /** Header of a block whose state is used during private execution (not the block the transaction is included in). */ blockHeader, utilityExecutor, /** List of transient auth witnesses to be used during this simulation */ Array.from(this.authwits.values()), /** List of transient auth witnesses to be used during this simulation */ [], HashedValuesCache.create([
|
|
194
223
|
new HashedValues(args, argsHash)
|
|
195
|
-
]), noteCache, taggingIndexCache, this.
|
|
224
|
+
]), noteCache, taggingIndexCache, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.senderTaggingStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore, 0, 1, undefined, undefined, /**
|
|
196
225
|
* In TXE, the typical transaction entrypoint is skipped, so we need to simulate the actions that such a
|
|
197
226
|
* contract would perform, including setting senderForTags.
|
|
198
227
|
*/ from, simulator);
|
|
@@ -221,7 +250,7 @@ export class TXEOracleTopLevelContext {
|
|
|
221
250
|
// can either be the first nullifier in the tx or the hash of the initial tx request
|
|
222
251
|
// if there are none.
|
|
223
252
|
const nonceGenerator = result.firstNullifier.equals(Fr.ZERO) ? protocolNullifier : result.firstNullifier;
|
|
224
|
-
const { publicInputs } = await generateSimulatedProvingResult(result, nonceGenerator, this.
|
|
253
|
+
const { publicInputs } = await generateSimulatedProvingResult(result, nonceGenerator, this.contractStore);
|
|
225
254
|
const globals = makeGlobalVariables();
|
|
226
255
|
globals.blockNumber = blockNumber;
|
|
227
256
|
globals.timestamp = this.nextBlockTimestamp;
|
|
@@ -229,7 +258,7 @@ export class TXEOracleTopLevelContext {
|
|
|
229
258
|
globals.version = this.version;
|
|
230
259
|
globals.gasFees = GasFees.empty();
|
|
231
260
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
232
|
-
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.
|
|
261
|
+
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
|
|
233
262
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
234
263
|
const config = PublicSimulatorConfig.from({
|
|
235
264
|
skipFeeEnforcement: true,
|
|
@@ -259,7 +288,7 @@ export class TXEOracleTopLevelContext {
|
|
|
259
288
|
} else if (!processedTx.revertCode.isOK()) {
|
|
260
289
|
if (processedTx.revertReason) {
|
|
261
290
|
try {
|
|
262
|
-
await enrichPublicSimulationError(processedTx.revertReason, this.
|
|
291
|
+
await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
|
|
263
292
|
// eslint-disable-next-line no-empty
|
|
264
293
|
} catch {}
|
|
265
294
|
throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
|
|
@@ -281,22 +310,21 @@ export class TXEOracleTopLevelContext {
|
|
|
281
310
|
txEffect.txHash = new TxHash(new Fr(blockNumber));
|
|
282
311
|
const l1ToL2Messages = Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero);
|
|
283
312
|
await forkedWorldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2Messages);
|
|
284
|
-
const
|
|
313
|
+
const l2Block = await makeTXEBlock(forkedWorldTrees, globals, [
|
|
285
314
|
txEffect
|
|
286
315
|
]);
|
|
287
|
-
const l2Block = new L2Block(makeAppendOnlyTreeSnapshot(), await makeTXEBlockHeader(forkedWorldTrees, globals), body);
|
|
288
316
|
await this.stateMachine.handleL2Block(l2Block);
|
|
289
317
|
await forkedWorldTrees.close();
|
|
290
318
|
return executionResult.returnValues ?? [];
|
|
291
319
|
}
|
|
292
320
|
async txePublicCallNewFlow(from, targetContractAddress, calldata, isStaticCall) {
|
|
293
|
-
this.logger.verbose(`Executing public function ${await this.
|
|
321
|
+
this.logger.verbose(`Executing public function ${await this.contractStore.getDebugFunctionName(targetContractAddress, FunctionSelector.fromField(calldata[0]))}@${targetContractAddress} isStaticCall=${isStaticCall}`);
|
|
294
322
|
const blockNumber = await this.txeGetNextBlockNumber();
|
|
295
323
|
const gasLimits = new Gas(DEFAULT_DA_GAS_LIMIT, DEFAULT_L2_GAS_LIMIT);
|
|
296
324
|
const teardownGasLimits = new Gas(DEFAULT_TEARDOWN_DA_GAS_LIMIT, DEFAULT_TEARDOWN_L2_GAS_LIMIT);
|
|
297
325
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, GasFees.empty(), GasFees.empty());
|
|
298
326
|
const txContext = new TxContext(this.chainId, this.version, gasSettings);
|
|
299
|
-
const anchorBlockHeader = await this.
|
|
327
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
300
328
|
const calldataHash = await computeCalldataHash(calldata);
|
|
301
329
|
const calldataHashedValues = new HashedValues(calldata, calldataHash);
|
|
302
330
|
const globals = makeGlobalVariables();
|
|
@@ -306,7 +334,7 @@ export class TXEOracleTopLevelContext {
|
|
|
306
334
|
globals.version = this.version;
|
|
307
335
|
globals.gasFees = GasFees.empty();
|
|
308
336
|
const forkedWorldTrees = await this.stateMachine.synchronizer.nativeWorldStateService.fork();
|
|
309
|
-
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.
|
|
337
|
+
const contractsDB = new PublicContractsDB(new TXEPublicContractDataSource(blockNumber, this.contractStore));
|
|
310
338
|
const guardedMerkleTrees = new GuardedMerkleTreeOperations(forkedWorldTrees);
|
|
311
339
|
const config = PublicSimulatorConfig.from({
|
|
312
340
|
skipFeeEnforcement: true,
|
|
@@ -352,7 +380,7 @@ export class TXEOracleTopLevelContext {
|
|
|
352
380
|
} else if (!processedTx.revertCode.isOK()) {
|
|
353
381
|
if (processedTx.revertReason) {
|
|
354
382
|
try {
|
|
355
|
-
await enrichPublicSimulationError(processedTx.revertReason, this.
|
|
383
|
+
await enrichPublicSimulationError(processedTx.revertReason, this.contractStore, this.logger);
|
|
356
384
|
// eslint-disable-next-line no-empty
|
|
357
385
|
} catch {}
|
|
358
386
|
throw new Error(`Contract execution has reverted: ${processedTx.revertReason.getMessage()}`);
|
|
@@ -375,25 +403,27 @@ export class TXEOracleTopLevelContext {
|
|
|
375
403
|
txEffect.txHash = new TxHash(new Fr(blockNumber));
|
|
376
404
|
const l1ToL2Messages = Array(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).fill(0).map(Fr.zero);
|
|
377
405
|
await forkedWorldTrees.appendLeaves(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, l1ToL2Messages);
|
|
378
|
-
const
|
|
406
|
+
const l2Block = await makeTXEBlock(forkedWorldTrees, globals, [
|
|
379
407
|
txEffect
|
|
380
408
|
]);
|
|
381
|
-
const l2Block = new L2Block(makeAppendOnlyTreeSnapshot(), await makeTXEBlockHeader(forkedWorldTrees, globals), body);
|
|
382
409
|
await this.stateMachine.handleL2Block(l2Block);
|
|
383
410
|
await forkedWorldTrees.close();
|
|
384
411
|
return returnValues ?? [];
|
|
385
412
|
}
|
|
386
413
|
async txeSimulateUtilityFunction(targetContractAddress, functionSelector, args) {
|
|
387
|
-
const artifact = await this.
|
|
414
|
+
const artifact = await this.contractStore.getFunctionArtifact(targetContractAddress, functionSelector);
|
|
388
415
|
if (!artifact) {
|
|
389
416
|
throw new Error(`Cannot call ${functionSelector} as there is no artifact found at ${targetContractAddress}.`);
|
|
390
417
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
418
|
+
// Sync notes before executing utility function to discover notes from previous transactions
|
|
419
|
+
await this.contractStore.syncPrivateState(targetContractAddress, functionSelector, async (call)=>{
|
|
420
|
+
await this.executeUtilityCall(call);
|
|
421
|
+
});
|
|
422
|
+
const call = new FunctionCall(artifact.name, targetContractAddress, functionSelector, FunctionType.UTILITY, false, false, args, []);
|
|
423
|
+
return this.executeUtilityCall(call);
|
|
424
|
+
}
|
|
425
|
+
async executeUtilityCall(call) {
|
|
426
|
+
const entryPointArtifact = await this.contractStore.getFunctionArtifactWithDebugMetadata(call.to, call.selector);
|
|
397
427
|
if (entryPointArtifact.functionType !== FunctionType.UTILITY) {
|
|
398
428
|
throw new Error(`Cannot run ${entryPointArtifact.functionType} function as utility`);
|
|
399
429
|
}
|
|
@@ -402,8 +432,9 @@ export class TXEOracleTopLevelContext {
|
|
|
402
432
|
selector: call.selector
|
|
403
433
|
});
|
|
404
434
|
try {
|
|
405
|
-
const
|
|
406
|
-
const
|
|
435
|
+
const anchorBlockHeader = await this.stateMachine.anchorBlockStore.getBlockHeader();
|
|
436
|
+
const oracle = new UtilityExecutionOracle(call.to, [], [], anchorBlockHeader, this.contractStore, this.noteStore, this.keyStore, this.addressStore, this.stateMachine.node, this.stateMachine.anchorBlockStore, this.recipientTaggingStore, this.senderAddressBookStore, this.capsuleStore, this.privateEventStore);
|
|
437
|
+
const acirExecutionResult = await new WASMSimulator().executeUserCircuit(toACVMWitness(0, call.args), entryPointArtifact, new Oracle(oracle).toACIRCallback()).catch((err)=>{
|
|
407
438
|
err.message = resolveAssertionMessageFromError(err, entryPointArtifact);
|
|
408
439
|
throw new ExecutionError(err.message, {
|
|
409
440
|
contractAddress: call.to,
|