@aztec/simulator 0.0.1-commit.d117d021b → 0.0.1-commit.d1da697d6
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/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/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/public_tx_simulation_tester.d.ts +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.d.ts.map +1 -1
- package/dest/public/fixtures/public_tx_simulation_tester.js +3 -3
- package/dest/public/fixtures/utils.d.ts +1 -1
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +5 -5
- 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 +6 -5
- package/dest/public/public_db_sources.d.ts +3 -3
- package/dest/public/public_db_sources.d.ts.map +1 -1
- package/dest/public/public_db_sources.js +10 -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 +1 -1
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +10 -12
- 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 +2 -1
- 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.js +2 -2
- package/package.json +15 -16
- package/src/public/avm/avm_simulator.ts +1 -1
- package/src/public/avm/calldata.ts +3 -2
- package/src/public/avm/opcodes/external_calls.ts +1 -1
- package/src/public/contracts_db_checkpoint.ts +1 -1
- package/src/public/fixtures/public_tx_simulation_tester.ts +4 -9
- package/src/public/fixtures/utils.ts +12 -8
- package/src/public/hinting_db_sources.ts +8 -6
- package/src/public/public_db_sources.ts +12 -14
- package/src/public/public_processor/guarded_merkle_tree.ts +5 -5
- package/src/public/public_processor/public_processor.ts +11 -13
- package/src/public/public_tx_simulator/contract_provider_for_cpp.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 +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_provider_for_cpp.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/contract_provider_for_cpp.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,qBAAa,sBAAuB,YAAW,gBAAgB;IAI3D,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,eAAe;IAJzB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACU,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACxC,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAEM,mBAAmB,oEAaxB;IAEK,gBAAgB,oEAerB;
|
|
1
|
+
{"version":3,"file":"contract_provider_for_cpp.d.ts","sourceRoot":"","sources":["../../../src/public/public_tx_simulator/contract_provider_for_cpp.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,cAAc,EAAgB,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,qBAAa,sBAAuB,YAAW,gBAAgB;IAI3D,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,eAAe;IAJzB,OAAO,CAAC,GAAG,CAAS;IAEpB,YACU,WAAW,EAAE,iBAAiB,EAC9B,eAAe,EAAE,eAAe,EACxC,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAEM,mBAAmB,oEAaxB;IAEK,gBAAgB,oEAerB;IAGK,YAAY,2EAWjB;IAEK,qBAAqB,oEAgB1B;IAEK,oBAAoB,qEAsBzB;IAEK,gBAAgB,sBAGrB;IAEK,gBAAgB,sBAGrB;IAEK,gBAAgB,sBAGrB;CACH"}
|
|
@@ -40,7 +40,7 @@ export class ContractProviderForCpp {
|
|
|
40
40
|
const contractDeploymentData = ContractDeploymentData.fromPlainObject(rawData);
|
|
41
41
|
// Add contracts to the contracts DB
|
|
42
42
|
this.log.trace(`Calling contractsDB.addContracts`);
|
|
43
|
-
|
|
43
|
+
this.contractsDB.addContracts(contractDeploymentData);
|
|
44
44
|
};
|
|
45
45
|
this.getBytecodeCommitment = async (classId)=>{
|
|
46
46
|
this.log.trace(`Contract provider callback: getBytecodeCommitment(${classId})`);
|
|
@@ -89,6 +89,7 @@ export class ContractProviderForCpp {
|
|
|
89
89
|
}
|
|
90
90
|
getContractInstance;
|
|
91
91
|
getContractClass;
|
|
92
|
+
// eslint-disable-next-line require-await
|
|
92
93
|
addContracts;
|
|
93
94
|
getBytecodeCommitment;
|
|
94
95
|
getDebugFunctionName;
|
|
@@ -75,8 +75,12 @@ export declare class PublicTxContext {
|
|
|
75
75
|
*/
|
|
76
76
|
consumeGas(phase: TxExecutionPhase, gas: Gas): void;
|
|
77
77
|
/**
|
|
78
|
-
* The gasUsed by public and private,
|
|
79
|
-
*
|
|
78
|
+
* The gasUsed by public and private, as if the entire teardown gas limit was consumed.
|
|
79
|
+
*
|
|
80
|
+
* This is intentional: teardown is used for gas accounting and refunds, so the transaction
|
|
81
|
+
* fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual
|
|
82
|
+
* consumption there would be a circular dependency. Billing the full teardown gas limit
|
|
83
|
+
* (set by the user) makes the fee known in advance and available to the teardown function.
|
|
80
84
|
*/
|
|
81
85
|
getTotalGasUsed(): Gas;
|
|
82
86
|
/**
|
|
@@ -128,4 +132,4 @@ declare class PhaseStateManager {
|
|
|
128
132
|
discardForkedState(): Promise<void>;
|
|
129
133
|
}
|
|
130
134
|
export {};
|
|
131
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
135
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3R4X2NvbnRleHQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wdWJsaWMvcHVibGljX3R4X3NpbXVsYXRvci9wdWJsaWNfdHhfY29udGV4dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFRQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUFlLEtBQUssY0FBYyxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBQ3ZGLE9BQU8sRUFHTCxzQkFBc0IsRUFFdEIsVUFBVSxFQUNYLE1BQU0sbUJBQW1CLENBQUM7QUFDM0IsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxFQUE2QixLQUFLLHNCQUFzQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFDaEcsT0FBTyxLQUFLLEVBQ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;AAED;;;;;;;;;GASG;AACH,cAAM,iBAAiB;IAMnB,OAAO,CAAC,QAAQ,CAAC,cAAc;IALjC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,2BAA2B,CAA4C;IAE/E,YACmB,cAAc,EAAE,6BAA6B,EAC9D,QAAQ,CAAC,EAAE,cAAc,EAG1B;IAEK,IAAI,kBAIT;IAED,qBAAqB,kCAEpB;IAED,QAAQ,YAEP;IAEK,gBAAgB,kBAMrB;IAEK,kBAAkB,kBAMvB;CACF"}
|
|
@@ -106,14 +106,8 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
106
106
|
}
|
|
107
107
|
if (phase === TxExecutionPhase.SETUP) {
|
|
108
108
|
this.log.warn(`Setup phase reverted! The transaction will be thrown out.`);
|
|
109
|
-
} else if (phase === TxExecutionPhase.APP_LOGIC) {
|
|
110
|
-
this.revertCode = RevertCode.
|
|
111
|
-
} else if (phase === TxExecutionPhase.TEARDOWN) {
|
|
112
|
-
if (this.revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
|
|
113
|
-
this.revertCode = RevertCode.BOTH_REVERTED;
|
|
114
|
-
} else {
|
|
115
|
-
this.revertCode = RevertCode.TEARDOWN_REVERTED;
|
|
116
|
-
}
|
|
109
|
+
} else if (phase === TxExecutionPhase.APP_LOGIC || phase === TxExecutionPhase.TEARDOWN) {
|
|
110
|
+
this.revertCode = RevertCode.REVERTED;
|
|
117
111
|
}
|
|
118
112
|
}
|
|
119
113
|
/**
|
|
@@ -168,8 +162,12 @@ import { getCallRequestsWithCalldataByPhase } from '../utils.js';
|
|
|
168
162
|
}
|
|
169
163
|
}
|
|
170
164
|
/**
|
|
171
|
-
* The gasUsed by public and private,
|
|
172
|
-
*
|
|
165
|
+
* The gasUsed by public and private, as if the entire teardown gas limit was consumed.
|
|
166
|
+
*
|
|
167
|
+
* This is intentional: teardown is used for gas accounting and refunds, so the transaction
|
|
168
|
+
* fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual
|
|
169
|
+
* consumption there would be a circular dependency. Billing the full teardown gas limit
|
|
170
|
+
* (set by the user) makes the fee known in advance and available to the teardown function.
|
|
173
171
|
*/ getTotalGasUsed() {
|
|
174
172
|
return this.gasUsedByPrivate.add(this.gasUsedByPublic);
|
|
175
173
|
}
|
|
@@ -255,7 +255,7 @@ export class PublicTxSimulator {
|
|
|
255
255
|
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
256
256
|
// will pick up the new contracts and will generate the necessary hints.
|
|
257
257
|
// So, a consumer of the hints will always see the new contracts.
|
|
258
|
-
|
|
258
|
+
this.contractsDB.addContracts(context.nonRevertibleContractDeploymentData);
|
|
259
259
|
}
|
|
260
260
|
/**
|
|
261
261
|
* Insert the revertible accumulated data from private into the public state.
|
|
@@ -316,7 +316,7 @@ export class PublicTxSimulator {
|
|
|
316
316
|
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
317
317
|
// will pick up the new contracts and will generate the necessary hints.
|
|
318
318
|
// So, a consumer of the hints will always see the new contracts.
|
|
319
|
-
|
|
319
|
+
this.contractsDB.addContracts(context.revertibleContractDeploymentData);
|
|
320
320
|
}
|
|
321
321
|
async payFee(context) {
|
|
322
322
|
const txFee = context.getTransactionFee(TxExecutionPhase.TEARDOWN);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.d1da697d6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -64,26 +64,25 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "0.0.1-commit.
|
|
68
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
69
|
-
"@aztec/native": "0.0.1-commit.
|
|
70
|
-
"@aztec/noir-acvm_js": "0.0.1-commit.
|
|
71
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
73
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
74
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
75
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
76
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
77
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
67
|
+
"@aztec/constants": "0.0.1-commit.d1da697d6",
|
|
68
|
+
"@aztec/foundation": "0.0.1-commit.d1da697d6",
|
|
69
|
+
"@aztec/native": "0.0.1-commit.d1da697d6",
|
|
70
|
+
"@aztec/noir-acvm_js": "0.0.1-commit.d1da697d6",
|
|
71
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.d1da697d6",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.d1da697d6",
|
|
73
|
+
"@aztec/noir-types": "0.0.1-commit.d1da697d6",
|
|
74
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d1da697d6",
|
|
75
|
+
"@aztec/stdlib": "0.0.1-commit.d1da697d6",
|
|
76
|
+
"@aztec/telemetry-client": "0.0.1-commit.d1da697d6",
|
|
77
|
+
"@aztec/world-state": "0.0.1-commit.d1da697d6",
|
|
78
78
|
"lodash.clonedeep": "^4.5.0",
|
|
79
79
|
"lodash.merge": "^4.6.2",
|
|
80
80
|
"tslib": "^2.4.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
84
|
-
"@aztec/
|
|
85
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
86
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.d117d021b",
|
|
83
|
+
"@aztec/kv-store": "0.0.1-commit.d1da697d6",
|
|
84
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.d1da697d6",
|
|
85
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.d1da697d6",
|
|
87
86
|
"@jest/globals": "^30.0.0",
|
|
88
87
|
"@types/jest": "^30.0.0",
|
|
89
88
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -63,7 +63,7 @@ export class AvmSimulator implements AvmSimulatorInterface {
|
|
|
63
63
|
public static async build(context: AvmContext): Promise<AvmSimulator> {
|
|
64
64
|
const simulator = new AvmSimulator(context);
|
|
65
65
|
const fnName = await context.persistableState.getPublicFunctionDebugName(context.environment);
|
|
66
|
-
simulator.log = createLogger(`simulator:avm(f:${fnName})`);
|
|
66
|
+
simulator.log = createLogger(`simulator:avm(f:${fnName.slice(0, 128)})`);
|
|
67
67
|
|
|
68
68
|
return simulator;
|
|
69
69
|
}
|
|
@@ -33,13 +33,14 @@ export class LazyReaderMemory implements LazyReader {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
public slice(start: number, end: number): Fr[] {
|
|
36
|
-
const clampedEnd = Math.min(end, this.size);
|
|
36
|
+
const clampedEnd = Math.min(end, this.size, TaggedMemory.MAX_MEMORY_SIZE - this.offset);
|
|
37
37
|
const length = Math.max(0, clampedEnd - start);
|
|
38
38
|
return this.memory.getSlice(this.offset + start, length).map(word => word.toFr());
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
public readAll(): Fr[] {
|
|
42
|
-
|
|
42
|
+
const size = Math.min(this.size, TaggedMemory.MAX_MEMORY_SIZE - this.offset);
|
|
43
|
+
return this.memory.getSlice(this.offset, size).map(word => word.toFr());
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
public length(): number {
|
|
@@ -14,8 +14,8 @@ abstract class ExternalCall extends Instruction {
|
|
|
14
14
|
OperandType.UINT16, // L2 gas offset
|
|
15
15
|
OperandType.UINT16, // DA gas offset
|
|
16
16
|
OperandType.UINT16, // Address offset
|
|
17
|
-
OperandType.UINT16, // Args offset
|
|
18
17
|
OperandType.UINT16, // Args size offset
|
|
18
|
+
OperandType.UINT16, // Args offset
|
|
19
19
|
];
|
|
20
20
|
|
|
21
21
|
constructor(
|
|
@@ -31,7 +31,7 @@ export class ContractsDbCheckpoint {
|
|
|
31
31
|
return this.bytecodeCommitments.get(classId.toString());
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
public
|
|
34
|
+
public fork(): ContractsDbCheckpoint {
|
|
35
35
|
const copy = new ContractsDbCheckpoint();
|
|
36
36
|
this.instances.forEach((value, key) => copy.instances.set(key, value));
|
|
37
37
|
this.classes.forEach((value, key) => copy.classes.set(key, value));
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_TEARDOWN_DA_GAS_LIMIT,
|
|
3
|
-
DEFAULT_TEARDOWN_L2_GAS_LIMIT,
|
|
4
|
-
PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
5
|
-
TX_DA_GAS_OVERHEAD,
|
|
6
|
-
} from '@aztec/constants';
|
|
1
|
+
import { PUBLIC_TX_L2_GAS_OVERHEAD, TX_DA_GAS_OVERHEAD } from '@aztec/constants';
|
|
7
2
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
8
3
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
9
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
5
|
import { type ContractArtifact, encodeArguments } from '@aztec/stdlib/abi';
|
|
11
6
|
import { PublicSimulatorConfig, type PublicTxResult } from '@aztec/stdlib/avm';
|
|
12
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
|
-
import { Gas, GasFees } from '@aztec/stdlib/gas';
|
|
8
|
+
import { FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT, Gas, GasFees } from '@aztec/stdlib/gas';
|
|
14
9
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
15
10
|
import { PublicCallRequest } from '@aztec/stdlib/kernel';
|
|
16
11
|
import { GlobalVariables, PublicCallRequestWithCalldata, type Tx } from '@aztec/stdlib/tx';
|
|
@@ -138,8 +133,8 @@ export class PublicTxSimulationTester extends BaseAvmSimulationTester {
|
|
|
138
133
|
feePayer,
|
|
139
134
|
/*gasUsedByPrivate*/ teardownCall
|
|
140
135
|
? new Gas(
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
FALLBACK_TEARDOWN_DA_GAS_LIMIT + TX_DA_GAS_OVERHEAD,
|
|
137
|
+
FALLBACK_TEARDOWN_L2_GAS_LIMIT + PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
143
138
|
)
|
|
144
139
|
: new Gas(TX_DA_GAS_OVERHEAD, PUBLIC_TX_L2_GAS_OVERHEAD),
|
|
145
140
|
defaultGlobals(),
|
|
@@ -2,10 +2,8 @@ import {
|
|
|
2
2
|
CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE,
|
|
3
3
|
CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
|
|
4
4
|
CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
DEFAULT_TEARDOWN_DA_GAS_LIMIT,
|
|
8
|
-
DEFAULT_TEARDOWN_L2_GAS_LIMIT,
|
|
5
|
+
MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT,
|
|
6
|
+
MAX_PROCESSABLE_L2_GAS,
|
|
9
7
|
PRIVATE_LOG_SIZE_IN_FIELDS,
|
|
10
8
|
} from '@aztec/constants';
|
|
11
9
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
@@ -14,7 +12,13 @@ import { CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG } from '@aztec/protocol-contracts
|
|
|
14
12
|
import { bufferAsFields } from '@aztec/stdlib/abi';
|
|
15
13
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
14
|
import type { ContractClassPublic, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
17
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
FALLBACK_TEARDOWN_DA_GAS_LIMIT,
|
|
17
|
+
FALLBACK_TEARDOWN_L2_GAS_LIMIT,
|
|
18
|
+
Gas,
|
|
19
|
+
GasFees,
|
|
20
|
+
GasSettings,
|
|
21
|
+
} from '@aztec/stdlib/gas';
|
|
18
22
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
19
23
|
import {
|
|
20
24
|
LogHash,
|
|
@@ -69,7 +73,7 @@ export async function createTxForPublicCalls(
|
|
|
69
73
|
"Can't create public tx with no enqueued calls",
|
|
70
74
|
);
|
|
71
75
|
// use max limits
|
|
72
|
-
gasLimits = gasLimits ?? new Gas(
|
|
76
|
+
gasLimits = gasLimits ?? new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
73
77
|
|
|
74
78
|
const forPublic = PartialPrivateTailPublicInputsForPublic.empty();
|
|
75
79
|
|
|
@@ -129,7 +133,7 @@ export async function createTxForPublicCalls(
|
|
|
129
133
|
|
|
130
134
|
const maxFeesPerGas = feePayer.isZero() ? GasFees.empty() : new GasFees(10, 10);
|
|
131
135
|
const teardownGasLimits = teardownCallRequest
|
|
132
|
-
? new Gas(
|
|
136
|
+
? new Gas(FALLBACK_TEARDOWN_DA_GAS_LIMIT, FALLBACK_TEARDOWN_L2_GAS_LIMIT)
|
|
133
137
|
: Gas.empty();
|
|
134
138
|
const gasSettings = new GasSettings(gasLimits, teardownGasLimits, maxFeesPerGas, GasFees.empty());
|
|
135
139
|
const txContext = new TxContext(Fr.zero(), Fr.zero(), gasSettings);
|
|
@@ -164,7 +168,7 @@ export async function createTxForPrivateOnly(
|
|
|
164
168
|
gasUsedByPrivate: Gas = new Gas(10, 10),
|
|
165
169
|
): Promise<Tx> {
|
|
166
170
|
// use max limits
|
|
167
|
-
const gasLimits = new Gas(
|
|
171
|
+
const gasLimits = new Gas(MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS);
|
|
168
172
|
|
|
169
173
|
const forRollup = PartialPrivateTailPublicInputsForRollup.empty();
|
|
170
174
|
|
|
@@ -410,12 +410,12 @@ export class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
-
public async createCheckpoint(): Promise<
|
|
413
|
+
public async createCheckpoint(): Promise<number> {
|
|
414
414
|
const actionCounter = this.checkpointActionCounter++;
|
|
415
415
|
const oldCheckpointId = this.getCurrentCheckpointId();
|
|
416
416
|
const treesStateHash = await this.getTreesStateHash();
|
|
417
417
|
|
|
418
|
-
await this.db.createCheckpoint();
|
|
418
|
+
const depth = await this.db.createCheckpoint();
|
|
419
419
|
this.checkpointStack.push(this.nextCheckpointId++);
|
|
420
420
|
const newCheckpointId = this.getCurrentCheckpointId();
|
|
421
421
|
|
|
@@ -424,14 +424,16 @@ export class HintingMerkleWriteOperations implements MerkleTreeWriteOperations {
|
|
|
424
424
|
HintingMerkleWriteOperations.log.trace(
|
|
425
425
|
`[createCheckpoint:${actionCounter}] Checkpoint evolved ${oldCheckpointId} -> ${newCheckpointId} at trees state ${treesStateHash}.`,
|
|
426
426
|
);
|
|
427
|
+
|
|
428
|
+
return depth;
|
|
427
429
|
}
|
|
428
430
|
|
|
429
|
-
public
|
|
430
|
-
throw new Error('
|
|
431
|
+
public commitAllCheckpointsTo(_depth: number): Promise<void> {
|
|
432
|
+
throw new Error('commitAllCheckpointsTo is not supported in HintingMerkleWriteOperations.');
|
|
431
433
|
}
|
|
432
434
|
|
|
433
|
-
public
|
|
434
|
-
throw new Error('
|
|
435
|
+
public revertAllCheckpointsTo(_depth: number): Promise<void> {
|
|
436
|
+
throw new Error('revertAllCheckpointsTo is not supported in HintingMerkleWriteOperations.');
|
|
435
437
|
}
|
|
436
438
|
|
|
437
439
|
public async commitCheckpoint(): Promise<void> {
|
|
@@ -55,10 +55,10 @@ export class PublicContractsDB implements PublicContractsDBInterface {
|
|
|
55
55
|
this.log = createLogger('simulator:contracts-data-source', bindings);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
public
|
|
58
|
+
public addContracts(contractDeploymentData: ContractDeploymentData): void {
|
|
59
59
|
const currentState = this.getCurrentState();
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
this.addContractClassesFromEvents(
|
|
62
62
|
ContractClassPublishedEvent.extractContractClassEvents(contractDeploymentData.getContractClassLogs()),
|
|
63
63
|
currentState,
|
|
64
64
|
);
|
|
@@ -69,10 +69,10 @@ export class PublicContractsDB implements PublicContractsDBInterface {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
public
|
|
72
|
+
public addNewContracts(tx: Tx): void {
|
|
73
73
|
const contractDeploymentData = AllContractDeploymentData.fromTx(tx);
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
this.addContracts(contractDeploymentData.getNonRevertibleContractDeploymentData());
|
|
75
|
+
this.addContracts(contractDeploymentData.getRevertibleContractDeploymentData());
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
@@ -81,7 +81,7 @@ export class PublicContractsDB implements PublicContractsDBInterface {
|
|
|
81
81
|
*/
|
|
82
82
|
public createCheckpoint(): void {
|
|
83
83
|
const currentState = this.getCurrentState();
|
|
84
|
-
const newState = currentState.
|
|
84
|
+
const newState = currentState.fork();
|
|
85
85
|
this.contractStateStack.push(newState);
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -174,17 +174,15 @@ export class PublicContractsDB implements PublicContractsDBInterface {
|
|
|
174
174
|
return await this.dataSource.getDebugFunctionName(address, selector);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
private
|
|
177
|
+
private addContractClassesFromEvents(
|
|
178
178
|
contractClassEvents: ContractClassPublishedEvent[],
|
|
179
179
|
state: ContractsDbCheckpoint,
|
|
180
180
|
) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}),
|
|
187
|
-
);
|
|
181
|
+
for (const event of contractClassEvents) {
|
|
182
|
+
this.log.debug(`Adding class ${event.contractClassId.toString()} to contract state`);
|
|
183
|
+
const contractClass = event.toContractClassPublic();
|
|
184
|
+
state.addClass(event.contractClassId, contractClass);
|
|
185
|
+
}
|
|
188
186
|
}
|
|
189
187
|
|
|
190
188
|
private addContractInstancesFromEvents(
|
|
@@ -134,7 +134,7 @@ export class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
|
|
|
134
134
|
): Promise<(BlockNumber | undefined)[]> {
|
|
135
135
|
return this.guardAndPush(() => this.target.getBlockNumbersForLeafIndices(treeId, leafIndices));
|
|
136
136
|
}
|
|
137
|
-
createCheckpoint(): Promise<
|
|
137
|
+
createCheckpoint(): Promise<number> {
|
|
138
138
|
return this.guardAndPush(() => this.target.createCheckpoint());
|
|
139
139
|
}
|
|
140
140
|
commitCheckpoint(): Promise<void> {
|
|
@@ -143,11 +143,11 @@ export class GuardedMerkleTreeOperations implements MerkleTreeWriteOperations {
|
|
|
143
143
|
revertCheckpoint(): Promise<void> {
|
|
144
144
|
return this.guardAndPush(() => this.target.revertCheckpoint());
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
return this.guardAndPush(() => this.target.
|
|
146
|
+
commitAllCheckpointsTo(depth: number): Promise<void> {
|
|
147
|
+
return this.guardAndPush(() => this.target.commitAllCheckpointsTo(depth));
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
return this.guardAndPush(() => this.target.
|
|
149
|
+
revertAllCheckpointsTo(depth: number): Promise<void> {
|
|
150
|
+
return this.guardAndPush(() => this.target.revertAllCheckpointsTo(depth));
|
|
151
151
|
}
|
|
152
152
|
findSiblingPaths<ID extends MerkleTreeId>(
|
|
153
153
|
treeId: ID,
|
|
@@ -306,6 +306,9 @@ export class PublicProcessor implements Traceable {
|
|
|
306
306
|
totalBlockGas = totalBlockGas.add(processedTx.gasUsed.totalGas);
|
|
307
307
|
totalSizeInBytes += txSize;
|
|
308
308
|
totalBlobFields += txBlobFields;
|
|
309
|
+
|
|
310
|
+
// Commit the tx-level contracts checkpoint on success
|
|
311
|
+
this.contractsDB.commitCheckpoint();
|
|
309
312
|
} catch (err: any) {
|
|
310
313
|
if (err?.name === 'PublicProcessorTimeoutError') {
|
|
311
314
|
this.log.warn(`Stopping tx processing due to timeout.`);
|
|
@@ -325,14 +328,10 @@ export class PublicProcessor implements Traceable {
|
|
|
325
328
|
// 1. At least one outstanding checkpoint that has not been committed (the one created before we processed the tx).
|
|
326
329
|
// 2. Possible state updates on that checkpoint or any others created during execution.
|
|
327
330
|
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
await checkpoint.
|
|
332
|
-
|
|
333
|
-
// Now we want to revert any/all remaining checkpoints, destroying any outstanding state updates.
|
|
334
|
-
// This needs to be done directly on the underlying fork as the guarded fork has been stopped.
|
|
335
|
-
await this.guardedMerkleTree.getUnderlyingFork().revertAllCheckpoints();
|
|
331
|
+
// Revert all checkpoints at or above this checkpoint's depth (inclusive), destroying any outstanding state
|
|
332
|
+
// updates from this tx and any nested checkpoints created during execution. This preserves any checkpoints
|
|
333
|
+
// created by callers below our depth.
|
|
334
|
+
await checkpoint.revertToCheckpoint();
|
|
336
335
|
|
|
337
336
|
// Revert any contracts added to the DB for the tx.
|
|
338
337
|
this.contractsDB.revertCheckpoint();
|
|
@@ -344,9 +343,9 @@ export class PublicProcessor implements Traceable {
|
|
|
344
343
|
break;
|
|
345
344
|
}
|
|
346
345
|
|
|
347
|
-
// Roll back state to start of TX before proceeding to next TX
|
|
348
|
-
|
|
349
|
-
await
|
|
346
|
+
// Roll back state to start of TX before proceeding to next TX.
|
|
347
|
+
// Reverts all checkpoints at or above this checkpoint's depth, preserving any caller checkpoints below.
|
|
348
|
+
await checkpoint.revertToCheckpoint();
|
|
350
349
|
this.contractsDB.revertCheckpoint();
|
|
351
350
|
const errorMessage = err instanceof Error || err instanceof AssertionError ? err.message : 'Unknown error';
|
|
352
351
|
this.log.warn(`Failed to process tx ${txHash.toString()}: ${errorMessage} ${err?.stack}`);
|
|
@@ -358,7 +357,6 @@ export class PublicProcessor implements Traceable {
|
|
|
358
357
|
} finally {
|
|
359
358
|
// Base case is we always commit the checkpoint. Using the ForkCheckpoint means this has no effect if the tx was previously reverted
|
|
360
359
|
await checkpoint.commit();
|
|
361
|
-
this.contractsDB.commitCheckpointOkIfNone();
|
|
362
360
|
}
|
|
363
361
|
}
|
|
364
362
|
|
|
@@ -550,7 +548,7 @@ export class PublicProcessor implements Traceable {
|
|
|
550
548
|
// Fee payment insertion has already been done. Do the rest.
|
|
551
549
|
await this.doTreeInsertionsForPrivateOnlyTx(processedTx);
|
|
552
550
|
|
|
553
|
-
|
|
551
|
+
this.contractsDB.addNewContracts(tx);
|
|
554
552
|
|
|
555
553
|
return [processedTx, undefined, []];
|
|
556
554
|
}
|
|
@@ -52,6 +52,7 @@ export class ContractProviderForCpp implements ContractProvider {
|
|
|
52
52
|
return serializeWithMessagePack(contractClass);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
+
// eslint-disable-next-line require-await
|
|
55
56
|
public addContracts = async (contractDeploymentDataBuffer: Buffer): Promise<void> => {
|
|
56
57
|
this.log.trace(`Contract provider callback: addContracts`);
|
|
57
58
|
|
|
@@ -62,7 +63,7 @@ export class ContractProviderForCpp implements ContractProvider {
|
|
|
62
63
|
|
|
63
64
|
// Add contracts to the contracts DB
|
|
64
65
|
this.log.trace(`Calling contractsDB.addContracts`);
|
|
65
|
-
|
|
66
|
+
this.contractsDB.addContracts(contractDeploymentData);
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
public getBytecodeCommitment = async (classId: string): Promise<Buffer | undefined> => {
|
|
@@ -174,14 +174,8 @@ export class PublicTxContext {
|
|
|
174
174
|
}
|
|
175
175
|
if (phase === TxExecutionPhase.SETUP) {
|
|
176
176
|
this.log.warn(`Setup phase reverted! The transaction will be thrown out.`);
|
|
177
|
-
} else if (phase === TxExecutionPhase.APP_LOGIC) {
|
|
178
|
-
this.revertCode = RevertCode.
|
|
179
|
-
} else if (phase === TxExecutionPhase.TEARDOWN) {
|
|
180
|
-
if (this.revertCode.equals(RevertCode.APP_LOGIC_REVERTED)) {
|
|
181
|
-
this.revertCode = RevertCode.BOTH_REVERTED;
|
|
182
|
-
} else {
|
|
183
|
-
this.revertCode = RevertCode.TEARDOWN_REVERTED;
|
|
184
|
-
}
|
|
177
|
+
} else if (phase === TxExecutionPhase.APP_LOGIC || phase === TxExecutionPhase.TEARDOWN) {
|
|
178
|
+
this.revertCode = RevertCode.REVERTED;
|
|
185
179
|
}
|
|
186
180
|
}
|
|
187
181
|
|
|
@@ -247,8 +241,12 @@ export class PublicTxContext {
|
|
|
247
241
|
}
|
|
248
242
|
|
|
249
243
|
/**
|
|
250
|
-
* The gasUsed by public and private,
|
|
251
|
-
*
|
|
244
|
+
* The gasUsed by public and private, as if the entire teardown gas limit was consumed.
|
|
245
|
+
*
|
|
246
|
+
* This is intentional: teardown is used for gas accounting and refunds, so the transaction
|
|
247
|
+
* fee must be deterministic _before_ teardown executes. If fees depended on teardown's actual
|
|
248
|
+
* consumption there would be a circular dependency. Billing the full teardown gas limit
|
|
249
|
+
* (set by the user) makes the fee known in advance and available to the teardown function.
|
|
252
250
|
*/
|
|
253
251
|
getTotalGasUsed(): Gas {
|
|
254
252
|
return this.gasUsedByPrivate.add(this.gasUsedByPublic);
|
|
@@ -401,7 +401,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
401
401
|
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
402
402
|
// will pick up the new contracts and will generate the necessary hints.
|
|
403
403
|
// So, a consumer of the hints will always see the new contracts.
|
|
404
|
-
|
|
404
|
+
this.contractsDB.addContracts(context.nonRevertibleContractDeploymentData);
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
/**
|
|
@@ -486,7 +486,7 @@ export class PublicTxSimulator implements PublicTxSimulatorInterface {
|
|
|
486
486
|
// However, things work as expected because later calls to getters on the hintingContractsDB
|
|
487
487
|
// will pick up the new contracts and will generate the necessary hints.
|
|
488
488
|
// So, a consumer of the hints will always see the new contracts.
|
|
489
|
-
|
|
489
|
+
this.contractsDB.addContracts(context.revertibleContractDeploymentData);
|
|
490
490
|
}
|
|
491
491
|
|
|
492
492
|
private async payFee(context: PublicTxContext) {
|