@aztec/stdlib 0.85.0 → 0.86.0
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/l2_block.js +1 -1
- package/dest/interfaces/aztec-node-admin.d.ts +3 -1
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +1 -2
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/prover-coordination.d.ts +4 -9
- package/dest/interfaces/prover-coordination.d.ts.map +1 -1
- package/dest/interfaces/prover-coordination.js +1 -7
- package/dest/kernel/private_kernel_data.d.ts +3 -3
- package/dest/kernel/private_kernel_data.d.ts.map +1 -1
- package/dest/kernel/private_kernel_data.js +8 -8
- package/dest/kernel/private_kernel_prover_output.d.ts +6 -2
- package/dest/kernel/private_kernel_prover_output.d.ts.map +1 -1
- package/dest/kernel/private_kernel_prover_output.js +17 -1
- package/dest/kernel/private_kernel_simulated_output.d.ts +3 -3
- package/dest/kernel/private_kernel_simulated_output.d.ts.map +1 -1
- package/dest/p2p/block_attestation.d.ts +4 -3
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +4 -4
- package/dest/p2p/block_proposal.d.ts +4 -3
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +5 -5
- package/dest/p2p/consensus_payload.d.ts +1 -1
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +2 -3
- package/dest/p2p/gossipable.d.ts +2 -1
- package/dest/p2p/gossipable.d.ts.map +1 -1
- package/dest/p2p/interface.d.ts +0 -13
- package/dest/p2p/interface.d.ts.map +1 -1
- package/dest/p2p/interface.js +1 -19
- package/dest/p2p/signature_utils.d.ts +3 -3
- package/dest/p2p/signature_utils.d.ts.map +1 -1
- package/dest/p2p/signature_utils.js +4 -4
- package/dest/p2p/topic_type.d.ts +2 -2
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +4 -4
- package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +0 -16
- package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts.map +1 -1
- package/dest/rollup/block_root_or_block_merge_public_inputs.js +2 -10
- package/dest/rollup/block_root_rollup.d.ts +9 -1
- package/dest/rollup/block_root_rollup.d.ts.map +1 -1
- package/dest/rollup/block_root_rollup.js +6 -1
- package/dest/rollup/root_rollup.d.ts +2 -4
- package/dest/rollup/root_rollup.d.ts.map +1 -1
- package/dest/rollup/root_rollup.js +3 -9
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +3 -3
- package/dest/tests/mocks.d.ts +2 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +6 -6
- package/dest/tx/block_header.d.ts +1 -0
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +3 -0
- package/dest/tx/profiled_tx.d.ts.map +1 -1
- package/dest/tx/profiled_tx.js +2 -1
- package/dest/tx/tx.d.ts +2 -1
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +2 -6
- package/package.json +7 -8
- package/src/block/l2_block.ts +1 -1
- package/src/interfaces/aztec-node-admin.ts +1 -1
- package/src/interfaces/aztec-node.ts +1 -3
- package/src/interfaces/prover-coordination.ts +6 -16
- package/src/kernel/private_kernel_data.ts +6 -6
- package/src/kernel/private_kernel_prover_output.ts +18 -2
- package/src/kernel/private_kernel_simulated_output.ts +3 -3
- package/src/p2p/block_attestation.ts +5 -8
- package/src/p2p/block_proposal.ts +5 -8
- package/src/p2p/consensus_payload.ts +3 -9
- package/src/p2p/gossipable.ts +3 -1
- package/src/p2p/interface.ts +0 -24
- package/src/p2p/signature_utils.ts +6 -9
- package/src/p2p/topic_type.ts +4 -4
- package/src/rollup/block_root_or_block_merge_public_inputs.ts +0 -12
- package/src/rollup/block_root_rollup.ts +6 -0
- package/src/rollup/root_rollup.ts +0 -8
- package/src/tests/factories.ts +11 -14
- package/src/tests/mocks.ts +6 -6
- package/src/tx/block_header.ts +4 -0
- package/src/tx/profiled_tx.ts +1 -0
- package/src/tx/tx.ts +2 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -63,16 +63,15 @@
|
|
|
63
63
|
"generate": "./scripts/copy-contracts.sh",
|
|
64
64
|
"build:dev": "tsc -b --watch",
|
|
65
65
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
66
|
-
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
67
|
-
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
68
66
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
69
67
|
},
|
|
70
68
|
"dependencies": {
|
|
71
|
-
"@aztec/bb.js": "0.
|
|
72
|
-
"@aztec/blob-lib": "0.
|
|
73
|
-
"@aztec/constants": "0.
|
|
74
|
-
"@aztec/ethereum": "0.
|
|
75
|
-
"@aztec/foundation": "0.
|
|
69
|
+
"@aztec/bb.js": "0.86.0",
|
|
70
|
+
"@aztec/blob-lib": "0.86.0",
|
|
71
|
+
"@aztec/constants": "0.86.0",
|
|
72
|
+
"@aztec/ethereum": "0.86.0",
|
|
73
|
+
"@aztec/foundation": "0.86.0",
|
|
74
|
+
"@aztec/noir-noirc_abi": "0.86.0",
|
|
76
75
|
"@google-cloud/storage": "^7.15.0",
|
|
77
76
|
"lodash.chunk": "^4.2.0",
|
|
78
77
|
"lodash.isequal": "^4.5.0",
|
package/src/block/l2_block.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface AztecNodeAdmin {
|
|
|
15
15
|
* Updates the configuration of this node.
|
|
16
16
|
* @param config - Updated configuration to be merged with the current one.
|
|
17
17
|
*/
|
|
18
|
-
setConfig(config: Partial<SequencerConfig & ProverConfig>): Promise<void>;
|
|
18
|
+
setConfig(config: Partial<SequencerConfig & ProverConfig & { maxTxPoolSize: number }>): Promise<void>;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Forces the next block to be built bypassing all time and pending checks.
|
|
@@ -56,7 +56,6 @@ import {
|
|
|
56
56
|
type GetPublicLogsResponse,
|
|
57
57
|
GetPublicLogsResponseSchema,
|
|
58
58
|
} from './get_logs_response.js';
|
|
59
|
-
import type { ProverCoordination } from './prover-coordination.js';
|
|
60
59
|
import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_state.js';
|
|
61
60
|
|
|
62
61
|
/**
|
|
@@ -64,8 +63,7 @@ import { type WorldStateSyncStatus, WorldStateSyncStatusSchema } from './world_s
|
|
|
64
63
|
* We will probably implement the additional interfaces by means other than Aztec Node as it's currently a privacy leak
|
|
65
64
|
*/
|
|
66
65
|
export interface AztecNode
|
|
67
|
-
extends
|
|
68
|
-
Pick<L2BlockSource, 'getBlocks' | 'getPublishedBlocks' | 'getBlockHeader' | 'getL2Tips'> {
|
|
66
|
+
extends Pick<L2BlockSource, 'getBlocks' | 'getPublishedBlocks' | 'getBlockHeader' | 'getL2Tips'> {
|
|
69
67
|
/**
|
|
70
68
|
* Returns the tips of the L2 chain.
|
|
71
69
|
*/
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
import type { ApiSchemaFor } from '../schemas/index.js';
|
|
4
1
|
import { Tx } from '../tx/tx.js';
|
|
5
2
|
import { TxHash } from '../tx/tx_hash.js';
|
|
3
|
+
import type { P2PClient } from './p2p.js';
|
|
6
4
|
|
|
7
5
|
/** Provides basic operations for ProverNodes to interact with other nodes in the network. */
|
|
8
6
|
export interface ProverCoordination {
|
|
9
|
-
/**
|
|
10
|
-
* Returns a transaction given its hash if available.
|
|
11
|
-
* @param txHash - The hash of the transaction, used as an ID.
|
|
12
|
-
* @returns The transaction, if found, 'undefined' otherwise.
|
|
13
|
-
*/
|
|
14
|
-
getTxByHash(txHash: TxHash): Promise<Tx | undefined>;
|
|
15
|
-
|
|
16
7
|
/**
|
|
17
8
|
* Returns a set of transactions given their hashes if available.
|
|
18
9
|
* @param txHashes - The hashes of the transactions, used as an ID.
|
|
19
|
-
* @returns The transactions
|
|
10
|
+
* @returns The transactions found, no necessarily in the same order as the hashes.
|
|
20
11
|
*/
|
|
21
12
|
getTxsByHash(txHashes: TxHash[]): Promise<Tx[]>;
|
|
22
|
-
}
|
|
23
13
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
14
|
+
gatherTxs(txHashes: TxHash[]): Promise<void>;
|
|
15
|
+
|
|
16
|
+
getP2PClient(): P2PClient | undefined;
|
|
17
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VK_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
5
|
|
|
6
6
|
import type { UInt32 } from '../types/shared.js';
|
|
7
|
-
import {
|
|
7
|
+
import { VerificationKeyData } from '../vks/verification_key.js';
|
|
8
8
|
import { PrivateKernelCircuitPublicInputs } from './private_kernel_circuit_public_inputs.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -21,7 +21,7 @@ export class PrivateKernelData {
|
|
|
21
21
|
/**
|
|
22
22
|
* Verification key of the previous kernel.
|
|
23
23
|
*/
|
|
24
|
-
public
|
|
24
|
+
public verificationKey: VerificationKeyData,
|
|
25
25
|
/**
|
|
26
26
|
* Index of the previous kernel's vk in a tree of vks.
|
|
27
27
|
*/
|
|
@@ -37,14 +37,14 @@ export class PrivateKernelData {
|
|
|
37
37
|
* @returns The buffer.
|
|
38
38
|
*/
|
|
39
39
|
toBuffer() {
|
|
40
|
-
return serializeToBuffer(this.publicInputs, this.
|
|
40
|
+
return serializeToBuffer(this.publicInputs, this.verificationKey, this.vkIndex, this.vkPath);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
static fromBuffer(buffer: Buffer | BufferReader): PrivateKernelData {
|
|
44
44
|
const reader = BufferReader.asReader(buffer);
|
|
45
45
|
return new this(
|
|
46
46
|
reader.readObject(PrivateKernelCircuitPublicInputs),
|
|
47
|
-
reader.readObject(
|
|
47
|
+
reader.readObject(VerificationKeyData),
|
|
48
48
|
reader.readNumber(),
|
|
49
49
|
reader.readArray(VK_TREE_HEIGHT, Fr),
|
|
50
50
|
);
|
|
@@ -53,7 +53,7 @@ export class PrivateKernelData {
|
|
|
53
53
|
static empty(): PrivateKernelData {
|
|
54
54
|
return new PrivateKernelData(
|
|
55
55
|
PrivateKernelCircuitPublicInputs.empty(),
|
|
56
|
-
|
|
56
|
+
VerificationKeyData.empty(),
|
|
57
57
|
0,
|
|
58
58
|
makeTuple(VK_TREE_HEIGHT, Fr.zero),
|
|
59
59
|
);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { bufferSchema, mapSchema } from '@aztec/foundation/schemas';
|
|
2
2
|
import type { WitnessMap } from '@aztec/noir-acvm_js';
|
|
3
|
+
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
3
4
|
|
|
5
|
+
import { Encoder } from 'msgpackr';
|
|
4
6
|
import { z } from 'zod';
|
|
5
7
|
|
|
6
8
|
import type { ClientIvcProof } from '../proofs/client_ivc_proof.js';
|
|
7
|
-
import type { VerificationKeyAsFields } from '../vks/verification_key.js';
|
|
8
9
|
import type { PrivateKernelCircuitPublicInputs } from './private_kernel_circuit_public_inputs.js';
|
|
9
10
|
import type { PrivateKernelTailCircuitPublicInputs } from './private_kernel_tail_circuit_public_inputs.js';
|
|
10
11
|
|
|
@@ -13,6 +14,7 @@ export const PrivateExecutionStepSchema = z.object({
|
|
|
13
14
|
gateCount: z.number().optional(),
|
|
14
15
|
bytecode: bufferSchema,
|
|
15
16
|
witness: mapSchema(z.number(), z.string()),
|
|
17
|
+
vk: bufferSchema,
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -23,6 +25,8 @@ export interface PrivateExecutionStep {
|
|
|
23
25
|
gateCount?: number;
|
|
24
26
|
bytecode: Buffer;
|
|
25
27
|
witness: WitnessMap;
|
|
28
|
+
/* TODO(https://github.com/AztecProtocol/barretenberg/issues/1328) this should get its own proper class. */
|
|
29
|
+
vk: Buffer;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
/** Represents the output of proven PrivateKernelSimulateOutput.*/
|
|
@@ -34,7 +38,7 @@ export interface PrivateKernelExecutionProofOutput<
|
|
|
34
38
|
/** The private IVC proof optimized for user devices. It will be consumed by an Aztec prover,
|
|
35
39
|
* which recursively verifies it through the "tube" circuit.*/
|
|
36
40
|
clientIvcProof: ClientIvcProof;
|
|
37
|
-
|
|
41
|
+
vk: Buffer;
|
|
38
42
|
/**
|
|
39
43
|
* The trace the clientIvcProof corresponds to.
|
|
40
44
|
* A trace of app circuits interleaved with private kernel circuits.
|
|
@@ -42,3 +46,15 @@ export interface PrivateKernelExecutionProofOutput<
|
|
|
42
46
|
*/
|
|
43
47
|
executionSteps: PrivateExecutionStep[];
|
|
44
48
|
}
|
|
49
|
+
|
|
50
|
+
export function serializePrivateExecutionSteps(steps: PrivateExecutionStep[]) {
|
|
51
|
+
const stepToStruct = (step: PrivateExecutionStep) => {
|
|
52
|
+
return {
|
|
53
|
+
bytecode: step.bytecode,
|
|
54
|
+
witness: serializeWitness(step.witness),
|
|
55
|
+
vk: step.vk,
|
|
56
|
+
functionName: step.functionName,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
return new Encoder({ useRecords: false }).pack(steps.map(stepToStruct));
|
|
60
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WitnessMap } from '@aztec/noir-acvm_js';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { VerificationKeyData } from '../vks/verification_key.js';
|
|
4
4
|
import type { PrivateKernelCircuitPublicInputs } from './private_kernel_circuit_public_inputs.js';
|
|
5
5
|
import type { PrivateKernelTailCircuitPublicInputs } from './private_kernel_tail_circuit_public_inputs.js';
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ export interface PrivateKernelSimulateOutput<
|
|
|
14
14
|
/** The public inputs required for the proof generation process. */
|
|
15
15
|
publicInputs: PublicInputsType;
|
|
16
16
|
outputWitness: WitnessMap;
|
|
17
|
-
verificationKey:
|
|
17
|
+
verificationKey: VerificationKeyData;
|
|
18
18
|
bytecode: Buffer;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -22,5 +22,5 @@ export interface PrivateKernelSimulateOutput<
|
|
|
22
22
|
* Represents the output of the circuit simulation process for init and inner private kernel circuit.
|
|
23
23
|
*/
|
|
24
24
|
export type AppCircuitSimulateOutput = {
|
|
25
|
-
verificationKey:
|
|
25
|
+
verificationKey: VerificationKeyData;
|
|
26
26
|
};
|
|
@@ -11,7 +11,7 @@ import type { ZodFor } from '../schemas/index.js';
|
|
|
11
11
|
import { ConsensusPayload } from './consensus_payload.js';
|
|
12
12
|
import { Gossipable } from './gossipable.js';
|
|
13
13
|
import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js';
|
|
14
|
-
import { TopicType
|
|
14
|
+
import { TopicType } from './topic_type.js';
|
|
15
15
|
|
|
16
16
|
export class BlockAttestationHash extends Buffer32 {
|
|
17
17
|
constructor(hash: Buffer) {
|
|
@@ -26,7 +26,7 @@ export class BlockAttestationHash extends Buffer32 {
|
|
|
26
26
|
* will produce a block attestation over the header of the block
|
|
27
27
|
*/
|
|
28
28
|
export class BlockAttestation extends Gossipable {
|
|
29
|
-
static override p2pTopic =
|
|
29
|
+
static override p2pTopic = TopicType.block_attestation;
|
|
30
30
|
|
|
31
31
|
private sender: EthAddress | undefined;
|
|
32
32
|
|
|
@@ -70,13 +70,10 @@ export class BlockAttestation extends Gossipable {
|
|
|
70
70
|
* Lazily evaluate and cache the sender of the attestation
|
|
71
71
|
* @returns The sender of the attestation
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
getSender(): EthAddress {
|
|
74
74
|
if (!this.sender) {
|
|
75
75
|
// Recover the sender from the attestation
|
|
76
|
-
const hashed =
|
|
77
|
-
this.payload,
|
|
78
|
-
SignatureDomainSeparator.blockAttestation,
|
|
79
|
-
);
|
|
76
|
+
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockAttestation);
|
|
80
77
|
// Cache the sender for later use
|
|
81
78
|
this.sender = recoverAddress(hashed, this.signature);
|
|
82
79
|
}
|
|
@@ -84,7 +81,7 @@ export class BlockAttestation extends Gossipable {
|
|
|
84
81
|
return this.sender;
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
getPayload():
|
|
84
|
+
getPayload(): Buffer {
|
|
88
85
|
return this.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation);
|
|
89
86
|
}
|
|
90
87
|
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
getHashedSignaturePayload,
|
|
13
13
|
getHashedSignaturePayloadEthSignedMessage,
|
|
14
14
|
} from './signature_utils.js';
|
|
15
|
-
import { TopicType
|
|
15
|
+
import { TopicType } from './topic_type.js';
|
|
16
16
|
|
|
17
17
|
export class BlockProposalHash extends Buffer32 {
|
|
18
18
|
constructor(hash: Buffer) {
|
|
@@ -27,7 +27,7 @@ export class BlockProposalHash extends Buffer32 {
|
|
|
27
27
|
* be included in the head of the chain
|
|
28
28
|
*/
|
|
29
29
|
export class BlockProposal extends Gossipable {
|
|
30
|
-
static override p2pTopic =
|
|
30
|
+
static override p2pTopic = TopicType.block_proposal;
|
|
31
31
|
|
|
32
32
|
private sender: EthAddress | undefined;
|
|
33
33
|
|
|
@@ -61,7 +61,7 @@ export class BlockProposal extends Gossipable {
|
|
|
61
61
|
payload: ConsensusPayload,
|
|
62
62
|
payloadSigner: (payload: Buffer32) => Promise<Signature>,
|
|
63
63
|
) {
|
|
64
|
-
const hashed =
|
|
64
|
+
const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal);
|
|
65
65
|
const sig = await payloadSigner(hashed);
|
|
66
66
|
|
|
67
67
|
return new BlockProposal(payload, sig);
|
|
@@ -70,12 +70,9 @@ export class BlockProposal extends Gossipable {
|
|
|
70
70
|
/**Get Sender
|
|
71
71
|
* Lazily evaluate the sender of the proposal; result is cached
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
getSender() {
|
|
74
74
|
if (!this.sender) {
|
|
75
|
-
const hashed =
|
|
76
|
-
this.payload,
|
|
77
|
-
SignatureDomainSeparator.blockProposal,
|
|
78
|
-
);
|
|
75
|
+
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
|
|
79
76
|
// Cache the sender for later use
|
|
80
77
|
this.sender = recoverAddress(hashed, this.signature);
|
|
81
78
|
}
|
|
@@ -38,18 +38,12 @@ export class ConsensusPayload implements Signable {
|
|
|
38
38
|
return [fields.header, fields.archive, fields.txHashes] as const;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
const abi = parseAbiParameters('uint8, (bytes32,
|
|
41
|
+
getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
|
|
42
|
+
const abi = parseAbiParameters('uint8, (bytes32, (uint256), bytes, bytes32[])');
|
|
43
43
|
const txArray = this.txHashes.map(tx => tx.toString());
|
|
44
44
|
const encodedData = encodeAbiParameters(abi, [
|
|
45
45
|
domainSeparator,
|
|
46
|
-
[
|
|
47
|
-
this.archive.toString(),
|
|
48
|
-
(await this.header.hash()).toString(),
|
|
49
|
-
[0n] /* @todo See #9963 */,
|
|
50
|
-
this.header.toString(),
|
|
51
|
-
txArray,
|
|
52
|
-
],
|
|
46
|
+
[this.archive.toString(), [0n] /* @todo See #9963 */, this.header.toString(), txArray],
|
|
53
47
|
] as const);
|
|
54
48
|
|
|
55
49
|
return hexToBuffer(encodedData);
|
package/src/p2p/gossipable.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
2
|
|
|
3
|
+
import type { TopicType } from './topic_type.js';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Gossipable
|
|
5
7
|
*
|
|
@@ -10,7 +12,7 @@ export abstract class Gossipable {
|
|
|
10
12
|
*
|
|
11
13
|
* - The p2p topic identifier, this determines how the message is handled
|
|
12
14
|
*/
|
|
13
|
-
static p2pTopic:
|
|
15
|
+
static p2pTopic: TopicType;
|
|
14
16
|
|
|
15
17
|
/** p2p Message Identifier
|
|
16
18
|
*
|
package/src/p2p/interface.ts
CHANGED
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import { Tx } from '../tx/tx.js';
|
|
2
|
-
import { BlockAttestation } from './block_attestation.js';
|
|
3
|
-
import { BlockProposal } from './block_proposal.js';
|
|
4
|
-
import type { Gossipable } from './gossipable.js';
|
|
5
|
-
import { TopicType } from './topic_type.js';
|
|
6
|
-
|
|
7
1
|
export interface RawGossipMessage {
|
|
8
2
|
topic: string;
|
|
9
3
|
data: Uint8Array;
|
|
10
4
|
}
|
|
11
|
-
|
|
12
|
-
// Force casts as we know that each field here extends Gossipable, and we just want types from Gossipable
|
|
13
|
-
export const TopicTypeMap: Record<string, typeof Gossipable> = {
|
|
14
|
-
[TopicType.tx]: Tx as unknown as typeof Gossipable,
|
|
15
|
-
[TopicType.block_proposal]: BlockProposal as unknown as typeof Gossipable,
|
|
16
|
-
[TopicType.block_attestation]: BlockAttestation as unknown as typeof Gossipable,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Map from topic to deserialiser
|
|
21
|
-
*
|
|
22
|
-
* Used in msgIdFn libp2p to get the p2pMessageIdentifier from a message
|
|
23
|
-
*/
|
|
24
|
-
export const TopicToDeserializer = {
|
|
25
|
-
[Tx.p2pTopic]: Tx.fromBuffer,
|
|
26
|
-
[BlockProposal.p2pTopic]: BlockProposal.fromBuffer,
|
|
27
|
-
[BlockAttestation.p2pTopic]: BlockAttestation.fromBuffer,
|
|
28
|
-
};
|
|
@@ -7,7 +7,7 @@ export enum SignatureDomainSeparator {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface Signable {
|
|
10
|
-
getPayloadToSign(domainSeparator: SignatureDomainSeparator):
|
|
10
|
+
getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -15,11 +15,8 @@ export interface Signable {
|
|
|
15
15
|
* @param s - The `Signable` to sign
|
|
16
16
|
* @returns The hashed payload for the signature of the `Signable`
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
19
|
-
s
|
|
20
|
-
domainSeparator: SignatureDomainSeparator,
|
|
21
|
-
): Promise<Buffer32> {
|
|
22
|
-
return Buffer32.fromBuffer(keccak256(await s.getPayloadToSign(domainSeparator)));
|
|
18
|
+
export function getHashedSignaturePayload(s: Signable, domainSeparator: SignatureDomainSeparator): Buffer32 {
|
|
19
|
+
return Buffer32.fromBuffer(keccak256(s.getPayloadToSign(domainSeparator)));
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
/**
|
|
@@ -27,10 +24,10 @@ export async function getHashedSignaturePayload(
|
|
|
27
24
|
* @param s - the `Signable` to sign
|
|
28
25
|
* @returns The hashed payload for the signature of the `Signable` as an Ethereum signed message
|
|
29
26
|
*/
|
|
30
|
-
export
|
|
27
|
+
export function getHashedSignaturePayloadEthSignedMessage(
|
|
31
28
|
s: Signable,
|
|
32
29
|
domainSeparator: SignatureDomainSeparator,
|
|
33
|
-
):
|
|
34
|
-
const payload =
|
|
30
|
+
): Buffer32 {
|
|
31
|
+
const payload = getHashedSignaturePayload(s, domainSeparator);
|
|
35
32
|
return makeEthSignDigest(payload);
|
|
36
33
|
}
|
package/src/p2p/topic_type.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { P2PClientType } from './client_type.js';
|
|
|
6
6
|
* @param topicType
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export function createTopicString(topicType: TopicType) {
|
|
10
|
-
return
|
|
9
|
+
export function createTopicString(topicType: TopicType, protocolVersion: string) {
|
|
10
|
+
return `/aztec/${TopicType[topicType]}/${protocolVersion}`;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -35,10 +35,10 @@ export function getTopicTypeForClientType(clientType: P2PClientType) {
|
|
|
35
35
|
* ...
|
|
36
36
|
* }
|
|
37
37
|
*/
|
|
38
|
-
export function metricsTopicStrToLabels() {
|
|
38
|
+
export function metricsTopicStrToLabels(protocolVersion: string) {
|
|
39
39
|
const topicStrToLabel = new Map<string, string>();
|
|
40
40
|
for (const topic in TopicType) {
|
|
41
|
-
topicStrToLabel.set(createTopicString(TopicType[topic as keyof typeof TopicType]), topic);
|
|
41
|
+
topicStrToLabel.set(createTopicString(TopicType[topic as keyof typeof TopicType], protocolVersion), topic);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return topicStrToLabel;
|
|
@@ -23,14 +23,6 @@ export class BlockRootOrBlockMergePublicInputs {
|
|
|
23
23
|
* Archive tree after adding this block range.
|
|
24
24
|
*/
|
|
25
25
|
public newArchive: AppendOnlyTreeSnapshot,
|
|
26
|
-
/**
|
|
27
|
-
* Identifier of the previous block before the range.
|
|
28
|
-
*/
|
|
29
|
-
public previousBlockHash: Fr,
|
|
30
|
-
/**
|
|
31
|
-
* Identifier of the last block in the range.
|
|
32
|
-
*/
|
|
33
|
-
public endBlockHash: Fr,
|
|
34
26
|
/**
|
|
35
27
|
* Global variables for the first block in the range.
|
|
36
28
|
*/
|
|
@@ -76,8 +68,6 @@ export class BlockRootOrBlockMergePublicInputs {
|
|
|
76
68
|
return new BlockRootOrBlockMergePublicInputs(
|
|
77
69
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
78
70
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
79
|
-
Fr.fromBuffer(reader),
|
|
80
|
-
Fr.fromBuffer(reader),
|
|
81
71
|
reader.readObject(GlobalVariables),
|
|
82
72
|
reader.readObject(GlobalVariables),
|
|
83
73
|
Fr.fromBuffer(reader),
|
|
@@ -97,8 +87,6 @@ export class BlockRootOrBlockMergePublicInputs {
|
|
|
97
87
|
return serializeToBuffer(
|
|
98
88
|
this.previousArchive,
|
|
99
89
|
this.newArchive,
|
|
100
|
-
this.previousBlockHash,
|
|
101
|
-
this.endBlockHash,
|
|
102
90
|
this.startGlobalVariables,
|
|
103
91
|
this.endGlobalVariables,
|
|
104
92
|
this.outHash,
|
|
@@ -25,6 +25,10 @@ export class BlockRootRollupData {
|
|
|
25
25
|
* Hint for inserting the new l1 to l2 message subtree.
|
|
26
26
|
*/
|
|
27
27
|
public l1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
|
|
28
|
+
/**
|
|
29
|
+
* Hint for checking the hash of previous_block_header is the last leaf of the previous archive.
|
|
30
|
+
*/
|
|
31
|
+
public previousArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
28
32
|
/**
|
|
29
33
|
* Hint for inserting the new block hash to the last archive.
|
|
30
34
|
*/
|
|
@@ -73,6 +77,7 @@ export class BlockRootRollupData {
|
|
|
73
77
|
return [
|
|
74
78
|
fields.l1ToL2Roots,
|
|
75
79
|
fields.l1ToL2MessageSubtreeSiblingPath,
|
|
80
|
+
fields.previousArchiveSiblingPath,
|
|
76
81
|
fields.newArchiveSiblingPath,
|
|
77
82
|
fields.previousBlockHeader,
|
|
78
83
|
fields.proverId,
|
|
@@ -90,6 +95,7 @@ export class BlockRootRollupData {
|
|
|
90
95
|
RootParityInput.fromBuffer(reader, NESTED_RECURSIVE_PROOF_LENGTH),
|
|
91
96
|
reader.readArray(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, Fr),
|
|
92
97
|
reader.readArray(ARCHIVE_HEIGHT, Fr),
|
|
98
|
+
reader.readArray(ARCHIVE_HEIGHT, Fr),
|
|
93
99
|
BlockHeader.fromBuffer(reader),
|
|
94
100
|
Fr.fromBuffer(reader),
|
|
95
101
|
);
|
|
@@ -103,8 +103,6 @@ export class RootRollupPublicInputs {
|
|
|
103
103
|
/** Snapshot of archive tree before/after this rollup been processed */
|
|
104
104
|
public previousArchive: AppendOnlyTreeSnapshot,
|
|
105
105
|
public endArchive: AppendOnlyTreeSnapshot,
|
|
106
|
-
public previousBlockHash: Fr,
|
|
107
|
-
public endBlockHash: Fr,
|
|
108
106
|
// This is a u64 in nr, but GlobalVariables contains this as a u64 and is mapped to ts as a field, so I'm doing the same here
|
|
109
107
|
public endTimestamp: Fr,
|
|
110
108
|
public endBlockNumber: Fr,
|
|
@@ -120,8 +118,6 @@ export class RootRollupPublicInputs {
|
|
|
120
118
|
return [
|
|
121
119
|
fields.previousArchive,
|
|
122
120
|
fields.endArchive,
|
|
123
|
-
fields.previousBlockHash,
|
|
124
|
-
fields.endBlockHash,
|
|
125
121
|
fields.endTimestamp,
|
|
126
122
|
fields.endBlockNumber,
|
|
127
123
|
fields.outHash,
|
|
@@ -158,8 +154,6 @@ export class RootRollupPublicInputs {
|
|
|
158
154
|
Fr.fromBuffer(reader),
|
|
159
155
|
Fr.fromBuffer(reader),
|
|
160
156
|
Fr.fromBuffer(reader),
|
|
161
|
-
Fr.fromBuffer(reader),
|
|
162
|
-
Fr.fromBuffer(reader),
|
|
163
157
|
reader.readArray(AZTEC_MAX_EPOCH_DURATION, FeeRecipient),
|
|
164
158
|
Fr.fromBuffer(reader),
|
|
165
159
|
Fr.fromBuffer(reader),
|
|
@@ -194,8 +188,6 @@ export class RootRollupPublicInputs {
|
|
|
194
188
|
Fr.random(),
|
|
195
189
|
Fr.random(),
|
|
196
190
|
Fr.random(),
|
|
197
|
-
Fr.random(),
|
|
198
|
-
Fr.random(),
|
|
199
191
|
makeTuple(AZTEC_MAX_EPOCH_DURATION, FeeRecipient.random),
|
|
200
192
|
Fr.random(),
|
|
201
193
|
Fr.random(),
|
package/src/tests/factories.ts
CHANGED
|
@@ -713,10 +713,8 @@ export function makeBlockRootOrBlockMergeRollupPublicInputs(
|
|
|
713
713
|
return new BlockRootOrBlockMergePublicInputs(
|
|
714
714
|
makeAppendOnlyTreeSnapshot(seed + 0x200),
|
|
715
715
|
makeAppendOnlyTreeSnapshot(seed + 0x300),
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
globalVariables ?? makeGlobalVariables(seed + 0x501),
|
|
719
|
-
globalVariables ?? makeGlobalVariables(seed + 0x502),
|
|
716
|
+
globalVariables ?? makeGlobalVariables(seed + 0x400),
|
|
717
|
+
globalVariables ?? makeGlobalVariables(seed + 0x500),
|
|
720
718
|
fr(seed + 0x600),
|
|
721
719
|
makeTuple(AZTEC_MAX_EPOCH_DURATION, () => makeFeeRecipient(seed), 0x700),
|
|
722
720
|
fr(seed + 0x800),
|
|
@@ -786,8 +784,9 @@ function makeBlockRootRollupData(seed = 0) {
|
|
|
786
784
|
makeRootParityInput<typeof NESTED_RECURSIVE_PROOF_LENGTH>(NESTED_RECURSIVE_PROOF_LENGTH, seed + 0x2000),
|
|
787
785
|
makeTuple(L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, fr, 0x2100),
|
|
788
786
|
makeTuple(ARCHIVE_HEIGHT, fr, 0x2200),
|
|
789
|
-
|
|
790
|
-
|
|
787
|
+
makeTuple(ARCHIVE_HEIGHT, fr, 0x2300),
|
|
788
|
+
makeHeader(seed + 0x2400),
|
|
789
|
+
fr(seed + 0x2500),
|
|
791
790
|
);
|
|
792
791
|
}
|
|
793
792
|
|
|
@@ -880,18 +879,16 @@ export function makeRootParityInputs(seed = 0): RootParityInputs {
|
|
|
880
879
|
*/
|
|
881
880
|
export function makeRootRollupPublicInputs(seed = 0): RootRollupPublicInputs {
|
|
882
881
|
return new RootRollupPublicInputs(
|
|
882
|
+
makeAppendOnlyTreeSnapshot(seed + 0x100),
|
|
883
883
|
makeAppendOnlyTreeSnapshot(seed + 0x200),
|
|
884
|
-
|
|
884
|
+
fr(seed + 0x300),
|
|
885
885
|
fr(seed + 0x400),
|
|
886
886
|
fr(seed + 0x500),
|
|
887
|
-
|
|
887
|
+
makeTuple(AZTEC_MAX_EPOCH_DURATION, () => makeFeeRecipient(seed), 0x600),
|
|
888
888
|
fr(seed + 0x700),
|
|
889
|
-
fr(seed +
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
fr(seed + 0x101),
|
|
893
|
-
fr(seed + 0x200),
|
|
894
|
-
makeTuple(AZTEC_MAX_EPOCH_DURATION, () => makeBlockBlobPublicInputs(seed), 0x300),
|
|
889
|
+
fr(seed + 0x701),
|
|
890
|
+
fr(seed + 0x702),
|
|
891
|
+
makeTuple(AZTEC_MAX_EPOCH_DURATION, () => makeBlockBlobPublicInputs(seed), 0x800),
|
|
895
892
|
);
|
|
896
893
|
}
|
|
897
894
|
|
package/src/tests/mocks.ts
CHANGED
|
@@ -221,7 +221,7 @@ export interface MakeConsensusPayloadOptions {
|
|
|
221
221
|
txHashes?: TxHash[];
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
const makeAndSignConsensusPayload =
|
|
224
|
+
const makeAndSignConsensusPayload = (
|
|
225
225
|
domainSeparator: SignatureDomainSeparator,
|
|
226
226
|
options?: MakeConsensusPayloadOptions,
|
|
227
227
|
) => {
|
|
@@ -238,19 +238,19 @@ const makeAndSignConsensusPayload = async (
|
|
|
238
238
|
txHashes,
|
|
239
239
|
});
|
|
240
240
|
|
|
241
|
-
const hash =
|
|
241
|
+
const hash = getHashedSignaturePayloadEthSignedMessage(payload, domainSeparator);
|
|
242
242
|
const signature = signer.sign(hash);
|
|
243
243
|
|
|
244
244
|
return { payload, signature };
|
|
245
245
|
};
|
|
246
246
|
|
|
247
|
-
export const makeBlockProposal =
|
|
248
|
-
const { payload, signature } =
|
|
247
|
+
export const makeBlockProposal = (options?: MakeConsensusPayloadOptions): BlockProposal => {
|
|
248
|
+
const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockProposal, options);
|
|
249
249
|
return new BlockProposal(payload, signature);
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028)
|
|
253
|
-
export const makeBlockAttestation =
|
|
254
|
-
const { payload, signature } =
|
|
253
|
+
export const makeBlockAttestation = (options?: MakeConsensusPayloadOptions): BlockAttestation => {
|
|
254
|
+
const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockAttestation, options);
|
|
255
255
|
return new BlockAttestation(payload, signature);
|
|
256
256
|
};
|
package/src/tx/block_header.ts
CHANGED