@aztec/simulator 0.0.1-commit.7b97ef96e → 0.0.1-commit.7cbc774
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/private/acvm_wasm.d.ts +1 -1
- package/dest/private/acvm_wasm.d.ts.map +1 -1
- package/dest/private/acvm_wasm.js +3 -1
- package/dest/private/circuit_recording/circuit_recorder.js +2 -2
- package/dest/public/avm/avm_simulator.js +1 -1
- package/dest/public/avm/calldata.d.ts +1 -1
- package/dest/public/avm/calldata.d.ts.map +1 -1
- package/dest/public/avm/calldata.js +3 -2
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts +2 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.d.ts.map +1 -1
- package/dest/public/avm/fixtures/base_avm_simulation_tester.js +17 -2
- package/dest/public/avm/fixtures/utils.d.ts +1 -1
- package/dest/public/avm/fixtures/utils.d.ts.map +1 -1
- package/dest/public/avm/fixtures/utils.js +3 -0
- package/dest/public/avm/opcodes/contract.d.ts +3 -2
- package/dest/public/avm/opcodes/contract.d.ts.map +1 -1
- package/dest/public/avm/opcodes/contract.js +5 -1
- package/dest/public/avm/opcodes/ec_add.d.ts +2 -4
- package/dest/public/avm/opcodes/ec_add.d.ts.map +1 -1
- package/dest/public/avm/opcodes/ec_add.js +13 -27
- package/dest/public/contracts_db_checkpoint.d.ts +2 -2
- package/dest/public/contracts_db_checkpoint.d.ts.map +1 -1
- package/dest/public/contracts_db_checkpoint.js +1 -1
- package/dest/public/fixtures/bulk_test.d.ts +1 -1
- package/dest/public/fixtures/bulk_test.d.ts.map +1 -1
- package/dest/public/fixtures/bulk_test.js +31 -4
- package/dest/public/fixtures/custom_bytecode_tests.d.ts +3 -1
- package/dest/public/fixtures/custom_bytecode_tests.d.ts.map +1 -1
- package/dest/public/fixtures/custom_bytecode_tests.js +61 -1
- package/dest/public/fixtures/opcode_spammer.d.ts +1 -1
- package/dest/public/fixtures/opcode_spammer.d.ts.map +1 -1
- package/dest/public/fixtures/opcode_spammer.js +2 -10
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts +6 -5
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +37 -10
- package/dest/public/fixtures/utils.d.ts +2 -2
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +15 -16
- package/dest/public/hinting_db_sources.d.ts +4 -4
- package/dest/public/hinting_db_sources.d.ts.map +1 -1
- package/dest/public/hinting_db_sources.js +7 -6
- package/dest/public/public_db_sources.d.ts +6 -3
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +16 -10
- package/dest/public/public_processor/guarded_merkle_tree.d.ts +4 -4
- package/dest/public/public_processor/guarded_merkle_tree.d.ts.map +1 -1
- package/dest/public/public_processor/guarded_merkle_tree.js +4 -4
- package/dest/public/public_processor/public_processor.d.ts +8 -6
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +98 -69
- package/dest/public/public_processor/public_processor_metrics.d.ts +4 -1
- package/dest/public/public_processor/public_processor_metrics.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor_metrics.js +8 -0
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/contract_provider_for_cpp.js +3 -2
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator.js +2 -3
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.js +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts +2 -2
- package/dest/public/public_tx_simulator/factories.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/factories.js +2 -2
- package/dest/public/public_tx_simulator/public_tx_context.d.ts +7 -3
- package/dest/public/public_tx_simulator/public_tx_context.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_context.js +8 -10
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts +6 -2
- package/dest/public/public_tx_simulator/public_tx_simulator.d.ts.map +1 -1
- package/dest/public/public_tx_simulator/public_tx_simulator.js +14 -9
- package/dest/public/test_executor_metrics.d.ts +6 -1
- package/dest/public/test_executor_metrics.d.ts.map +1 -1
- package/dest/public/test_executor_metrics.js +22 -0
- package/package.json +16 -16
- package/src/private/acvm_wasm.ts +4 -1
- package/src/private/circuit_recording/circuit_recorder.ts +2 -2
- package/src/public/avm/avm_simulator.ts +1 -1
- package/src/public/avm/calldata.ts +3 -2
- package/src/public/avm/fixtures/base_avm_simulation_tester.ts +22 -2
- package/src/public/avm/fixtures/utils.ts +3 -0
- package/src/public/avm/opcodes/contract.ts +5 -1
- package/src/public/avm/opcodes/ec_add.ts +12 -31
- package/src/public/avm/opcodes/external_calls.ts +1 -1
- package/src/public/contracts_db_checkpoint.ts +1 -1
- package/src/public/fixtures/bulk_test.ts +29 -4
- package/src/public/fixtures/custom_bytecode_tests.ts +139 -1
- package/src/public/fixtures/opcode_spammer.ts +4 -8
- package/src/public/fixtures/public_tx_simulation_tester.ts +47 -6
- package/src/public/fixtures/utils.ts +22 -18
- package/src/public/hinting_db_sources.ts +9 -6
- package/src/public/public_db_sources.ts +21 -14
- package/src/public/public_processor/guarded_merkle_tree.ts +5 -5
- package/src/public/public_processor/public_processor.ts +124 -81
- package/src/public/public_processor/public_processor_metrics.ts +12 -0
- package/src/public/public_tx_simulator/contract_provider_for_cpp.ts +3 -2
- package/src/public/public_tx_simulator/cpp_public_tx_simulator.ts +2 -3
- package/src/public/public_tx_simulator/cpp_public_tx_simulator_with_hinted_dbs.ts +2 -2
- package/src/public/public_tx_simulator/factories.ts +2 -1
- package/src/public/public_tx_simulator/public_tx_context.ts +8 -10
- package/src/public/public_tx_simulator/public_tx_simulator.ts +14 -10
- package/src/public/test_executor_metrics.ts +24 -0
|
@@ -26,22 +26,28 @@ import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from
|
|
|
26
26
|
];
|
|
27
27
|
this.log = createLogger('simulator:contracts-data-source', bindings);
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
/** Parses raw log data from the C++/NAPI bridge and inserts the resulting contracts into the current checkpoint. */ addContractsFromLogs(contractDeploymentData) {
|
|
30
30
|
const currentState = this.getCurrentState();
|
|
31
|
-
|
|
31
|
+
this.addContractClassesFromEvents(ContractClassPublishedEvent.extractContractClassEvents(contractDeploymentData.getContractClassLogs()), currentState);
|
|
32
32
|
this.addContractInstancesFromEvents(ContractInstancePublishedEvent.extractContractInstanceEvents(contractDeploymentData.getPrivateLogs()), currentState);
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
addNewContracts(tx) {
|
|
35
35
|
const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
this.addContractsFromLogs(contractDeploymentData.getNonRevertibleContractDeploymentData());
|
|
37
|
+
this.addContractsFromLogs(contractDeploymentData.getRevertibleContractDeploymentData());
|
|
38
|
+
}
|
|
39
|
+
/** Inserts typed contract instances directly into the current checkpoint. */ addContracts(contractInstances) {
|
|
40
|
+
const currentState = this.getCurrentState();
|
|
41
|
+
for (const instance of contractInstances ?? []){
|
|
42
|
+
currentState.addInstance(instance.address, instance);
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
/**
|
|
40
46
|
* Creates a new checkpoint, copying the current state for upcoming modifications,
|
|
41
47
|
* and enabling rollbacks to current state in case of a revert.
|
|
42
48
|
*/ createCheckpoint() {
|
|
43
49
|
const currentState = this.getCurrentState();
|
|
44
|
-
const newState = currentState.
|
|
50
|
+
const newState = currentState.fork();
|
|
45
51
|
this.contractStateStack.push(newState);
|
|
46
52
|
}
|
|
47
53
|
/**
|
|
@@ -115,12 +121,12 @@ import { L1ToL2MessageIndexOutOfRangeError, NoteHashIndexOutOfRangeError } from
|
|
|
115
121
|
async getDebugFunctionName(address, selector) {
|
|
116
122
|
return await this.dataSource.getDebugFunctionName(address, selector);
|
|
117
123
|
}
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
addContractClassesFromEvents(contractClassEvents, state) {
|
|
125
|
+
for (const event of contractClassEvents){
|
|
120
126
|
this.log.debug(`Adding class ${event.contractClassId.toString()} to contract state`);
|
|
121
|
-
const contractClass =
|
|
127
|
+
const contractClass = event.toContractClassPublic();
|
|
122
128
|
state.addClass(event.contractClassId, contractClass);
|
|
123
|
-
}
|
|
129
|
+
}
|
|
124
130
|
}
|
|
125
131
|
addContractInstancesFromEvents(contractInstanceEvents, state) {
|
|
126
132
|
contractInstanceEvents.forEach((e)=>{
|
|
@@ -38,14 +38,14 @@ export declare class GuardedMerkleTreeOperations implements MerkleTreeWriteOpera
|
|
|
38
38
|
findLeafIndicesAfter<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[], startIndex: bigint): Promise<(bigint | undefined)[]>;
|
|
39
39
|
getLeafValue<ID extends MerkleTreeId>(treeId: ID, index: bigint): Promise<MerkleTreeLeafType<typeof treeId> | undefined>;
|
|
40
40
|
getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(treeId: ID, leafIndices: bigint[]): Promise<(BlockNumber | undefined)[]>;
|
|
41
|
-
createCheckpoint(): Promise<
|
|
41
|
+
createCheckpoint(): Promise<number>;
|
|
42
42
|
commitCheckpoint(): Promise<void>;
|
|
43
43
|
revertCheckpoint(): Promise<void>;
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
commitAllCheckpointsTo(depth: number): Promise<void>;
|
|
45
|
+
revertAllCheckpointsTo(depth: number): Promise<void>;
|
|
46
46
|
findSiblingPaths<ID extends MerkleTreeId>(treeId: ID, values: MerkleTreeLeafType<ID>[]): Promise<({
|
|
47
47
|
path: SiblingPath<TreeHeights[ID]>;
|
|
48
48
|
index: bigint;
|
|
49
49
|
} | undefined)[]>;
|
|
50
50
|
}
|
|
51
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
51
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VhcmRlZF9tZXJrbGVfdHJlZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfcHJvY2Vzc29yL2d1YXJkZWRfbWVya2xlX3RyZWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFbkUsT0FBTyxLQUFLLEVBQUUsdUJBQXVCLEVBQUUsV0FBVyxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDcEYsT0FBTyxLQUFLLEVBQ1Ysb0JBQW9CLEVBQ3BCLGFBQWEsRUFDYixZQUFZLEVBQ1osa0JBQWtCLEVBQ2xCLHlCQUF5QixFQUN6Qix5QkFBeUIsRUFDekIsV0FBVyxFQUNYLFFBQVEsRUFDVCxNQUFNLHFCQUFxQixDQUFDO0FBQzdCLE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxjQUFjLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUNwRSxPQUFPLEtBQUssRUFBRSxrQkFBa0IsRUFBRSw0QkFBNEIsRUFBRSxNQUFNLDJCQUEyQixDQUFDO0FBRWxHOzs7OztHQUtHO0FBRUgscUJBQWEsMkJBQTRCLFlBQVcseUJBQXlCO0lBSS9ELE9BQU8sQ0FBQyxNQUFNO0lBSDFCLE9BQU8sQ0FBQyxTQUFTLENBQVM7SUFDM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FFLENBQUMsRUFBRSxHQUMvQixPQUFPLENBQUMsQ0FBQztRQUFFLElBQUksRUFBRSxXQUFXLENBQUMsV0FBVyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFBQyxLQUFLLEVBQUUsTUFBTSxDQUFBO0tBQUUsR0FBRyxTQUFTLENBQUMsRUFBRSxDQUFDLENBRWhGO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guarded_merkle_tree.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/guarded_merkle_tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,WAAW,EACX,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAElG;;;;;GAKG;AAEH,qBAAa,2BAA4B,YAAW,yBAAyB;IAI/D,OAAO,CAAC,MAAM;IAH1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAqB;IAExC,YAAoB,MAAM,EAAE,yBAAyB,EAEpD;IAED,OAAO,CAAC,KAAK;IAOb,OAAO,CAAC,YAAY;IAQb,iBAAiB,IAAI,yBAAyB,CAEpD;IAGK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAM1B;IAGD,YAAY,CAAC,EAAE,SAAS,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC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AE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAEjH;IACD,eAAe,CAAC,EAAE,SAAS,YAAY,EACrC,MAAM,EAAE,EAAE,EACV,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,GAC/B,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,CAEjC;IACD,oBAAoB,CAAC,EAAE,SAAS,YAAY,EAC1C,MAAM,EAAE,EAAE,EACV,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAChC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,CAEjC;IACD,YAAY,CAAC,EAAE,SAAS,YAAY,EAClC,MAAM,EAAE,EAAE,EACV,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,kBAAkB,CAAC,OAAO,MAAM,CAAC,GAAG,SAAS,CAAC,CAExD;IACD,6BAA6B,CAAC,EAAE,SAAS,YAAY,EACnD,MAAM,EAAE,EAAE,EACV,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,CAAC,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC,CAEtC;IACD,gBAAgB,IAAI,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"guarded_merkle_tree.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/guarded_merkle_tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpF,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,WAAW,EACX,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MA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E,GACpB,OAAO,CAAC,CAAC,WAAW,GAAG,SAAS,CAAC,EAAE,CAAC,CAEtC;IACD,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAElC;IACD,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhC;IACD,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEhC;IACD,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;IACD,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;IACD,gBAAgB,CAAC,EAAE,SAAS,YAAY,EACtC,MAAM,EAAE,EAAE,EACV,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAAC,EAAE,GAC/B,OAAO,CAAC,CAAC;QAAE,IAAI,EAAE,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,EAAE,CAAC,CAEhF;CACF"}
|
|
@@ -101,11 +101,11 @@ _computedKey = Symbol.asyncDispose;
|
|
|
101
101
|
revertCheckpoint() {
|
|
102
102
|
return this.guardAndPush(()=>this.target.revertCheckpoint());
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
return this.guardAndPush(()=>this.target.
|
|
104
|
+
commitAllCheckpointsTo(depth) {
|
|
105
|
+
return this.guardAndPush(()=>this.target.commitAllCheckpointsTo(depth));
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
return this.guardAndPush(()=>this.target.
|
|
107
|
+
revertAllCheckpointsTo(depth) {
|
|
108
|
+
return this.guardAndPush(()=>this.target.revertAllCheckpointsTo(depth));
|
|
109
109
|
}
|
|
110
110
|
findSiblingPaths(treeId, values) {
|
|
111
111
|
return this.guardAndPush(()=>this.target.findSiblingPaths(treeId, values));
|
|
@@ -3,7 +3,7 @@ import { DateProvider } from '@aztec/foundation/timer';
|
|
|
3
3
|
import { PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
4
4
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
5
5
|
import type { MerkleTreeWriteOperations, PublicProcessorLimits, PublicProcessorValidator, SequencerConfig } from '@aztec/stdlib/interfaces/server';
|
|
6
|
-
import type
|
|
6
|
+
import { type DebugLog, type DebugLogStore } from '@aztec/stdlib/logs';
|
|
7
7
|
import { type FailedTx, GlobalVariables, NestedProcessReturnValues, type ProcessedTx, Tx } from '@aztec/stdlib/tx';
|
|
8
8
|
import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
9
9
|
import { PublicContractsDB } from '../public_db_sources.js';
|
|
@@ -21,10 +21,10 @@ export declare class PublicProcessorFactory {
|
|
|
21
21
|
/**
|
|
22
22
|
* Creates a new instance of a PublicProcessor.
|
|
23
23
|
* @param globalVariables - The global variables for the block being processed.
|
|
24
|
-
* @param
|
|
24
|
+
* @param contractsDB - Optional pre-populated contracts DB; a fresh one is constructed if omitted.
|
|
25
25
|
* @returns A new instance of a PublicProcessor.
|
|
26
26
|
*/
|
|
27
|
-
create(merkleTree: MerkleTreeWriteOperations, globalVariables: GlobalVariables, config: PublicSimulatorConfig): PublicProcessor;
|
|
27
|
+
create(merkleTree: MerkleTreeWriteOperations, globalVariables: GlobalVariables, config: PublicSimulatorConfig, contractsDB?: PublicContractsDB): PublicProcessor;
|
|
28
28
|
protected createPublicTxSimulator(merkleTree: MerkleTreeWriteOperations, contractsDB: PublicContractsDB, globalVariables: GlobalVariables, config?: Partial<PublicTxSimulatorConfig>): PublicTxSimulatorInterface;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -39,8 +39,9 @@ export declare class PublicProcessor implements Traceable {
|
|
|
39
39
|
private dateProvider;
|
|
40
40
|
private log;
|
|
41
41
|
private opts;
|
|
42
|
+
private debugLogStore;
|
|
42
43
|
private metrics;
|
|
43
|
-
constructor(globalVariables: GlobalVariables, guardedMerkleTree: GuardedMerkleTreeOperations, contractsDB: PublicContractsDB, publicTxSimulator: PublicTxSimulatorInterface, dateProvider: DateProvider, telemetryClient: TelemetryClient | undefined, log: Logger, opts?: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'
|
|
44
|
+
constructor(globalVariables: GlobalVariables, guardedMerkleTree: GuardedMerkleTreeOperations, contractsDB: PublicContractsDB, publicTxSimulator: PublicTxSimulatorInterface, dateProvider: DateProvider, telemetryClient: TelemetryClient | undefined, log: Logger, opts?: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs' | 'fakeThrowAfterProcessingTxCount'>, debugLogStore?: DebugLogStore);
|
|
44
45
|
get tracer(): Tracer;
|
|
45
46
|
/**
|
|
46
47
|
* Run each tx through the public circuit and the public kernel circuit if needed.
|
|
@@ -49,11 +50,12 @@ export declare class PublicProcessor implements Traceable {
|
|
|
49
50
|
* @param validator - Pre-process validator and nullifier cache to use for processing the txs.
|
|
50
51
|
* @returns The list of processed txs with their circuit simulation outputs.
|
|
51
52
|
*/
|
|
52
|
-
process(txs: Iterable<Tx> | AsyncIterable<Tx>, limits?: PublicProcessorLimits, validator?: PublicProcessorValidator): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[],
|
|
53
|
+
process(txs: Iterable<Tx> | AsyncIterable<Tx>, limits?: PublicProcessorLimits, validator?: PublicProcessorValidator): Promise<[ProcessedTx[], FailedTx[], Tx[], NestedProcessReturnValues[], DebugLog[]]>;
|
|
53
54
|
private checkWorldStateUnchanged;
|
|
54
55
|
private processTx;
|
|
55
56
|
private doTreeInsertionsForPrivateOnlyTx;
|
|
56
57
|
private processTxWithinDeadline;
|
|
58
|
+
private getProcessingSignal;
|
|
57
59
|
private performFeePaymentPublicDataWrite;
|
|
58
60
|
private processPrivateOnlyTx;
|
|
59
61
|
private processTxWithPublicCalls;
|
|
@@ -62,4 +64,4 @@ export declare class PublicProcessor implements Traceable {
|
|
|
62
64
|
*/
|
|
63
65
|
private static generateProvingRequest;
|
|
64
66
|
}
|
|
65
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
67
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3Byb2Nlc3Nvci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3B1YmxpYy9wdWJsaWNfcHJvY2Vzc29yL3B1YmxpY19wcm9jZXNzb3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFFLEtBQUssY0FBYyxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBRXZGLE9BQU8sRUFBRSxZQUFZLEVBQWtDLE1BQU0seUJBQXlCLENBQUM7QUFJdkYsT0FBTyxFQU1MLHFCQUFxQixFQUN0QixNQUFNLG1CQUFtQixDQUFDO0FBRTNCLE9BQU8sS0FBSyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHakUsT0FBTyxLQUFLLEVBQ1YseUJBQXlCLEVBQ3pCLHFCQUFxQixFQUNyQix3QkFBd0IsRUFDeEIsZUFBZSxFQUNoQixNQUFNLGlDQUFpQyxDQUFDO0FBQ3pDLE9BQU8sRUFBRSxLQUFLLFFBQVEsRUFBRSxLQUFLLGFBQWEsRUFBcUIsTUFBTSxvQkFBb0IsQ0FBQztBQUcxRixPQUFPLEVBQ0wsS0FBSyxRQUFRLEVBQ2IsZUFBZSxFQUNmLHlCQUF5QixFQUN6QixLQUFLLFdBQVcsRUFFaEIsRUFBRSxFQUdILE1BQU0sa0JBQWtCLENBQUM7QUFDMUIsT0FBTyxFQUVMLEtBQUssZUFBZSxFQUNwQixLQUFLLFNBQVMsRUFDZCxLQUFLLE1BQU0sRUFHWixNQUFNLHlCQUF5QixDQUFDO0FBS2pDLE9BQU8sRUFBRSxpQkFBaUIsRUFBaUIsTUFBTSx5QkFBeUIsQ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d0I7SUF5Q3RDOztPQUVHO0lBQ0gsT0FBTyxDQUFDLE1BQU0sQ0FBQyxzQkFBc0I7Q0FTdEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAIvF,OAAO,EAML,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAIvF,OAAO,EAML,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AAG1F,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBAAyB,EACzB,KAAK,WAAW,EAEhB,EAAE,EAGH,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK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C5C,WAAW,EAAE,iBAAiB,EAC9B,iBAAiB,EAAE,0BAA0B,EAC/C,YAAY,EAAE,YAAY,EAClC,eAAe,6BAAwC,EAC/C,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,IAAI,CAAC,eAAe,EAAE,4BAA4B,GAAG,iCAAiC,CAAM,EAClG,aAAa,GAAE,aAAuC,EAG/D;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;;;OAMG;IACU,OAAO,CAClB,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC,EACrC,MAAM,GAAE,qBAA0B,EAClC,SAAS,GAAE,wBAA6B,GACvC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,yBAAyB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,CAmOrF;YAEa,wBAAwB;YAiBxB,SAAS;YAiCT,gCAAgC;YA4BhC,uBAAuB;IAiCrC,OAAO,CAAC,mBAAmB;YA0Bb,gCAAgC;YA0BhC,oBAAoB;YA+BpB,wBAAwB;IAyCtC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;CAStC"}
|
|
@@ -376,13 +376,14 @@ import { padArrayEnd } from '@aztec/foundation/collection';
|
|
|
376
376
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
377
377
|
import { createLogger } from '@aztec/foundation/log';
|
|
378
378
|
import { sleep } from '@aztec/foundation/sleep';
|
|
379
|
-
import { DateProvider, Timer, elapsed,
|
|
379
|
+
import { DateProvider, Timer, elapsed, execWithSignal } from '@aztec/foundation/timer';
|
|
380
380
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
381
381
|
import { ContractClassPublishedEvent } from '@aztec/protocol-contracts/class-registry';
|
|
382
382
|
import { computeFeePayerBalanceLeafSlot, computeFeePayerBalanceStorageSlot } from '@aztec/protocol-contracts/fee-juice';
|
|
383
383
|
import { AvmCircuitInputs, AvmExecutionHints, PublicDataWrite } from '@aztec/stdlib/avm';
|
|
384
384
|
import { computeTransactionFee } from '@aztec/stdlib/fees';
|
|
385
385
|
import { Gas } from '@aztec/stdlib/gas';
|
|
386
|
+
import { NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
386
387
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
387
388
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
388
389
|
import { NestedProcessReturnValues, makeProcessedTxFromPrivateOnlyTx, makeProcessedTxFromTxWithPublicCalls } from '@aztec/stdlib/tx';
|
|
@@ -409,14 +410,12 @@ import { PublicProcessorMetrics } from './public_processor_metrics.js';
|
|
|
409
410
|
/**
|
|
410
411
|
* Creates a new instance of a PublicProcessor.
|
|
411
412
|
* @param globalVariables - The global variables for the block being processed.
|
|
412
|
-
* @param
|
|
413
|
+
* @param contractsDB - Optional pre-populated contracts DB; a fresh one is constructed if omitted.
|
|
413
414
|
* @returns A new instance of a PublicProcessor.
|
|
414
|
-
*/ create(merkleTree, globalVariables, config) {
|
|
415
|
-
const bindings = this.log.getBindings();
|
|
416
|
-
const contractsDB = new PublicContractsDB(this.contractDataSource, bindings);
|
|
415
|
+
*/ create(merkleTree, globalVariables, config, contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings())) {
|
|
417
416
|
const guardedFork = new GuardedMerkleTreeOperations(merkleTree);
|
|
418
417
|
const publicTxSimulator = this.createPublicTxSimulator(guardedFork, contractsDB, globalVariables, config);
|
|
419
|
-
return new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, createLogger('simulator:public-processor',
|
|
418
|
+
return new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, createLogger('simulator:public-processor', this.log.getBindings()));
|
|
420
419
|
}
|
|
421
420
|
createPublicTxSimulator(merkleTree, contractsDB, globalVariables, config) {
|
|
422
421
|
return new TelemetryCppPublicTxSimulator(merkleTree, contractsDB, globalVariables, this.telemetryClient, config, this.log.getBindings());
|
|
@@ -428,6 +427,15 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
428
427
|
this.name = 'PublicProcessorTimeoutError';
|
|
429
428
|
}
|
|
430
429
|
}
|
|
430
|
+
class PublicProcessorAbortError extends Error {
|
|
431
|
+
constructor(message = 'Aborted while processing tx'){
|
|
432
|
+
super(message);
|
|
433
|
+
this.name = 'PublicProcessorAbortError';
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function isPublicProcessorInterruptError(err) {
|
|
437
|
+
return err?.name === 'PublicProcessorTimeoutError' || err?.name === 'PublicProcessorAbortError';
|
|
438
|
+
}
|
|
431
439
|
_dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
432
440
|
[Attributes.TX_HASH]: tx.getTxHash().toString()
|
|
433
441
|
})), _dec1 = trackSpan('PublicProcessor.processPrivateOnlyTx', (tx)=>({
|
|
@@ -446,6 +454,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
446
454
|
dateProvider;
|
|
447
455
|
log;
|
|
448
456
|
opts;
|
|
457
|
+
debugLogStore;
|
|
449
458
|
static{
|
|
450
459
|
({ e: [_initProto] } = _apply_decs_2203_r(this, [
|
|
451
460
|
[
|
|
@@ -466,7 +475,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
466
475
|
], []));
|
|
467
476
|
}
|
|
468
477
|
metrics;
|
|
469
|
-
constructor(globalVariables, guardedMerkleTree, contractsDB, publicTxSimulator, dateProvider, telemetryClient = getTelemetryClient(), log, opts = {}){
|
|
478
|
+
constructor(globalVariables, guardedMerkleTree, contractsDB, publicTxSimulator, dateProvider, telemetryClient = getTelemetryClient(), log, opts = {}, debugLogStore = new NullDebugLogStore()){
|
|
470
479
|
this.globalVariables = globalVariables;
|
|
471
480
|
this.guardedMerkleTree = guardedMerkleTree;
|
|
472
481
|
this.contractsDB = contractsDB;
|
|
@@ -474,6 +483,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
474
483
|
this.dateProvider = dateProvider;
|
|
475
484
|
this.log = log;
|
|
476
485
|
this.opts = opts;
|
|
486
|
+
this.debugLogStore = debugLogStore;
|
|
477
487
|
_initProto(this);
|
|
478
488
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
479
489
|
}
|
|
@@ -487,7 +497,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
487
497
|
* @param validator - Pre-process validator and nullifier cache to use for processing the txs.
|
|
488
498
|
* @returns The list of processed txs with their circuit simulation outputs.
|
|
489
499
|
*/ async process(txs, limits = {}, validator = {}) {
|
|
490
|
-
const { maxTransactions,
|
|
500
|
+
const { maxTransactions, deadline, maxBlockGas, maxBlobFields, isBuildingProposal, signal } = limits;
|
|
491
501
|
const { preprocessValidator, nullifierCache } = validator;
|
|
492
502
|
const result = [];
|
|
493
503
|
const usedTxs = [];
|
|
@@ -499,32 +509,40 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
499
509
|
let totalPublicGas = new Gas(0, 0);
|
|
500
510
|
let totalBlockGas = new Gas(0, 0);
|
|
501
511
|
let totalBlobFields = 0;
|
|
512
|
+
let silentlySkippedCount = 0;
|
|
513
|
+
let totalSilentlySkippedDurationMs = 0;
|
|
502
514
|
for await (const tx of txs){
|
|
503
515
|
// Only process up to the max tx limit
|
|
504
516
|
if (maxTransactions !== undefined && result.length >= maxTransactions) {
|
|
505
517
|
this.log.debug(`Stopping tx processing due to reaching the max tx limit.`);
|
|
506
518
|
break;
|
|
507
519
|
}
|
|
508
|
-
// Bail if we've hit the deadline
|
|
520
|
+
// Bail if we've hit the deadline or have been interrupted.
|
|
509
521
|
if (deadline && this.dateProvider.now() > +deadline) {
|
|
510
522
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
511
523
|
break;
|
|
512
524
|
}
|
|
513
|
-
|
|
525
|
+
if (signal?.aborted) {
|
|
526
|
+
this.log.warn(`Stopping tx processing due to abort signal.`);
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
514
529
|
const txHash = tx.getTxHash().toString();
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
530
|
+
// Skip this tx if its estimated blob fields would exceed the limit.
|
|
531
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
532
|
+
const txBlobFields = tx.getPrivateTxEffectsSizeInFields();
|
|
533
|
+
if (isBuildingProposal && maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
534
|
+
this.log.warn(`Skipping tx ${txHash} with ${txBlobFields} fields from private side effects due to blob fields limit`, {
|
|
518
535
|
txHash,
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
536
|
+
txBlobFields,
|
|
537
|
+
totalBlobFields,
|
|
538
|
+
maxBlobFields
|
|
522
539
|
});
|
|
523
540
|
continue;
|
|
524
541
|
}
|
|
525
|
-
// Skip this tx if its gas limit would exceed the block gas limit
|
|
542
|
+
// Skip this tx if its gas limit would exceed the block gas limit (either da or l2).
|
|
543
|
+
// Only done during proposal building: during re-execution we must process the exact txs from the proposal.
|
|
526
544
|
const txGasLimit = tx.data.constants.txContext.gasSettings.gasLimits;
|
|
527
|
-
if (maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
545
|
+
if (isBuildingProposal && maxBlockGas !== undefined && totalBlockGas.add(txGasLimit).gtAny(maxBlockGas)) {
|
|
528
546
|
this.log.warn(`Skipping processing of tx ${txHash} due to block gas limit`, {
|
|
529
547
|
txHash,
|
|
530
548
|
txGasLimit,
|
|
@@ -546,11 +564,6 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
546
564
|
});
|
|
547
565
|
returns.push(new NestedProcessReturnValues([]));
|
|
548
566
|
continue;
|
|
549
|
-
} else if (result.result === 'skipped') {
|
|
550
|
-
const reason = result.reason.join(', ');
|
|
551
|
-
this.log.debug(`Skipping tx ${txHash.toString()} due to pre-process validation: ${reason}`);
|
|
552
|
-
returns.push(new NestedProcessReturnValues([]));
|
|
553
|
-
continue;
|
|
554
567
|
} else {
|
|
555
568
|
this.log.trace(`Tx ${txHash.toString()} is valid before processing.`);
|
|
556
569
|
}
|
|
@@ -564,41 +577,46 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
564
577
|
const startStateReference = await this.guardedMerkleTree.getUnderlyingFork().getStateReference();
|
|
565
578
|
this.contractsDB.createCheckpoint();
|
|
566
579
|
try {
|
|
567
|
-
const [processedTx, returnValues, txDebugLogs] = await this.processTx(tx, deadline);
|
|
580
|
+
const [txProcessingTimeMs, [processedTx, returnValues, txDebugLogs]] = await elapsed(()=>this.processTx(tx, deadline, signal));
|
|
568
581
|
// Inject a fake processing failure after N txs if requested
|
|
569
582
|
const fakeThrowAfter = this.opts.fakeThrowAfterProcessingTxCount;
|
|
570
583
|
if (fakeThrowAfter !== undefined && result.length + failed.length + 1 >= fakeThrowAfter) {
|
|
571
584
|
throw new Error(`Fake error after processing ${fakeThrowAfter} txs`);
|
|
572
585
|
}
|
|
573
586
|
const txBlobFields = processedTx.txEffect.getNumBlobFields();
|
|
574
|
-
// If the actual size of this tx would exceed block size, skip it
|
|
575
587
|
const txSize = txBlobFields * Fr.SIZE_IN_BYTES;
|
|
576
|
-
|
|
577
|
-
this.log.debug(`Skipping processed tx ${txHash} sized ${txSize} due to max block size.`, {
|
|
578
|
-
txHash,
|
|
579
|
-
sizeInBytes: txSize,
|
|
580
|
-
totalSizeInBytes,
|
|
581
|
-
maxBlockSize
|
|
582
|
-
});
|
|
583
|
-
// Need to revert the checkpoint here and don't go any further
|
|
584
|
-
await checkpoint.revert();
|
|
585
|
-
this.contractsDB.revertCheckpoint();
|
|
586
|
-
continue;
|
|
587
|
-
}
|
|
588
|
-
// If the actual blob fields of this tx would exceed the limit, skip it
|
|
588
|
+
// If the actual blob fields of this tx would exceed the limit, skip it.
|
|
589
589
|
// Note: maxBlobFields already accounts for block end blob fields and previous blocks in checkpoint.
|
|
590
590
|
if (maxBlobFields !== undefined && totalBlobFields + txBlobFields > maxBlobFields) {
|
|
591
591
|
this.log.debug(`Skipping processed tx ${txHash} with ${txBlobFields} blob fields due to max blob fields limit.`, {
|
|
592
592
|
txHash,
|
|
593
593
|
txBlobFields,
|
|
594
594
|
totalBlobFields,
|
|
595
|
-
maxBlobFields
|
|
595
|
+
maxBlobFields,
|
|
596
|
+
txProcessingTimeMs
|
|
596
597
|
});
|
|
598
|
+
silentlySkippedCount += 1;
|
|
599
|
+
totalSilentlySkippedDurationMs += txProcessingTimeMs;
|
|
600
|
+
this.metrics.recordSilentlySkipped(txProcessingTimeMs);
|
|
597
601
|
// Need to revert the checkpoint here and don't go any further
|
|
598
602
|
await checkpoint.revert();
|
|
599
603
|
this.contractsDB.revertCheckpoint();
|
|
600
604
|
continue;
|
|
601
605
|
}
|
|
606
|
+
// During re-execution, check if the actual gas used by this tx would push the block over the gas limit.
|
|
607
|
+
// Unlike the proposal-building check (which uses declared gas limits pessimistically before processing),
|
|
608
|
+
// this uses actual gas and stops processing when the limit is exceeded.
|
|
609
|
+
if (!isBuildingProposal && maxBlockGas !== undefined && totalBlockGas.add(processedTx.gasUsed.totalGas).gtAny(maxBlockGas)) {
|
|
610
|
+
this.log.warn(`Stopping re-execution since tx ${txHash} would push block gas over limit`, {
|
|
611
|
+
txHash,
|
|
612
|
+
txGas: processedTx.gasUsed.totalGas,
|
|
613
|
+
totalBlockGas,
|
|
614
|
+
maxBlockGas
|
|
615
|
+
});
|
|
616
|
+
await checkpoint.revert();
|
|
617
|
+
this.contractsDB.revertCheckpoint();
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
602
620
|
// FIXME(fcarreiro): it's ugly to have to notify the validator of nullifiers.
|
|
603
621
|
// I'd rather pass the validators the processedTx as well and let them deal with it.
|
|
604
622
|
nullifierCache?.addNullifiers(processedTx.txEffect.nullifiers.map((n)=>n.toBuffer()));
|
|
@@ -606,42 +624,38 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
606
624
|
usedTxs.push(tx);
|
|
607
625
|
returns = returns.concat(returnValues);
|
|
608
626
|
debugLogs.push(...txDebugLogs);
|
|
627
|
+
this.debugLogStore.storeLogs(processedTx.hash.toString(), txDebugLogs);
|
|
609
628
|
totalPublicGas = totalPublicGas.add(processedTx.gasUsed.publicGas);
|
|
610
629
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
611
630
|
totalSizeInBytes += txSize;
|
|
612
631
|
totalBlobFields += txBlobFields;
|
|
632
|
+
// Commit the tx-level contracts checkpoint on success
|
|
633
|
+
this.contractsDB.commitCheckpoint();
|
|
613
634
|
} catch (err) {
|
|
614
|
-
if (err
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
//
|
|
618
|
-
// Signal cancellation AND WAIT for the simulation to actually stop.
|
|
619
|
-
// This is critical because C++ might be in the middle of a slow operation (e.g., pad_trees)
|
|
620
|
-
// and won't check the cancellation flag until that operation completes.
|
|
621
|
-
// Without waiting, we'd proceed to revert checkpoints while C++ is still writing to state.
|
|
622
|
-
// Wait for C++ to stop gracefully.
|
|
635
|
+
if (isPublicProcessorInterruptError(err)) {
|
|
636
|
+
const interruptReason = err.name === 'PublicProcessorTimeoutError' ? 'timeout' : 'abort signal';
|
|
637
|
+
this.log.warn(`Stopping tx processing due to ${interruptReason}.`);
|
|
638
|
+
// The tx may still be executing on a worker thread (C++ via NAPI).
|
|
639
|
+
// Signal cancellation AND WAIT for the simulation to actually stop before touching fork checkpoints.
|
|
623
640
|
await this.publicTxSimulator.cancel?.();
|
|
624
641
|
// Now stop the guarded fork to prevent any further TS-side access to the world state.
|
|
625
642
|
await this.guardedMerkleTree.stop();
|
|
626
643
|
// We now know there can't be any further access to world state. The fork is in a state where there is:
|
|
627
644
|
// 1. At least one outstanding checkpoint that has not been committed (the one created before we processed the tx).
|
|
628
645
|
// 2. Possible state updates on that checkpoint or any others created during execution.
|
|
629
|
-
//
|
|
630
|
-
//
|
|
631
|
-
//
|
|
632
|
-
await checkpoint.
|
|
633
|
-
// Now we want to revert any/all remaining checkpoints, destroying any outstanding state updates.
|
|
634
|
-
// This needs to be done directly on the underlying fork as the guarded fork has been stopped.
|
|
635
|
-
await this.guardedMerkleTree.getUnderlyingFork().revertAllCheckpoints();
|
|
646
|
+
// Revert all checkpoints at or above this checkpoint's depth (inclusive), destroying any outstanding state
|
|
647
|
+
// updates from this tx and any nested checkpoints created during execution. This preserves any checkpoints
|
|
648
|
+
// created by callers below our depth.
|
|
649
|
+
await checkpoint.revertToCheckpoint();
|
|
636
650
|
// Revert any contracts added to the DB for the tx.
|
|
637
651
|
this.contractsDB.revertCheckpoint();
|
|
638
652
|
// Ensure we're at the same state as when we started processing this tx.
|
|
639
653
|
await this.checkWorldStateUnchanged(startStateReference, txHash, err);
|
|
640
654
|
break;
|
|
641
655
|
}
|
|
642
|
-
// Roll back state to start of TX before proceeding to next TX
|
|
643
|
-
|
|
644
|
-
await
|
|
656
|
+
// Roll back state to start of TX before proceeding to next TX.
|
|
657
|
+
// Reverts all checkpoints at or above this checkpoint's depth, preserving any caller checkpoints below.
|
|
658
|
+
await checkpoint.revertToCheckpoint();
|
|
645
659
|
this.contractsDB.revertCheckpoint();
|
|
646
660
|
const errorMessage = err instanceof Error || err instanceof AssertionError ? err.message : 'Unknown error';
|
|
647
661
|
this.log.warn(`Failed to process tx ${txHash.toString()}: ${errorMessage} ${err?.stack}`);
|
|
@@ -655,25 +669,29 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
655
669
|
} finally{
|
|
656
670
|
// Base case is we always commit the checkpoint. Using the ForkCheckpoint means this has no effect if the tx was previously reverted
|
|
657
671
|
await checkpoint.commit();
|
|
658
|
-
this.contractsDB.commitCheckpointOkIfNone();
|
|
659
672
|
}
|
|
660
673
|
}
|
|
661
674
|
const duration = timer.s();
|
|
662
675
|
const rate = duration > 0 ? totalPublicGas.l2Gas / duration : 0;
|
|
663
676
|
this.metrics.recordAllTxs(totalPublicGas, rate);
|
|
664
|
-
|
|
677
|
+
const silentlySkippedDurationMs = Math.round(totalSilentlySkippedDurationMs);
|
|
678
|
+
this.log.info(`Processed ${result.length} successful txs and ${failed.length} failed txs ` + `(${silentlySkippedCount} silently skipped, ${silentlySkippedDurationMs}ms wasted) ` + `in ${duration}s`, {
|
|
679
|
+
blockNumber: this.globalVariables.blockNumber,
|
|
680
|
+
successfulCount: result.length,
|
|
681
|
+
failedCount: failed.length,
|
|
665
682
|
duration,
|
|
666
683
|
rate,
|
|
667
684
|
totalPublicGas,
|
|
668
685
|
totalBlockGas,
|
|
669
|
-
totalSizeInBytes
|
|
686
|
+
totalSizeInBytes,
|
|
687
|
+
silentlySkippedCount,
|
|
688
|
+
silentlySkippedDurationMs
|
|
670
689
|
});
|
|
671
690
|
return [
|
|
672
691
|
result,
|
|
673
692
|
failed,
|
|
674
693
|
usedTxs,
|
|
675
694
|
returns,
|
|
676
|
-
totalBlobFields,
|
|
677
695
|
debugLogs
|
|
678
696
|
];
|
|
679
697
|
}
|
|
@@ -690,8 +708,8 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
690
708
|
});
|
|
691
709
|
}
|
|
692
710
|
}
|
|
693
|
-
async processTx(tx, deadline) {
|
|
694
|
-
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(()=>this.processTxWithinDeadline(tx, deadline));
|
|
711
|
+
async processTx(tx, deadline, signal) {
|
|
712
|
+
const [time, [processedTx, returnValues, debugLogs]] = await elapsed(()=>this.processTxWithinDeadline(tx, deadline, signal));
|
|
695
713
|
this.log.verbose(!tx.hasPublicCalls() ? `Processed tx ${processedTx.hash} with no public calls in ${time}ms` : `Processed tx ${processedTx.hash} with ${tx.numberOfPublicCalls()} public calls in ${time}ms`, {
|
|
696
714
|
txHash: processedTx.hash,
|
|
697
715
|
txFee: processedTx.txEffect.transactionFee.toBigInt(),
|
|
@@ -732,7 +750,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
732
750
|
const treeInsertionEnd = process.hrtime.bigint();
|
|
733
751
|
this.metrics.recordTreeInsertions(Number(treeInsertionEnd - treeInsertionStart) / 1_000);
|
|
734
752
|
}
|
|
735
|
-
/** Processes the given tx within deadline
|
|
753
|
+
/** Processes the given tx within deadline or until the signal is aborted. */ async processTxWithinDeadline(tx, deadline, signal) {
|
|
736
754
|
const innerProcessFn = tx.hasPublicCalls() ? ()=>this.processTxWithPublicCalls(tx) : ()=>this.processPrivateOnlyTx(tx);
|
|
737
755
|
// Fake a delay per tx if instructed (used for tests)
|
|
738
756
|
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
@@ -742,20 +760,31 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
742
760
|
await sleep(fakeDelayPerTxMs);
|
|
743
761
|
return result;
|
|
744
762
|
} : innerProcessFn;
|
|
745
|
-
|
|
763
|
+
const processingSignal = this.getProcessingSignal(tx, deadline, signal);
|
|
764
|
+
if (!processingSignal) {
|
|
746
765
|
return await processFn();
|
|
747
766
|
}
|
|
748
|
-
|
|
767
|
+
return await execWithSignal(()=>processFn(), processingSignal, (signal)=>signal.reason?.name === 'TimeoutError' ? new PublicProcessorTimeoutError() : new PublicProcessorAbortError());
|
|
768
|
+
}
|
|
769
|
+
getProcessingSignal(tx, deadline, signal) {
|
|
770
|
+
if (!deadline) {
|
|
771
|
+
return signal;
|
|
772
|
+
}
|
|
749
773
|
const timeout = +deadline - this.dateProvider.now();
|
|
750
774
|
if (timeout <= 0) {
|
|
751
775
|
throw new PublicProcessorTimeoutError();
|
|
752
776
|
}
|
|
777
|
+
const txHash = tx.getTxHash();
|
|
753
778
|
this.log.debug(`Processing tx ${txHash.toString()} within ${timeout}ms`, {
|
|
754
779
|
deadline: deadline.toISOString(),
|
|
755
780
|
now: new Date(this.dateProvider.now()).toISOString(),
|
|
756
781
|
txHash
|
|
757
782
|
});
|
|
758
|
-
|
|
783
|
+
const timeoutSignal = AbortSignal.timeout(timeout);
|
|
784
|
+
return signal ? AbortSignal.any([
|
|
785
|
+
signal,
|
|
786
|
+
timeoutSignal
|
|
787
|
+
]) : timeoutSignal;
|
|
759
788
|
}
|
|
760
789
|
/**
|
|
761
790
|
* Creates the public data write for paying the tx fee.
|
|
@@ -784,7 +813,7 @@ _dec = trackSpan('PublicProcessor.processTx', (tx)=>({
|
|
|
784
813
|
this.metrics.recordClassPublication(...tx.getContractClassLogs().filter((log)=>ContractClassPublishedEvent.isContractClassPublishedEvent(log)).map((log)=>ContractClassPublishedEvent.fromLog(log)));
|
|
785
814
|
// Fee payment insertion has already been done. Do the rest.
|
|
786
815
|
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
787
|
-
|
|
816
|
+
this.contractsDB.addNewContracts(tx);
|
|
788
817
|
return [
|
|
789
818
|
processedTx,
|
|
790
819
|
undefined,
|
|
@@ -15,6 +15,8 @@ export declare class PublicProcessorMetrics {
|
|
|
15
15
|
private gasRate;
|
|
16
16
|
private txGas;
|
|
17
17
|
private treeInsertionDuration;
|
|
18
|
+
private silentlySkippedCount;
|
|
19
|
+
private silentlySkippedDuration;
|
|
18
20
|
constructor(client: TelemetryClient, name?: string);
|
|
19
21
|
recordPhaseDuration(phaseName: TxExecutionPhase, durationMs: number): void;
|
|
20
22
|
recordTx(phaseCount: number, durationMs: number, gasUsed: Gas): void;
|
|
@@ -23,5 +25,6 @@ export declare class PublicProcessorMetrics {
|
|
|
23
25
|
recordRevertedPhase(phaseName: TxExecutionPhase): void;
|
|
24
26
|
recordClassPublication(...events: ContractClassPublishedEvent[]): void;
|
|
25
27
|
recordTreeInsertions(durationUs: number): void;
|
|
28
|
+
recordSilentlySkipped(durationMs: number): void;
|
|
26
29
|
}
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
30
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjoz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FBRSxlQUFlLEVBQUUsSUFBSSxTQUFvQixFQWtDNUQ7SUFFRCxtQkFBbUIsQ0FBQyxTQUFTLEVBQUUsZ0JBQWdCLEVBQUUsVUFBVSxFQUFFLE1BQU0sUUFHbEU7SUFFRCxRQUFRLENBQUMsVUFBVSxFQUFFLE1BQU0sRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxHQUFHLFFBWTVEO0lBRUQsWUFBWSxDQUFDLFFBQVEsRUFBRSxHQUFHLEVBQUUsT0FBTyxFQUFFLE1BQU0sUUFnQjFDO0lBRUQsY0FBYyxTQUliO0lBRUQsbUJBQW1CLENBQUMsU0FBUyxFQUFFLGdCQUFnQixRQUU5QztJQUVELHNCQUFzQixDQUFDLEdBQUcsTUFBTSxFQUFFLDJCQUEyQixFQUFFLFFBUzlEO0lBRUQsb0JBQW9CLENBQUMsVUFBVSxFQUFFLE1BQU0sUUFFdEM7SUFFRCxxQkFBcUIsQ0FBQyxVQUFVLEVBQUUsTUFBTSxRQUd2QztDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_processor_metrics.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor_metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAC5F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,sBAAsB;IACjC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAgB;IAEpC,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,UAAU,CAAgB;IAElC,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,KAAK,CAAY;IAEzB,OAAO,CAAC,qBAAqB,CAAY;IAEzC,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,SAAoB,
|
|
1
|
+
{"version":3,"file":"public_processor_metrics.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor_metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAC;AAC5F,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,MAAM,EAGZ,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,sBAAsB;IACjC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAgB;IAEpC,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,UAAU,CAAgB;IAElC,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,iBAAiB,CAAY;IACrC,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,KAAK,CAAY;IAEzB,OAAO,CAAC,qBAAqB,CAAY;IAEzC,OAAO,CAAC,oBAAoB,CAAgB;IAC5C,OAAO,CAAC,uBAAuB,CAAY;IAE3C,YAAY,MAAM,EAAE,eAAe,EAAE,IAAI,SAAoB,EAkC5D;IAED,mBAAmB,CAAC,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,QAGlE;IAED,QAAQ,CAAC,UAA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