@aztec/simulator 0.79.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/common/db_interfaces.d.ts +24 -5
- package/dest/common/db_interfaces.d.ts.map +1 -1
- package/dest/common/debug_fn_name.d.ts +2 -2
- package/dest/common/debug_fn_name.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.d.ts +19 -0
- package/dest/private/acvm/deserialize.d.ts.map +1 -1
- package/dest/private/acvm/deserialize.js +29 -0
- package/dest/private/acvm/oracle/oracle.d.ts +2 -0
- package/dest/private/acvm/oracle/oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/oracle.js +18 -3
- package/dest/private/acvm/oracle/typed_oracle.d.ts +2 -1
- package/dest/private/acvm/oracle/typed_oracle.d.ts.map +1 -1
- package/dest/private/acvm/oracle/typed_oracle.js +3 -0
- package/dest/private/acvm/serialize.d.ts +11 -0
- package/dest/private/acvm/serialize.d.ts.map +1 -1
- package/dest/private/acvm/serialize.js +27 -0
- package/dest/private/execution_data_provider.d.ts +12 -4
- package/dest/private/execution_data_provider.d.ts.map +1 -1
- package/dest/private/private_execution_oracle.d.ts.map +1 -1
- package/dest/private/private_execution_oracle.js +1 -1
- package/dest/private/unconstrained_execution_oracle.d.ts +4 -2
- package/dest/private/unconstrained_execution_oracle.d.ts.map +1 -1
- package/dest/private/unconstrained_execution_oracle.js +6 -2
- package/dest/public/avm/fixtures/avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/avm_simulation_tester.js +5 -5
- package/dest/public/avm/fixtures/index.d.ts +6 -6
- package/dest/public/avm/fixtures/index.d.ts.map +1 -1
- package/dest/public/avm/fixtures/index.js +22 -18
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts +1 -2
- package/dest/public/avm/fixtures/simple_contract_data_source.d.ts.map +1 -1
- package/dest/public/avm/fixtures/simple_contract_data_source.js +0 -3
- package/dest/public/avm/journal/journal.d.ts +16 -70
- package/dest/public/avm/journal/journal.d.ts.map +1 -1
- package/dest/public/avm/journal/journal.js +88 -210
- package/dest/public/avm/journal/nullifiers.d.ts +2 -2
- package/dest/public/avm/journal/nullifiers.d.ts.map +1 -1
- package/dest/public/avm/journal/public_storage.d.ts +2 -2
- package/dest/public/avm/journal/public_storage.d.ts.map +1 -1
- package/dest/public/avm/test_utils.d.ts +10 -13
- package/dest/public/avm/test_utils.d.ts.map +1 -1
- package/dest/public/avm/test_utils.js +7 -12
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +3 -3
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +10 -9
- package/dest/public/hinting_db_sources.d.ts +19 -0
- package/dest/public/hinting_db_sources.d.ts.map +1 -0
- package/dest/public/hinting_db_sources.js +36 -0
- package/dest/public/public_db_sources.d.ts +45 -21
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +79 -24
- package/dest/public/public_processor/public_processor.d.ts +5 -5
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +21 -20
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +9 -14
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +15 -19
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +9 -6
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +28 -14
- package/dest/public/side_effect_trace.d.ts +6 -22
- package/dest/public/side_effect_trace.d.ts.map +1 -1
- package/dest/public/side_effect_trace.js +11 -70
- package/dest/public/side_effect_trace_interface.d.ts +5 -19
- package/dest/public/side_effect_trace_interface.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/common/db_interfaces.ts +26 -5
- package/src/common/debug_fn_name.ts +2 -2
- package/src/private/acvm/deserialize.ts +33 -0
- package/src/private/acvm/oracle/oracle.ts +37 -3
- package/src/private/acvm/oracle/typed_oracle.ts +5 -1
- package/src/private/acvm/serialize.ts +28 -0
- package/src/private/execution_data_provider.ts +13 -4
- package/src/private/private_execution_oracle.ts +5 -1
- package/src/private/unconstrained_execution_oracle.ts +12 -3
- package/src/public/avm/fixtures/avm_simulation_tester.ts +8 -5
- package/src/public/avm/fixtures/index.ts +38 -24
- package/src/public/avm/fixtures/simple_contract_data_source.ts +1 -10
- package/src/public/avm/journal/journal.ts +119 -353
- package/src/public/avm/journal/nullifiers.ts +2 -2
- package/src/public/avm/journal/public_storage.ts +2 -2
- package/src/public/avm/test_utils.ts +20 -29
- package/src/public/fixtures/public_tx_simulation_tester.ts +9 -12
- package/src/public/hinting_db_sources.ts +71 -0
- package/src/public/public_db_sources.ts +131 -29
- package/src/public/public_processor/public_processor.ts +22 -21
- package/src/public/public_tx_simulator/public_tx_context.ts +30 -38
- package/src/public/public_tx_simulator/public_tx_simulator.ts +47 -17
- package/src/public/side_effect_trace.ts +8 -172
- package/src/public/side_effect_trace_interface.ts +4 -55
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/index.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/index.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAEjC,MAAM,wBAAwB,CAA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CAAyC,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAKzG;AAED,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAOjF;AAED,wBAAgB,iCAAiC,CAAC,YAAY,EAAE,MAAM,GAAG,gBAAgB,CAOxF;AAED,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED,wBAAgB,iCAAiC,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED,wBAAgB,sCAAsC,CACpD,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,eAAe,EAC7B,MAAM,EAAE,EAAE,EAAE,GACX,MAAM,GAAG,SAAS,CAEpB;AAED,wBAAgB,6CAA6C,CAC3D,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,eAAe,EAC7B,MAAM,EAAE,EAAE,EAAE,GACX,MAAM,GAAG,SAAS,CAWpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,8BAA8B,CAClD,eAAe,EAAE,GAAG,EAAE,EACtB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,IAAI,SAAI,EACR,uBAAuB,CAAC,EAAE,EAAE,GAC3B,OAAO,CAAC;IACT,aAAa,EAAE,mBAAmB,CAAC;IACnC,gBAAgB,EAAE,2BAA2B,CAAC;IAC9C,wBAAwB,EAAE,EAAE,CAAC;CAC9B,CAAC,CA+BD"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { DEPLOYER_CONTRACT_ADDRESS, MAX_L2_GAS_PER_TX_PUBLIC_PORTION, PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
4
|
+
import { AvmGadgetsTestContract } from '@aztec/noir-contracts.js/AvmGadgetsTest';
|
|
5
|
+
import { AvmTestContract } from '@aztec/noir-contracts.js/AvmTest';
|
|
6
|
+
import { FunctionSelector, getAllFunctionAbis } from '@aztec/stdlib/abi';
|
|
7
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import { computeInitializationHash } from '@aztec/stdlib/contract';
|
|
9
9
|
import { isNoirCallStackUnresolved } from '@aztec/stdlib/errors';
|
|
10
10
|
import { GasFees } from '@aztec/stdlib/gas';
|
|
11
11
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
12
|
+
import { deriveKeys } from '@aztec/stdlib/keys';
|
|
12
13
|
import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec/stdlib/testing';
|
|
13
14
|
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
14
15
|
import { strict as assert } from 'assert';
|
|
15
16
|
import { mock } from 'jest-mock-extended';
|
|
16
17
|
import merge from 'lodash.merge';
|
|
17
18
|
import { resolveAssertionMessageFromRevertData, traverseCauseChain } from '../../../common/index.js';
|
|
19
|
+
import { DEFAULT_BLOCK_NUMBER } from '../../fixtures/public_tx_simulation_tester.js';
|
|
18
20
|
import { AvmContext } from '../avm_context.js';
|
|
19
21
|
import { AvmExecutionEnvironment } from '../avm_execution_environment.js';
|
|
20
22
|
import { AvmMachineState } from '../avm_machine_state.js';
|
|
21
23
|
import { Field, Uint8, Uint32, Uint64 } from '../avm_memory_types.js';
|
|
22
24
|
import { AvmSimulator } from '../avm_simulator.js';
|
|
23
25
|
import { AvmPersistableStateManager } from '../journal/journal.js';
|
|
24
|
-
import { NullifierManager } from '../journal/nullifiers.js';
|
|
25
|
-
import { PublicStorage } from '../journal/public_storage.js';
|
|
26
26
|
export const PUBLIC_DISPATCH_FN_NAME = 'public_dispatch';
|
|
27
27
|
/**
|
|
28
28
|
* Create a new AVM context with default values.
|
|
@@ -32,8 +32,8 @@ export const PUBLIC_DISPATCH_FN_NAME = 'public_dispatch';
|
|
|
32
32
|
return ctx;
|
|
33
33
|
}
|
|
34
34
|
/** Creates an empty state manager with mocked host storage. */ export function initPersistableStateManager(overrides) {
|
|
35
|
-
const
|
|
36
|
-
return new AvmPersistableStateManager(
|
|
35
|
+
const treesDB = overrides?.treesDB || mock();
|
|
36
|
+
return new AvmPersistableStateManager(treesDB, overrides?.contractsDB || mock(), overrides?.trace || mock(), overrides?.firstNullifier || new Fr(27), overrides?.blockNumber || DEFAULT_BLOCK_NUMBER, overrides?.doMerkleOperations || false, overrides?.publicStorage, overrides?.nullifiers);
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Create an empty instance of the Execution Environment where all values are zero, unless overridden in the overrides object
|
|
@@ -79,7 +79,7 @@ export function randomMemoryFields(length) {
|
|
|
79
79
|
].map((_)=>new Field(Fr.random()));
|
|
80
80
|
}
|
|
81
81
|
export function getFunctionSelector(functionName, contractArtifact) {
|
|
82
|
-
const fnArtifact = contractArtifact.
|
|
82
|
+
const fnArtifact = getAllFunctionAbis(contractArtifact).find((f)=>f.name === functionName);
|
|
83
83
|
assert(!!fnArtifact, `Function ${functionName} not found in ${contractArtifact.name}`);
|
|
84
84
|
const params = fnArtifact.parameters;
|
|
85
85
|
return FunctionSelector.fromNameAndParameters(fnArtifact.name, params);
|
|
@@ -87,7 +87,8 @@ export function getFunctionSelector(functionName, contractArtifact) {
|
|
|
87
87
|
export function getContractFunctionArtifact(functionName, contractArtifact) {
|
|
88
88
|
const artifact = contractArtifact.functions.find((f)=>f.name === functionName);
|
|
89
89
|
if (!artifact) {
|
|
90
|
-
|
|
90
|
+
const abi = getAllFunctionAbis(contractArtifact).find((f)=>f.name === functionName);
|
|
91
|
+
return abi || undefined;
|
|
91
92
|
}
|
|
92
93
|
return artifact;
|
|
93
94
|
}
|
|
@@ -95,28 +96,28 @@ export function resolveContractAssertionMessage(functionName, revertReason, outp
|
|
|
95
96
|
traverseCauseChain(revertReason, (cause)=>{
|
|
96
97
|
revertReason = cause;
|
|
97
98
|
});
|
|
98
|
-
const functionArtifact = contractArtifact.
|
|
99
|
+
const functionArtifact = getAllFunctionAbis(contractArtifact).find((f)=>f.name === functionName);
|
|
99
100
|
if (!functionArtifact || !revertReason.noirCallStack || !isNoirCallStackUnresolved(revertReason.noirCallStack)) {
|
|
100
101
|
return undefined;
|
|
101
102
|
}
|
|
102
103
|
return resolveAssertionMessageFromRevertData(output, functionArtifact);
|
|
103
104
|
}
|
|
104
105
|
export function getAvmTestContractFunctionSelector(functionName) {
|
|
105
|
-
return getFunctionSelector(functionName,
|
|
106
|
+
return getFunctionSelector(functionName, AvmTestContract.artifactForPublic);
|
|
106
107
|
}
|
|
107
108
|
export function getAvmGadgetsTestContractFunctionSelector(functionName) {
|
|
108
|
-
const artifact =
|
|
109
|
+
const artifact = getAllFunctionAbis(AvmGadgetsTestContract.artifactForPublic).find((f)=>f.name === functionName);
|
|
109
110
|
assert(!!artifact, `Function ${functionName} not found in AvmGadgetsTestContractArtifact`);
|
|
110
111
|
const params = artifact.parameters;
|
|
111
112
|
return FunctionSelector.fromNameAndParameters(artifact.name, params);
|
|
112
113
|
}
|
|
113
114
|
export function getAvmTestContractArtifact(functionName) {
|
|
114
|
-
const artifact = getContractFunctionArtifact(functionName,
|
|
115
|
+
const artifact = getContractFunctionArtifact(functionName, AvmTestContract.artifactForPublic);
|
|
115
116
|
assert(!!artifact?.bytecode, `No bytecode found for function ${functionName}. Try re-running bootstrap.sh on the repository root.`);
|
|
116
117
|
return artifact;
|
|
117
118
|
}
|
|
118
119
|
export function getAvmGadgetsTestContractArtifact(functionName) {
|
|
119
|
-
const artifact =
|
|
120
|
+
const artifact = AvmGadgetsTestContract.artifactForPublic.functions.find((f)=>f.name === functionName);
|
|
120
121
|
assert(!!artifact?.bytecode, `No bytecode found for function ${functionName}. Try re-running bootstrap.sh on the repository root.`);
|
|
121
122
|
return artifact;
|
|
122
123
|
}
|
|
@@ -129,13 +130,13 @@ export function getAvmGadgetsTestContractBytecode(functionName) {
|
|
|
129
130
|
return artifact.bytecode;
|
|
130
131
|
}
|
|
131
132
|
export function resolveAvmTestContractAssertionMessage(functionName, revertReason, output) {
|
|
132
|
-
return resolveContractAssertionMessage(functionName, revertReason, output,
|
|
133
|
+
return resolveContractAssertionMessage(functionName, revertReason, output, AvmTestContract.artifactForPublic);
|
|
133
134
|
}
|
|
134
135
|
export function resolveAvmGadgetsTestContractAssertionMessage(functionName, revertReason, output) {
|
|
135
136
|
traverseCauseChain(revertReason, (cause)=>{
|
|
136
137
|
revertReason = cause;
|
|
137
138
|
});
|
|
138
|
-
const functionArtifact =
|
|
139
|
+
const functionArtifact = AvmGadgetsTestContract.artifactForPublic.functions.find((f)=>f.name === functionName);
|
|
139
140
|
if (!functionArtifact || !revertReason.noirCallStack || !isNoirCallStackUnresolved(revertReason.noirCallStack)) {
|
|
140
141
|
return undefined;
|
|
141
142
|
}
|
|
@@ -157,14 +158,17 @@ export function resolveAvmGadgetsTestContractAssertionMessage(functionName, reve
|
|
|
157
158
|
selector: new FunctionSelector(PUBLIC_DISPATCH_SELECTOR)
|
|
158
159
|
});
|
|
159
160
|
const constructorAbi = getContractFunctionArtifact('constructor', contractArtifact);
|
|
161
|
+
const { publicKeys } = await deriveKeys(Fr.random());
|
|
160
162
|
const initializationHash = await computeInitializationHash(constructorAbi, constructorArgs);
|
|
161
163
|
const contractInstance = originalContractClassId === undefined ? await makeContractInstanceFromClassId(contractClass.id, seed, {
|
|
162
164
|
deployer,
|
|
163
|
-
initializationHash
|
|
165
|
+
initializationHash,
|
|
166
|
+
publicKeys
|
|
164
167
|
}) : await makeContractInstanceFromClassId(originalContractClassId, seed, {
|
|
165
168
|
deployer,
|
|
166
169
|
initializationHash,
|
|
167
|
-
currentClassId: contractClass.id
|
|
170
|
+
currentClassId: contractClass.id,
|
|
171
|
+
publicKeys
|
|
168
172
|
});
|
|
169
173
|
const contractAddressNullifier = await siloNullifier(AztecAddress.fromNumber(DEPLOYER_CONTRACT_ADDRESS), contractInstance.address.toField());
|
|
170
174
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { 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, ContractDataSource, ContractInstanceWithAddress
|
|
4
|
+
import type { ContractClassPublic, ContractDataSource, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
/**
|
|
6
6
|
* This class is used during public/avm testing to function as a database of
|
|
7
7
|
* contract contract classes and instances. Tests can populate it with classes
|
|
@@ -20,7 +20,6 @@ export declare class SimpleContractDataSource implements ContractDataSource {
|
|
|
20
20
|
*/
|
|
21
21
|
addNewContract(contractArtifact: ContractArtifact, contractClass: ContractClassPublic, contractInstance: ContractInstanceWithAddress): Promise<void>;
|
|
22
22
|
addContractArtifact(classId: Fr, artifact: ContractArtifact): void;
|
|
23
|
-
getPublicFunction(_address: AztecAddress, _selector: FunctionSelector): Promise<PublicFunction>;
|
|
24
23
|
getBlockNumber(): Promise<number>;
|
|
25
24
|
getContractClass(id: Fr): Promise<ContractClassPublic | undefined>;
|
|
26
25
|
getBytecodeCommitment(_id: Fr): Promise<Fr | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple_contract_data_source.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/simple_contract_data_source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,EAAE,KAAK,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"simple_contract_data_source.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/fixtures/simple_contract_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EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhG,gBAAgB,CAAC,aAAa,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnE,mBAAmB,CAAC,gBAAgB,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC;CAIlF"}
|
|
@@ -29,9 +29,6 @@ import { PUBLIC_DISPATCH_FN_NAME } from './index.js';
|
|
|
29
29
|
}
|
|
30
30
|
/////////////////////////////////////////////////////////////
|
|
31
31
|
// ContractDataSource function implementations
|
|
32
|
-
getPublicFunction(_address, _selector) {
|
|
33
|
-
throw new Error('Method not implemented.');
|
|
34
|
-
}
|
|
35
32
|
getBlockNumber() {
|
|
36
33
|
throw new Error('Method not implemented.');
|
|
37
34
|
}
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
-
import type { IndexedTreeLeafPreimage } from '@aztec/foundation/trees';
|
|
5
|
-
import { AvmPublicDataReadTreeHint } from '@aztec/stdlib/avm';
|
|
6
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
5
|
import { SerializableContractInstance } from '@aztec/stdlib/contract';
|
|
8
6
|
import type { ContractClassWithCommitment } from '@aztec/stdlib/contract';
|
|
9
|
-
import type { IndexedTreeId, MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
10
7
|
import type { PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
11
|
-
import {
|
|
12
|
-
import type {
|
|
8
|
+
import type { PublicTreesDB } from '../../../public/public_db_sources.js';
|
|
9
|
+
import type { PublicContractsDBInterface } from '../../../server.js';
|
|
13
10
|
import type { PublicSideEffectTraceInterface } from '../../side_effect_trace_interface.js';
|
|
14
11
|
import type { AvmExecutionEnvironment } from '../avm_execution_environment.js';
|
|
15
12
|
import { NullifierManager } from './nullifiers.js';
|
|
16
13
|
import { PublicStorage } from './public_storage.js';
|
|
17
|
-
/**
|
|
18
|
-
* The result of fetching a leaf from an indexed tree. Contains the preimage and wether the leaf was already present
|
|
19
|
-
* or it's a low leaf.
|
|
20
|
-
*/
|
|
21
|
-
type GetLeafResult<T extends IndexedTreeLeafPreimage> = {
|
|
22
|
-
preimage: T;
|
|
23
|
-
leafOrLowLeafIndex: bigint;
|
|
24
|
-
alreadyPresent: boolean;
|
|
25
|
-
};
|
|
26
14
|
/**
|
|
27
15
|
* A class to manage persistable AVM state for contract calls.
|
|
28
16
|
* Maintains a cache of the current world state,
|
|
@@ -33,36 +21,25 @@ type GetLeafResult<T extends IndexedTreeLeafPreimage> = {
|
|
|
33
21
|
* Manages merging of successful/reverted child state into current state.
|
|
34
22
|
*/
|
|
35
23
|
export declare class AvmPersistableStateManager {
|
|
36
|
-
|
|
37
|
-
private readonly
|
|
38
|
-
|
|
39
|
-
readonly
|
|
40
|
-
|
|
24
|
+
private readonly treesDB;
|
|
25
|
+
private readonly contractsDB;
|
|
26
|
+
private readonly trace;
|
|
27
|
+
private readonly firstNullifier;
|
|
28
|
+
private readonly blockNumber;
|
|
29
|
+
private readonly doMerkleOperations;
|
|
41
30
|
private readonly publicStorage;
|
|
42
|
-
/** Nullifier set, including cached/recently-emitted nullifiers */
|
|
43
31
|
private readonly nullifiers;
|
|
44
|
-
private readonly doMerkleOperations;
|
|
45
|
-
/** DB interface for merkle tree operations */
|
|
46
|
-
db: MerkleTreeWriteOperations;
|
|
47
|
-
readonly firstNullifier: Fr;
|
|
48
32
|
private readonly log;
|
|
49
33
|
/** Make sure a forked state is never merged twice. */
|
|
50
34
|
private alreadyMergedIntoParent;
|
|
51
|
-
constructor(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/** Side effect trace */
|
|
55
|
-
trace: PublicSideEffectTraceInterface,
|
|
56
|
-
/** Public storage, including cached writes */
|
|
57
|
-
publicStorage: PublicStorage,
|
|
58
|
-
/** Nullifier set, including cached/recently-emitted nullifiers */
|
|
59
|
-
nullifiers: NullifierManager, doMerkleOperations: boolean,
|
|
60
|
-
/** DB interface for merkle tree operations */
|
|
61
|
-
db: MerkleTreeWriteOperations, firstNullifier: Fr);
|
|
35
|
+
constructor(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, trace: PublicSideEffectTraceInterface, firstNullifier: Fr, // Needed for note hashes.
|
|
36
|
+
blockNumber: number, // Needed for contract updates.
|
|
37
|
+
doMerkleOperations?: boolean, publicStorage?: PublicStorage, nullifiers?: NullifierManager);
|
|
62
38
|
/**
|
|
63
39
|
* Create a new state manager
|
|
64
40
|
*/
|
|
65
|
-
static create(
|
|
41
|
+
static create(treesDB: PublicTreesDB, contractsDB: PublicContractsDBInterface, trace: PublicSideEffectTraceInterface, doMerkleOperations: boolean | undefined, firstNullifier: Fr, blockNumber: number): AvmPersistableStateManager;
|
|
42
|
+
deprecatedGetTreesForPIGeneration(): PublicTreesDB;
|
|
66
43
|
/**
|
|
67
44
|
* Create a new state manager forked from this one
|
|
68
45
|
*/
|
|
@@ -85,27 +62,13 @@ export declare class AvmPersistableStateManager {
|
|
|
85
62
|
*/
|
|
86
63
|
writeStorage(contractAddress: AztecAddress, slot: Fr, value: Fr, protocolWrite?: boolean): Promise<void>;
|
|
87
64
|
/**
|
|
88
|
-
* Read from public storage
|
|
65
|
+
* Read from public storage.
|
|
89
66
|
*
|
|
90
67
|
* @param contractAddress - the address of the contract whose storage is being read from
|
|
91
68
|
* @param slot - the slot in the contract's storage being read from
|
|
92
69
|
* @returns the latest value written to slot, or 0 if never written to before
|
|
93
70
|
*/
|
|
94
71
|
readStorage(contractAddress: AztecAddress, slot: Fr): Promise<Fr>;
|
|
95
|
-
getPublicDataMembership(contractAddress: AztecAddress, slot: Fr): Promise<{
|
|
96
|
-
value: Fr;
|
|
97
|
-
leafPreimage: PublicDataTreeLeafPreimage;
|
|
98
|
-
leafIndex: Fr;
|
|
99
|
-
leafPath: Fr[];
|
|
100
|
-
}>;
|
|
101
|
-
/**
|
|
102
|
-
* Read from public storage, don't trace the read.
|
|
103
|
-
*
|
|
104
|
-
* @param contractAddress - the address of the contract whose storage is being read from
|
|
105
|
-
* @param slot - the slot in the contract's storage being read from
|
|
106
|
-
* @returns the latest value written to slot, or 0 if never written to before
|
|
107
|
-
*/
|
|
108
|
-
peekStorage(contractAddress: AztecAddress, slot: Fr): Promise<Fr>;
|
|
109
72
|
/**
|
|
110
73
|
* Check if a note hash exists at the given leaf index, trace the check.
|
|
111
74
|
*
|
|
@@ -137,18 +100,6 @@ export declare class AvmPersistableStateManager {
|
|
|
137
100
|
* @returns exists - whether the nullifier exists in the nullifier set
|
|
138
101
|
*/
|
|
139
102
|
checkNullifierExists(contractAddress: AztecAddress, nullifier: Fr): Promise<boolean>;
|
|
140
|
-
/**
|
|
141
|
-
* Helper to get membership information for a siloed nullifier when checking its existence.
|
|
142
|
-
* Optionally trace the nullifier check.
|
|
143
|
-
*
|
|
144
|
-
* @param siloedNullifier - the siloed nullifier to get membership information for
|
|
145
|
-
* @returns
|
|
146
|
-
* - exists - whether the nullifier exists in the nullifier set
|
|
147
|
-
* - leafOrLowLeafPreimage - the preimage of the nullifier leaf or its low-leaf if it doesn't exist
|
|
148
|
-
* - leafOrLowLeafIndex - the leaf index of the nullifier leaf or its low-leaf if it doesn't exist
|
|
149
|
-
* - leafOrLowLeafPath - the sibling path of the nullifier leaf or its low-leaf if it doesn't exist
|
|
150
|
-
*/
|
|
151
|
-
private getNullifierMembership;
|
|
152
103
|
/**
|
|
153
104
|
* Write a nullifier to the nullifier set, trace the write.
|
|
154
105
|
* @param contractAddress - address of the contract that the nullifier is associated with
|
|
@@ -187,6 +138,7 @@ export declare class AvmPersistableStateManager {
|
|
|
187
138
|
* @returns the contract instance or undefined if it does not exist.
|
|
188
139
|
*/
|
|
189
140
|
getContractInstance(contractAddress: AztecAddress): Promise<SerializableContractInstance | undefined>;
|
|
141
|
+
private checkContractUpdateInformation;
|
|
190
142
|
/**
|
|
191
143
|
* Get a contract class.
|
|
192
144
|
* @param classId - class id to retrieve.
|
|
@@ -197,13 +149,7 @@ export declare class AvmPersistableStateManager {
|
|
|
197
149
|
* Get a contract's bytecode from the contracts DB, also trace the contract class and instance indirectly.
|
|
198
150
|
*/
|
|
199
151
|
getBytecode(contractAddress: AztecAddress): Promise<Buffer | undefined>;
|
|
200
|
-
|
|
201
|
-
updateMembership: AvmPublicDataReadTreeHint;
|
|
202
|
-
updatePreimage: Fr[];
|
|
203
|
-
}>;
|
|
204
|
-
traceEnqueuedCall(publicCallRequest: PublicCallRequest, calldata: Fr[], reverted: boolean): void;
|
|
152
|
+
traceEnqueuedCall(publicCallRequest: PublicCallRequest): void;
|
|
205
153
|
getPublicFunctionDebugName(avmEnvironment: AvmExecutionEnvironment): Promise<string>;
|
|
206
|
-
getLeafOrLowLeafInfo<ID extends IndexedTreeId, T extends IndexedTreeLeafPreimage>(treeId: ID, key: bigint): Promise<GetLeafResult<T>>;
|
|
207
154
|
}
|
|
208
|
-
export {};
|
|
209
155
|
//# sourceMappingURL=journal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/journal/journal.ts"],"names":[],"mappings":";;AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/journal/journal.ts"],"names":[],"mappings":";;AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAK9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,EAAE,2BAA2B,EAA+B,MAAM,wBAAwB,CAAC;AAQvG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAO9D,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