@aztec/stdlib 2.0.0-rc.8 → 2.0.2-rc.2
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 +43 -0
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +10 -1
- package/dest/interfaces/aztec-node-admin.d.ts +17 -3
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +6 -1
- package/dest/interfaces/aztec-node.d.ts +5 -2
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +1 -0
- package/dest/interfaces/block-builder.d.ts +5 -6
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/pxe.d.ts +8 -1
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +1 -0
- package/dest/messaging/inbox_leaf.d.ts +2 -0
- package/dest/messaging/inbox_leaf.d.ts.map +1 -1
- package/dest/messaging/inbox_leaf.js +3 -0
- 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/dest/zkpassport/index.d.ts +3 -3
- package/dest/zkpassport/index.d.ts.map +1 -1
- package/dest/zkpassport/index.js +7 -7
- 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 +38 -1
- package/src/interfaces/aztec-node-admin.ts +12 -1
- package/src/interfaces/aztec-node.ts +8 -2
- package/src/interfaces/block-builder.ts +9 -6
- package/src/interfaces/pxe.ts +10 -1
- package/src/messaging/inbox_leaf.ts +5 -0
- 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
- package/src/zkpassport/index.ts +6 -6
|
@@ -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.
|
package/src/tests/mocks.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
6
6
|
|
|
7
7
|
import type { ContractArtifact } from '../abi/abi.js';
|
|
8
8
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
9
|
-
import { CommitteeAttestation } from '../block/index.js';
|
|
9
|
+
import { CommitteeAttestation, L1PublishedData } from '../block/index.js';
|
|
10
10
|
import { L2Block } from '../block/l2_block.js';
|
|
11
|
-
import
|
|
11
|
+
import { PublishedL2Block } from '../block/published_l2_block.js';
|
|
12
12
|
import { computeContractAddressFromInstance } from '../contract/contract_address.js';
|
|
13
13
|
import { getContractClassFromArtifact } from '../contract/contract_class.js';
|
|
14
14
|
import { SerializableContractInstance } from '../contract/contract_instance.js';
|
|
@@ -306,16 +306,16 @@ export async function randomPublishedL2Block(
|
|
|
306
306
|
opts: { signers?: Secp256k1Signer[] } = {},
|
|
307
307
|
): Promise<PublishedL2Block> {
|
|
308
308
|
const block = await L2Block.random(l2BlockNumber);
|
|
309
|
-
const l1 = {
|
|
309
|
+
const l1 = L1PublishedData.fromFields({
|
|
310
310
|
blockNumber: BigInt(block.number),
|
|
311
311
|
timestamp: block.header.globalVariables.timestamp,
|
|
312
312
|
blockHash: Buffer32.random().toString(),
|
|
313
|
-
};
|
|
313
|
+
});
|
|
314
314
|
|
|
315
315
|
const signers = opts.signers ?? times(3, () => Secp256k1Signer.random());
|
|
316
316
|
const atts = await Promise.all(signers.map(signer => makeBlockAttestationFromBlock(block, signer)));
|
|
317
317
|
const attestations = atts.map(
|
|
318
318
|
(attestation, i) => new CommitteeAttestation(signers[i].address, attestation.signature),
|
|
319
319
|
);
|
|
320
|
-
return
|
|
320
|
+
return new PublishedL2Block(block, l1, attestations);
|
|
321
321
|
}
|
|
@@ -75,6 +75,10 @@ export class ContentCommitment {
|
|
|
75
75
|
return new ContentCommitment(reader.readField(), reader.readField(), reader.readField());
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
static random(): ContentCommitment {
|
|
79
|
+
return new ContentCommitment(Fr.random(), Fr.random(), Fr.random());
|
|
80
|
+
}
|
|
81
|
+
|
|
78
82
|
static empty(): ContentCommitment {
|
|
79
83
|
return new ContentCommitment(Fr.zero(), Fr.zero(), Fr.zero());
|
|
80
84
|
}
|
|
@@ -64,6 +64,14 @@ export class PartialStateReference {
|
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
static random(): PartialStateReference {
|
|
68
|
+
return new PartialStateReference(
|
|
69
|
+
AppendOnlyTreeSnapshot.random(),
|
|
70
|
+
AppendOnlyTreeSnapshot.random(),
|
|
71
|
+
AppendOnlyTreeSnapshot.random(),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
67
75
|
toViem(): ViemPartialStateReference {
|
|
68
76
|
return {
|
|
69
77
|
noteHashTree: this.noteHashTree.toViem(),
|
|
@@ -116,6 +116,19 @@ export class ProposedBlockHeader {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
static random(): ProposedBlockHeader {
|
|
120
|
+
return new ProposedBlockHeader(
|
|
121
|
+
Fr.random(),
|
|
122
|
+
ContentCommitment.random(),
|
|
123
|
+
new Fr(BigInt(Math.floor(Math.random() * 1000) + 1)),
|
|
124
|
+
BigInt(Math.floor(Date.now() / 1000)),
|
|
125
|
+
EthAddress.random(),
|
|
126
|
+
new AztecAddress(Fr.random()),
|
|
127
|
+
GasFees.random(),
|
|
128
|
+
new Fr(BigInt(Math.floor(Math.random() * 1000000))),
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
119
132
|
isEmpty(): boolean {
|
|
120
133
|
return (
|
|
121
134
|
this.lastArchiveRoot.isZero() &&
|
|
@@ -78,6 +78,10 @@ export class StateReference {
|
|
|
78
78
|
return new StateReference(AppendOnlyTreeSnapshot.empty(), PartialStateReference.empty());
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
static random(): StateReference {
|
|
82
|
+
return new StateReference(AppendOnlyTreeSnapshot.random(), PartialStateReference.random());
|
|
83
|
+
}
|
|
84
|
+
|
|
81
85
|
toViem(): ViemStateReference {
|
|
82
86
|
return {
|
|
83
87
|
l1ToL2MessageTree: this.l1ToL2MessageTree.toViem(),
|
|
@@ -43,7 +43,7 @@ export class UpdateChecker extends EventEmitter<EventMap> {
|
|
|
43
43
|
private rollupVersion: bigint,
|
|
44
44
|
private fetch: typeof globalThis.fetch,
|
|
45
45
|
private getLatestRollupVersion: () => Promise<bigint>,
|
|
46
|
-
private checkIntervalMs = 60_000, // every
|
|
46
|
+
private checkIntervalMs = 10 * 60_000, // every 10 mins
|
|
47
47
|
private log = createLogger('foundation:update-check'),
|
|
48
48
|
) {
|
|
49
49
|
super();
|
package/src/zkpassport/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type ViemZkPassportProofParams = {
|
|
|
10
10
|
publicInputs: `0x${string}`[];
|
|
11
11
|
committedInputs: `0x${string}`;
|
|
12
12
|
committedInputCounts: bigint[];
|
|
13
|
-
|
|
13
|
+
validityPeriodInSeconds: bigint;
|
|
14
14
|
domain: string;
|
|
15
15
|
scope: string;
|
|
16
16
|
devMode: boolean;
|
|
@@ -26,7 +26,7 @@ export class ZkPassportProofParams {
|
|
|
26
26
|
public publicInputs: Fr[],
|
|
27
27
|
public committedInputs: Buffer,
|
|
28
28
|
public committedInputCounts: bigint[],
|
|
29
|
-
public
|
|
29
|
+
public validityPeriodInSeconds: bigint,
|
|
30
30
|
public domain: string,
|
|
31
31
|
public scope: string,
|
|
32
32
|
) {}
|
|
@@ -43,7 +43,7 @@ export class ZkPassportProofParams {
|
|
|
43
43
|
this.committedInputs,
|
|
44
44
|
this.committedInputCounts.length,
|
|
45
45
|
this.committedInputCounts,
|
|
46
|
-
this.
|
|
46
|
+
this.validityPeriodInSeconds,
|
|
47
47
|
this.domain,
|
|
48
48
|
this.scope,
|
|
49
49
|
]);
|
|
@@ -64,7 +64,7 @@ export class ZkPassportProofParams {
|
|
|
64
64
|
publicInputs,
|
|
65
65
|
committedInputs,
|
|
66
66
|
committedInputCounts,
|
|
67
|
-
BigInt(100),
|
|
67
|
+
BigInt(100 * 60 * 60 * 24),
|
|
68
68
|
'sequencer.alpha-testnet.aztec.network',
|
|
69
69
|
'personhood',
|
|
70
70
|
);
|
|
@@ -93,7 +93,7 @@ export class ZkPassportProofParams {
|
|
|
93
93
|
params.publicInputs.map(input => Fr.fromString(input)),
|
|
94
94
|
Buffer.from(withoutHexPrefix(params.committedInputs), 'hex'),
|
|
95
95
|
params.committedInputCounts,
|
|
96
|
-
params.
|
|
96
|
+
params.validityPeriodInSeconds,
|
|
97
97
|
params.domain,
|
|
98
98
|
params.scope,
|
|
99
99
|
);
|
|
@@ -107,7 +107,7 @@ export class ZkPassportProofParams {
|
|
|
107
107
|
publicInputs: this.publicInputs.map(input => input.toString()),
|
|
108
108
|
committedInputs: `0x${this.committedInputs.toString('hex')}`,
|
|
109
109
|
committedInputCounts: this.committedInputCounts,
|
|
110
|
-
|
|
110
|
+
validityPeriodInSeconds: this.validityPeriodInSeconds,
|
|
111
111
|
domain: this.domain,
|
|
112
112
|
scope: this.scope,
|
|
113
113
|
};
|