@aztec/stdlib 2.1.0-rc.1 → 2.1.0-rc.11
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/attestation_info.d.ts +30 -0
- package/dest/block/attestation_info.d.ts.map +1 -0
- package/dest/block/attestation_info.js +39 -0
- 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/proposal/attestations_and_signers.js +1 -1
- package/dest/block/published_l2_block.d.ts +0 -2
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +0 -6
- package/dest/epoch-helpers/index.d.ts +2 -0
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +3 -0
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +18 -0
- package/dest/file-store/interface.d.ts +8 -2
- package/dest/file-store/interface.d.ts.map +1 -1
- package/dest/file-store/s3.d.ts +26 -0
- package/dest/file-store/s3.d.ts.map +1 -0
- package/dest/file-store/s3.js +252 -0
- package/dest/interfaces/aztec-node-admin.d.ts +3 -0
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +5 -0
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/p2p.d.ts +2 -0
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +2 -1
- package/dest/l1-contracts/slash_factory.d.ts +1 -1
- package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
- package/dest/l1-contracts/slash_factory.js +1 -1
- package/dest/p2p/block_attestation.d.ts +47 -1
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +43 -9
- package/dest/p2p/consensus_payload.js +1 -1
- package/dest/p2p/gossipable.d.ts +2 -4
- package/dest/p2p/gossipable.d.ts.map +1 -1
- package/dest/p2p/gossipable.js +5 -14
- package/dest/snapshots/download.d.ts.map +1 -1
- package/dest/snapshots/download.js +58 -2
- package/dest/snapshots/upload.d.ts.map +1 -1
- package/dest/snapshots/upload.js +1 -0
- package/dest/tests/mocks.d.ts +3 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +31 -9
- package/package.json +10 -9
- package/src/block/attestation_info.ts +62 -0
- package/src/block/index.ts +1 -0
- package/src/block/proposal/attestations_and_signers.ts +1 -1
- package/src/block/published_l2_block.ts +0 -11
- package/src/epoch-helpers/index.ts +8 -0
- package/src/file-store/factory.ts +15 -0
- package/src/file-store/interface.ts +8 -2
- package/src/file-store/s3.ts +254 -0
- package/src/interfaces/configs.ts +3 -0
- package/src/interfaces/p2p.ts +4 -0
- package/src/l1-contracts/slash_factory.ts +1 -1
- package/src/p2p/block_attestation.ts +57 -6
- package/src/p2p/consensus_payload.ts +1 -1
- package/src/p2p/gossipable.ts +6 -16
- package/src/snapshots/download.ts +66 -2
- package/src/snapshots/upload.ts +1 -0
- package/src/tests/mocks.ts +51 -12
package/src/tests/mocks.ts
CHANGED
|
@@ -248,6 +248,8 @@ export const randomDeployedContract = async () => {
|
|
|
248
248
|
|
|
249
249
|
export interface MakeConsensusPayloadOptions {
|
|
250
250
|
signer?: Secp256k1Signer;
|
|
251
|
+
attesterSigner?: Secp256k1Signer;
|
|
252
|
+
proposerSigner?: Secp256k1Signer;
|
|
251
253
|
header?: BlockHeader;
|
|
252
254
|
archive?: Fr;
|
|
253
255
|
stateReference?: StateReference;
|
|
@@ -296,21 +298,58 @@ export const makeBlockProposal = (options?: MakeConsensusPayloadOptions): BlockP
|
|
|
296
298
|
|
|
297
299
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028)
|
|
298
300
|
export const makeBlockAttestation = (options?: MakeConsensusPayloadOptions): BlockAttestation => {
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
const header = options?.header ?? makeHeader(1);
|
|
302
|
+
const {
|
|
303
|
+
signer,
|
|
304
|
+
attesterSigner = signer ?? Secp256k1Signer.random(),
|
|
305
|
+
proposerSigner = signer ?? Secp256k1Signer.random(),
|
|
306
|
+
archive = Fr.random(),
|
|
307
|
+
stateReference = header.state,
|
|
308
|
+
} = options ?? {};
|
|
309
|
+
|
|
310
|
+
const payload = ConsensusPayload.fromFields({
|
|
311
|
+
header: header.toPropose(),
|
|
312
|
+
archive,
|
|
313
|
+
stateReference,
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Sign as attester
|
|
317
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
318
|
+
const attestationSignature = attesterSigner.sign(attestationHash);
|
|
319
|
+
|
|
320
|
+
// Sign as proposer
|
|
321
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
322
|
+
const proposerSignature = proposerSigner.sign(proposalHash);
|
|
323
|
+
|
|
324
|
+
return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
304
325
|
};
|
|
305
326
|
|
|
306
|
-
export const makeBlockAttestationFromBlock = (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
327
|
+
export const makeBlockAttestationFromBlock = (
|
|
328
|
+
block: L2Block,
|
|
329
|
+
attesterSigner?: Secp256k1Signer,
|
|
330
|
+
proposerSigner?: Secp256k1Signer,
|
|
331
|
+
): BlockAttestation => {
|
|
332
|
+
const header = block.header;
|
|
333
|
+
const archive = block.archive.root;
|
|
334
|
+
const stateReference = block.header.state;
|
|
335
|
+
|
|
336
|
+
const payload = ConsensusPayload.fromFields({
|
|
337
|
+
header: header.toPropose(),
|
|
338
|
+
archive,
|
|
339
|
+
stateReference,
|
|
313
340
|
});
|
|
341
|
+
|
|
342
|
+
// Sign as attester
|
|
343
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
344
|
+
const attestationSigner = attesterSigner ?? Secp256k1Signer.random();
|
|
345
|
+
const attestationSignature = attestationSigner.sign(attestationHash);
|
|
346
|
+
|
|
347
|
+
// Sign as proposer
|
|
348
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
349
|
+
const proposalSignerToUse = proposerSigner ?? Secp256k1Signer.random();
|
|
350
|
+
const proposerSignature = proposalSignerToUse.sign(proposalHash);
|
|
351
|
+
|
|
352
|
+
return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
314
353
|
};
|
|
315
354
|
|
|
316
355
|
export async function randomPublishedL2Block(
|