@aztec/stdlib 1.0.0-nightly.20250606 → 1.0.0-nightly.20250607
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/avm/avm.d.ts +304 -304
- package/dest/avm/avm_circuit_public_inputs.d.ts +60 -60
- package/dest/avm/avm_proving_request.d.ts +184 -184
- package/dest/avm/message_pack.d.ts.map +1 -1
- package/dest/avm/message_pack.js +2 -1
- package/dest/block/l2_block.js +1 -1
- package/dest/block/l2_block_code_to_purge.js +1 -1
- package/dest/block/l2_block_source.d.ts +2 -0
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/fees/transaction_fee.js +3 -3
- package/dest/gas/gas.js +1 -1
- package/dest/gas/gas_fees.d.ts +15 -14
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +17 -18
- package/dest/gas/gas_settings.d.ts +24 -24
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +1 -0
- package/dest/interfaces/proving-job.d.ts +185 -185
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/service.d.ts +1 -2
- package/dest/interfaces/service.d.ts.map +1 -1
- package/dest/interfaces/service.js +0 -7
- package/dest/kernel/combined_constant_data.d.ts +71 -0
- package/dest/kernel/combined_constant_data.d.ts.map +1 -0
- package/dest/kernel/combined_constant_data.js +73 -0
- package/dest/kernel/index.d.ts +1 -0
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +1 -0
- package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts +3 -3
- package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/base_or_merge_rollup_public_inputs.js +3 -3
- package/dest/rollup/base_rollup_hints.d.ts +14 -15
- package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
- package/dest/rollup/base_rollup_hints.js +12 -13
- package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +24 -9
- package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts.map +1 -1
- package/dest/rollup/block_root_or_block_merge_public_inputs.js +14 -7
- package/dest/rollup/block_root_rollup.d.ts +2 -2
- package/dest/rollup/block_root_rollup.js +1 -1
- package/dest/rollup/constant_rollup_data.d.ts +45 -0
- package/dest/rollup/constant_rollup_data.d.ts.map +1 -0
- package/dest/rollup/{block_constant_data.js → constant_rollup_data.js} +13 -10
- package/dest/rollup/empty_block_root_rollup_inputs.d.ts +4 -4
- package/dest/rollup/empty_block_root_rollup_inputs.d.ts.map +1 -1
- package/dest/rollup/empty_block_root_rollup_inputs.js +2 -2
- package/dest/rollup/index.d.ts +1 -2
- package/dest/rollup/index.d.ts.map +1 -1
- package/dest/rollup/index.js +1 -2
- package/dest/rollup/root_rollup.d.ts +6 -2
- package/dest/rollup/root_rollup.d.ts.map +1 -1
- package/dest/rollup/root_rollup.js +6 -3
- package/dest/tests/factories.d.ts +10 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +33 -20
- package/dest/tests/mocks.js +2 -2
- package/dest/trees/append_only_tree_snapshot.d.ts +2 -2
- package/dest/trees/append_only_tree_snapshot.d.ts.map +1 -1
- package/dest/trees/append_only_tree_snapshot.js +2 -2
- package/dest/tx/block_header.js +2 -2
- package/dest/tx/global_variables.d.ts +12 -12
- package/dest/tx/global_variables.js +2 -2
- package/dest/tx/partial_state_reference.js +2 -2
- package/dest/tx/processed_tx.d.ts +3 -2
- package/dest/tx/processed_tx.d.ts.map +1 -1
- package/dest/tx/processed_tx.js +7 -5
- package/dest/tx/proposed_block_header.d.ts +2 -2
- package/dest/tx/proposed_block_header.js +1 -1
- package/dest/tx/public_simulation_output.d.ts +3 -3
- package/dest/tx/public_simulation_output.d.ts.map +1 -1
- package/dest/tx/public_simulation_output.js +7 -7
- package/dest/tx/state_reference.js +2 -2
- package/dest/tx/tree_snapshots.js +2 -2
- package/dest/tx/tx_context.d.ts +32 -32
- package/dest/types/shared.d.ts +4 -0
- package/dest/types/shared.d.ts.map +1 -1
- package/dest/zkpassport/index.d.ts +31 -0
- package/dest/zkpassport/index.d.ts.map +1 -0
- package/dest/zkpassport/index.js +81 -0
- package/package.json +9 -8
- package/src/avm/message_pack.ts +1 -0
- package/src/block/l2_block.ts +1 -1
- package/src/block/l2_block_code_to_purge.ts +1 -1
- package/src/block/l2_block_source.ts +3 -0
- package/src/fees/transaction_fee.ts +5 -5
- package/src/gas/gas.ts +1 -1
- package/src/gas/gas_fees.ts +27 -23
- package/src/gas/gas_settings.ts +1 -5
- package/src/interfaces/archiver.ts +1 -0
- package/src/interfaces/service.ts +1 -11
- package/src/kernel/combined_constant_data.ts +128 -0
- package/src/kernel/index.ts +1 -0
- package/src/rollup/base_or_merge_rollup_public_inputs.ts +4 -4
- package/src/rollup/base_rollup_hints.ts +11 -12
- package/src/rollup/block_root_or_block_merge_public_inputs.ts +18 -7
- package/src/rollup/block_root_rollup.ts +1 -1
- package/src/rollup/constant_rollup_data.ts +54 -0
- package/src/rollup/empty_block_root_rollup_inputs.ts +3 -3
- package/src/rollup/index.ts +1 -2
- package/src/rollup/root_rollup.ts +7 -5
- package/src/tests/factories.ts +54 -30
- package/src/tests/mocks.ts +2 -2
- package/src/trees/append_only_tree_snapshot.ts +2 -2
- package/src/tx/block_header.ts +2 -2
- package/src/tx/global_variables.ts +2 -2
- package/src/tx/partial_state_reference.ts +4 -4
- package/src/tx/processed_tx.ts +10 -7
- package/src/tx/proposed_block_header.ts +1 -1
- package/src/tx/public_simulation_output.ts +5 -5
- package/src/tx/state_reference.ts +2 -2
- package/src/tx/tree_snapshots.ts +8 -8
- package/src/types/shared.ts +5 -0
- package/src/zkpassport/index.ts +115 -0
- package/dest/rollup/block_constant_data.d.ts +0 -37
- package/dest/rollup/block_constant_data.d.ts.map +0 -1
- package/dest/rollup/epoch_constant_data.d.ts +0 -39
- package/dest/rollup/epoch_constant_data.d.ts.map +0 -1
- package/dest/rollup/epoch_constant_data.js +0 -40
- package/src/rollup/block_constant_data.ts +0 -63
- package/src/rollup/epoch_constant_data.ts +0 -44
|
@@ -10,15 +10,15 @@ import type { GasSettings } from '../gas/gas_settings.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export function computeEffectiveGasFees(gasFees: GasFees, gasSettings: GasSettings): GasFees {
|
|
12
12
|
const { maxFeesPerGas, maxPriorityFeesPerGas } = gasSettings;
|
|
13
|
-
const
|
|
13
|
+
const minBigInt = (f1: bigint, f2: bigint) => (f1 < f2 ? f1 : f2);
|
|
14
14
|
const priorityFees = new GasFees(
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
minBigInt(maxPriorityFeesPerGas.feePerDaGas, maxFeesPerGas.feePerDaGas - gasFees.feePerDaGas),
|
|
16
|
+
minBigInt(maxPriorityFeesPerGas.feePerL2Gas, maxFeesPerGas.feePerL2Gas - gasFees.feePerL2Gas),
|
|
17
17
|
);
|
|
18
18
|
|
|
19
19
|
const effectiveFees = new GasFees(
|
|
20
|
-
gasFees.feePerDaGas
|
|
21
|
-
gasFees.feePerL2Gas
|
|
20
|
+
gasFees.feePerDaGas + priorityFees.feePerDaGas,
|
|
21
|
+
gasFees.feePerL2Gas + priorityFees.feePerL2Gas,
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
return effectiveFees;
|
package/src/gas/gas.ts
CHANGED
|
@@ -88,7 +88,7 @@ export class Gas {
|
|
|
88
88
|
|
|
89
89
|
computeFee(gasFees: GasFees) {
|
|
90
90
|
return GasDimensions.reduce(
|
|
91
|
-
(acc, dimension) => acc.add(gasFees.get(dimension).mul(new Fr(this.get(dimension)))),
|
|
91
|
+
(acc, dimension) => acc.add(new Fr(gasFees.get(dimension)).mul(new Fr(this.get(dimension)))),
|
|
92
92
|
Fr.ZERO,
|
|
93
93
|
);
|
|
94
94
|
}
|
package/src/gas/gas_fees.ts
CHANGED
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { schemas } from '@aztec/foundation/schemas';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BufferReader,
|
|
5
|
+
FieldReader,
|
|
6
|
+
bigintToUInt128BE,
|
|
7
|
+
serializeToBuffer,
|
|
8
|
+
serializeToFields,
|
|
9
|
+
} from '@aztec/foundation/serialize';
|
|
4
10
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
11
|
|
|
6
12
|
import { inspect } from 'util';
|
|
7
13
|
import { z } from 'zod';
|
|
8
14
|
|
|
15
|
+
import type { UInt128 } from '../types/shared.js';
|
|
9
16
|
import type { GasDimensions } from './gas.js';
|
|
10
17
|
|
|
11
18
|
/** Gas prices for each dimension. */
|
|
12
19
|
export class GasFees {
|
|
13
|
-
public readonly feePerDaGas:
|
|
14
|
-
public readonly feePerL2Gas:
|
|
20
|
+
public readonly feePerDaGas: UInt128;
|
|
21
|
+
public readonly feePerL2Gas: UInt128;
|
|
15
22
|
|
|
16
|
-
constructor(feePerDaGas:
|
|
17
|
-
this.feePerDaGas =
|
|
18
|
-
this.feePerL2Gas =
|
|
23
|
+
constructor(feePerDaGas: number | bigint, feePerL2Gas: number | bigint) {
|
|
24
|
+
this.feePerDaGas = BigInt(feePerDaGas);
|
|
25
|
+
this.feePerL2Gas = BigInt(feePerL2Gas);
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
static get schema() {
|
|
22
29
|
return z
|
|
23
30
|
.object({
|
|
24
|
-
feePerDaGas: schemas.
|
|
25
|
-
feePerL2Gas: schemas.
|
|
31
|
+
feePerDaGas: schemas.BigInt,
|
|
32
|
+
feePerL2Gas: schemas.BigInt,
|
|
26
33
|
})
|
|
27
34
|
.transform(GasFees.from);
|
|
28
35
|
}
|
|
@@ -32,7 +39,7 @@ export class GasFees {
|
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
equals(other: GasFees) {
|
|
35
|
-
return this.feePerDaGas
|
|
42
|
+
return this.feePerDaGas === other.feePerDaGas && this.feePerL2Gas === other.feePerL2Gas;
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
get(dimension: GasDimensions) {
|
|
@@ -48,12 +55,9 @@ export class GasFees {
|
|
|
48
55
|
if (scalar === 1 || scalar === 1n) {
|
|
49
56
|
return this.clone();
|
|
50
57
|
} else if (typeof scalar === 'bigint') {
|
|
51
|
-
return new GasFees(
|
|
58
|
+
return new GasFees(this.feePerDaGas * scalar, this.feePerL2Gas * scalar);
|
|
52
59
|
} else {
|
|
53
|
-
return new GasFees(
|
|
54
|
-
new Fr(this.feePerDaGas.toNumberUnsafe() * scalar),
|
|
55
|
-
new Fr(this.feePerL2Gas.toNumberUnsafe() * scalar),
|
|
56
|
-
);
|
|
60
|
+
return new GasFees(Number(this.feePerDaGas) * scalar, Number(this.feePerL2Gas) * scalar);
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -62,29 +66,29 @@ export class GasFees {
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
static random() {
|
|
65
|
-
return new GasFees(
|
|
69
|
+
return new GasFees(Math.floor(Math.random() * 1e9), Math.floor(Math.random() * 1e9));
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
static empty() {
|
|
69
|
-
return new GasFees(
|
|
73
|
+
return new GasFees(0, 0);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
isEmpty() {
|
|
73
|
-
return this.feePerDaGas
|
|
77
|
+
return this.feePerDaGas === 0n && this.feePerL2Gas === 0n;
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
static fromBuffer(buffer: Buffer | BufferReader): GasFees {
|
|
77
81
|
const reader = BufferReader.asReader(buffer);
|
|
78
|
-
return new GasFees(reader.
|
|
82
|
+
return new GasFees(reader.readUInt128(), reader.readUInt128());
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
toBuffer() {
|
|
82
|
-
return serializeToBuffer(this.feePerDaGas, this.feePerL2Gas);
|
|
86
|
+
return serializeToBuffer(bigintToUInt128BE(this.feePerDaGas), bigintToUInt128BE(this.feePerL2Gas));
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
86
90
|
const reader = FieldReader.asReader(fields);
|
|
87
|
-
return new GasFees(reader.readField(), reader.readField());
|
|
91
|
+
return new GasFees(reader.readField().toBigInt(), reader.readField().toBigInt());
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
toFields() {
|
|
@@ -93,12 +97,12 @@ export class GasFees {
|
|
|
93
97
|
|
|
94
98
|
toInspect() {
|
|
95
99
|
return {
|
|
96
|
-
feePerDaGas: this.feePerDaGas
|
|
97
|
-
feePerL2Gas: this.feePerL2Gas
|
|
100
|
+
feePerDaGas: this.feePerDaGas,
|
|
101
|
+
feePerL2Gas: this.feePerL2Gas,
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
[inspect.custom]() {
|
|
102
|
-
return `GasFees { feePerDaGas=${this.feePerDaGas
|
|
106
|
+
return `GasFees { feePerDaGas=${this.feePerDaGas} feePerL2Gas=${this.feePerL2Gas} }`;
|
|
103
107
|
}
|
|
104
108
|
}
|
package/src/gas/gas_settings.ts
CHANGED
|
@@ -60,11 +60,7 @@ export class GasSettings {
|
|
|
60
60
|
/** Returns the maximum fee to be paid according to gas limits and max fees set. */
|
|
61
61
|
getFeeLimit() {
|
|
62
62
|
return GasDimensions.reduce(
|
|
63
|
-
(acc, dimension) =>
|
|
64
|
-
this.maxFeesPerGas
|
|
65
|
-
.get(dimension)
|
|
66
|
-
.mul(new Fr(this.gasLimits.get(dimension)))
|
|
67
|
-
.add(acc),
|
|
63
|
+
(acc, dimension) => new Fr(this.maxFeesPerGas.get(dimension)).mul(new Fr(this.gasLimits.get(dimension))).add(acc),
|
|
68
64
|
Fr.ZERO,
|
|
69
65
|
);
|
|
70
66
|
}
|
|
@@ -73,5 +73,6 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
73
73
|
getL1ToL2MessageIndex: z.function().args(schemas.Fr).returns(schemas.BigInt.optional()),
|
|
74
74
|
getDebugFunctionName: z.function().args(schemas.AztecAddress, schemas.FunctionSelector).returns(optional(z.string())),
|
|
75
75
|
getL1Constants: z.function().args().returns(L1RollupConstantsSchema),
|
|
76
|
+
getL1Timestamp: z.function().args().returns(schemas.BigInt),
|
|
76
77
|
syncImmediate: z.function().args().returns(z.void()),
|
|
77
78
|
};
|
|
@@ -16,7 +16,7 @@ export interface Service {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** Tries to call stop on a given object and awaits it. Logs any errors and does not rethrow. */
|
|
19
|
-
export async function tryStop(service?: Partial<Service
|
|
19
|
+
export async function tryStop(service?: Partial<Pick<Service, 'stop'>>, logger?: Logger): Promise<void> {
|
|
20
20
|
try {
|
|
21
21
|
return typeof service === 'object' && service && 'stop' in service && typeof service.stop === 'function'
|
|
22
22
|
? await service.stop()
|
|
@@ -25,13 +25,3 @@ export async function tryStop(service?: Partial<Service>, logger?: Logger): Prom
|
|
|
25
25
|
logger?.error(`Error stopping service ${(service as object).constructor?.name}: ${err}`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
export function tryRestart(service?: Partial<Service>, logger?: Logger) {
|
|
30
|
-
try {
|
|
31
|
-
return typeof service === 'object' && service && 'restart' in service && typeof service.restart === 'function'
|
|
32
|
-
? service.restart()
|
|
33
|
-
: Promise.resolve();
|
|
34
|
-
} catch (err) {
|
|
35
|
-
logger?.error(`Error restarting service ${(service as object).constructor?.name}: ${err}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { type ZodFor, hexSchemaFor, schemas } from '@aztec/foundation/schemas';
|
|
3
|
+
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
import { BlockHeader } from '../tx/block_header.js';
|
|
9
|
+
import { GlobalVariables } from '../tx/global_variables.js';
|
|
10
|
+
import type { TxConstantData } from '../tx/tx_constant_data.js';
|
|
11
|
+
import { TxContext } from '../tx/tx_context.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Data that is constant/not modified by neither of the kernels.
|
|
15
|
+
*/
|
|
16
|
+
export class CombinedConstantData {
|
|
17
|
+
constructor(
|
|
18
|
+
/** Header of a block whose state is used during execution (not the block the transaction is included in). */
|
|
19
|
+
public historicalHeader: BlockHeader,
|
|
20
|
+
/**
|
|
21
|
+
* Context of the transaction.
|
|
22
|
+
*
|
|
23
|
+
* Note: `chainId` and `version` in txContext are not redundant to the values in
|
|
24
|
+
* self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such
|
|
25
|
+
* a situation we could be using header from a block before the upgrade took place but be using the updated
|
|
26
|
+
* protocol to execute and prove the transaction.
|
|
27
|
+
*/
|
|
28
|
+
public txContext: TxContext,
|
|
29
|
+
/**
|
|
30
|
+
* Root of the vk tree for the protocol circuits.
|
|
31
|
+
*/
|
|
32
|
+
public vkTreeRoot: Fr,
|
|
33
|
+
/**
|
|
34
|
+
* Root of the tree for the protocol contracts.
|
|
35
|
+
*/
|
|
36
|
+
public protocolContractTreeRoot: Fr,
|
|
37
|
+
/** Present when output by a public kernel, empty otherwise. */
|
|
38
|
+
public globalVariables: GlobalVariables,
|
|
39
|
+
) {}
|
|
40
|
+
|
|
41
|
+
static combine(TxConstantData: TxConstantData, globalVariables: GlobalVariables) {
|
|
42
|
+
return new CombinedConstantData(
|
|
43
|
+
TxConstantData.historicalHeader,
|
|
44
|
+
TxConstantData.txContext,
|
|
45
|
+
TxConstantData.vkTreeRoot,
|
|
46
|
+
TxConstantData.protocolContractTreeRoot,
|
|
47
|
+
globalVariables,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static get schema(): ZodFor<CombinedConstantData> {
|
|
52
|
+
return z
|
|
53
|
+
.object({
|
|
54
|
+
historicalHeader: BlockHeader.schema,
|
|
55
|
+
txContext: TxContext.schema,
|
|
56
|
+
vkTreeRoot: schemas.Fr,
|
|
57
|
+
protocolContractTreeRoot: schemas.Fr,
|
|
58
|
+
globalVariables: GlobalVariables.schema,
|
|
59
|
+
})
|
|
60
|
+
.transform(CombinedConstantData.from)
|
|
61
|
+
.or(hexSchemaFor(CombinedConstantData));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
toBuffer() {
|
|
65
|
+
return serializeToBuffer(
|
|
66
|
+
this.historicalHeader,
|
|
67
|
+
this.txContext,
|
|
68
|
+
this.vkTreeRoot,
|
|
69
|
+
this.protocolContractTreeRoot,
|
|
70
|
+
this.globalVariables,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
clone(): CombinedConstantData {
|
|
75
|
+
return CombinedConstantData.fromBuffer(this.toBuffer());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
getSize() {
|
|
79
|
+
return (
|
|
80
|
+
this.historicalHeader.getSize() +
|
|
81
|
+
this.txContext.getSize() +
|
|
82
|
+
this.vkTreeRoot.size +
|
|
83
|
+
this.protocolContractTreeRoot.size +
|
|
84
|
+
this.globalVariables.getSize()
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
static from({
|
|
89
|
+
historicalHeader,
|
|
90
|
+
txContext,
|
|
91
|
+
vkTreeRoot,
|
|
92
|
+
protocolContractTreeRoot,
|
|
93
|
+
globalVariables,
|
|
94
|
+
}: FieldsOf<CombinedConstantData>): CombinedConstantData {
|
|
95
|
+
return new CombinedConstantData(historicalHeader, txContext, vkTreeRoot, protocolContractTreeRoot, globalVariables);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
100
|
+
* @param buffer - Buffer or buffer reader to read from.
|
|
101
|
+
* @returns A new instance of CombinedConstantData.
|
|
102
|
+
*/
|
|
103
|
+
static fromBuffer(buffer: Buffer | BufferReader): CombinedConstantData {
|
|
104
|
+
const reader = BufferReader.asReader(buffer);
|
|
105
|
+
return new CombinedConstantData(
|
|
106
|
+
reader.readObject(BlockHeader),
|
|
107
|
+
reader.readObject(TxContext),
|
|
108
|
+
Fr.fromBuffer(reader),
|
|
109
|
+
Fr.fromBuffer(reader),
|
|
110
|
+
reader.readObject(GlobalVariables),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static fromFields(fields: Fr[] | FieldReader): CombinedConstantData {
|
|
115
|
+
const reader = FieldReader.asReader(fields);
|
|
116
|
+
return new CombinedConstantData(
|
|
117
|
+
reader.readObject(BlockHeader),
|
|
118
|
+
reader.readObject(TxContext),
|
|
119
|
+
reader.readField(),
|
|
120
|
+
reader.readField(),
|
|
121
|
+
reader.readObject(GlobalVariables),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static empty() {
|
|
126
|
+
return new CombinedConstantData(BlockHeader.empty(), TxContext.empty(), Fr.ZERO, Fr.ZERO, GlobalVariables.empty());
|
|
127
|
+
}
|
|
128
|
+
}
|
package/src/kernel/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
|
6
6
|
|
|
7
7
|
import { PartialStateReference } from '../tx/partial_state_reference.js';
|
|
8
8
|
import { RollupTypes } from '../types/shared.js';
|
|
9
|
-
import {
|
|
9
|
+
import { ConstantRollupData } from './constant_rollup_data.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Output of the base and merge rollup circuits.
|
|
@@ -24,7 +24,7 @@ export class BaseOrMergeRollupPublicInputs {
|
|
|
24
24
|
/**
|
|
25
25
|
* Data which is forwarded through the rollup circuits unchanged.
|
|
26
26
|
*/
|
|
27
|
-
public constants:
|
|
27
|
+
public constants: ConstantRollupData,
|
|
28
28
|
/**
|
|
29
29
|
* Partial state reference at the start of the rollup circuit.
|
|
30
30
|
*/
|
|
@@ -61,7 +61,7 @@ export class BaseOrMergeRollupPublicInputs {
|
|
|
61
61
|
return new BaseOrMergeRollupPublicInputs(
|
|
62
62
|
RollupTypes.Base,
|
|
63
63
|
0,
|
|
64
|
-
|
|
64
|
+
ConstantRollupData.empty(),
|
|
65
65
|
PartialStateReference.empty(),
|
|
66
66
|
PartialStateReference.empty(),
|
|
67
67
|
SpongeBlob.empty(),
|
|
@@ -83,7 +83,7 @@ export class BaseOrMergeRollupPublicInputs {
|
|
|
83
83
|
return new BaseOrMergeRollupPublicInputs(
|
|
84
84
|
reader.readNumber(),
|
|
85
85
|
reader.readNumber(),
|
|
86
|
-
reader.readObject(
|
|
86
|
+
reader.readObject(ConstantRollupData),
|
|
87
87
|
reader.readObject(PartialStateReference),
|
|
88
88
|
reader.readObject(PartialStateReference),
|
|
89
89
|
reader.readObject(SpongeBlob),
|
|
@@ -8,9 +8,8 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
8
8
|
|
|
9
9
|
import { PublicDataHint } from '../avm/public_data_hint.js';
|
|
10
10
|
import { ContractClassLogFields } from '../logs/index.js';
|
|
11
|
-
import { AppendOnlyTreeSnapshot } from '../trees/index.js';
|
|
12
11
|
import { PartialStateReference } from '../tx/partial_state_reference.js';
|
|
13
|
-
import {
|
|
12
|
+
import { ConstantRollupData } from './constant_rollup_data.js';
|
|
14
13
|
import { PrivateBaseStateDiffHints } from './state_diff_hints.js';
|
|
15
14
|
|
|
16
15
|
export type BaseRollupHints = PrivateBaseRollupHints | PublicBaseRollupHints;
|
|
@@ -44,7 +43,7 @@ export class PrivateBaseRollupHints {
|
|
|
44
43
|
/**
|
|
45
44
|
* Data which is not modified by the base rollup circuit.
|
|
46
45
|
*/
|
|
47
|
-
public constants:
|
|
46
|
+
public constants: ConstantRollupData,
|
|
48
47
|
) {}
|
|
49
48
|
|
|
50
49
|
static from(fields: FieldsOf<PrivateBaseRollupHints>): PrivateBaseRollupHints {
|
|
@@ -88,7 +87,7 @@ export class PrivateBaseRollupHints {
|
|
|
88
87
|
reader.readObject(PublicDataHint),
|
|
89
88
|
MembershipWitness.fromBuffer(reader, ARCHIVE_HEIGHT),
|
|
90
89
|
makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, () => reader.readObject(ContractClassLogFields)),
|
|
91
|
-
reader.readObject(
|
|
90
|
+
reader.readObject(ConstantRollupData),
|
|
92
91
|
);
|
|
93
92
|
}
|
|
94
93
|
|
|
@@ -104,7 +103,7 @@ export class PrivateBaseRollupHints {
|
|
|
104
103
|
PublicDataHint.empty(),
|
|
105
104
|
MembershipWitness.empty(ARCHIVE_HEIGHT),
|
|
106
105
|
makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, ContractClassLogFields.empty),
|
|
107
|
-
|
|
106
|
+
ConstantRollupData.empty(),
|
|
108
107
|
);
|
|
109
108
|
}
|
|
110
109
|
}
|
|
@@ -115,10 +114,6 @@ export class PublicBaseRollupHints {
|
|
|
115
114
|
* Sponge state to absorb blob inputs at the start of the rollup.
|
|
116
115
|
*/
|
|
117
116
|
public startSpongeBlob: SpongeBlob,
|
|
118
|
-
/**
|
|
119
|
-
* Archive tree snapshot at the very beginning of the block containing this base rollup.
|
|
120
|
-
*/
|
|
121
|
-
public lastArchive: AppendOnlyTreeSnapshot,
|
|
122
117
|
/**
|
|
123
118
|
* Membership witnesses of blocks referred by each of the 2 kernels.
|
|
124
119
|
*/
|
|
@@ -127,6 +122,10 @@ export class PublicBaseRollupHints {
|
|
|
127
122
|
* Preimages to the kernel's contractClassLogsHashes.
|
|
128
123
|
*/
|
|
129
124
|
public contractClassLogsFields: Tuple<ContractClassLogFields, typeof MAX_CONTRACT_CLASS_LOGS_PER_TX>,
|
|
125
|
+
/**
|
|
126
|
+
* Data which is not modified by the base rollup circuit.
|
|
127
|
+
*/
|
|
128
|
+
public constants: ConstantRollupData,
|
|
130
129
|
) {}
|
|
131
130
|
|
|
132
131
|
static from(fields: FieldsOf<PublicBaseRollupHints>): PublicBaseRollupHints {
|
|
@@ -136,9 +135,9 @@ export class PublicBaseRollupHints {
|
|
|
136
135
|
static getFields(fields: FieldsOf<PublicBaseRollupHints>) {
|
|
137
136
|
return [
|
|
138
137
|
fields.startSpongeBlob,
|
|
139
|
-
fields.lastArchive,
|
|
140
138
|
fields.archiveRootMembershipWitness,
|
|
141
139
|
fields.contractClassLogsFields,
|
|
140
|
+
fields.constants,
|
|
142
141
|
] as const;
|
|
143
142
|
}
|
|
144
143
|
|
|
@@ -162,9 +161,9 @@ export class PublicBaseRollupHints {
|
|
|
162
161
|
const reader = BufferReader.asReader(buffer);
|
|
163
162
|
return new PublicBaseRollupHints(
|
|
164
163
|
reader.readObject(SpongeBlob),
|
|
165
|
-
reader.readObject(AppendOnlyTreeSnapshot),
|
|
166
164
|
MembershipWitness.fromBuffer(reader, ARCHIVE_HEIGHT),
|
|
167
165
|
makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, () => reader.readObject(ContractClassLogFields)),
|
|
166
|
+
reader.readObject(ConstantRollupData),
|
|
168
167
|
);
|
|
169
168
|
}
|
|
170
169
|
|
|
@@ -175,9 +174,9 @@ export class PublicBaseRollupHints {
|
|
|
175
174
|
static empty() {
|
|
176
175
|
return new PublicBaseRollupHints(
|
|
177
176
|
SpongeBlob.empty(),
|
|
178
|
-
AppendOnlyTreeSnapshot.empty(),
|
|
179
177
|
MembershipWitness.empty(ARCHIVE_HEIGHT),
|
|
180
178
|
makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, ContractClassLogFields.empty),
|
|
179
|
+
ConstantRollupData.empty(),
|
|
181
180
|
);
|
|
182
181
|
}
|
|
183
182
|
}
|
|
@@ -9,17 +9,12 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
9
9
|
|
|
10
10
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
11
11
|
import { GlobalVariables } from '../tx/global_variables.js';
|
|
12
|
-
import { EpochConstantData } from './epoch_constant_data.js';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Output of the block root and block merge rollup circuits.
|
|
16
15
|
*/
|
|
17
16
|
export class BlockRootOrBlockMergePublicInputs {
|
|
18
17
|
constructor(
|
|
19
|
-
/**
|
|
20
|
-
* Constants for the entire epoch.
|
|
21
|
-
*/
|
|
22
|
-
public constants: EpochConstantData,
|
|
23
18
|
/**
|
|
24
19
|
* Archive tree immediately before this block range.
|
|
25
20
|
*/
|
|
@@ -49,6 +44,18 @@ export class BlockRootOrBlockMergePublicInputs {
|
|
|
49
44
|
* The summed `transaction_fee`s and recipients of the constituent blocks.
|
|
50
45
|
*/
|
|
51
46
|
public fees: Tuple<FeeRecipient, typeof AZTEC_MAX_EPOCH_DURATION>,
|
|
47
|
+
/**
|
|
48
|
+
* Root of the verification key tree.
|
|
49
|
+
*/
|
|
50
|
+
public vkTreeRoot: Fr,
|
|
51
|
+
/**
|
|
52
|
+
* Root of the protocol contract tree.
|
|
53
|
+
*/
|
|
54
|
+
public protocolContractTreeRoot: Fr,
|
|
55
|
+
/**
|
|
56
|
+
* TODO(#7346): Temporarily added prover_id while we verify block-root proofs on L1
|
|
57
|
+
*/
|
|
58
|
+
public proverId: Fr,
|
|
52
59
|
/**
|
|
53
60
|
* Public inputs required to verify a blob (challenge point z, evaluation y = p(z), and the commitment to p() for each blob)
|
|
54
61
|
*/
|
|
@@ -63,7 +70,6 @@ export class BlockRootOrBlockMergePublicInputs {
|
|
|
63
70
|
static fromBuffer(buffer: Buffer | BufferReader): BlockRootOrBlockMergePublicInputs {
|
|
64
71
|
const reader = BufferReader.asReader(buffer);
|
|
65
72
|
return new BlockRootOrBlockMergePublicInputs(
|
|
66
|
-
reader.readObject(EpochConstantData),
|
|
67
73
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
68
74
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
69
75
|
reader.readObject(GlobalVariables),
|
|
@@ -71,6 +77,9 @@ export class BlockRootOrBlockMergePublicInputs {
|
|
|
71
77
|
Fr.fromBuffer(reader),
|
|
72
78
|
reader.readArray(AZTEC_MAX_EPOCH_DURATION, Fr),
|
|
73
79
|
reader.readArray(AZTEC_MAX_EPOCH_DURATION, FeeRecipient),
|
|
80
|
+
Fr.fromBuffer(reader),
|
|
81
|
+
Fr.fromBuffer(reader),
|
|
82
|
+
Fr.fromBuffer(reader),
|
|
74
83
|
reader.readArray(AZTEC_MAX_EPOCH_DURATION, BlockBlobPublicInputs),
|
|
75
84
|
);
|
|
76
85
|
}
|
|
@@ -81,7 +90,6 @@ export class BlockRootOrBlockMergePublicInputs {
|
|
|
81
90
|
*/
|
|
82
91
|
toBuffer() {
|
|
83
92
|
return serializeToBuffer(
|
|
84
|
-
this.constants,
|
|
85
93
|
this.previousArchive,
|
|
86
94
|
this.newArchive,
|
|
87
95
|
this.startGlobalVariables,
|
|
@@ -89,6 +97,9 @@ export class BlockRootOrBlockMergePublicInputs {
|
|
|
89
97
|
this.outHash,
|
|
90
98
|
this.proposedBlockHeaderHashes,
|
|
91
99
|
this.fees,
|
|
100
|
+
this.vkTreeRoot,
|
|
101
|
+
this.protocolContractTreeRoot,
|
|
102
|
+
this.proverId,
|
|
92
103
|
this.blobPublicInputs,
|
|
93
104
|
);
|
|
94
105
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
4
|
+
|
|
5
|
+
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
6
|
+
import { GlobalVariables } from '../tx/global_variables.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Data which is forwarded through the base rollup circuits unchanged.
|
|
10
|
+
*/
|
|
11
|
+
export class ConstantRollupData {
|
|
12
|
+
constructor(
|
|
13
|
+
/** Archive tree snapshot at the very beginning of the entire rollup. */
|
|
14
|
+
public lastArchive: AppendOnlyTreeSnapshot,
|
|
15
|
+
/**
|
|
16
|
+
* Root of the verification key tree.
|
|
17
|
+
*/
|
|
18
|
+
public vkTreeRoot: Fr,
|
|
19
|
+
/**
|
|
20
|
+
* Root of the protocol contract tree.
|
|
21
|
+
*/
|
|
22
|
+
public protocolContractTreeRoot: Fr,
|
|
23
|
+
/**
|
|
24
|
+
* Global variables for the block
|
|
25
|
+
*/
|
|
26
|
+
public globalVariables: GlobalVariables,
|
|
27
|
+
) {}
|
|
28
|
+
|
|
29
|
+
static from(fields: FieldsOf<ConstantRollupData>): ConstantRollupData {
|
|
30
|
+
return new ConstantRollupData(...ConstantRollupData.getFields(fields));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static fromBuffer(buffer: Buffer | BufferReader): ConstantRollupData {
|
|
34
|
+
const reader = BufferReader.asReader(buffer);
|
|
35
|
+
return new ConstantRollupData(
|
|
36
|
+
reader.readObject(AppendOnlyTreeSnapshot),
|
|
37
|
+
Fr.fromBuffer(reader),
|
|
38
|
+
Fr.fromBuffer(reader),
|
|
39
|
+
reader.readObject(GlobalVariables),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static getFields(fields: FieldsOf<ConstantRollupData>) {
|
|
44
|
+
return [fields.lastArchive, fields.vkTreeRoot, fields.protocolContractTreeRoot, fields.globalVariables] as const;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static empty() {
|
|
48
|
+
return new ConstantRollupData(AppendOnlyTreeSnapshot.zero(), Fr.ZERO, Fr.ZERO, GlobalVariables.empty());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
toBuffer() {
|
|
52
|
+
return serializeToBuffer(...ConstantRollupData.getFields(this));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -3,8 +3,8 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
|
3
3
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
4
4
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
5
|
|
|
6
|
-
import { BlockConstantData } from './block_constant_data.js';
|
|
7
6
|
import { BlockRootRollupData } from './block_root_rollup.js';
|
|
7
|
+
import { ConstantRollupData } from './constant_rollup_data.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Represents inputs of the empty block root rollup circuit.
|
|
@@ -12,7 +12,7 @@ import { BlockRootRollupData } from './block_root_rollup.js';
|
|
|
12
12
|
export class EmptyBlockRootRollupInputs {
|
|
13
13
|
constructor(
|
|
14
14
|
public readonly data: BlockRootRollupData,
|
|
15
|
-
public readonly constants:
|
|
15
|
+
public readonly constants: ConstantRollupData,
|
|
16
16
|
public readonly isPadding: boolean,
|
|
17
17
|
) {}
|
|
18
18
|
|
|
@@ -59,7 +59,7 @@ export class EmptyBlockRootRollupInputs {
|
|
|
59
59
|
const reader = BufferReader.asReader(buffer);
|
|
60
60
|
return new EmptyBlockRootRollupInputs(
|
|
61
61
|
reader.readObject(BlockRootRollupData),
|
|
62
|
-
reader.readObject(
|
|
62
|
+
reader.readObject(ConstantRollupData),
|
|
63
63
|
reader.readBoolean(),
|
|
64
64
|
);
|
|
65
65
|
}
|
package/src/rollup/index.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export * from './avm_proof_data.js';
|
|
2
2
|
export * from './base_or_merge_rollup_public_inputs.js';
|
|
3
3
|
export * from './base_rollup_hints.js';
|
|
4
|
-
export * from './block_constant_data.js';
|
|
5
4
|
export * from './block_merge_rollup.js';
|
|
6
5
|
export * from './block_root_or_block_merge_public_inputs.js';
|
|
6
|
+
export * from './constant_rollup_data.js';
|
|
7
7
|
export * from './empty_block_root_rollup_inputs.js';
|
|
8
|
-
export * from './epoch_constant_data.js';
|
|
9
8
|
export * from './block_root_rollup.js';
|
|
10
9
|
export * from './merge_rollup.js';
|
|
11
10
|
export * from './previous_rollup_block_data.js';
|
|
@@ -21,6 +21,8 @@ export class RootRollupInputs {
|
|
|
21
21
|
* from 2 block merge circuits.
|
|
22
22
|
*/
|
|
23
23
|
public previousRollupData: [PreviousRollupBlockData, PreviousRollupBlockData],
|
|
24
|
+
/** Identifier of the prover for this root rollup. */
|
|
25
|
+
public proverId: Fr,
|
|
24
26
|
) {}
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -54,7 +56,7 @@ export class RootRollupInputs {
|
|
|
54
56
|
* @returns An array of fields.
|
|
55
57
|
*/
|
|
56
58
|
static getFields(fields: FieldsOf<RootRollupInputs>) {
|
|
57
|
-
return [fields.previousRollupData] as const;
|
|
59
|
+
return [fields.previousRollupData, fields.proverId] as const;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
/**
|
|
@@ -64,10 +66,10 @@ export class RootRollupInputs {
|
|
|
64
66
|
*/
|
|
65
67
|
static fromBuffer(buffer: Buffer | BufferReader): RootRollupInputs {
|
|
66
68
|
const reader = BufferReader.asReader(buffer);
|
|
67
|
-
return new RootRollupInputs(
|
|
68
|
-
reader.readObject(PreviousRollupBlockData),
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
return new RootRollupInputs(
|
|
70
|
+
[reader.readObject(PreviousRollupBlockData), reader.readObject(PreviousRollupBlockData)],
|
|
71
|
+
Fr.fromBuffer(reader),
|
|
72
|
+
);
|
|
71
73
|
}
|
|
72
74
|
|
|
73
75
|
/**
|