@aztec/simulator 1.0.0-nightly.20250708 → 1.0.0-staging.1
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/opcodes/environment_getters.d.ts +2 -2
- package/dest/public/avm/opcodes/environment_getters.d.ts.map +1 -1
- package/dest/public/avm/opcodes/environment_getters.js +6 -6
- package/dest/public/avm/opcodes/memory.d.ts.map +1 -1
- package/dest/public/avm/opcodes/memory.js +0 -3
- package/dest/public/avm/serialization/instruction_serialization.d.ts.map +1 -1
- package/dest/public/avm/serialization/instruction_serialization.js +4 -10
- package/dest/public/fixtures/utils.d.ts.map +1 -1
- package/dest/public/fixtures/utils.js +3 -5
- package/dest/public/public_processor/public_processor.d.ts +2 -3
- package/dest/public/public_processor/public_processor.d.ts.map +1 -1
- package/dest/public/public_processor/public_processor.js +2 -13
- package/package.json +15 -15
- package/src/public/avm/opcodes/environment_getters.ts +8 -8
- package/src/public/avm/opcodes/memory.ts +0 -6
- package/src/public/avm/serialization/instruction_serialization.ts +4 -13
- package/src/public/fixtures/utils.ts +3 -4
- package/src/public/public_processor/public_processor.ts +3 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment_getters.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/environment_getters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,oBAAY,mBAAmB;IAC7B,OAAO,IAAA;IACP,MAAM,IAAA;IACN,cAAc,IAAA;IACd,OAAO,IAAA;IACP,OAAO,IAAA;IACP,WAAW,IAAA;IACX,SAAS,IAAA;IACT,
|
|
1
|
+
{"version":3,"file":"environment_getters.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/environment_getters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,oBAAY,mBAAmB;IAC7B,OAAO,IAAA;IACP,MAAM,IAAA;IACN,cAAc,IAAA;IACd,OAAO,IAAA;IACP,OAAO,IAAA;IACP,WAAW,IAAA;IACX,SAAS,IAAA;IACT,WAAW,IAAA;IACX,WAAW,IAAA;IACX,YAAY,IAAA;IACZ,SAAS,KAAA;IACT,SAAS,KAAA;CACV;AAiCD,qBAAa,SAAU,SAAQ,WAAW;IAWtC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IAZjB,gBAAuB,IAAI,EAAE,MAAM,CAAe;IAClD,gBAAuB,MAAM,EAAE,MAAM,CAAuB;IAC5D,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,EAAE,CAKzC;gBAGQ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM;IAKZ,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBzD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field,
|
|
1
|
+
import { Field, Uint32, Uint64, Uint128 } from '../avm_memory_types.js';
|
|
2
2
|
import { InstructionExecutionError } from '../errors.js';
|
|
3
3
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
4
4
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -11,8 +11,8 @@ export var EnvironmentVariable = /*#__PURE__*/ function(EnvironmentVariable) {
|
|
|
11
11
|
EnvironmentVariable[EnvironmentVariable["VERSION"] = 4] = "VERSION";
|
|
12
12
|
EnvironmentVariable[EnvironmentVariable["BLOCKNUMBER"] = 5] = "BLOCKNUMBER";
|
|
13
13
|
EnvironmentVariable[EnvironmentVariable["TIMESTAMP"] = 6] = "TIMESTAMP";
|
|
14
|
-
EnvironmentVariable[EnvironmentVariable["
|
|
15
|
-
EnvironmentVariable[EnvironmentVariable["
|
|
14
|
+
EnvironmentVariable[EnvironmentVariable["FEEPERL2GAS"] = 7] = "FEEPERL2GAS";
|
|
15
|
+
EnvironmentVariable[EnvironmentVariable["FEEPERDAGAS"] = 8] = "FEEPERDAGAS";
|
|
16
16
|
EnvironmentVariable[EnvironmentVariable["ISSTATICCALL"] = 9] = "ISSTATICCALL";
|
|
17
17
|
EnvironmentVariable[EnvironmentVariable["L2GASLEFT"] = 10] = "L2GASLEFT";
|
|
18
18
|
EnvironmentVariable[EnvironmentVariable["DAGASLEFT"] = 11] = "DAGASLEFT";
|
|
@@ -39,11 +39,11 @@ function getValue(e, ctx) {
|
|
|
39
39
|
case 8:
|
|
40
40
|
return new Uint128(ctx.environment.globals.gasFees.feePerDaGas);
|
|
41
41
|
case 9:
|
|
42
|
-
return new
|
|
42
|
+
return new Field(ctx.environment.isStaticCall ? 1 : 0);
|
|
43
43
|
case 10:
|
|
44
|
-
return new
|
|
44
|
+
return new Field(ctx.machineState.l2GasLeft);
|
|
45
45
|
case 11:
|
|
46
|
-
return new
|
|
46
|
+
return new Field(ctx.machineState.daGasLeft);
|
|
47
47
|
default:
|
|
48
48
|
throw new Error(`Unknown environment variable ${e}`);
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/memory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/opcodes/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,+CAA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UAAU,EAAE,WAAW,EAAE,CAA8D;gBAG7F,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM;IAKd,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAazD;AAED,qBAAa,cAAe,SAAQ,WAAW;IAa3C,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IAfnB,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAoB;IAChD,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAyB;IAEvD,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,EAAE,CAMvC;gBAGQ,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM;IAKd,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;CAuBzD"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { strict as assert } from 'assert';
|
|
3
1
|
import { Field, TaggedMemory, TypeTag, Uint32 } from '../avm_memory_types.js';
|
|
4
2
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
5
3
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -56,7 +54,6 @@ export class Set extends Instruction {
|
|
|
56
54
|
];
|
|
57
55
|
constructor(indirect, dstOffset, inTag, value){
|
|
58
56
|
super(), this.indirect = indirect, this.dstOffset = dstOffset, this.inTag = inTag, this.value = value;
|
|
59
|
-
assert(this.value < Fr.MODULUS, 'Value is larger than Fr.MODULUS');
|
|
60
57
|
}
|
|
61
58
|
async execute(context) {
|
|
62
59
|
// Constructor ensured that this.inTag is a valid tag
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruction_serialization.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/serialization/instruction_serialization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instruction_serialization.d.ts","sourceRoot":"","sources":["../../../../src/public/avm/serialization/instruction_serialization.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;GAGG;AACH,oBAAY,MAAM;IAEhB,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,OAAO,IAAA;IACP,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,IAAI,KAAA;IACJ,KAAK,KAAA;IACL,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,MAAM,KAAA;IACN,OAAO,KAAA;IAEP,YAAY,KAAA;IACZ,YAAY,KAAA;IACZ,WAAW,KAAA;IACX,cAAc,KAAA;IACd,cAAc,KAAA;IAEd,OAAO,KAAA;IACP,QAAQ,KAAA;IACR,YAAY,KAAA;IACZ,cAAc,KAAA;IAEd,KAAK,KAAA;IACL,MAAM,KAAA;IACN,MAAM,KAAA;IACN,MAAM,KAAA;IACN,OAAO,KAAA;IACP,MAAM,KAAA;IACN,KAAK,KAAA;IACL,MAAM,KAAA;IAEN,KAAK,KAAA;IACL,MAAM,KAAA;IACN,cAAc,KAAA;IACd,YAAY,KAAA;IACZ,eAAe,KAAA;IACf,aAAa,KAAA;IACb,eAAe,KAAA;IACf,mBAAmB,KAAA;IACnB,kBAAkB,KAAA;IAClB,aAAa,KAAA;IAEb,IAAI,KAAA;IACJ,UAAU,KAAA;IACV,MAAM,KAAA;IACN,QAAQ,KAAA;IACR,SAAS,KAAA;IAET,QAAQ,KAAA;IAER,SAAS,KAAA;IACT,iBAAiB,KAAA;IACjB,WAAW,KAAA;IACX,KAAK,KAAA;IAEL,SAAS,KAAA;CACV;AAED,eAAO,MAAM,gBAAgB,QAI5B,CAAC;AAIF,oBAAY,WAAW;IACrB,KAAK,IAAA;IACL,MAAM,IAAA;IACN,MAAM,IAAA;IACN,MAAM,IAAA;IACN,OAAO,IAAA;IACP,EAAE,IAAA;IACF,GAAG,IAAA;CACJ;AAGD,KAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,CAAC;AAoDzC;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,iBAAiB,EAAE,CAyBvG;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,CAmBrF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
1
|
import { strict as assert } from 'assert';
|
|
3
2
|
import { TaggedMemory } from '../avm_memory_types.js';
|
|
4
3
|
import { BufferCursor } from './buffer_cursor.js';
|
|
@@ -159,17 +158,12 @@ const OPERAND_SPEC = new Map([
|
|
|
159
158
|
]);
|
|
160
159
|
function readBigInt254BE(offset) {
|
|
161
160
|
const totalBytes = 32;
|
|
162
|
-
let
|
|
161
|
+
let ret = 0n;
|
|
163
162
|
for(let i = 0; i < totalBytes; ++i){
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
// In circuit, we only support values up to Fr.MODULUS and any deserialized value
|
|
168
|
-
// would naturally undergo a modulus reduction.
|
|
169
|
-
if (value >= Fr.MODULUS) {
|
|
170
|
-
value = value % Fr.MODULUS;
|
|
163
|
+
ret <<= 8n;
|
|
164
|
+
ret |= BigInt(this.readUint8(i + offset));
|
|
171
165
|
}
|
|
172
|
-
return
|
|
166
|
+
return ret;
|
|
173
167
|
}
|
|
174
168
|
function writeBigInt254BE(value) {
|
|
175
169
|
const totalBytes = 32;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAwB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/public/fixtures/utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,GAAG,EAAwB,MAAM,mBAAmB,CAAC;AAY9D,OAAO,EAEL,eAAe,EAEf,6BAA6B,EAC7B,EAAE,EAGH,MAAM,kBAAkB,CAAC;AAI1B,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,CAAC,EAAE;QACX,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC;KACnB,CAAC;IACF,aAAa,CAAC,EAAE;QACd,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC;KACnB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,qBAAqB,EACxC,iBAAiB,EAAE,6BAA6B,EAAE,EAClD,eAAe,EAAE,6BAA6B,EAAE,EAChD,mBAAmB,CAAC,EAAE,6BAA6B,EACnD,QAAQ,eAAsB,EAC9B,gBAAgB,GAAE,GAAiB,EACnC,OAAO,GAAE,eAAyC,GACjD,EAAE,CA2EJ;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,eAAsB,EAAE,gBAAgB,GAAE,GAAqB,GAAG,EAAE,CAoBlH;AAED,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,EAAE,EACN,aAAa,EAAE,mBAAmB,EAClC,sBAAsB,UAAQ,iBA6B/B;AAED,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,EAAE,EACN,gBAAgB,EAAE,2BAA2B,EAC7C,sBAAsB,UAAQ,iBA0C/B"}
|
|
@@ -6,7 +6,7 @@ import { bufferAsFields } from '@aztec/stdlib/abi';
|
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
7
|
import { Gas, GasFees, GasSettings } from '@aztec/stdlib/gas';
|
|
8
8
|
import { siloNullifier } from '@aztec/stdlib/hash';
|
|
9
|
-
import { LogHash, PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, countAccumulatedItems } from '@aztec/stdlib/kernel';
|
|
9
|
+
import { LogHash, PartialPrivateTailPublicInputsForPublic, PartialPrivateTailPublicInputsForRollup, PrivateKernelTailCircuitPublicInputs, RollupValidationRequests, countAccumulatedItems } from '@aztec/stdlib/kernel';
|
|
10
10
|
import { ContractClassLogFields, PrivateLog } from '@aztec/stdlib/logs';
|
|
11
11
|
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
12
12
|
import { BlockHeader, GlobalVariables, HashedValues, Tx, TxConstantData, TxContext } from '@aztec/stdlib/tx';
|
|
@@ -63,8 +63,7 @@ import { strict as assert } from 'assert';
|
|
|
63
63
|
const header = BlockHeader.empty();
|
|
64
64
|
header.globalVariables = globals;
|
|
65
65
|
const constantData = new TxConstantData(header, txContext, Fr.zero(), Fr.zero());
|
|
66
|
-
const
|
|
67
|
-
const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsedByPrivate, feePayer, includeByTimestamp, forPublic);
|
|
66
|
+
const txData = new PrivateKernelTailCircuitPublicInputs(constantData, RollupValidationRequests.empty(), /*gasUsed=*/ gasUsedByPrivate, feePayer, forPublic);
|
|
68
67
|
const calldata = [
|
|
69
68
|
...setupCallRequests,
|
|
70
69
|
...appCallRequests,
|
|
@@ -82,8 +81,7 @@ export function createTxForPrivateOnly(feePayer = AztecAddress.zero(), gasUsedBy
|
|
|
82
81
|
const gasSettings = new GasSettings(gasLimits, Gas.empty(), maxFeesPerGas, GasFees.empty());
|
|
83
82
|
const txContext = new TxContext(Fr.zero(), Fr.zero(), gasSettings);
|
|
84
83
|
const constantData = new TxConstantData(BlockHeader.empty(), txContext, Fr.zero(), Fr.zero());
|
|
85
|
-
const
|
|
86
|
-
const txData = new PrivateKernelTailCircuitPublicInputs(constantData, /*gasUsed=*/ gasUsedByPrivate, feePayer, includeByTimestamp, /*forPublic=*/ undefined, forRollup);
|
|
84
|
+
const txData = new PrivateKernelTailCircuitPublicInputs(constantData, RollupValidationRequests.empty(), /*gasUsed=*/ gasUsedByPrivate, feePayer, /*forPublic=*/ undefined, forRollup);
|
|
87
85
|
return new Tx(txData, ClientIvcProof.empty(), [], []);
|
|
88
86
|
}
|
|
89
87
|
export async function addNewContractClassToTx(tx, contractClass, skipNullifierInsertion = false) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
2
2
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { MerkleTreeWriteOperations, PublicProcessorLimits, PublicProcessorValidator
|
|
3
|
+
import type { MerkleTreeWriteOperations, PublicProcessorLimits, PublicProcessorValidator } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import { type FailedTx, GlobalVariables, NestedProcessReturnValues, type ProcessedTx, Tx } from '@aztec/stdlib/tx';
|
|
5
5
|
import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
6
6
|
import { PublicContractsDB } from '../public_db_sources.js';
|
|
@@ -35,9 +35,8 @@ export declare class PublicProcessor implements Traceable {
|
|
|
35
35
|
protected publicTxSimulator: PublicTxSimulator;
|
|
36
36
|
private dateProvider;
|
|
37
37
|
private log;
|
|
38
|
-
private opts;
|
|
39
38
|
private metrics;
|
|
40
|
-
constructor(globalVariables: GlobalVariables, guardedMerkleTree: GuardedMerkleTreeOperations, contractsDB: PublicContractsDB, publicTxSimulator: PublicTxSimulator, dateProvider: DateProvider, telemetryClient?: TelemetryClient, log?: import("@aztec/foundation/log").Logger
|
|
39
|
+
constructor(globalVariables: GlobalVariables, guardedMerkleTree: GuardedMerkleTreeOperations, contractsDB: PublicContractsDB, publicTxSimulator: PublicTxSimulator, dateProvider: DateProvider, telemetryClient?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
41
40
|
get tracer(): Tracer;
|
|
42
41
|
/**
|
|
43
42
|
* Run each tx through the public circuit and the public kernel circuit if needed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"public_processor.d.ts","sourceRoot":"","sources":["../../../src/public/public_processor/public_processor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAMvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,KAAK,QAAQ,EACb,eAAe,EACf,yBA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,iBAAiB,EAC9B,iBAAiB,EAAE,iBAAiB,EACtC,YAAY,EAAE,YAAY,EAClC,eAAe,GAAE,eAAsC,EAC/C,GAAG,yCAA6C;IAK1D,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,CAAC,CAAC;YAkK5D,SAAS;YA2BT,gCAAgC;IAoC9C,kFAAkF;YACpE,uBAAuB;IA+BrC;;;;OAIG;YACW,gCAAgC;YA0BhC,oBAAoB;YAkCpB,wBAAwB;CA4CvC"}
|
|
@@ -8,7 +8,6 @@ import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT
|
|
|
8
8
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
9
9
|
import { Fr } from '@aztec/foundation/fields';
|
|
10
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
11
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
12
11
|
import { DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
|
|
13
12
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
14
13
|
import { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
|
|
@@ -66,16 +65,14 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
66
65
|
publicTxSimulator;
|
|
67
66
|
dateProvider;
|
|
68
67
|
log;
|
|
69
|
-
opts;
|
|
70
68
|
metrics;
|
|
71
|
-
constructor(globalVariables, guardedMerkleTree, contractsDB, publicTxSimulator, dateProvider, telemetryClient = getTelemetryClient(), log = createLogger('simulator:public-processor')
|
|
69
|
+
constructor(globalVariables, guardedMerkleTree, contractsDB, publicTxSimulator, dateProvider, telemetryClient = getTelemetryClient(), log = createLogger('simulator:public-processor')){
|
|
72
70
|
this.globalVariables = globalVariables;
|
|
73
71
|
this.guardedMerkleTree = guardedMerkleTree;
|
|
74
72
|
this.contractsDB = contractsDB;
|
|
75
73
|
this.publicTxSimulator = publicTxSimulator;
|
|
76
74
|
this.dateProvider = dateProvider;
|
|
77
75
|
this.log = log;
|
|
78
|
-
this.opts = opts;
|
|
79
76
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
80
77
|
}
|
|
81
78
|
get tracer() {
|
|
@@ -283,15 +280,7 @@ class PublicProcessorTimeoutError extends Error {
|
|
|
283
280
|
this.metrics.recordTreeInsertions(Number(treeInsertionEnd - treeInsertionStart) / 1_000);
|
|
284
281
|
}
|
|
285
282
|
/** Processes the given tx within deadline. Returns timeout if deadline is hit. */ async processTxWithinDeadline(tx, deadline) {
|
|
286
|
-
const
|
|
287
|
-
// Fake a delay per tx if instructed (used for tests)
|
|
288
|
-
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
289
|
-
const processFn = fakeDelayPerTxMs && fakeDelayPerTxMs > 0 ? async ()=>{
|
|
290
|
-
const result = await innerProcessFn();
|
|
291
|
-
this.log.warn(`Sleeping ${fakeDelayPerTxMs}ms after processing tx ${await tx.getTxHash()}`);
|
|
292
|
-
await sleep(fakeDelayPerTxMs);
|
|
293
|
-
return result;
|
|
294
|
-
} : innerProcessFn;
|
|
283
|
+
const processFn = tx.hasPublicCalls() ? ()=>this.processTxWithPublicCalls(tx) : ()=>this.processPrivateOnlyTx(tx);
|
|
295
284
|
if (!deadline) {
|
|
296
285
|
return await processFn();
|
|
297
286
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/simulator",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-staging.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./server": "./dest/server.js",
|
|
@@ -62,25 +62,25 @@
|
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@aztec/constants": "1.0.0-
|
|
66
|
-
"@aztec/foundation": "1.0.0-
|
|
67
|
-
"@aztec/noir-acvm_js": "1.0.0-
|
|
68
|
-
"@aztec/noir-noirc_abi": "1.0.0-
|
|
69
|
-
"@aztec/noir-protocol-circuits-types": "1.0.0-
|
|
70
|
-
"@aztec/noir-types": "1.0.0-
|
|
71
|
-
"@aztec/protocol-contracts": "1.0.0-
|
|
72
|
-
"@aztec/stdlib": "1.0.0-
|
|
73
|
-
"@aztec/telemetry-client": "1.0.0-
|
|
74
|
-
"@aztec/world-state": "1.0.0-
|
|
65
|
+
"@aztec/constants": "1.0.0-staging.1",
|
|
66
|
+
"@aztec/foundation": "1.0.0-staging.1",
|
|
67
|
+
"@aztec/noir-acvm_js": "1.0.0-staging.1",
|
|
68
|
+
"@aztec/noir-noirc_abi": "1.0.0-staging.1",
|
|
69
|
+
"@aztec/noir-protocol-circuits-types": "1.0.0-staging.1",
|
|
70
|
+
"@aztec/noir-types": "1.0.0-staging.1",
|
|
71
|
+
"@aztec/protocol-contracts": "1.0.0-staging.1",
|
|
72
|
+
"@aztec/stdlib": "1.0.0-staging.1",
|
|
73
|
+
"@aztec/telemetry-client": "1.0.0-staging.1",
|
|
74
|
+
"@aztec/world-state": "1.0.0-staging.1",
|
|
75
75
|
"lodash.clonedeep": "^4.5.0",
|
|
76
76
|
"lodash.merge": "^4.6.2",
|
|
77
77
|
"tslib": "^2.4.0"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@aztec/kv-store": "1.0.0-
|
|
81
|
-
"@aztec/merkle-tree": "1.0.0-
|
|
82
|
-
"@aztec/noir-contracts.js": "1.0.0-
|
|
83
|
-
"@aztec/noir-test-contracts.js": "1.0.0-
|
|
80
|
+
"@aztec/kv-store": "1.0.0-staging.1",
|
|
81
|
+
"@aztec/merkle-tree": "1.0.0-staging.1",
|
|
82
|
+
"@aztec/noir-contracts.js": "1.0.0-staging.1",
|
|
83
|
+
"@aztec/noir-test-contracts.js": "1.0.0-staging.1",
|
|
84
84
|
"@jest/globals": "^30.0.0",
|
|
85
85
|
"@types/jest": "^30.0.0",
|
|
86
86
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AvmContext } from '../avm_context.js';
|
|
2
|
-
import { Field,
|
|
2
|
+
import { Field, Uint32, Uint64, Uint128 } from '../avm_memory_types.js';
|
|
3
3
|
import { InstructionExecutionError } from '../errors.js';
|
|
4
4
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
5
5
|
import { Addressing } from './addressing_mode.js';
|
|
@@ -13,8 +13,8 @@ export enum EnvironmentVariable {
|
|
|
13
13
|
VERSION,
|
|
14
14
|
BLOCKNUMBER,
|
|
15
15
|
TIMESTAMP,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
FEEPERL2GAS,
|
|
17
|
+
FEEPERDAGAS,
|
|
18
18
|
ISSTATICCALL,
|
|
19
19
|
L2GASLEFT,
|
|
20
20
|
DAGASLEFT,
|
|
@@ -36,16 +36,16 @@ function getValue(e: EnvironmentVariable, ctx: AvmContext) {
|
|
|
36
36
|
return new Uint32(ctx.environment.globals.blockNumber);
|
|
37
37
|
case EnvironmentVariable.TIMESTAMP:
|
|
38
38
|
return new Uint64(ctx.environment.globals.timestamp);
|
|
39
|
-
case EnvironmentVariable.
|
|
39
|
+
case EnvironmentVariable.FEEPERL2GAS:
|
|
40
40
|
return new Uint128(ctx.environment.globals.gasFees.feePerL2Gas);
|
|
41
|
-
case EnvironmentVariable.
|
|
41
|
+
case EnvironmentVariable.FEEPERDAGAS:
|
|
42
42
|
return new Uint128(ctx.environment.globals.gasFees.feePerDaGas);
|
|
43
43
|
case EnvironmentVariable.ISSTATICCALL:
|
|
44
|
-
return new
|
|
44
|
+
return new Field(ctx.environment.isStaticCall ? 1 : 0);
|
|
45
45
|
case EnvironmentVariable.L2GASLEFT:
|
|
46
|
-
return new
|
|
46
|
+
return new Field(ctx.machineState.l2GasLeft);
|
|
47
47
|
case EnvironmentVariable.DAGASLEFT:
|
|
48
|
-
return new
|
|
48
|
+
return new Field(ctx.machineState.daGasLeft);
|
|
49
49
|
default:
|
|
50
50
|
throw new Error(`Unknown environment variable ${e}`);
|
|
51
51
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
|
|
3
|
-
import { strict as assert } from 'assert';
|
|
4
|
-
|
|
5
1
|
import type { AvmContext } from '../avm_context.js';
|
|
6
2
|
import { Field, TaggedMemory, TypeTag, Uint32 } from '../avm_memory_types.js';
|
|
7
3
|
import { Opcode, OperandType } from '../serialization/instruction_serialization.js';
|
|
@@ -63,8 +59,6 @@ export class Set extends Instruction {
|
|
|
63
59
|
private value: bigint | number,
|
|
64
60
|
) {
|
|
65
61
|
super();
|
|
66
|
-
|
|
67
|
-
assert(this.value < Fr.MODULUS, 'Value is larger than Fr.MODULUS');
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
public async execute(context: AvmContext): Promise<void> {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
|
|
3
1
|
import { strict as assert } from 'assert';
|
|
4
2
|
|
|
5
3
|
import { TaggedMemory } from '../avm_memory_types.js';
|
|
@@ -126,19 +124,12 @@ const OPERAND_SPEC = new Map<OperandType, [number, (offset: number) => OperandNa
|
|
|
126
124
|
|
|
127
125
|
function readBigInt254BE(this: Buffer, offset: number): bigint {
|
|
128
126
|
const totalBytes = 32;
|
|
129
|
-
let
|
|
127
|
+
let ret: bigint = 0n;
|
|
130
128
|
for (let i = 0; i < totalBytes; ++i) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// In circuit, we only support values up to Fr.MODULUS and any deserialized value
|
|
136
|
-
// would naturally undergo a modulus reduction.
|
|
137
|
-
if (value >= Fr.MODULUS) {
|
|
138
|
-
value = value % Fr.MODULUS;
|
|
129
|
+
ret <<= 8n;
|
|
130
|
+
ret |= BigInt(this.readUint8(i + offset));
|
|
139
131
|
}
|
|
140
|
-
|
|
141
|
-
return value;
|
|
132
|
+
return ret;
|
|
142
133
|
}
|
|
143
134
|
|
|
144
135
|
function writeBigInt254BE(this: Buffer, value: bigint): void {
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
PartialPrivateTailPublicInputsForPublic,
|
|
20
20
|
PartialPrivateTailPublicInputsForRollup,
|
|
21
21
|
PrivateKernelTailCircuitPublicInputs,
|
|
22
|
+
RollupValidationRequests,
|
|
22
23
|
countAccumulatedItems,
|
|
23
24
|
} from '@aztec/stdlib/kernel';
|
|
24
25
|
import { ContractClassLogFields, PrivateLog } from '@aztec/stdlib/logs';
|
|
@@ -116,13 +117,12 @@ export function createTxForPublicCalls(
|
|
|
116
117
|
const header = BlockHeader.empty();
|
|
117
118
|
header.globalVariables = globals;
|
|
118
119
|
const constantData = new TxConstantData(header, txContext, Fr.zero(), Fr.zero());
|
|
119
|
-
const includeByTimestamp = 0n; // Not used in the simulator.
|
|
120
120
|
|
|
121
121
|
const txData = new PrivateKernelTailCircuitPublicInputs(
|
|
122
122
|
constantData,
|
|
123
|
+
RollupValidationRequests.empty(),
|
|
123
124
|
/*gasUsed=*/ gasUsedByPrivate,
|
|
124
125
|
feePayer,
|
|
125
|
-
includeByTimestamp,
|
|
126
126
|
forPublic,
|
|
127
127
|
);
|
|
128
128
|
|
|
@@ -145,13 +145,12 @@ export function createTxForPrivateOnly(feePayer = AztecAddress.zero(), gasUsedBy
|
|
|
145
145
|
const gasSettings = new GasSettings(gasLimits, Gas.empty(), maxFeesPerGas, GasFees.empty());
|
|
146
146
|
const txContext = new TxContext(Fr.zero(), Fr.zero(), gasSettings);
|
|
147
147
|
const constantData = new TxConstantData(BlockHeader.empty(), txContext, Fr.zero(), Fr.zero());
|
|
148
|
-
const includeByTimestamp = 0n; // Not used in the simulator.
|
|
149
148
|
|
|
150
149
|
const txData = new PrivateKernelTailCircuitPublicInputs(
|
|
151
150
|
constantData,
|
|
151
|
+
RollupValidationRequests.empty(),
|
|
152
152
|
/*gasUsed=*/ gasUsedByPrivate,
|
|
153
153
|
feePayer,
|
|
154
|
-
includeByTimestamp,
|
|
155
154
|
/*forPublic=*/ undefined,
|
|
156
155
|
forRollup,
|
|
157
156
|
);
|
|
@@ -2,7 +2,6 @@ import { MAX_NOTE_HASHES_PER_TX, MAX_NULLIFIERS_PER_TX, NULLIFIER_SUBTREE_HEIGHT
|
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { sleep } from '@aztec/foundation/sleep';
|
|
6
5
|
import { DateProvider, Timer, elapsed, executeTimeout } from '@aztec/foundation/timer';
|
|
7
6
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
8
7
|
import { ContractClassRegisteredEvent } from '@aztec/protocol-contracts/class-registerer';
|
|
@@ -15,7 +14,6 @@ import type {
|
|
|
15
14
|
MerkleTreeWriteOperations,
|
|
16
15
|
PublicProcessorLimits,
|
|
17
16
|
PublicProcessorValidator,
|
|
18
|
-
SequencerConfig,
|
|
19
17
|
} from '@aztec/stdlib/interfaces/server';
|
|
20
18
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
21
19
|
import {
|
|
@@ -131,7 +129,6 @@ export class PublicProcessor implements Traceable {
|
|
|
131
129
|
private dateProvider: DateProvider,
|
|
132
130
|
telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
133
131
|
private log = createLogger('simulator:public-processor'),
|
|
134
|
-
private opts: Pick<SequencerConfig, 'fakeProcessingDelayPerTxMs'> = {},
|
|
135
132
|
) {
|
|
136
133
|
this.metrics = new PublicProcessorMetrics(telemetryClient, 'PublicProcessor');
|
|
137
134
|
}
|
|
@@ -313,7 +310,7 @@ export class PublicProcessor implements Traceable {
|
|
|
313
310
|
}
|
|
314
311
|
|
|
315
312
|
@trackSpan('PublicProcessor.processTx', async tx => ({ [Attributes.TX_HASH]: (await tx.getTxHash()).toString() }))
|
|
316
|
-
private async processTx(tx: Tx, deadline
|
|
313
|
+
private async processTx(tx: Tx, deadline?: Date): Promise<[ProcessedTx, NestedProcessReturnValues[]]> {
|
|
317
314
|
const [time, [processedTx, returnValues]] = await elapsed(() => this.processTxWithinDeadline(tx, deadline));
|
|
318
315
|
|
|
319
316
|
this.log.verbose(
|
|
@@ -379,24 +376,12 @@ export class PublicProcessor implements Traceable {
|
|
|
379
376
|
/** Processes the given tx within deadline. Returns timeout if deadline is hit. */
|
|
380
377
|
private async processTxWithinDeadline(
|
|
381
378
|
tx: Tx,
|
|
382
|
-
deadline
|
|
379
|
+
deadline?: Date,
|
|
383
380
|
): Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> {
|
|
384
|
-
const
|
|
381
|
+
const processFn: () => Promise<[ProcessedTx, NestedProcessReturnValues[] | undefined]> = tx.hasPublicCalls()
|
|
385
382
|
? () => this.processTxWithPublicCalls(tx)
|
|
386
383
|
: () => this.processPrivateOnlyTx(tx);
|
|
387
384
|
|
|
388
|
-
// Fake a delay per tx if instructed (used for tests)
|
|
389
|
-
const fakeDelayPerTxMs = this.opts.fakeProcessingDelayPerTxMs;
|
|
390
|
-
const processFn =
|
|
391
|
-
fakeDelayPerTxMs && fakeDelayPerTxMs > 0
|
|
392
|
-
? async () => {
|
|
393
|
-
const result = await innerProcessFn();
|
|
394
|
-
this.log.warn(`Sleeping ${fakeDelayPerTxMs}ms after processing tx ${await tx.getTxHash()}`);
|
|
395
|
-
await sleep(fakeDelayPerTxMs);
|
|
396
|
-
return result;
|
|
397
|
-
}
|
|
398
|
-
: innerProcessFn;
|
|
399
|
-
|
|
400
385
|
if (!deadline) {
|
|
401
386
|
return await processFn();
|
|
402
387
|
}
|