@aztec/stdlib 3.0.0-nightly.20251114 → 3.0.0-nightly.20251118
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 +139 -45
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +58 -19
- package/dest/avm/avm_proving_request.d.ts +21 -21
- package/dest/avm/public_data_write.d.ts +1 -1
- package/dest/avm/public_data_write.d.ts.map +1 -1
- package/dest/avm/revert_code.d.ts +2 -1
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +8 -8
- package/dest/block/body.d.ts +3 -6
- package/dest/block/body.d.ts.map +1 -1
- package/dest/block/body.js +6 -25
- package/dest/block/index.d.ts +1 -0
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -0
- package/dest/block/l2_block.d.ts +5 -0
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +34 -4
- package/dest/block/l2_block_new.d.ts +97 -0
- package/dest/block/l2_block_new.d.ts.map +1 -0
- package/dest/block/l2_block_new.js +113 -0
- package/dest/checkpoint/checkpoint.d.ts +108 -0
- package/dest/checkpoint/checkpoint.d.ts.map +1 -0
- package/dest/checkpoint/checkpoint.js +39 -0
- package/dest/checkpoint/index.d.ts +1 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -1
- package/dest/interfaces/proving-job.d.ts +21 -21
- package/dest/logs/private_log.d.ts +1 -1
- package/dest/logs/private_log.d.ts.map +1 -1
- package/dest/logs/private_log.js +2 -5
- package/dest/messaging/in_hash.d.ts +4 -0
- package/dest/messaging/in_hash.d.ts.map +1 -0
- package/dest/messaging/in_hash.js +15 -0
- package/dest/messaging/index.d.ts +2 -0
- package/dest/messaging/index.d.ts.map +1 -1
- package/dest/messaging/index.js +2 -0
- package/dest/messaging/out_hash.d.ts +5 -0
- package/dest/messaging/out_hash.d.ts.map +1 -0
- package/dest/messaging/out_hash.js +28 -0
- package/dest/rollup/checkpoint_constant_data.d.ts +16 -0
- package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -1
- package/dest/rollup/checkpoint_constant_data.js +17 -0
- package/dest/tests/factories.d.ts +21 -25
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +24 -121
- package/dest/tests/mocks.d.ts +17 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +108 -4
- package/dest/tx/partial_state_reference.d.ts +3 -0
- package/dest/tx/partial_state_reference.d.ts.map +1 -1
- package/dest/tx/partial_state_reference.js +10 -0
- package/dest/tx/state_reference.d.ts +3 -0
- package/dest/tx/state_reference.d.ts.map +1 -1
- package/dest/tx/state_reference.js +9 -0
- package/dest/tx/tx_effect.d.ts +9 -6
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +53 -57
- package/dest/vks/verification_key.d.ts +9 -0
- package/dest/vks/verification_key.d.ts.map +1 -1
- package/dest/vks/verification_key.js +20 -0
- package/package.json +8 -8
- package/src/avm/avm.ts +66 -28
- package/src/avm/public_data_write.ts +1 -1
- package/src/avm/revert_code.ts +9 -8
- package/src/block/body.ts +7 -32
- package/src/block/index.ts +1 -0
- package/src/block/l2_block.ts +33 -2
- package/src/block/l2_block_new.ts +143 -0
- package/src/checkpoint/checkpoint.ts +46 -0
- package/src/checkpoint/index.ts +1 -1
- package/src/logs/private_log.ts +2 -3
- package/src/messaging/in_hash.ts +15 -0
- package/src/messaging/index.ts +2 -0
- package/src/messaging/out_hash.ts +36 -0
- package/src/rollup/checkpoint_constant_data.ts +20 -0
- package/src/tests/factories.ts +109 -211
- package/src/tests/mocks.ts +196 -4
- package/src/tx/partial_state_reference.ts +9 -0
- package/src/tx/state_reference.ts +9 -0
- package/src/tx/tx_effect.ts +61 -67
- package/src/vks/verification_key.ts +25 -0
- package/dest/checkpoint/checkpoint_body.d.ts +0 -4
- package/dest/checkpoint/checkpoint_body.d.ts.map +0 -1
- package/dest/checkpoint/checkpoint_body.js +0 -9
- package/src/checkpoint/checkpoint_body.ts +0 -10
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type BlockBlobData } from '@aztec/blob-lib/encoding';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
6
|
+
import { BlockHeader } from '../tx/block_header.js';
|
|
7
|
+
import { Body } from './body.js';
|
|
8
|
+
import type { L2BlockInfo } from './l2_block_info.js';
|
|
9
|
+
/**
|
|
10
|
+
* An L2 block with a header and a body.
|
|
11
|
+
* TODO: Delete the existing `L2Block` class and rename this to `L2Block`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class L2BlockNew {
|
|
14
|
+
/** Snapshot of archive tree after the block is applied. */
|
|
15
|
+
archive: AppendOnlyTreeSnapshot;
|
|
16
|
+
/** Header of the block. */
|
|
17
|
+
header: BlockHeader;
|
|
18
|
+
/** L2 block body. */
|
|
19
|
+
body: Body;
|
|
20
|
+
private blockHash;
|
|
21
|
+
constructor(
|
|
22
|
+
/** Snapshot of archive tree after the block is applied. */
|
|
23
|
+
archive: AppendOnlyTreeSnapshot,
|
|
24
|
+
/** Header of the block. */
|
|
25
|
+
header: BlockHeader,
|
|
26
|
+
/** L2 block body. */
|
|
27
|
+
body: Body, blockHash?: Fr | undefined);
|
|
28
|
+
get number(): number;
|
|
29
|
+
get timestamp(): bigint;
|
|
30
|
+
static get schema(): z.ZodEffects<z.ZodObject<{
|
|
31
|
+
archive: z.ZodEffects<z.ZodObject<{
|
|
32
|
+
root: z.ZodType<Fr, any, string>;
|
|
33
|
+
nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
root: Fr;
|
|
36
|
+
nextAvailableLeafIndex: number;
|
|
37
|
+
}, {
|
|
38
|
+
root: string;
|
|
39
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
40
|
+
}>, AppendOnlyTreeSnapshot, {
|
|
41
|
+
root: string;
|
|
42
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
43
|
+
}>;
|
|
44
|
+
header: import("@aztec/foundation/schemas").ZodFor<BlockHeader>;
|
|
45
|
+
body: import("@aztec/foundation/schemas").ZodFor<Body>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
archive: AppendOnlyTreeSnapshot;
|
|
48
|
+
header: BlockHeader;
|
|
49
|
+
body: Body;
|
|
50
|
+
}, {
|
|
51
|
+
archive: {
|
|
52
|
+
root: string;
|
|
53
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
54
|
+
};
|
|
55
|
+
header?: any;
|
|
56
|
+
body?: any;
|
|
57
|
+
}>, L2BlockNew, {
|
|
58
|
+
archive: {
|
|
59
|
+
root: string;
|
|
60
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
61
|
+
};
|
|
62
|
+
header?: any;
|
|
63
|
+
body?: any;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Deserializes a block from a buffer
|
|
67
|
+
* @returns A deserialized L2 block.
|
|
68
|
+
*/
|
|
69
|
+
static fromBuffer(buf: Buffer | BufferReader): L2BlockNew;
|
|
70
|
+
/**
|
|
71
|
+
* Serializes a block
|
|
72
|
+
* @returns A serialized L2 block as a Buffer.
|
|
73
|
+
*/
|
|
74
|
+
toBuffer(): Buffer<ArrayBufferLike>;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the block's hash (hash of block header).
|
|
77
|
+
* @returns The block's hash.
|
|
78
|
+
*/
|
|
79
|
+
hash(): Promise<Fr>;
|
|
80
|
+
toBlobFields(isFirstBlock: boolean): Fr[];
|
|
81
|
+
toBlockBlobData(isFirstBlock: boolean): BlockBlobData;
|
|
82
|
+
/**
|
|
83
|
+
* Returns stats used for logging.
|
|
84
|
+
* @returns Stats on tx count, number, and log size and count.
|
|
85
|
+
*/
|
|
86
|
+
getStats(): {
|
|
87
|
+
privateLogCount: number;
|
|
88
|
+
publicLogCount: number;
|
|
89
|
+
contractClassLogCount: number;
|
|
90
|
+
contractClassLogSize: number;
|
|
91
|
+
txCount: number;
|
|
92
|
+
blockNumber: number;
|
|
93
|
+
blockTimestamp: number;
|
|
94
|
+
};
|
|
95
|
+
toBlockInfo(): L2BlockInfo;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=l2_block_new.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"l2_block_new.d.ts","sourceRoot":"","sources":["../../src/block/l2_block_new.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAuB,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,qBAAa,UAAU;IAEnB,2DAA2D;IACpD,OAAO,EAAE,sBAAsB;IACtC,2BAA2B;IACpB,MAAM,EAAE,WAAW;IAC1B,qBAAqB;IACd,IAAI,EAAE,IAAI;IACjB,OAAO,CAAC,SAAS;;IANjB,2DAA2D;IACpD,OAAO,EAAE,sBAAsB;IACtC,2BAA2B;IACpB,MAAM,EAAE,WAAW;IAC1B,qBAAqB;IACd,IAAI,EAAE,IAAI,EACT,SAAS,GAAE,EAAE,GAAG,SAAqB;IAG/C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAQhB;IAED;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IAS5C;;;OAGG;IACH,QAAQ;IAIR;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,EAAE,CAAC;IAOzB,YAAY,CAAC,YAAY,EAAE,OAAO,GAAG,EAAE,EAAE;IAKzC,eAAe,CAAC,YAAY,EAAE,OAAO,GAAG,aAAa;IAuB5D;;;OAGG;IACH,QAAQ;;;;;;;;;IAuBR,WAAW,IAAI,WAAW;CAW3B"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { encodeBlockBlobData } from '@aztec/blob-lib/encoding';
|
|
2
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
5
|
+
import { BlockHeader } from '../tx/block_header.js';
|
|
6
|
+
import { Body } from './body.js';
|
|
7
|
+
/**
|
|
8
|
+
* An L2 block with a header and a body.
|
|
9
|
+
* TODO: Delete the existing `L2Block` class and rename this to `L2Block`.
|
|
10
|
+
*/ export class L2BlockNew {
|
|
11
|
+
archive;
|
|
12
|
+
header;
|
|
13
|
+
body;
|
|
14
|
+
blockHash;
|
|
15
|
+
constructor(/** Snapshot of archive tree after the block is applied. */ archive, /** Header of the block. */ header, /** L2 block body. */ body, blockHash = undefined){
|
|
16
|
+
this.archive = archive;
|
|
17
|
+
this.header = header;
|
|
18
|
+
this.body = body;
|
|
19
|
+
this.blockHash = blockHash;
|
|
20
|
+
}
|
|
21
|
+
get number() {
|
|
22
|
+
return this.header.globalVariables.blockNumber;
|
|
23
|
+
}
|
|
24
|
+
get timestamp() {
|
|
25
|
+
return this.header.globalVariables.timestamp;
|
|
26
|
+
}
|
|
27
|
+
static get schema() {
|
|
28
|
+
return z.object({
|
|
29
|
+
archive: AppendOnlyTreeSnapshot.schema,
|
|
30
|
+
header: BlockHeader.schema,
|
|
31
|
+
body: Body.schema
|
|
32
|
+
}).transform(({ archive, header, body })=>new L2BlockNew(archive, header, body));
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Deserializes a block from a buffer
|
|
36
|
+
* @returns A deserialized L2 block.
|
|
37
|
+
*/ static fromBuffer(buf) {
|
|
38
|
+
const reader = BufferReader.asReader(buf);
|
|
39
|
+
const header = reader.readObject(BlockHeader);
|
|
40
|
+
const archive = reader.readObject(AppendOnlyTreeSnapshot);
|
|
41
|
+
const body = reader.readObject(Body);
|
|
42
|
+
return new L2BlockNew(archive, header, body);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Serializes a block
|
|
46
|
+
* @returns A serialized L2 block as a Buffer.
|
|
47
|
+
*/ toBuffer() {
|
|
48
|
+
return serializeToBuffer(this.header, this.archive, this.body);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the block's hash (hash of block header).
|
|
52
|
+
* @returns The block's hash.
|
|
53
|
+
*/ async hash() {
|
|
54
|
+
if (this.blockHash === undefined) {
|
|
55
|
+
this.blockHash = await this.header.hash();
|
|
56
|
+
}
|
|
57
|
+
return this.blockHash;
|
|
58
|
+
}
|
|
59
|
+
toBlobFields(isFirstBlock) {
|
|
60
|
+
const blockBlobData = this.toBlockBlobData(isFirstBlock);
|
|
61
|
+
return encodeBlockBlobData(blockBlobData);
|
|
62
|
+
}
|
|
63
|
+
toBlockBlobData(isFirstBlock) {
|
|
64
|
+
return {
|
|
65
|
+
blockEndMarker: {
|
|
66
|
+
numTxs: this.body.txEffects.length,
|
|
67
|
+
timestamp: this.header.globalVariables.timestamp,
|
|
68
|
+
blockNumber: this.number
|
|
69
|
+
},
|
|
70
|
+
blockEndStateField: {
|
|
71
|
+
l1ToL2MessageNextAvailableLeafIndex: this.header.state.l1ToL2MessageTree.nextAvailableLeafIndex,
|
|
72
|
+
noteHashNextAvailableLeafIndex: this.header.state.partial.noteHashTree.nextAvailableLeafIndex,
|
|
73
|
+
nullifierNextAvailableLeafIndex: this.header.state.partial.nullifierTree.nextAvailableLeafIndex,
|
|
74
|
+
publicDataNextAvailableLeafIndex: this.header.state.partial.publicDataTree.nextAvailableLeafIndex,
|
|
75
|
+
totalManaUsed: this.header.totalManaUsed.toBigInt()
|
|
76
|
+
},
|
|
77
|
+
lastArchiveRoot: this.header.lastArchive.root,
|
|
78
|
+
noteHashRoot: this.header.state.partial.noteHashTree.root,
|
|
79
|
+
nullifierRoot: this.header.state.partial.nullifierTree.root,
|
|
80
|
+
publicDataRoot: this.header.state.partial.publicDataTree.root,
|
|
81
|
+
l1ToL2MessageRoot: isFirstBlock ? this.header.state.l1ToL2MessageTree.root : undefined,
|
|
82
|
+
txs: this.body.toTxBlobData()
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns stats used for logging.
|
|
87
|
+
* @returns Stats on tx count, number, and log size and count.
|
|
88
|
+
*/ getStats() {
|
|
89
|
+
const logsStats = {
|
|
90
|
+
privateLogCount: this.body.txEffects.reduce((logCount, txEffect)=>logCount + txEffect.privateLogs.length, 0),
|
|
91
|
+
publicLogCount: this.body.txEffects.reduce((logCount, txEffect)=>logCount + txEffect.publicLogs.length, 0),
|
|
92
|
+
contractClassLogCount: this.body.txEffects.reduce((logCount, txEffect)=>logCount + txEffect.contractClassLogs.length, 0),
|
|
93
|
+
contractClassLogSize: this.body.txEffects.reduce((totalLogSize, txEffect)=>totalLogSize + txEffect.contractClassLogs.reduce((acc, log)=>acc + log.emittedLength, 0), 0)
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
txCount: this.body.txEffects.length,
|
|
97
|
+
blockNumber: this.number,
|
|
98
|
+
blockTimestamp: Number(this.header.globalVariables.timestamp),
|
|
99
|
+
...logsStats
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
toBlockInfo() {
|
|
103
|
+
return {
|
|
104
|
+
blockHash: this.blockHash,
|
|
105
|
+
archive: this.archive.root,
|
|
106
|
+
lastArchive: this.header.lastArchive.root,
|
|
107
|
+
blockNumber: this.number,
|
|
108
|
+
slotNumber: Number(this.header.getSlot()),
|
|
109
|
+
txCount: this.body.txEffects.length,
|
|
110
|
+
timestamp: this.header.globalVariables.timestamp
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { L2BlockNew } from '../block/l2_block_new.js';
|
|
5
|
+
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
6
|
+
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
7
|
+
export declare class Checkpoint {
|
|
8
|
+
/** Snapshot of archive tree after the checkpoint is added. */
|
|
9
|
+
archive: AppendOnlyTreeSnapshot;
|
|
10
|
+
/** Header of the checkpoint. */
|
|
11
|
+
header: CheckpointHeader;
|
|
12
|
+
/** L2 blocks in the checkpoint. */
|
|
13
|
+
blocks: L2BlockNew[];
|
|
14
|
+
constructor(
|
|
15
|
+
/** Snapshot of archive tree after the checkpoint is added. */
|
|
16
|
+
archive: AppendOnlyTreeSnapshot,
|
|
17
|
+
/** Header of the checkpoint. */
|
|
18
|
+
header: CheckpointHeader,
|
|
19
|
+
/** L2 blocks in the checkpoint. */
|
|
20
|
+
blocks: L2BlockNew[]);
|
|
21
|
+
static get schema(): z.ZodEffects<z.ZodObject<{
|
|
22
|
+
archive: z.ZodEffects<z.ZodObject<{
|
|
23
|
+
root: z.ZodType<Fr, any, string>;
|
|
24
|
+
nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
root: Fr;
|
|
27
|
+
nextAvailableLeafIndex: number;
|
|
28
|
+
}, {
|
|
29
|
+
root: string;
|
|
30
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
31
|
+
}>, AppendOnlyTreeSnapshot, {
|
|
32
|
+
root: string;
|
|
33
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
34
|
+
}>;
|
|
35
|
+
header: import("@aztec/foundation/schemas").ZodFor<CheckpointHeader>;
|
|
36
|
+
blocks: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
37
|
+
archive: z.ZodEffects<z.ZodObject<{
|
|
38
|
+
root: z.ZodType<Fr, any, string>;
|
|
39
|
+
nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
root: Fr;
|
|
42
|
+
nextAvailableLeafIndex: number;
|
|
43
|
+
}, {
|
|
44
|
+
root: string;
|
|
45
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
46
|
+
}>, AppendOnlyTreeSnapshot, {
|
|
47
|
+
root: string;
|
|
48
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
49
|
+
}>;
|
|
50
|
+
header: import("@aztec/foundation/schemas").ZodFor<import("../tx/block_header.js").BlockHeader>;
|
|
51
|
+
body: import("@aztec/foundation/schemas").ZodFor<import("../block/body.js").Body>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
archive: AppendOnlyTreeSnapshot;
|
|
54
|
+
header: import("../tx/block_header.js").BlockHeader;
|
|
55
|
+
body: import("../block/body.js").Body;
|
|
56
|
+
}, {
|
|
57
|
+
archive: {
|
|
58
|
+
root: string;
|
|
59
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
60
|
+
};
|
|
61
|
+
header?: any;
|
|
62
|
+
body?: any;
|
|
63
|
+
}>, L2BlockNew, {
|
|
64
|
+
archive: {
|
|
65
|
+
root: string;
|
|
66
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
67
|
+
};
|
|
68
|
+
header?: any;
|
|
69
|
+
body?: any;
|
|
70
|
+
}>, "many">;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
archive: AppendOnlyTreeSnapshot;
|
|
73
|
+
header: CheckpointHeader;
|
|
74
|
+
blocks: L2BlockNew[];
|
|
75
|
+
}, {
|
|
76
|
+
archive: {
|
|
77
|
+
root: string;
|
|
78
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
79
|
+
};
|
|
80
|
+
blocks: {
|
|
81
|
+
archive: {
|
|
82
|
+
root: string;
|
|
83
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
84
|
+
};
|
|
85
|
+
header?: any;
|
|
86
|
+
body?: any;
|
|
87
|
+
}[];
|
|
88
|
+
header?: any;
|
|
89
|
+
}>, Checkpoint, {
|
|
90
|
+
archive: {
|
|
91
|
+
root: string;
|
|
92
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
93
|
+
};
|
|
94
|
+
blocks: {
|
|
95
|
+
archive: {
|
|
96
|
+
root: string;
|
|
97
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
98
|
+
};
|
|
99
|
+
header?: any;
|
|
100
|
+
body?: any;
|
|
101
|
+
}[];
|
|
102
|
+
header?: any;
|
|
103
|
+
}>;
|
|
104
|
+
static fromBuffer(buf: Buffer | BufferReader): Checkpoint;
|
|
105
|
+
toBuffer(): Buffer<ArrayBufferLike>;
|
|
106
|
+
toBlobFields(): Fr[];
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=checkpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../src/checkpoint/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,qBAAa,UAAU;IAEnB,8DAA8D;IACvD,OAAO,EAAE,sBAAsB;IACtC,gCAAgC;IACzB,MAAM,EAAE,gBAAgB;IAC/B,mCAAmC;IAC5B,MAAM,EAAE,UAAU,EAAE;;IAL3B,8DAA8D;IACvD,OAAO,EAAE,sBAAsB;IACtC,gCAAgC;IACzB,MAAM,EAAE,gBAAgB;IAC/B,mCAAmC;IAC5B,MAAM,EAAE,UAAU,EAAE;IAG7B,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAQhB;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IAQ5C,QAAQ;IAID,YAAY;CAIpB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { L2BlockNew } from '../block/l2_block_new.js';
|
|
5
|
+
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
6
|
+
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
7
|
+
export class Checkpoint {
|
|
8
|
+
archive;
|
|
9
|
+
header;
|
|
10
|
+
blocks;
|
|
11
|
+
constructor(/** Snapshot of archive tree after the checkpoint is added. */ archive, /** Header of the checkpoint. */ header, /** L2 blocks in the checkpoint. */ blocks){
|
|
12
|
+
this.archive = archive;
|
|
13
|
+
this.header = header;
|
|
14
|
+
this.blocks = blocks;
|
|
15
|
+
}
|
|
16
|
+
static get schema() {
|
|
17
|
+
return z.object({
|
|
18
|
+
archive: AppendOnlyTreeSnapshot.schema,
|
|
19
|
+
header: CheckpointHeader.schema,
|
|
20
|
+
blocks: z.array(L2BlockNew.schema)
|
|
21
|
+
}).transform(({ archive, header, blocks })=>new Checkpoint(archive, header, blocks));
|
|
22
|
+
}
|
|
23
|
+
static fromBuffer(buf) {
|
|
24
|
+
const reader = BufferReader.asReader(buf);
|
|
25
|
+
const archive = reader.readObject(AppendOnlyTreeSnapshot);
|
|
26
|
+
const header = reader.readObject(CheckpointHeader);
|
|
27
|
+
const blocks = reader.readVector(L2BlockNew);
|
|
28
|
+
return new Checkpoint(archive, header, blocks);
|
|
29
|
+
}
|
|
30
|
+
toBuffer() {
|
|
31
|
+
return serializeToBuffer(this.archive, this.header, this.blocks.length, this.blocks);
|
|
32
|
+
}
|
|
33
|
+
toBlobFields() {
|
|
34
|
+
const blocksBlobFields = this.blocks.flatMap((block, i)=>block.toBlobFields(i === 0));
|
|
35
|
+
return [
|
|
36
|
+
new Fr(blocksBlobFields.length + 1)
|
|
37
|
+
].concat(blocksBlobFields);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './checkpoint.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/checkpoint/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/checkpoint/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
package/dest/checkpoint/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './checkpoint.js';
|
|
@@ -774,7 +774,7 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
774
774
|
selector?: any;
|
|
775
775
|
address?: any;
|
|
776
776
|
}>, "many">;
|
|
777
|
-
|
|
777
|
+
contractDbCreateCheckpointHints: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
778
778
|
actionCounter: z.ZodNumber;
|
|
779
779
|
oldCheckpointId: z.ZodNumber;
|
|
780
780
|
newCheckpointId: z.ZodNumber;
|
|
@@ -795,7 +795,7 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
795
795
|
oldCheckpointId: number;
|
|
796
796
|
newCheckpointId: number;
|
|
797
797
|
}>, "many">;
|
|
798
|
-
|
|
798
|
+
contractDbCommitCheckpointHints: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
799
799
|
actionCounter: z.ZodNumber;
|
|
800
800
|
oldCheckpointId: z.ZodNumber;
|
|
801
801
|
newCheckpointId: z.ZodNumber;
|
|
@@ -816,7 +816,7 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
816
816
|
oldCheckpointId: number;
|
|
817
817
|
newCheckpointId: number;
|
|
818
818
|
}>, "many">;
|
|
819
|
-
|
|
819
|
+
contractDbRevertCheckpointHints: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
820
820
|
actionCounter: z.ZodNumber;
|
|
821
821
|
oldCheckpointId: z.ZodNumber;
|
|
822
822
|
newCheckpointId: z.ZodNumber;
|
|
@@ -2409,17 +2409,17 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
2409
2409
|
contractClasses: import("../avm/avm.js").AvmContractClassHint[];
|
|
2410
2410
|
bytecodeCommitments: import("../avm/avm.js").AvmBytecodeCommitmentHint[];
|
|
2411
2411
|
debugFunctionNames: import("../avm/avm.js").AvmDebugFunctionNameHint[];
|
|
2412
|
-
|
|
2412
|
+
contractDbCreateCheckpointHints: {
|
|
2413
2413
|
readonly actionCounter: number;
|
|
2414
2414
|
readonly oldCheckpointId: number;
|
|
2415
2415
|
readonly newCheckpointId: number;
|
|
2416
2416
|
}[];
|
|
2417
|
-
|
|
2417
|
+
contractDbCommitCheckpointHints: {
|
|
2418
2418
|
readonly actionCounter: number;
|
|
2419
2419
|
readonly oldCheckpointId: number;
|
|
2420
2420
|
readonly newCheckpointId: number;
|
|
2421
2421
|
}[];
|
|
2422
|
-
|
|
2422
|
+
contractDbRevertCheckpointHints: {
|
|
2423
2423
|
readonly actionCounter: number;
|
|
2424
2424
|
readonly oldCheckpointId: number;
|
|
2425
2425
|
readonly newCheckpointId: number;
|
|
@@ -2612,17 +2612,17 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
2612
2612
|
selector?: any;
|
|
2613
2613
|
address?: any;
|
|
2614
2614
|
}[];
|
|
2615
|
-
|
|
2615
|
+
contractDbCreateCheckpointHints: {
|
|
2616
2616
|
actionCounter: number;
|
|
2617
2617
|
oldCheckpointId: number;
|
|
2618
2618
|
newCheckpointId: number;
|
|
2619
2619
|
}[];
|
|
2620
|
-
|
|
2620
|
+
contractDbCommitCheckpointHints: {
|
|
2621
2621
|
actionCounter: number;
|
|
2622
2622
|
oldCheckpointId: number;
|
|
2623
2623
|
newCheckpointId: number;
|
|
2624
2624
|
}[];
|
|
2625
|
-
|
|
2625
|
+
contractDbRevertCheckpointHints: {
|
|
2626
2626
|
actionCounter: number;
|
|
2627
2627
|
oldCheckpointId: number;
|
|
2628
2628
|
newCheckpointId: number;
|
|
@@ -3014,17 +3014,17 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
3014
3014
|
selector?: any;
|
|
3015
3015
|
address?: any;
|
|
3016
3016
|
}[];
|
|
3017
|
-
|
|
3017
|
+
contractDbCreateCheckpointHints: {
|
|
3018
3018
|
actionCounter: number;
|
|
3019
3019
|
oldCheckpointId: number;
|
|
3020
3020
|
newCheckpointId: number;
|
|
3021
3021
|
}[];
|
|
3022
|
-
|
|
3022
|
+
contractDbCommitCheckpointHints: {
|
|
3023
3023
|
actionCounter: number;
|
|
3024
3024
|
oldCheckpointId: number;
|
|
3025
3025
|
newCheckpointId: number;
|
|
3026
3026
|
}[];
|
|
3027
|
-
|
|
3027
|
+
contractDbRevertCheckpointHints: {
|
|
3028
3028
|
actionCounter: number;
|
|
3029
3029
|
oldCheckpointId: number;
|
|
3030
3030
|
newCheckpointId: number;
|
|
@@ -4663,17 +4663,17 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
4663
4663
|
selector?: any;
|
|
4664
4664
|
address?: any;
|
|
4665
4665
|
}[];
|
|
4666
|
-
|
|
4666
|
+
contractDbCreateCheckpointHints: {
|
|
4667
4667
|
actionCounter: number;
|
|
4668
4668
|
oldCheckpointId: number;
|
|
4669
4669
|
newCheckpointId: number;
|
|
4670
4670
|
}[];
|
|
4671
|
-
|
|
4671
|
+
contractDbCommitCheckpointHints: {
|
|
4672
4672
|
actionCounter: number;
|
|
4673
4673
|
oldCheckpointId: number;
|
|
4674
4674
|
newCheckpointId: number;
|
|
4675
4675
|
}[];
|
|
4676
|
-
|
|
4676
|
+
contractDbRevertCheckpointHints: {
|
|
4677
4677
|
actionCounter: number;
|
|
4678
4678
|
oldCheckpointId: number;
|
|
4679
4679
|
newCheckpointId: number;
|
|
@@ -5232,17 +5232,17 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
5232
5232
|
selector?: any;
|
|
5233
5233
|
address?: any;
|
|
5234
5234
|
}[];
|
|
5235
|
-
|
|
5235
|
+
contractDbCreateCheckpointHints: {
|
|
5236
5236
|
actionCounter: number;
|
|
5237
5237
|
oldCheckpointId: number;
|
|
5238
5238
|
newCheckpointId: number;
|
|
5239
5239
|
}[];
|
|
5240
|
-
|
|
5240
|
+
contractDbCommitCheckpointHints: {
|
|
5241
5241
|
actionCounter: number;
|
|
5242
5242
|
oldCheckpointId: number;
|
|
5243
5243
|
newCheckpointId: number;
|
|
5244
5244
|
}[];
|
|
5245
|
-
|
|
5245
|
+
contractDbRevertCheckpointHints: {
|
|
5246
5246
|
actionCounter: number;
|
|
5247
5247
|
oldCheckpointId: number;
|
|
5248
5248
|
newCheckpointId: number;
|
|
@@ -5807,17 +5807,17 @@ export declare const ProvingJobInputs: z.ZodDiscriminatedUnion<"type", [z.ZodObj
|
|
|
5807
5807
|
selector?: any;
|
|
5808
5808
|
address?: any;
|
|
5809
5809
|
}[];
|
|
5810
|
-
|
|
5810
|
+
contractDbCreateCheckpointHints: {
|
|
5811
5811
|
actionCounter: number;
|
|
5812
5812
|
oldCheckpointId: number;
|
|
5813
5813
|
newCheckpointId: number;
|
|
5814
5814
|
}[];
|
|
5815
|
-
|
|
5815
|
+
contractDbCommitCheckpointHints: {
|
|
5816
5816
|
actionCounter: number;
|
|
5817
5817
|
oldCheckpointId: number;
|
|
5818
5818
|
newCheckpointId: number;
|
|
5819
5819
|
}[];
|
|
5820
|
-
|
|
5820
|
+
contractDbRevertCheckpointHints: {
|
|
5821
5821
|
actionCounter: number;
|
|
5822
5822
|
oldCheckpointId: number;
|
|
5823
5823
|
newCheckpointId: number;
|
|
@@ -16,7 +16,7 @@ export declare class PrivateLog {
|
|
|
16
16
|
getEmittedFields(): Fr[];
|
|
17
17
|
getEmittedFieldsWithoutTag(): Fr[];
|
|
18
18
|
toBlobFields(): Fr[];
|
|
19
|
-
static fromBlobFields(fields: Fr[] | FieldReader): PrivateLog;
|
|
19
|
+
static fromBlobFields(emittedLength: number, fields: Fr[] | FieldReader): PrivateLog;
|
|
20
20
|
isEmpty(): boolean;
|
|
21
21
|
static empty(): PrivateLog;
|
|
22
22
|
toBuffer(): Buffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"private_log.d.ts","sourceRoot":"","sources":["../../src/logs/private_log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,KAAK,KAAK,EAGX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,UAAU;IAIZ,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,0BAA0B,CAAC;IAEpD,aAAa,EAAE,MAAM;IAL9B,MAAM,CAAC,aAAa,SAAyC;gBAGpD,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,0BAA0B,CAAC,EAEpD,aAAa,EAAE,MAAM;IAG9B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;IAIxC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;IAI7C,QAAQ,IAAI,EAAE,EAAE;IAIhB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAK5C,gBAAgB;IAIhB,0BAA0B;IAI1B,YAAY,IAAI,EAAE,EAAE;IAIpB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;
|
|
1
|
+
{"version":3,"file":"private_log.d.ts","sourceRoot":"","sources":["../../src/logs/private_log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,KAAK,KAAK,EAGX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,UAAU;IAIZ,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,0BAA0B,CAAC;IAEpD,aAAa,EAAE,MAAM;IAL9B,MAAM,CAAC,aAAa,SAAyC;gBAGpD,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,0BAA0B,CAAC,EAEpD,aAAa,EAAE,MAAM;IAG9B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;IAIxC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC;IAI7C,QAAQ,IAAI,EAAE,EAAE;IAIhB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAK5C,gBAAgB;IAIhB,0BAA0B;IAI1B,YAAY,IAAI,EAAE,EAAE;IAIpB,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAMvE,OAAO;IAIP,MAAM,CAAC,KAAK;IAIZ,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAK/C,MAAM,CAAC,MAAM,CAAC,GAAG,KAAc;IAM/B,MAAM,KAAK,MAAM;;;;;;;;;;;;OAQhB;IAED;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU;IAU5C,MAAM,CAAC,KAAK,EAAE,UAAU;IAIxB,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM;CAM3B"}
|
package/dest/logs/private_log.js
CHANGED
|
@@ -38,13 +38,10 @@ export class PrivateLog {
|
|
|
38
38
|
return this.fields.slice(1, this.emittedLength);
|
|
39
39
|
}
|
|
40
40
|
toBlobFields() {
|
|
41
|
-
return
|
|
42
|
-
new Fr(this.emittedLength)
|
|
43
|
-
].concat(this.getEmittedFields());
|
|
41
|
+
return this.getEmittedFields();
|
|
44
42
|
}
|
|
45
|
-
static fromBlobFields(fields) {
|
|
43
|
+
static fromBlobFields(emittedLength, fields) {
|
|
46
44
|
const reader = FieldReader.asReader(fields);
|
|
47
|
-
const emittedLength = reader.readU32();
|
|
48
45
|
const emittedFields = reader.readFieldArray(emittedLength);
|
|
49
46
|
return new PrivateLog(padArrayEnd(emittedFields, Fr.ZERO, PRIVATE_LOG_SIZE_IN_FIELDS), emittedLength);
|
|
50
47
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
/** Computes the inHash for a block's ContentCommitment given its l1 to l2 messages. */
|
|
3
|
+
export declare function computeInHashFromL1ToL2Messages(unpaddedL1ToL2Messages: Fr[]): Promise<Fr>;
|
|
4
|
+
//# sourceMappingURL=in_hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in_hash.d.ts","sourceRoot":"","sources":["../../src/messaging/in_hash.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,uFAAuF;AACvF,wBAAsB,+BAA+B,CAAC,sBAAsB,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAO/F"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP } from '@aztec/constants';
|
|
2
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
|
+
import { sha256Trunc } from '@aztec/foundation/crypto';
|
|
4
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
+
import { MerkleTreeCalculator } from '@aztec/foundation/trees';
|
|
6
|
+
/** Computes the inHash for a block's ContentCommitment given its l1 to l2 messages. */ export async function computeInHashFromL1ToL2Messages(unpaddedL1ToL2Messages) {
|
|
7
|
+
const l1ToL2Messages = padArrayEnd(unpaddedL1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
8
|
+
const hasher = (left, right)=>Promise.resolve(sha256Trunc(Buffer.concat([
|
|
9
|
+
left,
|
|
10
|
+
right
|
|
11
|
+
])));
|
|
12
|
+
const parityHeight = Math.ceil(Math.log2(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP));
|
|
13
|
+
const parityCalculator = await MerkleTreeCalculator.create(parityHeight, Fr.ZERO.toBuffer(), hasher);
|
|
14
|
+
return new Fr(await parityCalculator.computeTreeRoot(l1ToL2Messages.map((msg)=>msg.toBuffer())));
|
|
15
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './in_hash.js';
|
|
1
2
|
export * from './inbox_leaf.js';
|
|
2
3
|
export * from './l1_to_l2_message.js';
|
|
3
4
|
export * from './l1_to_l2_message_source.js';
|
|
@@ -5,4 +6,5 @@ export * from './l1_actor.js';
|
|
|
5
6
|
export * from './l2_actor.js';
|
|
6
7
|
export * from './l2_to_l1_message.js';
|
|
7
8
|
export * from './l2_to_l1_membership.js';
|
|
9
|
+
export * from './out_hash.js';
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messaging/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messaging/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC"}
|
package/dest/messaging/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './in_hash.js';
|
|
1
2
|
export * from './inbox_leaf.js';
|
|
2
3
|
export * from './l1_to_l2_message.js';
|
|
3
4
|
export * from './l1_to_l2_message_source.js';
|
|
@@ -5,3 +6,4 @@ export * from './l1_actor.js';
|
|
|
5
6
|
export * from './l2_actor.js';
|
|
6
7
|
export * from './l2_to_l1_message.js';
|
|
7
8
|
export * from './l2_to_l1_membership.js';
|
|
9
|
+
export * from './out_hash.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
export declare function computeTxOutHash(messages: Fr[]): Fr;
|
|
3
|
+
export declare function computeBlockOutHash(messagesPerBlock: Fr[][]): Fr;
|
|
4
|
+
export declare function computeCheckpointOutHash(messagesForAllTxs: Fr[][][]): Fr;
|
|
5
|
+
//# sourceMappingURL=out_hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"out_hash.d.ts","sourceRoot":"","sources":["../../src/messaging/out_hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,CAOnD;AAED,wBAAgB,mBAAmB,CAAC,gBAAgB,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAGhE;AAED,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAGxE"}
|