@aztec/stdlib 3.0.0-nightly.20250910 → 3.0.0-nightly.20250911
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/index.d.ts +2 -0
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +2 -0
- package/dest/block/l2_block.d.ts +2 -8
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +5 -3
- package/dest/block/l2_block_info.d.ts +41 -0
- package/dest/block/l2_block_info.d.ts.map +1 -0
- package/dest/block/l2_block_info.js +40 -0
- package/dest/block/l2_block_source.d.ts +1 -428
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +0 -28
- package/dest/block/published_l2_block.d.ts +25 -1
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +20 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +2 -1
- package/dest/block/validate_block_result.d.ts +222 -0
- package/dest/block/validate_block_result.d.ts.map +1 -0
- package/dest/block/validate_block_result.js +83 -0
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +2 -1
- package/dest/p2p/block_attestation.d.ts +1 -0
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +3 -0
- package/dest/p2p/block_proposal.d.ts +2 -2
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +3 -1
- package/dest/p2p/consensus_payload.d.ts +1 -0
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +6 -4
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +5 -8
- package/dest/tx/content_commitment.d.ts +1 -0
- package/dest/tx/content_commitment.d.ts.map +1 -1
- package/dest/tx/content_commitment.js +3 -0
- package/dest/tx/partial_state_reference.d.ts +1 -0
- package/dest/tx/partial_state_reference.d.ts.map +1 -1
- package/dest/tx/partial_state_reference.js +3 -0
- package/dest/tx/proposed_block_header.d.ts +1 -0
- package/dest/tx/proposed_block_header.d.ts.map +1 -1
- package/dest/tx/proposed_block_header.js +3 -0
- package/dest/tx/state_reference.d.ts +1 -0
- package/dest/tx/state_reference.d.ts.map +1 -1
- package/dest/tx/state_reference.js +3 -0
- package/dest/update-checker/update-checker.d.ts +1 -1
- package/dest/update-checker/update-checker.d.ts.map +1 -1
- package/dest/update-checker/update-checker.js +1 -1
- package/package.json +8 -8
- package/src/block/index.ts +2 -0
- package/src/block/l2_block.ts +6 -11
- package/src/block/l2_block_info.ts +63 -0
- package/src/block/l2_block_source.ts +1 -51
- package/src/block/published_l2_block.ts +38 -5
- package/src/block/test/l2_tips_store_test_suite.ts +7 -6
- package/src/block/validate_block_result.ts +122 -0
- package/src/interfaces/archiver.ts +2 -1
- package/src/p2p/block_attestation.ts +4 -0
- package/src/p2p/block_proposal.ts +5 -3
- package/src/p2p/consensus_payload.ts +7 -4
- package/src/tests/mocks.ts +5 -5
- package/src/tx/content_commitment.ts +4 -0
- package/src/tx/partial_state_reference.ts +8 -0
- package/src/tx/proposed_block_header.ts +13 -0
- package/src/tx/state_reference.ts +4 -0
- package/src/update-checker/update-checker.ts +1 -1
|
@@ -60,6 +60,9 @@ export class ContentCommitment {
|
|
|
60
60
|
const reader = FieldReader.asReader(fields);
|
|
61
61
|
return new ContentCommitment(reader.readField(), reader.readField(), reader.readField());
|
|
62
62
|
}
|
|
63
|
+
static random() {
|
|
64
|
+
return new ContentCommitment(Fr.random(), Fr.random(), Fr.random());
|
|
65
|
+
}
|
|
63
66
|
static empty() {
|
|
64
67
|
return new ContentCommitment(Fr.zero(), Fr.zero(), Fr.zero());
|
|
65
68
|
}
|
|
@@ -95,6 +95,7 @@ export declare class PartialStateReference {
|
|
|
95
95
|
static fromBuffer(buffer: Buffer | BufferReader): PartialStateReference;
|
|
96
96
|
static fromFields(fields: Fr[] | FieldReader): PartialStateReference;
|
|
97
97
|
static fromViem(stateReference: ViemPartialStateReference): PartialStateReference;
|
|
98
|
+
static random(): PartialStateReference;
|
|
98
99
|
toViem(): ViemPartialStateReference;
|
|
99
100
|
toAbi(): [
|
|
100
101
|
ReturnType<AppendOnlyTreeSnapshot['toAbi']>,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partial_state_reference.d.ts","sourceRoot":"","sources":["../../src/tx/partial_state_reference.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAE3F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E;;GAEG;AACH,qBAAa,qBAAqB;IAE9B,sCAAsC;aACtB,YAAY,EAAE,sBAAsB;IACpD,sCAAsC;aACtB,aAAa,EAAE,sBAAsB;IACrD,wCAAwC;aACxB,cAAc,EAAE,sBAAsB;;IALtD,sCAAsC;IACtB,YAAY,EAAE,sBAAsB;IACpD,sCAAsC;IACtB,aAAa,EAAE,sBAAsB;IACrD,wCAAwC;IACxB,cAAc,EAAE,sBAAsB;IAGxD,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAWhB;IAED,OAAO;IAIP,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,qBAAqB;IASvE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,qBAAqB;IAUpE,MAAM,CAAC,QAAQ,CAAC,cAAc,EAA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CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,qBAAqB;IAUpE,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,yBAAyB;IAQzD,MAAM,CAAC,MAAM,IAAI,qBAAqB;IAQtC,MAAM,IAAI,yBAAyB;IAQnC,KAAK,IAAI;QACP,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAC3C,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAC3C,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;KAC5C;IAID,MAAM,CAAC,KAAK,IAAI,qBAAqB;IAQrC,QAAQ;IAIR,QAAQ;IAcR,OAAO,IAAI,OAAO;IAIX,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;CAOpC"}
|
|
@@ -37,6 +37,9 @@ import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
|
37
37
|
static fromViem(stateReference) {
|
|
38
38
|
return new PartialStateReference(AppendOnlyTreeSnapshot.fromViem(stateReference.noteHashTree), AppendOnlyTreeSnapshot.fromViem(stateReference.nullifierTree), AppendOnlyTreeSnapshot.fromViem(stateReference.publicDataTree));
|
|
39
39
|
}
|
|
40
|
+
static random() {
|
|
41
|
+
return new PartialStateReference(AppendOnlyTreeSnapshot.random(), AppendOnlyTreeSnapshot.random(), AppendOnlyTreeSnapshot.random());
|
|
42
|
+
}
|
|
40
43
|
toViem() {
|
|
41
44
|
return {
|
|
42
45
|
noteHashTree: this.noteHashTree.toViem(),
|
|
@@ -51,6 +51,7 @@ export declare class ProposedBlockHeader {
|
|
|
51
51
|
toBuffer(): Buffer<ArrayBufferLike>;
|
|
52
52
|
hash(): Fr;
|
|
53
53
|
static empty(fields?: Partial<FieldsOf<ProposedBlockHeader>>): ProposedBlockHeader;
|
|
54
|
+
static random(): ProposedBlockHeader;
|
|
54
55
|
isEmpty(): boolean;
|
|
55
56
|
/**
|
|
56
57
|
* Serializes this instance into a string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proposed_block_header.d.ts","sourceRoot":"","sources":["../../src/tx/proposed_block_header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAuC,MAAM,6BAA6B,CAAC;AAEhG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,0CAA0C;AAC1C,qBAAa,mBAAmB;IAE5B,2DAA2D;IACpD,eAAe,EAAE,EAAE;IAC1B,0CAA0C;IACnC,iBAAiB,EAAE,iBAAiB;IAC3C,kCAAkC;IAC3B,UAAU,EAAE,EAAE;IACrB,iCAAiC;IAC1B,SAAS,EAAE,MAAM;IACxB,iCAAiC;IAC1B,QAAQ,EAAE,UAAU;IAC3B,+BAA+B;IACxB,YAAY,EAAE,YAAY;IACjC,wCAAwC;IACjC,OAAO,EAAE,OAAO;IACvB,wEAAwE;IACjE,aAAa,EAAE,EAAE;;IAfxB,2DAA2D;IACpD,eAAe,EAAE,EAAE;IAC1B,0CAA0C;IACnC,iBAAiB,EAAE,iBAAiB;IAC3C,kCAAkC;IAC3B,UAAU,EAAE,EAAE;IACrB,iCAAiC;IAC1B,SAAS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MAAM,GAAG,YAAY,GAAG,mBAAmB;IAerE,QAAQ;IAcR,IAAI,IAAI,EAAE;IAIV,MAAM,CAAC,KAAK,CAAC,MAAM,GAAE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAM,GAAG,mBAAmB;IActF,MAAM,CAAC,MAAM,IAAI,mBAAmB;IAapC,OAAO,IAAI,OAAO;IAalB;;;OAGG;IACI,QAAQ;IAIf,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,mBAAmB;IAInD,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU;IAalC,MAAM,IAAI,UAAU;IAgBpB,SAAS;;;;;;;;;;;;;;;;;IAaT,CAAC,OAAO,CAAC,MAAM,CAAC;CAajB"}
|
|
@@ -90,6 +90,9 @@ import { ContentCommitment } from './content_commitment.js';
|
|
|
90
90
|
...fields
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
+
static random() {
|
|
94
|
+
return new ProposedBlockHeader(Fr.random(), ContentCommitment.random(), new Fr(BigInt(Math.floor(Math.random() * 1000) + 1)), BigInt(Math.floor(Date.now() / 1000)), EthAddress.random(), new AztecAddress(Fr.random()), GasFees.random(), new Fr(BigInt(Math.floor(Math.random() * 1000000))));
|
|
95
|
+
}
|
|
93
96
|
isEmpty() {
|
|
94
97
|
return this.lastArchiveRoot.isZero() && this.contentCommitment.isEmpty() && this.slotNumber.isZero() && this.timestamp === 0n && this.coinbase.isZero() && this.feeRecipient.isZero() && this.gasFees.isEmpty() && this.totalManaUsed.isZero();
|
|
95
98
|
}
|
|
@@ -152,6 +152,7 @@ export declare class StateReference {
|
|
|
152
152
|
static fromFields(fields: Fr[] | FieldReader): StateReference;
|
|
153
153
|
static fromViem(stateReference: ViemStateReference): StateReference;
|
|
154
154
|
static empty(): StateReference;
|
|
155
|
+
static random(): StateReference;
|
|
155
156
|
toViem(): ViemStateReference;
|
|
156
157
|
toAbi(): [ReturnType<AppendOnlyTreeSnapshot['toAbi']>, ReturnType<PartialStateReference['toAbi']>];
|
|
157
158
|
isEmpty(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state_reference.d.ts","sourceRoot":"","sources":["../../src/tx/state_reference.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAqB,MAAM,6BAA6B,CAAC;AAE3F,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE;;GAEG;AACH,qBAAa,cAAc;IAEvB,6CAA6C;IACtC,iBAAiB,EAAE,sBAAsB;IAChD,0CAA0C;IACnC,OAAO,EAAE,qBAAqB;;IAHrC,6CAA6C;IACtC,iBAAiB,EAAE,sBAAsB;IAChD,0CAA0C;IACnC,OAAO,EAAE,qBAAqB;IAGvC,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAOhB;IAED,OAAO;IAIP,QAAQ;IAKR,QAAQ,IAAI,EAAE,EAAE;IAUhB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,cAAc;IAKhE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,cAAc;IAS7D,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,kBAAkB;IAOlD,MAAM,CAAC,KAAK,IAAI,cAAc;I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B,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,cAAc;IAKhE,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,GAAG,cAAc;IAS7D,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,kBAAkB;IAOlD,MAAM,CAAC,KAAK,IAAI,cAAc;IAI9B,MAAM,CAAC,MAAM,IAAI,cAAc;IAI/B,MAAM,IAAI,kBAAkB;IAO5B,KAAK,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IAIlG,OAAO,IAAI,OAAO;IAIlB,SAAS;;;;;;IAST;;OAEG;IACI,QAAQ;IAkBf,CAAC,OAAO,CAAC,MAAM,CAAC;IAST,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;CAGpC"}
|
|
@@ -52,6 +52,9 @@ import { PartialStateReference } from './partial_state_reference.js';
|
|
|
52
52
|
static empty() {
|
|
53
53
|
return new StateReference(AppendOnlyTreeSnapshot.empty(), PartialStateReference.empty());
|
|
54
54
|
}
|
|
55
|
+
static random() {
|
|
56
|
+
return new StateReference(AppendOnlyTreeSnapshot.random(), PartialStateReference.random());
|
|
57
|
+
}
|
|
55
58
|
toViem() {
|
|
56
59
|
return {
|
|
57
60
|
l1ToL2MessageTree: this.l1ToL2MessageTree.toViem(),
|
|
@@ -32,7 +32,7 @@ export declare class UpdateChecker extends EventEmitter<EventMap> {
|
|
|
32
32
|
private runningPromise;
|
|
33
33
|
private lastPatchedConfig;
|
|
34
34
|
private lastPatchedPublicTelemetryConfig;
|
|
35
|
-
constructor(updatesUrl: URL, nodeVersion: string | undefined, rollupVersion: bigint, fetch: typeof globalThis.fetch, getLatestRollupVersion: () => Promise<bigint>, checkIntervalMs?: number, // every
|
|
35
|
+
constructor(updatesUrl: URL, nodeVersion: string | undefined, rollupVersion: bigint, fetch: typeof globalThis.fetch, getLatestRollupVersion: () => Promise<bigint>, checkIntervalMs?: number, // every 10 mins
|
|
36
36
|
log?: import("@aztec/foundation/log").Logger);
|
|
37
37
|
static new(config: Config): Promise<UpdateChecker>;
|
|
38
38
|
start(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-checker.d.ts","sourceRoot":"","sources":["../../src/update-checker/update-checker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAK3D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAYtC,MAAM,MAAM,QAAQ,GAAG;IACrB,gBAAgB,EAAE,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,cAAc,EAAE,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpE,gBAAgB,EAAE,CAAC,MAAM,CAAC,CAAC;IAC3B,2BAA2B,EAAE,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uBAAuB,EAAE,UAAU,CAAC;IACpC,YAAY,EAAE,UAAU,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB,CAAC;AAEF,qBAAa,aAAc,SAAQ,YAAY,CAAC,QAAQ,CAAC;IAMrD,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,eAAe;IACvB,OAAO,C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IACnB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,sBAAsB;IAC9B,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,GAAG;IAXb,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,iBAAiB,CAAc;IACvC,OAAO,CAAC,gCAAgC,CAAc;gBAG5C,UAAU,EAAE,GAAG,EACf,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,EAC9B,sBAAsB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAC7C,eAAe,SAAc,EAAE,gBAAgB;IAC/C,GAAG,yCAA0C;WAMnC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAcxD,KAAK,IAAI,IAAI;IAab,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,OAAO,CAAC,SAAS,CAEf;YAEY,kBAAkB;YAelB,WAAW;CAsC1B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAWtD"}
|
|
@@ -23,7 +23,7 @@ export class UpdateChecker extends EventEmitter {
|
|
|
23
23
|
runningPromise;
|
|
24
24
|
lastPatchedConfig;
|
|
25
25
|
lastPatchedPublicTelemetryConfig;
|
|
26
|
-
constructor(updatesUrl, nodeVersion, rollupVersion, fetch1, getLatestRollupVersion, checkIntervalMs = 60_000, log = createLogger('foundation:update-check')){
|
|
26
|
+
constructor(updatesUrl, nodeVersion, rollupVersion, fetch1, getLatestRollupVersion, checkIntervalMs = 10 * 60_000, log = createLogger('foundation:update-check')){
|
|
27
27
|
super(), this.updatesUrl = updatesUrl, this.nodeVersion = nodeVersion, this.rollupVersion = rollupVersion, this.fetch = fetch1, this.getLatestRollupVersion = getLatestRollupVersion, this.checkIntervalMs = checkIntervalMs, this.log = log, this.lastPatchedConfig = {}, this.lastPatchedPublicTelemetryConfig = {}, this.runChecks = async ()=>{
|
|
28
28
|
await Promise.all([
|
|
29
29
|
this.checkRollupVersion(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20250911",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@aztec/bb.js": "3.0.0-nightly.
|
|
73
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
74
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
75
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
76
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
77
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
78
|
-
"@aztec/noir-noirc_abi": "3.0.0-nightly.
|
|
72
|
+
"@aztec/bb.js": "3.0.0-nightly.20250911",
|
|
73
|
+
"@aztec/blob-lib": "3.0.0-nightly.20250911",
|
|
74
|
+
"@aztec/constants": "3.0.0-nightly.20250911",
|
|
75
|
+
"@aztec/ethereum": "3.0.0-nightly.20250911",
|
|
76
|
+
"@aztec/foundation": "3.0.0-nightly.20250911",
|
|
77
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20250911",
|
|
78
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20250911",
|
|
79
79
|
"@google-cloud/storage": "^7.15.0",
|
|
80
80
|
"axios": "^1.9.0",
|
|
81
81
|
"json-stringify-deterministic": "1.0.12",
|
package/src/block/index.ts
CHANGED
package/src/block/l2_block.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
|
8
8
|
import { BlockHeader } from '../tx/block_header.js';
|
|
9
9
|
import { Body } from './body.js';
|
|
10
10
|
import { makeAppendOnlyTreeSnapshot, makeHeader } from './l2_block_code_to_purge.js';
|
|
11
|
+
import type { L2BlockInfo } from './l2_block_info.js';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* The data that makes up the rollup proof, with encoder decoder functions.
|
|
@@ -156,13 +157,15 @@ export class L2Block {
|
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
toBlockInfo():
|
|
160
|
+
toBlockInfo(): L2BlockInfo {
|
|
160
161
|
return {
|
|
161
|
-
blockHash: this.blockHash
|
|
162
|
-
archive: this.archive.root
|
|
162
|
+
blockHash: this.blockHash,
|
|
163
|
+
archive: this.archive.root,
|
|
164
|
+
lastArchive: this.header.lastArchive.root,
|
|
163
165
|
blockNumber: this.number,
|
|
164
166
|
slotNumber: Number(this.header.getSlot()),
|
|
165
167
|
txCount: this.body.txEffects.length,
|
|
168
|
+
timestamp: this.header.globalVariables.timestamp,
|
|
166
169
|
};
|
|
167
170
|
}
|
|
168
171
|
|
|
@@ -170,11 +173,3 @@ export class L2Block {
|
|
|
170
173
|
return this.archive.equals(other.archive) && this.header.equals(other.header) && this.body.equals(other.body);
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
|
-
|
|
174
|
-
export type BlockInfo = {
|
|
175
|
-
blockHash?: string;
|
|
176
|
-
archive: string;
|
|
177
|
-
blockNumber: number;
|
|
178
|
-
slotNumber: number;
|
|
179
|
-
txCount: number;
|
|
180
|
-
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
|
+
import { schemas } from '@aztec/foundation/schemas';
|
|
3
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
export type L2BlockInfo = {
|
|
8
|
+
blockHash?: Fr;
|
|
9
|
+
archive: Fr;
|
|
10
|
+
lastArchive: Fr;
|
|
11
|
+
blockNumber: number;
|
|
12
|
+
slotNumber: number;
|
|
13
|
+
txCount: number;
|
|
14
|
+
timestamp: bigint;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function randomBlockInfo(blockNumber?: number): L2BlockInfo {
|
|
18
|
+
return {
|
|
19
|
+
blockHash: Fr.random(),
|
|
20
|
+
archive: Fr.random(),
|
|
21
|
+
lastArchive: Fr.random(),
|
|
22
|
+
blockNumber: blockNumber ?? Math.floor(Math.random() * 100000) + 1,
|
|
23
|
+
slotNumber: Math.floor(Math.random() * 100000) + 1,
|
|
24
|
+
txCount: Math.floor(Math.random() * 100),
|
|
25
|
+
timestamp: BigInt(Math.floor(Date.now() / 1000)),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const BlockInfoSchema = z.object({
|
|
30
|
+
blockHash: schemas.Fr.optional(),
|
|
31
|
+
archive: schemas.Fr,
|
|
32
|
+
lastArchive: schemas.Fr,
|
|
33
|
+
blockNumber: z.number(),
|
|
34
|
+
slotNumber: z.number(),
|
|
35
|
+
txCount: z.number(),
|
|
36
|
+
timestamp: schemas.BigInt,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export function serializeBlockInfo(blockInfo: L2BlockInfo): Buffer {
|
|
40
|
+
return serializeToBuffer(
|
|
41
|
+
blockInfo.blockHash ?? Fr.ZERO,
|
|
42
|
+
blockInfo.archive,
|
|
43
|
+
blockInfo.lastArchive,
|
|
44
|
+
blockInfo.blockNumber,
|
|
45
|
+
blockInfo.slotNumber,
|
|
46
|
+
blockInfo.txCount,
|
|
47
|
+
blockInfo.timestamp,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function deserializeBlockInfo(buffer: Buffer | BufferReader): L2BlockInfo {
|
|
52
|
+
const reader = BufferReader.asReader(buffer);
|
|
53
|
+
const blockHash = reader.readObject(Fr);
|
|
54
|
+
return {
|
|
55
|
+
blockHash: blockHash.equals(Fr.ZERO) ? undefined : blockHash,
|
|
56
|
+
archive: reader.readObject(Fr),
|
|
57
|
+
lastArchive: reader.readObject(Fr),
|
|
58
|
+
blockNumber: reader.readNumber(),
|
|
59
|
+
slotNumber: reader.readNumber(),
|
|
60
|
+
txCount: reader.readNumber(),
|
|
61
|
+
timestamp: reader.readBigInt(),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { type ZodFor, schemas } from '@aztec/foundation/schemas';
|
|
3
2
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
4
3
|
|
|
5
4
|
import { z } from 'zod';
|
|
6
5
|
|
|
7
6
|
import type { L1RollupConstants } from '../epoch-helpers/index.js';
|
|
8
|
-
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
9
7
|
import type { BlockHeader } from '../tx/block_header.js';
|
|
10
8
|
import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
|
|
11
9
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
12
10
|
import type { TxReceipt } from '../tx/tx_receipt.js';
|
|
13
11
|
import type { L2Block } from './l2_block.js';
|
|
14
12
|
import { PublishedL2Block } from './published_l2_block.js';
|
|
13
|
+
import type { ValidateBlockNegativeResult, ValidateBlockResult } from './validate_block_result.js';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Interface of classes allowing for the retrieval of L2 blocks.
|
|
@@ -140,59 +139,10 @@ export interface L2BlockSource {
|
|
|
140
139
|
syncImmediate(): Promise<void>;
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
/** Subtype for invalid block validation results */
|
|
144
|
-
export type ValidateBlockNegativeResult =
|
|
145
|
-
| {
|
|
146
|
-
valid: false;
|
|
147
|
-
block: PublishedL2Block;
|
|
148
|
-
committee: EthAddress[];
|
|
149
|
-
epoch: bigint;
|
|
150
|
-
seed: bigint;
|
|
151
|
-
attestations: BlockAttestation[];
|
|
152
|
-
reason: 'insufficient-attestations';
|
|
153
|
-
}
|
|
154
|
-
| {
|
|
155
|
-
valid: false;
|
|
156
|
-
block: PublishedL2Block;
|
|
157
|
-
committee: EthAddress[];
|
|
158
|
-
epoch: bigint;
|
|
159
|
-
seed: bigint;
|
|
160
|
-
reason: 'invalid-attestation';
|
|
161
|
-
attestations: BlockAttestation[];
|
|
162
|
-
invalidIndex: number;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
/** Result type for validating a block attestations */
|
|
166
|
-
export type ValidateBlockResult = { valid: true } | ValidateBlockNegativeResult;
|
|
167
|
-
|
|
168
|
-
export const ValidateBlockResultSchema = z.union([
|
|
169
|
-
z.object({ valid: z.literal(true), block: PublishedL2Block.schema.optional() }),
|
|
170
|
-
z.object({
|
|
171
|
-
valid: z.literal(false),
|
|
172
|
-
block: PublishedL2Block.schema,
|
|
173
|
-
committee: z.array(schemas.EthAddress),
|
|
174
|
-
epoch: schemas.BigInt,
|
|
175
|
-
seed: schemas.BigInt,
|
|
176
|
-
attestations: z.array(BlockAttestation.schema),
|
|
177
|
-
reason: z.literal('insufficient-attestations'),
|
|
178
|
-
}),
|
|
179
|
-
z.object({
|
|
180
|
-
valid: z.literal(false),
|
|
181
|
-
block: PublishedL2Block.schema,
|
|
182
|
-
committee: z.array(schemas.EthAddress),
|
|
183
|
-
epoch: schemas.BigInt,
|
|
184
|
-
seed: schemas.BigInt,
|
|
185
|
-
attestations: z.array(BlockAttestation.schema),
|
|
186
|
-
reason: z.literal('invalid-attestation'),
|
|
187
|
-
invalidIndex: z.number(),
|
|
188
|
-
}),
|
|
189
|
-
]) satisfies ZodFor<ValidateBlockResult>;
|
|
190
|
-
|
|
191
142
|
/**
|
|
192
143
|
* L2BlockSource that emits events upon pending / proven chain changes.
|
|
193
144
|
* see L2BlockSourceEvents for the events emitted.
|
|
194
145
|
*/
|
|
195
|
-
|
|
196
146
|
export type ArchiverEmitter = TypedEventEmitter<{
|
|
197
147
|
[L2BlockSourceEvents.L2PruneDetected]: (args: L2BlockPruneEvent) => void;
|
|
198
148
|
[L2BlockSourceEvents.L2BlockProven]: (args: L2BlockProvenEvent) => void;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
3
|
import { randomBigInt } from '@aztec/foundation/crypto';
|
|
4
4
|
import { schemas } from '@aztec/foundation/schemas';
|
|
5
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
5
7
|
|
|
6
8
|
import { z } from 'zod';
|
|
7
9
|
|
|
@@ -32,6 +34,10 @@ export class L1PublishedData {
|
|
|
32
34
|
Buffer32.random().toString(),
|
|
33
35
|
);
|
|
34
36
|
}
|
|
37
|
+
|
|
38
|
+
static fromFields(fields: FieldsOf<L1PublishedData>) {
|
|
39
|
+
return new L1PublishedData(fields.blockNumber, fields.timestamp, fields.blockHash);
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
export class PublishedL2Block {
|
|
@@ -42,11 +48,38 @@ export class PublishedL2Block {
|
|
|
42
48
|
) {}
|
|
43
49
|
|
|
44
50
|
static get schema() {
|
|
45
|
-
return z
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
return z
|
|
52
|
+
.object({
|
|
53
|
+
block: L2Block.schema,
|
|
54
|
+
l1: L1PublishedData.schema,
|
|
55
|
+
attestations: z.array(CommitteeAttestation.schema),
|
|
56
|
+
})
|
|
57
|
+
.transform(obj => PublishedL2Block.fromFields(obj));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static fromBuffer(bufferOrReader: Buffer | BufferReader): PublishedL2Block {
|
|
61
|
+
const reader = BufferReader.asReader(bufferOrReader);
|
|
62
|
+
const block = reader.readObject(L2Block);
|
|
63
|
+
const l1BlockNumber = reader.readBigInt();
|
|
64
|
+
const l1BlockHash = reader.readString();
|
|
65
|
+
const l1Timestamp = reader.readBigInt();
|
|
66
|
+
const attestations = reader.readVector(CommitteeAttestation);
|
|
67
|
+
return new PublishedL2Block(block, new L1PublishedData(l1BlockNumber, l1Timestamp, l1BlockHash), attestations);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static fromFields(fields: FieldsOf<PublishedL2Block>) {
|
|
71
|
+
return new PublishedL2Block(fields.block, fields.l1, fields.attestations);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public toBuffer(): Buffer {
|
|
75
|
+
return serializeToBuffer(
|
|
76
|
+
this.block,
|
|
77
|
+
this.l1.blockNumber,
|
|
78
|
+
this.l1.blockHash,
|
|
79
|
+
this.l1.timestamp,
|
|
80
|
+
this.attestations.length,
|
|
81
|
+
this.attestations,
|
|
82
|
+
);
|
|
50
83
|
}
|
|
51
84
|
}
|
|
52
85
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { times } from '@aztec/foundation/collection';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import type
|
|
3
|
+
import { type L2Block, type L2BlockId, PublishedL2Block } from '@aztec/stdlib/block';
|
|
4
4
|
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
5
5
|
|
|
6
6
|
import { jestExpect as expect } from '@jest/expect';
|
|
@@ -14,11 +14,12 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
|
|
|
14
14
|
tipsStore = await makeTipsStore();
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
const makeBlock = (number: number): PublishedL2Block =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const makeBlock = (number: number): PublishedL2Block =>
|
|
18
|
+
PublishedL2Block.fromFields({
|
|
19
|
+
block: { number, header: { hash: () => Promise.resolve(new Fr(number)) } as BlockHeader } as L2Block,
|
|
20
|
+
l1: { blockNumber: BigInt(number), blockHash: `0x${number}`, timestamp: BigInt(number) },
|
|
21
|
+
attestations: [],
|
|
22
|
+
});
|
|
22
23
|
|
|
23
24
|
const makeBlockId = (number: number): L2BlockId => ({
|
|
24
25
|
number,
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { type ZodFor, schemas } from '@aztec/foundation/schemas';
|
|
3
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
import { BlockInfoSchema, type L2BlockInfo, deserializeBlockInfo, serializeBlockInfo } from './l2_block_info.js';
|
|
8
|
+
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
9
|
+
|
|
10
|
+
/** Subtype for invalid block validation results */
|
|
11
|
+
export type ValidateBlockNegativeResult =
|
|
12
|
+
| {
|
|
13
|
+
valid: false;
|
|
14
|
+
/** Identifiers from the invalid block */
|
|
15
|
+
block: L2BlockInfo;
|
|
16
|
+
/** Committee members at the epoch this block was proposed */
|
|
17
|
+
committee: EthAddress[];
|
|
18
|
+
/** Epoch in which this block was proposed */
|
|
19
|
+
epoch: bigint;
|
|
20
|
+
/** Proposer selection seed for the epoch */
|
|
21
|
+
seed: bigint;
|
|
22
|
+
/** List of committee members who signed this block proposal */
|
|
23
|
+
attestors: EthAddress[];
|
|
24
|
+
/** Committee attestations for this block as they were posted to L1 */
|
|
25
|
+
attestations: CommitteeAttestation[];
|
|
26
|
+
/** Reason for the block being invalid: not enough attestations were posted */
|
|
27
|
+
reason: 'insufficient-attestations';
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
valid: false;
|
|
31
|
+
/** Identifiers from the invalid block */
|
|
32
|
+
block: L2BlockInfo;
|
|
33
|
+
/** Committee members at the epoch this block was proposed */
|
|
34
|
+
committee: EthAddress[];
|
|
35
|
+
/** Epoch in which this block was proposed */
|
|
36
|
+
epoch: bigint;
|
|
37
|
+
/** Proposer selection seed for the epoch */
|
|
38
|
+
seed: bigint;
|
|
39
|
+
/** List of committee members who signed this block proposal */
|
|
40
|
+
attestors: EthAddress[];
|
|
41
|
+
/** Committee attestations for this block as they were posted to L1 */
|
|
42
|
+
attestations: CommitteeAttestation[];
|
|
43
|
+
/** Reason for the block being invalid: an invalid attestation was posted */
|
|
44
|
+
reason: 'invalid-attestation';
|
|
45
|
+
/** Index in the attestations array of the invalid attestation posted */
|
|
46
|
+
invalidIndex: number;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** Result type for validating a block attestations */
|
|
50
|
+
export type ValidateBlockResult = { valid: true } | ValidateBlockNegativeResult;
|
|
51
|
+
|
|
52
|
+
export const ValidateBlockResultSchema = z.union([
|
|
53
|
+
z.object({ valid: z.literal(true) }),
|
|
54
|
+
z.object({
|
|
55
|
+
valid: z.literal(false),
|
|
56
|
+
block: BlockInfoSchema,
|
|
57
|
+
committee: z.array(schemas.EthAddress),
|
|
58
|
+
epoch: schemas.BigInt,
|
|
59
|
+
seed: schemas.BigInt,
|
|
60
|
+
attestors: z.array(schemas.EthAddress),
|
|
61
|
+
attestations: z.array(CommitteeAttestation.schema),
|
|
62
|
+
reason: z.literal('insufficient-attestations'),
|
|
63
|
+
}),
|
|
64
|
+
z.object({
|
|
65
|
+
valid: z.literal(false),
|
|
66
|
+
block: BlockInfoSchema,
|
|
67
|
+
committee: z.array(schemas.EthAddress),
|
|
68
|
+
epoch: schemas.BigInt,
|
|
69
|
+
seed: schemas.BigInt,
|
|
70
|
+
attestors: z.array(schemas.EthAddress),
|
|
71
|
+
attestations: z.array(CommitteeAttestation.schema),
|
|
72
|
+
reason: z.literal('invalid-attestation'),
|
|
73
|
+
invalidIndex: z.number(),
|
|
74
|
+
}),
|
|
75
|
+
]) satisfies ZodFor<ValidateBlockResult>;
|
|
76
|
+
|
|
77
|
+
export function serializeValidateBlockResult(result: ValidateBlockResult): Buffer {
|
|
78
|
+
if (result.valid) {
|
|
79
|
+
return serializeToBuffer(true);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const l2Block = serializeBlockInfo(result.block);
|
|
83
|
+
return serializeToBuffer(
|
|
84
|
+
result.valid,
|
|
85
|
+
result.reason,
|
|
86
|
+
l2Block.length,
|
|
87
|
+
l2Block,
|
|
88
|
+
result.committee.length,
|
|
89
|
+
result.committee,
|
|
90
|
+
result.epoch,
|
|
91
|
+
result.seed ?? 0n,
|
|
92
|
+
result.attestors.length,
|
|
93
|
+
result.attestors,
|
|
94
|
+
result.attestations.length,
|
|
95
|
+
result.attestations,
|
|
96
|
+
result.reason === 'invalid-attestation' ? result.invalidIndex : 0,
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function deserializeValidateBlockResult(bufferOrReader: Buffer | BufferReader): ValidateBlockResult {
|
|
101
|
+
const reader = BufferReader.asReader(bufferOrReader);
|
|
102
|
+
const valid = reader.readBoolean();
|
|
103
|
+
if (valid) {
|
|
104
|
+
return { valid };
|
|
105
|
+
}
|
|
106
|
+
const reason = reader.readString() as 'insufficient-attestations' | 'invalid-attestation';
|
|
107
|
+
const block = deserializeBlockInfo(reader.readBuffer());
|
|
108
|
+
const committee = reader.readVector(EthAddress);
|
|
109
|
+
const epoch = reader.readBigInt();
|
|
110
|
+
const seed = reader.readBigInt();
|
|
111
|
+
const attestors = reader.readVector(EthAddress);
|
|
112
|
+
const attestations = reader.readVector(CommitteeAttestation);
|
|
113
|
+
const invalidIndex = reader.readNumber();
|
|
114
|
+
if (reason === 'insufficient-attestations') {
|
|
115
|
+
return { valid, reason, block, committee, epoch, seed, attestors, attestations: attestations };
|
|
116
|
+
} else if (reason === 'invalid-attestation') {
|
|
117
|
+
return { valid, reason, block, committee, epoch, seed, attestors, invalidIndex, attestations: attestations };
|
|
118
|
+
} else {
|
|
119
|
+
const _: never = reason;
|
|
120
|
+
throw new Error(`Unknown reason: ${reason}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -3,8 +3,9 @@ import type { ApiSchemaFor } from '@aztec/foundation/schemas';
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
import { L2Block } from '../block/l2_block.js';
|
|
6
|
-
import { type L2BlockSource, L2TipsSchema
|
|
6
|
+
import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
|
|
7
7
|
import { PublishedL2Block } from '../block/published_l2_block.js';
|
|
8
|
+
import { ValidateBlockResultSchema } from '../block/validate_block_result.js';
|
|
8
9
|
import {
|
|
9
10
|
ContractClassPublicSchema,
|
|
10
11
|
type ContractDataSource,
|
|
@@ -98,6 +98,10 @@ export class BlockAttestation extends Gossipable {
|
|
|
98
98
|
return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty());
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
static random(): BlockAttestation {
|
|
102
|
+
return new BlockAttestation(Math.floor(Math.random() * 1000) + 1, ConsensusPayload.random(), Signature.random());
|
|
103
|
+
}
|
|
104
|
+
|
|
101
105
|
getSize(): number {
|
|
102
106
|
return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize();
|
|
103
107
|
}
|
|
@@ -5,7 +5,7 @@ import { Signature } from '@aztec/foundation/eth-signature';
|
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
9
9
|
import { TxHash } from '../tx/index.js';
|
|
10
10
|
import { Tx } from '../tx/tx.js';
|
|
11
11
|
import type { UInt32 } from '../types/index.js';
|
|
@@ -71,11 +71,13 @@ export class BlockProposal extends Gossipable {
|
|
|
71
71
|
return this.payload.header.slotNumber;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
toBlockInfo():
|
|
74
|
+
toBlockInfo(): L2BlockInfo {
|
|
75
75
|
return {
|
|
76
76
|
blockNumber: this.blockNumber,
|
|
77
77
|
slotNumber: this.slotNumber.toNumber(),
|
|
78
|
-
|
|
78
|
+
lastArchive: this.payload.header.lastArchiveRoot,
|
|
79
|
+
timestamp: this.payload.header.timestamp,
|
|
80
|
+
archive: this.archive,
|
|
79
81
|
txCount: this.txHashes.length,
|
|
80
82
|
};
|
|
81
83
|
}
|
|
@@ -60,18 +60,17 @@ export class ConsensusPayload implements Signable {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
toBuffer(): Buffer {
|
|
63
|
-
|
|
64
|
-
this.size = buffer.length;
|
|
65
|
-
return buffer;
|
|
63
|
+
return serializeToBuffer([this.header, this.archive, this.stateReference]);
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
static fromBuffer(buf: Buffer | BufferReader): ConsensusPayload {
|
|
69
67
|
const reader = BufferReader.asReader(buf);
|
|
70
|
-
|
|
68
|
+
const payload = new ConsensusPayload(
|
|
71
69
|
reader.readObject(ProposedBlockHeader),
|
|
72
70
|
reader.readObject(Fr),
|
|
73
71
|
reader.readObject(StateReference),
|
|
74
72
|
);
|
|
73
|
+
return payload;
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
static fromFields(fields: FieldsOf<ConsensusPayload>): ConsensusPayload {
|
|
@@ -86,6 +85,10 @@ export class ConsensusPayload implements Signable {
|
|
|
86
85
|
return new ConsensusPayload(ProposedBlockHeader.empty(), Fr.ZERO, StateReference.empty());
|
|
87
86
|
}
|
|
88
87
|
|
|
88
|
+
static random(): ConsensusPayload {
|
|
89
|
+
return new ConsensusPayload(ProposedBlockHeader.random(), Fr.random(), StateReference.random());
|
|
90
|
+
}
|
|
91
|
+
|
|
89
92
|
/**
|
|
90
93
|
* Get the size of the consensus payload in bytes.
|
|
91
94
|
* @returns The size of the consensus payload.
|