@aztec/stdlib 0.85.0-alpha-testnet.3 → 0.85.0-alpha-testnet.5
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/published_l2_block.d.ts +2 -1
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +5 -18
- package/dest/tests/mocks.d.ts +10 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +30 -2
- package/dest/tx/validator/error_texts.d.ts +3 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +3 -1
- package/package.json +7 -7
- package/src/block/published_l2_block.ts +6 -16
- package/src/tests/mocks.ts +43 -2
- package/src/tx/validator/error_texts.ts +3 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
2
2
|
import { L2Block } from '@aztec/stdlib/block';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
4
5
|
export type L1PublishedData = {
|
|
5
6
|
blockNumber: bigint;
|
|
6
7
|
timestamp: bigint;
|
|
@@ -85,5 +86,5 @@ export declare const PublishedL2BlockSchema: z.ZodObject<{
|
|
|
85
86
|
};
|
|
86
87
|
signatures: string[];
|
|
87
88
|
}>;
|
|
88
|
-
export declare function
|
|
89
|
+
export declare function getAttestationsFromPublishedL2Block(block: PublishedL2Block): BlockAttestation[];
|
|
89
90
|
//# sourceMappingURL=published_l2_block.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"published_l2_block.d.ts","sourceRoot":"","sources":["../../src/block/published_l2_block.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"published_l2_block.d.ts","sourceRoot":"","sources":["../../src/block/published_l2_block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,EAAE,EAAE,eAAe,CAAC;IACpB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQjC,CAAC;AAEH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,gBAAgB,sBAG1E"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { times } from '@aztec/foundation/collection';
|
|
3
|
-
import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
4
1
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
2
|
import { schemas } from '@aztec/foundation/schemas';
|
|
6
3
|
import { L2Block } from '@aztec/stdlib/block';
|
|
7
4
|
import { z } from 'zod';
|
|
5
|
+
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
6
|
+
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
8
7
|
export const PublishedL2BlockSchema = z.object({
|
|
9
8
|
block: L2Block.schema,
|
|
10
9
|
l1: z.object({
|
|
@@ -14,19 +13,7 @@ export const PublishedL2BlockSchema = z.object({
|
|
|
14
13
|
}),
|
|
15
14
|
signatures: z.array(Signature.schema)
|
|
16
15
|
});
|
|
17
|
-
export
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
blockNumber: BigInt(block.number),
|
|
21
|
-
timestamp: block.header.globalVariables.timestamp.toBigInt(),
|
|
22
|
-
blockHash: Buffer32.random().toString()
|
|
23
|
-
};
|
|
24
|
-
// Create valid signatures
|
|
25
|
-
const signers = times(3, ()=>Secp256k1Signer.random());
|
|
26
|
-
const signatures = await Promise.all(times(3, async (i)=>signers[i].signMessage(Buffer32.fromField(await block.hash()))));
|
|
27
|
-
return {
|
|
28
|
-
block,
|
|
29
|
-
l1,
|
|
30
|
-
signatures
|
|
31
|
-
};
|
|
16
|
+
export function getAttestationsFromPublishedL2Block(block) {
|
|
17
|
+
const payload = ConsensusPayload.fromBlock(block.block);
|
|
18
|
+
return block.signatures.filter((sig)=>!sig.isEmpty).map((signature)=>new BlockAttestation(payload, signature));
|
|
32
19
|
}
|
package/dest/tests/mocks.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import type { ContractArtifact } from '../abi/abi.js';
|
|
4
4
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
5
|
+
import type { PublishedL2Block } from '../block/published_l2_block.js';
|
|
5
6
|
import type { ContractInstanceWithAddress } from '../contract/index.js';
|
|
6
7
|
import { GasFees } from '../gas/gas_fees.js';
|
|
7
8
|
import { ExtendedNote, UniqueNote } from '../note/extended_note.js';
|
|
@@ -14,7 +15,7 @@ import { TxHash } from '../tx/tx_hash.js';
|
|
|
14
15
|
export declare const randomTxHash: () => TxHash;
|
|
15
16
|
export declare const randomExtendedNote: ({ note, recipient, contractAddress, txHash, storageSlot, }?: Partial<ExtendedNote>) => Promise<ExtendedNote>;
|
|
16
17
|
export declare const randomUniqueNote: ({ note, recipient, contractAddress, txHash, storageSlot, nonce, }?: Partial<UniqueNote>) => Promise<UniqueNote>;
|
|
17
|
-
export declare const mockTx: (seed?: number, { numberOfNonRevertiblePublicCallRequests, numberOfRevertiblePublicCallRequests, numberOfRevertibleNullifiers, hasPublicTeardownCallRequest, publicCalldataSize, feePayer, clientIvcProof, maxPriorityFeesPerGas, }?: {
|
|
18
|
+
export declare const mockTx: (seed?: number, { numberOfNonRevertiblePublicCallRequests, numberOfRevertiblePublicCallRequests, numberOfRevertibleNullifiers, hasPublicTeardownCallRequest, publicCalldataSize, feePayer, clientIvcProof, maxPriorityFeesPerGas, chainId, version, vkTreeRoot, protocolContractTreeRoot, }?: {
|
|
18
19
|
numberOfNonRevertiblePublicCallRequests?: number;
|
|
19
20
|
numberOfRevertiblePublicCallRequests?: number;
|
|
20
21
|
numberOfRevertibleNullifiers?: number;
|
|
@@ -23,8 +24,12 @@ export declare const mockTx: (seed?: number, { numberOfNonRevertiblePublicCallRe
|
|
|
23
24
|
feePayer?: AztecAddress;
|
|
24
25
|
clientIvcProof?: ClientIvcProof;
|
|
25
26
|
maxPriorityFeesPerGas?: GasFees;
|
|
27
|
+
chainId?: Fr;
|
|
28
|
+
version?: Fr;
|
|
29
|
+
vkTreeRoot?: Fr;
|
|
30
|
+
protocolContractTreeRoot?: Fr;
|
|
26
31
|
}) => Promise<Tx>;
|
|
27
|
-
export declare const mockTxForRollup: (seed?: number) => Promise<Tx>;
|
|
32
|
+
export declare const mockTxForRollup: (seed?: number, opts?: Parameters<typeof mockTx>[1]) => Promise<Tx>;
|
|
28
33
|
export declare const mockSimulatedTx: (seed?: number) => Promise<TxSimulationResult>;
|
|
29
34
|
export declare const randomContractArtifact: () => ContractArtifact;
|
|
30
35
|
export declare const randomContractInstanceWithAddress: (opts?: {
|
|
@@ -42,4 +47,7 @@ export interface MakeConsensusPayloadOptions {
|
|
|
42
47
|
}
|
|
43
48
|
export declare const makeBlockProposal: (options?: MakeConsensusPayloadOptions) => Promise<BlockProposal>;
|
|
44
49
|
export declare const makeBlockAttestation: (options?: MakeConsensusPayloadOptions) => Promise<BlockAttestation>;
|
|
50
|
+
export declare function randomPublishedL2Block(l2BlockNumber: number, opts?: {
|
|
51
|
+
signers?: Secp256k1Signer[];
|
|
52
|
+
}): Promise<PublishedL2Block>;
|
|
45
53
|
//# sourceMappingURL=mocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAe,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIvE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAoE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEnH,OAAO,EAAE,kBAAkB,EAAiC,MAAM,uBAAuB,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,eAAO,MAAM,YAAY,QAAO,MAAyB,CAAC;AAE1D,eAAO,MAAM,kBAAkB,gEAM5B,QAAQ,YAAY,CAAC,0BAQvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,uEAO1B,QAAQ,UAAU,CAAC,wBASrB,CAAC;AAEF,eAAO,MAAM,MAAM,gSAed;IACD,uCAAuC,CAAC,EAAE,MAAM,CAAC;IACjD,oCAAoC,CAAC,EAAE,MAAM,CAAC;IAC9C,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,EAAE,CAAC;IACb,OAAO,CAAC,EAAE,EAAE,CAAC;IACb,UAAU,CAAC,EAAE,EAAE,CAAC;IAChB,wBAAwB,CAAC,EAAE,EAAE,CAAC;CAC/B,gBAyDF,CAAC;AAEF,eAAO,MAAM,eAAe,yBAAoB,WAAW,aAAa,CAAC,CAAC,CAAC,CAAC,gBACoC,CAAC;AAkBjH,eAAO,MAAM,eAAe,gDAgB3B,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAO,gBAWxC,CAAC;AAEH,eAAO,MAAM,iCAAiC,UACtC;IAAE,eAAe,CAAC,EAAE,EAAE,CAAA;CAAE,YACpB,YAAY,KACrB,QAAQ,2BAA2B,CAUrC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;EAIlC,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,EAAE,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAyBD,eAAO,MAAM,iBAAiB,aAAoB,2BAA2B,KAAG,QAAQ,aAAa,CAGpG,CAAC;AAGF,eAAO,MAAM,oBAAoB,aAAoB,2BAA2B,KAAG,QAAQ,gBAAgB,CAG1G,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,eAAe,EAAE,CAAA;CAAO,GACzC,OAAO,CAAC,gBAAgB,CAAC,CAqB3B"}
|
package/dest/tests/mocks.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { MAX_ENQUEUED_CALLS_PER_TX } from '@aztec/constants';
|
|
2
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
3
4
|
import { Secp256k1Signer, randomBytes } from '@aztec/foundation/crypto';
|
|
4
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
6
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
7
|
+
import { L2Block } from '../block/l2_block.js';
|
|
6
8
|
import { computeContractAddressFromInstance } from '../contract/contract_address.js';
|
|
7
9
|
import { getContractClassFromArtifact } from '../contract/contract_class.js';
|
|
8
10
|
import { SerializableContractInstance } from '../contract/contract_instance.js';
|
|
@@ -32,7 +34,7 @@ export const randomExtendedNote = async ({ note = Note.random(), recipient = und
|
|
|
32
34
|
export const randomUniqueNote = async ({ note = Note.random(), recipient = undefined, contractAddress = undefined, txHash = randomTxHash(), storageSlot = Fr.random(), nonce = Fr.random() } = {})=>{
|
|
33
35
|
return new UniqueNote(note, recipient ?? await AztecAddress.random(), contractAddress ?? await AztecAddress.random(), storageSlot, txHash, nonce);
|
|
34
36
|
};
|
|
35
|
-
export const mockTx = async (seed = 1, { numberOfNonRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2, numberOfRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2, numberOfRevertibleNullifiers = 0, hasPublicTeardownCallRequest = false, publicCalldataSize = 2, feePayer, clientIvcProof = ClientIvcProof.empty(), maxPriorityFeesPerGas } = {})=>{
|
|
37
|
+
export const mockTx = async (seed = 1, { numberOfNonRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2, numberOfRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2, numberOfRevertibleNullifiers = 0, hasPublicTeardownCallRequest = false, publicCalldataSize = 2, feePayer, clientIvcProof = ClientIvcProof.empty(), maxPriorityFeesPerGas, chainId = Fr.ZERO, version = Fr.ZERO, vkTreeRoot = Fr.ZERO, protocolContractTreeRoot = Fr.ZERO } = {})=>{
|
|
36
38
|
const totalPublicCallRequests = numberOfNonRevertiblePublicCallRequests + numberOfRevertiblePublicCallRequests + (hasPublicTeardownCallRequest ? 1 : 0);
|
|
37
39
|
const isForPublic = totalPublicCallRequests > 0;
|
|
38
40
|
const data = PrivateKernelTailCircuitPublicInputs.empty();
|
|
@@ -42,6 +44,10 @@ export const mockTx = async (seed = 1, { numberOfNonRevertiblePublicCallRequests
|
|
|
42
44
|
maxPriorityFeesPerGas
|
|
43
45
|
});
|
|
44
46
|
data.feePayer = feePayer ?? await AztecAddress.random();
|
|
47
|
+
data.constants.txContext.chainId = chainId;
|
|
48
|
+
data.constants.txContext.version = version;
|
|
49
|
+
data.constants.vkTreeRoot = vkTreeRoot;
|
|
50
|
+
data.constants.protocolContractTreeRoot = protocolContractTreeRoot;
|
|
45
51
|
const publicFunctionCalldata = [];
|
|
46
52
|
if (!isForPublic) {
|
|
47
53
|
data.forRollup.end.nullifiers[0] = firstNullifier.value;
|
|
@@ -69,7 +75,8 @@ export const mockTx = async (seed = 1, { numberOfNonRevertiblePublicCallRequests
|
|
|
69
75
|
}
|
|
70
76
|
return new Tx(data, clientIvcProof, [], publicFunctionCalldata);
|
|
71
77
|
};
|
|
72
|
-
export const mockTxForRollup = (seed = 1)=>mockTx(seed, {
|
|
78
|
+
export const mockTxForRollup = (seed = 1, opts = {})=>mockTx(seed, {
|
|
79
|
+
...opts,
|
|
73
80
|
numberOfNonRevertiblePublicCallRequests: 0,
|
|
74
81
|
numberOfRevertiblePublicCallRequests: 0
|
|
75
82
|
});
|
|
@@ -147,3 +154,24 @@ export const makeBlockAttestation = async (options)=>{
|
|
|
147
154
|
const { payload, signature } = await makeAndSignConsensusPayload(SignatureDomainSeparator.blockAttestation, options);
|
|
148
155
|
return new BlockAttestation(payload, signature);
|
|
149
156
|
};
|
|
157
|
+
export async function randomPublishedL2Block(l2BlockNumber, opts = {}) {
|
|
158
|
+
const block = await L2Block.random(l2BlockNumber);
|
|
159
|
+
const l1 = {
|
|
160
|
+
blockNumber: BigInt(block.number),
|
|
161
|
+
timestamp: block.header.globalVariables.timestamp.toBigInt(),
|
|
162
|
+
blockHash: Buffer32.random().toString()
|
|
163
|
+
};
|
|
164
|
+
const signers = opts.signers ?? times(3, ()=>Secp256k1Signer.random());
|
|
165
|
+
const attestations = await Promise.all(signers.map((signer)=>makeBlockAttestation({
|
|
166
|
+
signer,
|
|
167
|
+
header: block.header,
|
|
168
|
+
archive: block.archive.root,
|
|
169
|
+
txHashes: block.body.txEffects.map((tx)=>tx.txHash)
|
|
170
|
+
})));
|
|
171
|
+
const signatures = attestations.map((attestation)=>attestation.signature);
|
|
172
|
+
return {
|
|
173
|
+
block,
|
|
174
|
+
l1,
|
|
175
|
+
signatures
|
|
176
|
+
};
|
|
177
|
+
}
|
|
@@ -5,8 +5,10 @@ export declare const TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED = "Setup function not o
|
|
|
5
5
|
export declare const TX_ERROR_DUPLICATE_NULLIFIER_IN_TX = "Duplicate nullifier in tx";
|
|
6
6
|
export declare const TX_ERROR_EXISTING_NULLIFIER = "Existing nullifier";
|
|
7
7
|
export declare const TX_ERROR_INVALID_BLOCK_NUMBER = "Invalid block number";
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const TX_ERROR_INCORRECT_L1_CHAIN_ID = "Incorrect L1 chain id";
|
|
9
9
|
export declare const TX_ERROR_INCORRECT_ROLLUP_VERSION = "Incorrect rollup version";
|
|
10
|
+
export declare const TX_ERROR_INCORRECT_VK_TREE_ROOT = "Incorrect protocol circuits tree root";
|
|
11
|
+
export declare const TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT = "Incorrect protocol contracts tree root";
|
|
10
12
|
export declare const TX_ERROR_INVALID_PROOF = "Invalid proof";
|
|
11
13
|
export declare const TX_ERROR_INCORRECT_CALLDATA = "Incorrect calldata for public call";
|
|
12
14
|
export declare const TX_ERROR_CALLDATA_COUNT_MISMATCH = "Wrong number of calldata for public calls";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error_texts.d.ts","sourceRoot":"","sources":["../../../src/tx/validator/error_texts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,uCAAuC,mCAAmC,CAAC;AACxF,eAAO,MAAM,+BAA+B,8CAA8C,CAAC;AAG3F,eAAO,MAAM,mCAAmC,qCAAqC,CAAC;AAGtF,eAAO,MAAM,kCAAkC,8BAA8B,CAAC;AAC9E,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAGhE,eAAO,MAAM,6BAA6B,yBAAyB,CAAC;AACpE,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"error_texts.d.ts","sourceRoot":"","sources":["../../../src/tx/validator/error_texts.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,uCAAuC,mCAAmC,CAAC;AACxF,eAAO,MAAM,+BAA+B,8CAA8C,CAAC;AAG3F,eAAO,MAAM,mCAAmC,qCAAqC,CAAC;AAGtF,eAAO,MAAM,kCAAkC,8BAA8B,CAAC;AAC9E,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAGhE,eAAO,MAAM,6BAA6B,yBAAyB,CAAC;AACpE,eAAO,MAAM,8BAA8B,0BAA0B,CAAC;AACtE,eAAO,MAAM,iCAAiC,6BAA6B,CAAC;AAC5E,eAAO,MAAM,+BAA+B,0CAA0C,CAAC;AACvF,eAAO,MAAM,8CAA8C,2CAA2C,CAAC;AAGvG,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAGtD,eAAO,MAAM,2BAA2B,uCAAuC,CAAC;AAChF,eAAO,MAAM,gCAAgC,8CAA8C,CAAC;AAC5F,eAAO,MAAM,iCAAiC,uDAAuD,CAAC;AACtG,eAAO,MAAM,iCAAiC,6CAA6C,CAAC;AAC5F,eAAO,MAAM,kCAAkC,0CAA0C,CAAC;AAC1F,eAAO,MAAM,4BAA4B,mCAAmC,CAAC;AAC7E,eAAO,MAAM,mCAAmC,2CAA2C,CAAC;AAG5F,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAG9D,eAAO,MAAM,0BAA0B,uCAAuC,CAAC"}
|
|
@@ -9,8 +9,10 @@ export const TX_ERROR_DUPLICATE_NULLIFIER_IN_TX = 'Duplicate nullifier in tx';
|
|
|
9
9
|
export const TX_ERROR_EXISTING_NULLIFIER = 'Existing nullifier';
|
|
10
10
|
// Metadata
|
|
11
11
|
export const TX_ERROR_INVALID_BLOCK_NUMBER = 'Invalid block number';
|
|
12
|
-
export const
|
|
12
|
+
export const TX_ERROR_INCORRECT_L1_CHAIN_ID = 'Incorrect L1 chain id';
|
|
13
13
|
export const TX_ERROR_INCORRECT_ROLLUP_VERSION = 'Incorrect rollup version';
|
|
14
|
+
export const TX_ERROR_INCORRECT_VK_TREE_ROOT = 'Incorrect protocol circuits tree root';
|
|
15
|
+
export const TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT = 'Incorrect protocol contracts tree root';
|
|
14
16
|
// Proof
|
|
15
17
|
export const TX_ERROR_INVALID_PROOF = 'Invalid proof';
|
|
16
18
|
//Data
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.85.0-alpha-testnet.
|
|
3
|
+
"version": "0.85.0-alpha-testnet.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@aztec/bb.js": "0.85.0-alpha-testnet.
|
|
72
|
-
"@aztec/blob-lib": "0.85.0-alpha-testnet.
|
|
73
|
-
"@aztec/constants": "0.85.0-alpha-testnet.
|
|
74
|
-
"@aztec/ethereum": "0.85.0-alpha-testnet.
|
|
75
|
-
"@aztec/foundation": "0.85.0-alpha-testnet.
|
|
76
|
-
"@aztec/noir-noirc_abi": "0.85.0-alpha-testnet.
|
|
71
|
+
"@aztec/bb.js": "0.85.0-alpha-testnet.5",
|
|
72
|
+
"@aztec/blob-lib": "0.85.0-alpha-testnet.5",
|
|
73
|
+
"@aztec/constants": "0.85.0-alpha-testnet.5",
|
|
74
|
+
"@aztec/ethereum": "0.85.0-alpha-testnet.5",
|
|
75
|
+
"@aztec/foundation": "0.85.0-alpha-testnet.5",
|
|
76
|
+
"@aztec/noir-noirc_abi": "0.85.0-alpha-testnet.5",
|
|
77
77
|
"@google-cloud/storage": "^7.15.0",
|
|
78
78
|
"lodash.chunk": "^4.2.0",
|
|
79
79
|
"lodash.isequal": "^4.5.0",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { times } from '@aztec/foundation/collection';
|
|
3
|
-
import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
4
1
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
2
|
import { schemas } from '@aztec/foundation/schemas';
|
|
6
3
|
import { L2Block } from '@aztec/stdlib/block';
|
|
7
4
|
|
|
8
5
|
import { z } from 'zod';
|
|
9
6
|
|
|
7
|
+
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
8
|
+
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
9
|
+
|
|
10
10
|
export type L1PublishedData = {
|
|
11
11
|
blockNumber: bigint;
|
|
12
12
|
timestamp: bigint;
|
|
@@ -29,17 +29,7 @@ export const PublishedL2BlockSchema = z.object({
|
|
|
29
29
|
signatures: z.array(Signature.schema),
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
export
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
blockNumber: BigInt(block.number),
|
|
36
|
-
timestamp: block.header.globalVariables.timestamp.toBigInt(),
|
|
37
|
-
blockHash: Buffer32.random().toString(),
|
|
38
|
-
};
|
|
39
|
-
// Create valid signatures
|
|
40
|
-
const signers = times(3, () => Secp256k1Signer.random());
|
|
41
|
-
const signatures = await Promise.all(
|
|
42
|
-
times(3, async i => signers[i].signMessage(Buffer32.fromField(await block.hash()))),
|
|
43
|
-
);
|
|
44
|
-
return { block, l1, signatures };
|
|
32
|
+
export function getAttestationsFromPublishedL2Block(block: PublishedL2Block) {
|
|
33
|
+
const payload = ConsensusPayload.fromBlock(block.block);
|
|
34
|
+
return block.signatures.filter(sig => !sig.isEmpty).map(signature => new BlockAttestation(payload, signature));
|
|
45
35
|
}
|
package/src/tests/mocks.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { MAX_ENQUEUED_CALLS_PER_TX } from '@aztec/constants';
|
|
2
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
3
4
|
import { Secp256k1Signer, randomBytes } from '@aztec/foundation/crypto';
|
|
4
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
6
|
|
|
6
7
|
import type { ContractArtifact } from '../abi/abi.js';
|
|
7
8
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
9
|
+
import { L2Block } from '../block/l2_block.js';
|
|
10
|
+
import type { PublishedL2Block } from '../block/published_l2_block.js';
|
|
8
11
|
import { computeContractAddressFromInstance } from '../contract/contract_address.js';
|
|
9
12
|
import { getContractClassFromArtifact } from '../contract/contract_class.js';
|
|
10
13
|
import { SerializableContractInstance } from '../contract/contract_instance.js';
|
|
@@ -79,6 +82,10 @@ export const mockTx = async (
|
|
|
79
82
|
feePayer,
|
|
80
83
|
clientIvcProof = ClientIvcProof.empty(),
|
|
81
84
|
maxPriorityFeesPerGas,
|
|
85
|
+
chainId = Fr.ZERO,
|
|
86
|
+
version = Fr.ZERO,
|
|
87
|
+
vkTreeRoot = Fr.ZERO,
|
|
88
|
+
protocolContractTreeRoot = Fr.ZERO,
|
|
82
89
|
}: {
|
|
83
90
|
numberOfNonRevertiblePublicCallRequests?: number;
|
|
84
91
|
numberOfRevertiblePublicCallRequests?: number;
|
|
@@ -88,6 +95,10 @@ export const mockTx = async (
|
|
|
88
95
|
feePayer?: AztecAddress;
|
|
89
96
|
clientIvcProof?: ClientIvcProof;
|
|
90
97
|
maxPriorityFeesPerGas?: GasFees;
|
|
98
|
+
chainId?: Fr;
|
|
99
|
+
version?: Fr;
|
|
100
|
+
vkTreeRoot?: Fr;
|
|
101
|
+
protocolContractTreeRoot?: Fr;
|
|
91
102
|
} = {},
|
|
92
103
|
) => {
|
|
93
104
|
const totalPublicCallRequests =
|
|
@@ -102,6 +113,10 @@ export const mockTx = async (
|
|
|
102
113
|
maxPriorityFeesPerGas,
|
|
103
114
|
});
|
|
104
115
|
data.feePayer = feePayer ?? (await AztecAddress.random());
|
|
116
|
+
data.constants.txContext.chainId = chainId;
|
|
117
|
+
data.constants.txContext.version = version;
|
|
118
|
+
data.constants.vkTreeRoot = vkTreeRoot;
|
|
119
|
+
data.constants.protocolContractTreeRoot = protocolContractTreeRoot;
|
|
105
120
|
|
|
106
121
|
const publicFunctionCalldata: HashedValues[] = [];
|
|
107
122
|
if (!isForPublic) {
|
|
@@ -143,8 +158,8 @@ export const mockTx = async (
|
|
|
143
158
|
return new Tx(data, clientIvcProof, [], publicFunctionCalldata);
|
|
144
159
|
};
|
|
145
160
|
|
|
146
|
-
export const mockTxForRollup = (seed = 1) =>
|
|
147
|
-
mockTx(seed, { numberOfNonRevertiblePublicCallRequests: 0, numberOfRevertiblePublicCallRequests: 0 });
|
|
161
|
+
export const mockTxForRollup = (seed = 1, opts: Parameters<typeof mockTx>[1] = {}) =>
|
|
162
|
+
mockTx(seed, { ...opts, numberOfNonRevertiblePublicCallRequests: 0, numberOfRevertiblePublicCallRequests: 0 });
|
|
148
163
|
|
|
149
164
|
const emptyPrivateCallExecutionResult = () =>
|
|
150
165
|
new PrivateCallExecutionResult(
|
|
@@ -254,3 +269,29 @@ export const makeBlockAttestation = async (options?: MakeConsensusPayloadOptions
|
|
|
254
269
|
const { payload, signature } = await makeAndSignConsensusPayload(SignatureDomainSeparator.blockAttestation, options);
|
|
255
270
|
return new BlockAttestation(payload, signature);
|
|
256
271
|
};
|
|
272
|
+
|
|
273
|
+
export async function randomPublishedL2Block(
|
|
274
|
+
l2BlockNumber: number,
|
|
275
|
+
opts: { signers?: Secp256k1Signer[] } = {},
|
|
276
|
+
): Promise<PublishedL2Block> {
|
|
277
|
+
const block = await L2Block.random(l2BlockNumber);
|
|
278
|
+
const l1 = {
|
|
279
|
+
blockNumber: BigInt(block.number),
|
|
280
|
+
timestamp: block.header.globalVariables.timestamp.toBigInt(),
|
|
281
|
+
blockHash: Buffer32.random().toString(),
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const signers = opts.signers ?? times(3, () => Secp256k1Signer.random());
|
|
285
|
+
const attestations = await Promise.all(
|
|
286
|
+
signers.map(signer =>
|
|
287
|
+
makeBlockAttestation({
|
|
288
|
+
signer,
|
|
289
|
+
header: block.header,
|
|
290
|
+
archive: block.archive.root,
|
|
291
|
+
txHashes: block.body.txEffects.map(tx => tx.txHash),
|
|
292
|
+
}),
|
|
293
|
+
),
|
|
294
|
+
);
|
|
295
|
+
const signatures = attestations.map(attestation => attestation.signature);
|
|
296
|
+
return { block, l1, signatures };
|
|
297
|
+
}
|
|
@@ -12,8 +12,10 @@ export const TX_ERROR_EXISTING_NULLIFIER = 'Existing nullifier';
|
|
|
12
12
|
|
|
13
13
|
// Metadata
|
|
14
14
|
export const TX_ERROR_INVALID_BLOCK_NUMBER = 'Invalid block number';
|
|
15
|
-
export const
|
|
15
|
+
export const TX_ERROR_INCORRECT_L1_CHAIN_ID = 'Incorrect L1 chain id';
|
|
16
16
|
export const TX_ERROR_INCORRECT_ROLLUP_VERSION = 'Incorrect rollup version';
|
|
17
|
+
export const TX_ERROR_INCORRECT_VK_TREE_ROOT = 'Incorrect protocol circuits tree root';
|
|
18
|
+
export const TX_ERROR_INCORRECT_PROTOCOL_CONTRACT_TREE_ROOT = 'Incorrect protocol contracts tree root';
|
|
17
19
|
|
|
18
20
|
// Proof
|
|
19
21
|
export const TX_ERROR_INVALID_PROOF = 'Invalid proof';
|