@aztec/stdlib 1.0.0-nightly.20250607 → 1.0.0-nightly.20250610
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/block/l2_block.js +1 -1
- package/dest/hash/hash.d.ts +8 -2
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +8 -16
- package/dest/interfaces/epoch-prover.d.ts +3 -1
- package/dest/interfaces/epoch-prover.d.ts.map +1 -1
- package/dest/interfaces/proving-job.d.ts +1 -1
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/service.d.ts +1 -1
- package/dest/interfaces/service.d.ts.map +1 -1
- package/dest/kernel/index.d.ts +0 -1
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +0 -1
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +9 -3
- 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 +15 -14
- package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
- package/dest/rollup/base_rollup_hints.js +13 -12
- package/dest/rollup/block_constant_data.d.ts +37 -0
- package/dest/rollup/block_constant_data.d.ts.map +1 -0
- package/dest/rollup/{constant_rollup_data.js → block_constant_data.js} +10 -13
- package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +12 -27
- 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 +8 -15
- package/dest/rollup/block_root_rollup.d.ts +24 -9
- package/dest/rollup/block_root_rollup.d.ts.map +1 -1
- package/dest/rollup/block_root_rollup.js +15 -7
- 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/epoch_constant_data.d.ts +39 -0
- package/dest/rollup/epoch_constant_data.d.ts.map +1 -0
- package/dest/rollup/epoch_constant_data.js +40 -0
- package/dest/rollup/index.d.ts +2 -1
- package/dest/rollup/index.d.ts.map +1 -1
- package/dest/rollup/index.js +2 -1
- package/dest/rollup/root_rollup.d.ts +7 -11
- package/dest/rollup/root_rollup.d.ts.map +1 -1
- package/dest/rollup/root_rollup.js +7 -10
- package/dest/snapshots/types.d.ts +4 -4
- package/dest/tests/factories.d.ts +1 -10
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +23 -36
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +3 -3
- package/dest/trees/append_only_tree_snapshot.d.ts +6 -2
- package/dest/trees/append_only_tree_snapshot.d.ts.map +1 -1
- package/dest/trees/append_only_tree_snapshot.js +17 -2
- package/dest/tx/block_header.js +3 -3
- package/dest/tx/content_commitment.d.ts +3 -0
- package/dest/tx/content_commitment.d.ts.map +1 -1
- package/dest/tx/content_commitment.js +12 -1
- package/dest/tx/global_variables.js +1 -1
- package/dest/tx/index.d.ts +1 -0
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +1 -0
- package/dest/tx/offchain_message.d.ts +15 -0
- package/dest/tx/offchain_message.d.ts.map +1 -0
- package/dest/tx/offchain_message.js +4 -0
- package/dest/tx/partial_state_reference.d.ts +8 -0
- package/dest/tx/partial_state_reference.d.ts.map +1 -1
- package/dest/tx/partial_state_reference.js +19 -2
- package/dest/tx/private_execution_result.d.ts +18 -0
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +32 -2
- package/dest/tx/processed_tx.d.ts +2 -3
- package/dest/tx/processed_tx.d.ts.map +1 -1
- package/dest/tx/processed_tx.js +18 -8
- package/dest/tx/proposed_block_header.d.ts +3 -0
- package/dest/tx/proposed_block_header.d.ts.map +1 -1
- package/dest/tx/proposed_block_header.js +19 -1
- package/dest/tx/proven_tx.d.ts +2 -0
- package/dest/tx/proven_tx.d.ts.map +1 -1
- package/dest/tx/proven_tx.js +4 -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.d.ts +4 -0
- package/dest/tx/state_reference.d.ts.map +1 -1
- package/dest/tx/state_reference.js +20 -3
- package/dest/tx/tree_snapshots.js +3 -3
- package/dest/tx/tx.d.ts +1 -1
- package/dest/tx/tx.js +1 -1
- package/dest/tx/tx_hash.d.ts +1 -0
- package/dest/tx/tx_hash.d.ts.map +1 -1
- package/dest/tx/tx_hash.js +1 -0
- package/package.json +7 -7
- package/src/block/l2_block.ts +1 -1
- package/src/hash/hash.ts +16 -19
- package/src/interfaces/epoch-prover.ts +8 -2
- package/src/interfaces/service.ts +1 -1
- package/src/kernel/index.ts +0 -1
- package/src/p2p/consensus_payload.ts +13 -3
- package/src/rollup/base_or_merge_rollup_public_inputs.ts +4 -4
- package/src/rollup/base_rollup_hints.ts +12 -11
- package/src/rollup/block_constant_data.ts +63 -0
- package/src/rollup/block_root_or_block_merge_public_inputs.ts +10 -21
- package/src/rollup/block_root_rollup.ts +17 -5
- package/src/rollup/empty_block_root_rollup_inputs.ts +3 -3
- package/src/rollup/epoch_constant_data.ts +44 -0
- package/src/rollup/index.ts +2 -1
- package/src/rollup/root_rollup.ts +10 -12
- package/src/tests/factories.ts +36 -58
- package/src/tests/mocks.ts +3 -2
- package/src/trees/append_only_tree_snapshot.ts +18 -2
- package/src/tx/block_header.ts +3 -3
- package/src/tx/content_commitment.ts +19 -1
- package/src/tx/global_variables.ts +1 -1
- package/src/tx/index.ts +1 -0
- package/src/tx/offchain_message.ts +16 -0
- package/src/tx/partial_state_reference.ts +29 -4
- package/src/tx/private_execution_result.ts +30 -0
- package/src/tx/processed_tx.ts +26 -13
- package/src/tx/proposed_block_header.ts +31 -1
- package/src/tx/proven_tx.ts +10 -1
- package/src/tx/public_simulation_output.ts +5 -5
- package/src/tx/state_reference.ts +22 -3
- package/src/tx/tree_snapshots.ts +9 -9
- package/src/tx/tx.ts +1 -1
- package/src/tx/tx_hash.ts +1 -0
- package/dest/kernel/combined_constant_data.d.ts +0 -71
- package/dest/kernel/combined_constant_data.d.ts.map +0 -1
- package/dest/kernel/combined_constant_data.js +0 -73
- package/dest/rollup/constant_rollup_data.d.ts +0 -45
- package/dest/rollup/constant_rollup_data.d.ts.map +0 -1
- package/src/kernel/combined_constant_data.ts +0 -128
- package/src/rollup/constant_rollup_data.ts +0 -54
|
@@ -7,8 +7,8 @@ import { z } from 'zod';
|
|
|
7
7
|
import { SimulationError } from '../errors/simulation_error.js';
|
|
8
8
|
import { Gas } from '../gas/gas.js';
|
|
9
9
|
import type { GasUsed } from '../gas/gas_used.js';
|
|
10
|
-
import { CombinedConstantData } from '../kernel/combined_constant_data.js';
|
|
11
10
|
import { TxEffect } from '../tx/tx_effect.js';
|
|
11
|
+
import { GlobalVariables } from './global_variables.js';
|
|
12
12
|
|
|
13
13
|
/** Return values of simulating a circuit. */
|
|
14
14
|
export type ProcessReturnValues = Fr[] | undefined;
|
|
@@ -50,7 +50,7 @@ export class NestedProcessReturnValues {
|
|
|
50
50
|
export class PublicSimulationOutput {
|
|
51
51
|
constructor(
|
|
52
52
|
public revertReason: SimulationError | undefined,
|
|
53
|
-
public
|
|
53
|
+
public globalVariables: GlobalVariables,
|
|
54
54
|
public txEffect: TxEffect,
|
|
55
55
|
public publicReturnValues: NestedProcessReturnValues[],
|
|
56
56
|
public gasUsed: GasUsed,
|
|
@@ -60,7 +60,7 @@ export class PublicSimulationOutput {
|
|
|
60
60
|
return z
|
|
61
61
|
.object({
|
|
62
62
|
revertReason: SimulationError.schema.optional(),
|
|
63
|
-
|
|
63
|
+
globalVariables: GlobalVariables.schema,
|
|
64
64
|
txEffect: TxEffect.schema,
|
|
65
65
|
publicReturnValues: z.array(NestedProcessReturnValues.schema),
|
|
66
66
|
gasUsed: z.object({
|
|
@@ -74,7 +74,7 @@ export class PublicSimulationOutput {
|
|
|
74
74
|
fields =>
|
|
75
75
|
new PublicSimulationOutput(
|
|
76
76
|
fields.revertReason,
|
|
77
|
-
fields.
|
|
77
|
+
fields.globalVariables,
|
|
78
78
|
fields.txEffect,
|
|
79
79
|
fields.publicReturnValues,
|
|
80
80
|
fields.gasUsed,
|
|
@@ -85,7 +85,7 @@ export class PublicSimulationOutput {
|
|
|
85
85
|
static async random() {
|
|
86
86
|
return new PublicSimulationOutput(
|
|
87
87
|
await SimulationError.random(),
|
|
88
|
-
|
|
88
|
+
GlobalVariables.empty(),
|
|
89
89
|
TxEffect.empty(),
|
|
90
90
|
times(2, NestedProcessReturnValues.random),
|
|
91
91
|
{ teardownGas: Gas.random(), totalGas: Gas.random(), publicGas: Gas.random(), billedGas: Gas.random() },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { STATE_REFERENCE_LENGTH } from '@aztec/constants';
|
|
2
|
+
import type { ViemStateReference } from '@aztec/ethereum';
|
|
2
3
|
import type { Fr } from '@aztec/foundation/fields';
|
|
3
4
|
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
5
|
|
|
@@ -33,7 +34,7 @@ export class StateReference {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
toBuffer() {
|
|
36
|
-
// Note: The order here must match the order in the
|
|
37
|
+
// Note: The order here must match the order in the ProposedHeaderLib solidity library.
|
|
37
38
|
return serializeToBuffer(this.l1ToL2MessageTree, this.partial);
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -61,12 +62,30 @@ export class StateReference {
|
|
|
61
62
|
return new StateReference(l1ToL2MessageTree, partial);
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
static fromViem(stateReference: ViemStateReference) {
|
|
66
|
+
return new StateReference(
|
|
67
|
+
AppendOnlyTreeSnapshot.fromViem(stateReference.l1ToL2MessageTree),
|
|
68
|
+
PartialStateReference.fromViem(stateReference.partialStateReference),
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
64
72
|
static empty(): StateReference {
|
|
65
|
-
return new StateReference(AppendOnlyTreeSnapshot.
|
|
73
|
+
return new StateReference(AppendOnlyTreeSnapshot.empty(), PartialStateReference.empty());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
toViem(): ViemStateReference {
|
|
77
|
+
return {
|
|
78
|
+
l1ToL2MessageTree: this.l1ToL2MessageTree.toViem(),
|
|
79
|
+
partialStateReference: this.partial.toViem(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
toAbi(): [ReturnType<AppendOnlyTreeSnapshot['toAbi']>, ReturnType<PartialStateReference['toAbi']>] {
|
|
84
|
+
return [this.l1ToL2MessageTree.toAbi(), [...this.partial.toAbi()]];
|
|
66
85
|
}
|
|
67
86
|
|
|
68
87
|
isEmpty(): boolean {
|
|
69
|
-
return this.l1ToL2MessageTree.
|
|
88
|
+
return this.l1ToL2MessageTree.isEmpty() && this.partial.isEmpty();
|
|
70
89
|
}
|
|
71
90
|
|
|
72
91
|
toInspect() {
|
package/src/tx/tree_snapshots.ts
CHANGED
|
@@ -52,7 +52,7 @@ export class TreeSnapshots {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
toBuffer() {
|
|
55
|
-
// Note: The order here must match the order in the
|
|
55
|
+
// Note: The order here must match the order in the ProposedHeaderLib solidity library.
|
|
56
56
|
return serializeToBuffer(this.l1ToL2MessageTree, this.noteHashTree, this.nullifierTree, this.publicDataTree);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -84,19 +84,19 @@ export class TreeSnapshots {
|
|
|
84
84
|
|
|
85
85
|
static empty(): TreeSnapshots {
|
|
86
86
|
return new TreeSnapshots(
|
|
87
|
-
AppendOnlyTreeSnapshot.
|
|
88
|
-
AppendOnlyTreeSnapshot.
|
|
89
|
-
AppendOnlyTreeSnapshot.
|
|
90
|
-
AppendOnlyTreeSnapshot.
|
|
87
|
+
AppendOnlyTreeSnapshot.empty(),
|
|
88
|
+
AppendOnlyTreeSnapshot.empty(),
|
|
89
|
+
AppendOnlyTreeSnapshot.empty(),
|
|
90
|
+
AppendOnlyTreeSnapshot.empty(),
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
isEmpty(): boolean {
|
|
95
95
|
return (
|
|
96
|
-
this.l1ToL2MessageTree.
|
|
97
|
-
this.noteHashTree.
|
|
98
|
-
this.nullifierTree.
|
|
99
|
-
this.publicDataTree.
|
|
96
|
+
this.l1ToL2MessageTree.isEmpty() &&
|
|
97
|
+
this.noteHashTree.isEmpty() &&
|
|
98
|
+
this.nullifierTree.isEmpty() &&
|
|
99
|
+
this.publicDataTree.isEmpty()
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
package/src/tx/tx.ts
CHANGED
|
@@ -163,7 +163,7 @@ export class Tx extends Gossipable {
|
|
|
163
163
|
|
|
164
164
|
/**
|
|
165
165
|
* Gets either revertible or non revertible contract class logs emitted by this tx.
|
|
166
|
-
* @param revertible - true for revertible only logs, false for non
|
|
166
|
+
* @param revertible - true for revertible only logs, false for non revertible only logs.
|
|
167
167
|
* @returns The requested logs.
|
|
168
168
|
*/
|
|
169
169
|
getSplitContractClassLogs(revertible: boolean): ContractClassLog[] {
|
package/src/tx/tx_hash.ts
CHANGED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { type ZodFor } from '@aztec/foundation/schemas';
|
|
3
|
-
import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
|
|
4
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
|
-
import { BlockHeader } from '../tx/block_header.js';
|
|
6
|
-
import { GlobalVariables } from '../tx/global_variables.js';
|
|
7
|
-
import type { TxConstantData } from '../tx/tx_constant_data.js';
|
|
8
|
-
import { TxContext } from '../tx/tx_context.js';
|
|
9
|
-
/**
|
|
10
|
-
* Data that is constant/not modified by neither of the kernels.
|
|
11
|
-
*/
|
|
12
|
-
export declare class CombinedConstantData {
|
|
13
|
-
/** Header of a block whose state is used during execution (not the block the transaction is included in). */
|
|
14
|
-
historicalHeader: BlockHeader;
|
|
15
|
-
/**
|
|
16
|
-
* Context of the transaction.
|
|
17
|
-
*
|
|
18
|
-
* Note: `chainId` and `version` in txContext are not redundant to the values in
|
|
19
|
-
* self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such
|
|
20
|
-
* a situation we could be using header from a block before the upgrade took place but be using the updated
|
|
21
|
-
* protocol to execute and prove the transaction.
|
|
22
|
-
*/
|
|
23
|
-
txContext: TxContext;
|
|
24
|
-
/**
|
|
25
|
-
* Root of the vk tree for the protocol circuits.
|
|
26
|
-
*/
|
|
27
|
-
vkTreeRoot: Fr;
|
|
28
|
-
/**
|
|
29
|
-
* Root of the tree for the protocol contracts.
|
|
30
|
-
*/
|
|
31
|
-
protocolContractTreeRoot: Fr;
|
|
32
|
-
/** Present when output by a public kernel, empty otherwise. */
|
|
33
|
-
globalVariables: GlobalVariables;
|
|
34
|
-
constructor(
|
|
35
|
-
/** Header of a block whose state is used during execution (not the block the transaction is included in). */
|
|
36
|
-
historicalHeader: BlockHeader,
|
|
37
|
-
/**
|
|
38
|
-
* Context of the transaction.
|
|
39
|
-
*
|
|
40
|
-
* Note: `chainId` and `version` in txContext are not redundant to the values in
|
|
41
|
-
* self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such
|
|
42
|
-
* a situation we could be using header from a block before the upgrade took place but be using the updated
|
|
43
|
-
* protocol to execute and prove the transaction.
|
|
44
|
-
*/
|
|
45
|
-
txContext: TxContext,
|
|
46
|
-
/**
|
|
47
|
-
* Root of the vk tree for the protocol circuits.
|
|
48
|
-
*/
|
|
49
|
-
vkTreeRoot: Fr,
|
|
50
|
-
/**
|
|
51
|
-
* Root of the tree for the protocol contracts.
|
|
52
|
-
*/
|
|
53
|
-
protocolContractTreeRoot: Fr,
|
|
54
|
-
/** Present when output by a public kernel, empty otherwise. */
|
|
55
|
-
globalVariables: GlobalVariables);
|
|
56
|
-
static combine(TxConstantData: TxConstantData, globalVariables: GlobalVariables): CombinedConstantData;
|
|
57
|
-
static get schema(): ZodFor<CombinedConstantData>;
|
|
58
|
-
toBuffer(): Buffer<ArrayBufferLike>;
|
|
59
|
-
clone(): CombinedConstantData;
|
|
60
|
-
getSize(): number;
|
|
61
|
-
static from({ historicalHeader, txContext, vkTreeRoot, protocolContractTreeRoot, globalVariables, }: FieldsOf<CombinedConstantData>): CombinedConstantData;
|
|
62
|
-
/**
|
|
63
|
-
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
64
|
-
* @param buffer - Buffer or buffer reader to read from.
|
|
65
|
-
* @returns A new instance of CombinedConstantData.
|
|
66
|
-
*/
|
|
67
|
-
static fromBuffer(buffer: Buffer | BufferReader): CombinedConstantData;
|
|
68
|
-
static fromFields(fields: Fr[] | FieldReader): CombinedConstantData;
|
|
69
|
-
static empty(): CombinedConstantData;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=combined_constant_data.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"combined_constant_data.d.ts","sourceRoot":"","sources":["../../src/kernel/combined_constant_data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAyB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAC3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;GAEG;AACH,qBAAa,oBAAoB;IAE7B,6GAA6G;IACtG,gBAAgB,EAAE,WAAW;IACpC;;;;;;;OAOG;IACI,SAAS,EAAE,SAAS;IAC3B;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC,+DAA+D;IACxD,eAAe,EAAE,eAAe;;IApBvC,6GAA6G;IACtG,gBAAgB,EAAE,WAAW;IACpC;;;;;;;OAOG;IACI,SAAS,EAAE,SAAS;IAC3B;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC,+DAA+D;IACxD,eAAe,EAAE,eAAe;IAGzC,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe;IAU/E,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,oBAAoB,CAAC,CAWhD;IAED,QAAQ;IAUR,KAAK,IAAI,oBAAoB;IAI7B,OAAO;IAUP,MAAM,CAAC,IAAI,CAAC,EACV,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,wBAAwB,EACxB,eAAe,GAChB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,oBAAoB;IAIxD;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,oBAAoB;IAWtE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,oBAAoB;IAWnE,MAAM,CAAC,KAAK;CAGb"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { hexSchemaFor, schemas } from '@aztec/foundation/schemas';
|
|
3
|
-
import { BufferReader, FieldReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
import { BlockHeader } from '../tx/block_header.js';
|
|
6
|
-
import { GlobalVariables } from '../tx/global_variables.js';
|
|
7
|
-
import { TxContext } from '../tx/tx_context.js';
|
|
8
|
-
/**
|
|
9
|
-
* Data that is constant/not modified by neither of the kernels.
|
|
10
|
-
*/ export class CombinedConstantData {
|
|
11
|
-
historicalHeader;
|
|
12
|
-
txContext;
|
|
13
|
-
vkTreeRoot;
|
|
14
|
-
protocolContractTreeRoot;
|
|
15
|
-
globalVariables;
|
|
16
|
-
constructor(/** Header of a block whose state is used during execution (not the block the transaction is included in). */ historicalHeader, /**
|
|
17
|
-
* Context of the transaction.
|
|
18
|
-
*
|
|
19
|
-
* Note: `chainId` and `version` in txContext are not redundant to the values in
|
|
20
|
-
* self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such
|
|
21
|
-
* a situation we could be using header from a block before the upgrade took place but be using the updated
|
|
22
|
-
* protocol to execute and prove the transaction.
|
|
23
|
-
*/ txContext, /**
|
|
24
|
-
* Root of the vk tree for the protocol circuits.
|
|
25
|
-
*/ vkTreeRoot, /**
|
|
26
|
-
* Root of the tree for the protocol contracts.
|
|
27
|
-
*/ protocolContractTreeRoot, /** Present when output by a public kernel, empty otherwise. */ globalVariables){
|
|
28
|
-
this.historicalHeader = historicalHeader;
|
|
29
|
-
this.txContext = txContext;
|
|
30
|
-
this.vkTreeRoot = vkTreeRoot;
|
|
31
|
-
this.protocolContractTreeRoot = protocolContractTreeRoot;
|
|
32
|
-
this.globalVariables = globalVariables;
|
|
33
|
-
}
|
|
34
|
-
static combine(TxConstantData, globalVariables) {
|
|
35
|
-
return new CombinedConstantData(TxConstantData.historicalHeader, TxConstantData.txContext, TxConstantData.vkTreeRoot, TxConstantData.protocolContractTreeRoot, globalVariables);
|
|
36
|
-
}
|
|
37
|
-
static get schema() {
|
|
38
|
-
return z.object({
|
|
39
|
-
historicalHeader: BlockHeader.schema,
|
|
40
|
-
txContext: TxContext.schema,
|
|
41
|
-
vkTreeRoot: schemas.Fr,
|
|
42
|
-
protocolContractTreeRoot: schemas.Fr,
|
|
43
|
-
globalVariables: GlobalVariables.schema
|
|
44
|
-
}).transform(CombinedConstantData.from).or(hexSchemaFor(CombinedConstantData));
|
|
45
|
-
}
|
|
46
|
-
toBuffer() {
|
|
47
|
-
return serializeToBuffer(this.historicalHeader, this.txContext, this.vkTreeRoot, this.protocolContractTreeRoot, this.globalVariables);
|
|
48
|
-
}
|
|
49
|
-
clone() {
|
|
50
|
-
return CombinedConstantData.fromBuffer(this.toBuffer());
|
|
51
|
-
}
|
|
52
|
-
getSize() {
|
|
53
|
-
return this.historicalHeader.getSize() + this.txContext.getSize() + this.vkTreeRoot.size + this.protocolContractTreeRoot.size + this.globalVariables.getSize();
|
|
54
|
-
}
|
|
55
|
-
static from({ historicalHeader, txContext, vkTreeRoot, protocolContractTreeRoot, globalVariables }) {
|
|
56
|
-
return new CombinedConstantData(historicalHeader, txContext, vkTreeRoot, protocolContractTreeRoot, globalVariables);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
60
|
-
* @param buffer - Buffer or buffer reader to read from.
|
|
61
|
-
* @returns A new instance of CombinedConstantData.
|
|
62
|
-
*/ static fromBuffer(buffer) {
|
|
63
|
-
const reader = BufferReader.asReader(buffer);
|
|
64
|
-
return new CombinedConstantData(reader.readObject(BlockHeader), reader.readObject(TxContext), Fr.fromBuffer(reader), Fr.fromBuffer(reader), reader.readObject(GlobalVariables));
|
|
65
|
-
}
|
|
66
|
-
static fromFields(fields) {
|
|
67
|
-
const reader = FieldReader.asReader(fields);
|
|
68
|
-
return new CombinedConstantData(reader.readObject(BlockHeader), reader.readObject(TxContext), reader.readField(), reader.readField(), reader.readObject(GlobalVariables));
|
|
69
|
-
}
|
|
70
|
-
static empty() {
|
|
71
|
-
return new CombinedConstantData(BlockHeader.empty(), TxContext.empty(), Fr.ZERO, Fr.ZERO, GlobalVariables.empty());
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
-
import { BufferReader } from '@aztec/foundation/serialize';
|
|
3
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
4
|
-
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
5
|
-
import { GlobalVariables } from '../tx/global_variables.js';
|
|
6
|
-
/**
|
|
7
|
-
* Data which is forwarded through the base rollup circuits unchanged.
|
|
8
|
-
*/
|
|
9
|
-
export declare class ConstantRollupData {
|
|
10
|
-
/** Archive tree snapshot at the very beginning of the entire rollup. */
|
|
11
|
-
lastArchive: AppendOnlyTreeSnapshot;
|
|
12
|
-
/**
|
|
13
|
-
* Root of the verification key tree.
|
|
14
|
-
*/
|
|
15
|
-
vkTreeRoot: Fr;
|
|
16
|
-
/**
|
|
17
|
-
* Root of the protocol contract tree.
|
|
18
|
-
*/
|
|
19
|
-
protocolContractTreeRoot: Fr;
|
|
20
|
-
/**
|
|
21
|
-
* Global variables for the block
|
|
22
|
-
*/
|
|
23
|
-
globalVariables: GlobalVariables;
|
|
24
|
-
constructor(
|
|
25
|
-
/** Archive tree snapshot at the very beginning of the entire rollup. */
|
|
26
|
-
lastArchive: AppendOnlyTreeSnapshot,
|
|
27
|
-
/**
|
|
28
|
-
* Root of the verification key tree.
|
|
29
|
-
*/
|
|
30
|
-
vkTreeRoot: Fr,
|
|
31
|
-
/**
|
|
32
|
-
* Root of the protocol contract tree.
|
|
33
|
-
*/
|
|
34
|
-
protocolContractTreeRoot: Fr,
|
|
35
|
-
/**
|
|
36
|
-
* Global variables for the block
|
|
37
|
-
*/
|
|
38
|
-
globalVariables: GlobalVariables);
|
|
39
|
-
static from(fields: FieldsOf<ConstantRollupData>): ConstantRollupData;
|
|
40
|
-
static fromBuffer(buffer: Buffer | BufferReader): ConstantRollupData;
|
|
41
|
-
static getFields(fields: FieldsOf<ConstantRollupData>): readonly [AppendOnlyTreeSnapshot, Fr, Fr, GlobalVariables];
|
|
42
|
-
static empty(): ConstantRollupData;
|
|
43
|
-
toBuffer(): Buffer<ArrayBufferLike>;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=constant_rollup_data.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constant_rollup_data.d.ts","sourceRoot":"","sources":["../../src/rollup/constant_rollup_data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;GAEG;AACH,qBAAa,kBAAkB;IAE3B,wEAAwE;IACjE,WAAW,EAAE,sBAAsB;IAC1C;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC;;OAEG;IACI,eAAe,EAAE,eAAe;;IAbvC,wEAAwE;IACjE,WAAW,EAAE,sBAAsB;IAC1C;;OAEG;IACI,UAAU,EAAE,EAAE;IACrB;;OAEG;IACI,wBAAwB,EAAE,EAAE;IACnC;;OAEG;IACI,eAAe,EAAE,eAAe;IAGzC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,kBAAkB;IAIrE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,kBAAkB;IAUpE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC;IAIrD,MAAM,CAAC,KAAK;IAIZ,QAAQ;CAGT"}
|
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
}
|