@aztec/stdlib 2.1.0-rc.9 → 2.1.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/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/l2_block_source.d.ts +34 -5
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/published_l2_block.d.ts +0 -6
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +0 -9
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +10 -3
- package/dest/interfaces/aztec-node-admin.d.ts +35 -34
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +2 -2
- package/dest/interfaces/aztec-node.d.ts +24 -0
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +4 -0
- 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/interfaces/tx_provider.d.ts +1 -1
- package/dest/interfaces/tx_provider.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +93 -1
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +6 -0
- package/dest/p2p/block_attestation.d.ts +13 -13
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +27 -25
- package/dest/p2p/block_proposal.d.ts +4 -8
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +10 -13
- package/dest/p2p/gossipable.d.ts +4 -12
- package/dest/p2p/gossipable.d.ts.map +1 -1
- package/dest/p2p/gossipable.js +4 -7
- package/dest/p2p/topic_type.d.ts +4 -8
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +14 -8
- package/dest/tests/factories.d.ts +1 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +6 -5
- package/dest/tests/mocks.d.ts +3 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +33 -11
- package/dest/zkpassport/index.d.ts +15 -11
- package/dest/zkpassport/index.d.ts.map +1 -1
- package/dest/zkpassport/index.js +18 -17
- package/package.json +9 -9
- package/src/block/attestation_info.ts +62 -0
- package/src/block/index.ts +1 -0
- package/src/block/l2_block_source.ts +37 -5
- package/src/block/published_l2_block.ts +0 -17
- package/src/interfaces/archiver.ts +12 -4
- package/src/interfaces/aztec-node-admin.ts +2 -2
- package/src/interfaces/aztec-node.ts +36 -0
- package/src/interfaces/p2p.ts +4 -0
- package/src/interfaces/tx_provider.ts +1 -0
- package/src/interfaces/validator.ts +14 -1
- package/src/p2p/block_attestation.ts +31 -24
- package/src/p2p/block_proposal.ts +9 -16
- package/src/p2p/gossipable.ts +4 -12
- package/src/p2p/topic_type.ts +15 -8
- package/src/tests/factories.ts +7 -10
- package/src/tests/mocks.ts +53 -17
- package/src/zkpassport/index.ts +37 -33
|
@@ -2,6 +2,7 @@ import type { SecretValue } from '@aztec/foundation/config';
|
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
|
+
import { type ZodFor } from '@aztec/foundation/schemas';
|
|
5
6
|
import type { SequencerConfig, SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
6
7
|
import type { BlockAttestation, BlockProposal, BlockProposalOptions } from '@aztec/stdlib/p2p';
|
|
7
8
|
import type { ProposedBlockHeader, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
@@ -29,7 +30,13 @@ export interface ValidatorClientConfig {
|
|
|
29
30
|
/** Whether to always reexecute block proposals, even for non-validator nodes or when out of the currnet committee */
|
|
30
31
|
alwaysReexecuteBlockProposals?: boolean;
|
|
31
32
|
}
|
|
32
|
-
export type ValidatorClientFullConfig = ValidatorClientConfig & Pick<SequencerConfig, 'txPublicSetupAllowList'> & Pick<SlasherConfig, 'slashBroadcastedInvalidBlockPenalty'
|
|
33
|
+
export type ValidatorClientFullConfig = ValidatorClientConfig & Pick<SequencerConfig, 'txPublicSetupAllowList'> & Pick<SlasherConfig, 'slashBroadcastedInvalidBlockPenalty'> & {
|
|
34
|
+
/**
|
|
35
|
+
* Whether transactions are disabled for this node
|
|
36
|
+
* @remarks This should match the property in P2PConfig. It's not picked from there to avoid circular dependencies.
|
|
37
|
+
*/
|
|
38
|
+
disableTransactions?: boolean;
|
|
39
|
+
};
|
|
33
40
|
export declare const ValidatorClientConfigSchema: z.ZodObject<{
|
|
34
41
|
validatorAddresses: z.ZodOptional<z.ZodArray<z.ZodType<EthAddress, any, string>, "many">>;
|
|
35
42
|
disableValidator: z.ZodBoolean;
|
|
@@ -55,6 +62,91 @@ export declare const ValidatorClientConfigSchema: z.ZodObject<{
|
|
|
55
62
|
validatorAddresses?: string[] | undefined;
|
|
56
63
|
alwaysReexecuteBlockProposals?: boolean | undefined;
|
|
57
64
|
}>;
|
|
65
|
+
export declare const ValidatorClientFullConfigSchema: z.ZodObject<{
|
|
66
|
+
validatorAddresses: z.ZodOptional<z.ZodArray<z.ZodType<EthAddress, any, string>, "many">>;
|
|
67
|
+
disableValidator: z.ZodBoolean;
|
|
68
|
+
disabledValidators: z.ZodArray<z.ZodType<EthAddress, any, string>, "many">;
|
|
69
|
+
attestationPollingIntervalMs: z.ZodNumber;
|
|
70
|
+
validatorReexecute: z.ZodBoolean;
|
|
71
|
+
validatorReexecuteDeadlineMs: z.ZodNumber;
|
|
72
|
+
alwaysReexecuteBlockProposals: z.ZodOptional<z.ZodBoolean>;
|
|
73
|
+
} & {
|
|
74
|
+
txPublicSetupAllowList: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
75
|
+
address: ZodFor<import("../aztec-address/index.js").AztecAddress>;
|
|
76
|
+
selector: ZodFor<import("../abi/function_selector.js").FunctionSelector>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
selector: import("../abi/function_selector.js").FunctionSelector;
|
|
79
|
+
address: import("../aztec-address/index.js").AztecAddress;
|
|
80
|
+
}, {
|
|
81
|
+
selector?: any;
|
|
82
|
+
address?: any;
|
|
83
|
+
}>, z.ZodObject<{
|
|
84
|
+
address: ZodFor<import("../aztec-address/index.js").AztecAddress>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
address: import("../aztec-address/index.js").AztecAddress;
|
|
87
|
+
}, {
|
|
88
|
+
address?: any;
|
|
89
|
+
}>, z.ZodObject<{
|
|
90
|
+
classId: ZodFor<Fr>;
|
|
91
|
+
selector: ZodFor<import("../abi/function_selector.js").FunctionSelector>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
selector: import("../abi/function_selector.js").FunctionSelector;
|
|
94
|
+
classId: Fr;
|
|
95
|
+
}, {
|
|
96
|
+
selector?: any;
|
|
97
|
+
classId?: any;
|
|
98
|
+
}>, z.ZodObject<{
|
|
99
|
+
classId: ZodFor<Fr>;
|
|
100
|
+
}, "strip", z.ZodTypeAny, {
|
|
101
|
+
classId: Fr;
|
|
102
|
+
}, {
|
|
103
|
+
classId?: any;
|
|
104
|
+
}>]>, "many">>;
|
|
105
|
+
slashBroadcastedInvalidBlockPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
106
|
+
disableTransactions: z.ZodOptional<z.ZodBoolean>;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
slashBroadcastedInvalidBlockPenalty: bigint;
|
|
109
|
+
disableValidator: boolean;
|
|
110
|
+
disabledValidators: EthAddress[];
|
|
111
|
+
attestationPollingIntervalMs: number;
|
|
112
|
+
validatorReexecute: boolean;
|
|
113
|
+
validatorReexecuteDeadlineMs: number;
|
|
114
|
+
txPublicSetupAllowList?: ({
|
|
115
|
+
selector: import("../abi/function_selector.js").FunctionSelector;
|
|
116
|
+
address: import("../aztec-address/index.js").AztecAddress;
|
|
117
|
+
} | {
|
|
118
|
+
address: import("../aztec-address/index.js").AztecAddress;
|
|
119
|
+
} | {
|
|
120
|
+
selector: import("../abi/function_selector.js").FunctionSelector;
|
|
121
|
+
classId: Fr;
|
|
122
|
+
} | {
|
|
123
|
+
classId: Fr;
|
|
124
|
+
})[] | undefined;
|
|
125
|
+
validatorAddresses?: EthAddress[] | undefined;
|
|
126
|
+
alwaysReexecuteBlockProposals?: boolean | undefined;
|
|
127
|
+
disableTransactions?: boolean | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
slashBroadcastedInvalidBlockPenalty: string | number | bigint;
|
|
130
|
+
disableValidator: boolean;
|
|
131
|
+
disabledValidators: string[];
|
|
132
|
+
attestationPollingIntervalMs: number;
|
|
133
|
+
validatorReexecute: boolean;
|
|
134
|
+
validatorReexecuteDeadlineMs: number;
|
|
135
|
+
txPublicSetupAllowList?: ({
|
|
136
|
+
selector?: any;
|
|
137
|
+
address?: any;
|
|
138
|
+
} | {
|
|
139
|
+
address?: any;
|
|
140
|
+
} | {
|
|
141
|
+
selector?: any;
|
|
142
|
+
classId?: any;
|
|
143
|
+
} | {
|
|
144
|
+
classId?: any;
|
|
145
|
+
})[] | undefined;
|
|
146
|
+
validatorAddresses?: string[] | undefined;
|
|
147
|
+
alwaysReexecuteBlockProposals?: boolean | undefined;
|
|
148
|
+
disableTransactions?: boolean | undefined;
|
|
149
|
+
}>;
|
|
58
150
|
export interface Validator {
|
|
59
151
|
start(): Promise<void>;
|
|
60
152
|
updateConfig(config: Partial<ValidatorClientFullConfig>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/interfaces/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/interfaces/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAGzE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,oBAAoB,CAAC,EAAE,WAAW,CAAC,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC;IAEpD,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,UAAU,EA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AAG,SAAS,CAAC,CAAC;IAEnG,sBAAsB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC5G,0BAA0B,CACxB,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,SAAS,CAAC,CAAC;CACvB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { schemas } from '@aztec/foundation/schemas';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { AllowedElementSchema } from './allowed_element.js';
|
|
3
4
|
export const ValidatorClientConfigSchema = z.object({
|
|
4
5
|
validatorAddresses: z.array(schemas.EthAddress).optional(),
|
|
5
6
|
disableValidator: z.boolean(),
|
|
@@ -9,3 +10,8 @@ export const ValidatorClientConfigSchema = z.object({
|
|
|
9
10
|
validatorReexecuteDeadlineMs: z.number().min(0),
|
|
10
11
|
alwaysReexecuteBlockProposals: z.boolean().optional()
|
|
11
12
|
});
|
|
13
|
+
export const ValidatorClientFullConfigSchema = ValidatorClientConfigSchema.extend({
|
|
14
|
+
txPublicSetupAllowList: z.array(AllowedElementSchema).optional(),
|
|
15
|
+
slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
|
|
16
|
+
disableTransactions: z.boolean().optional()
|
|
17
|
+
});
|
|
@@ -3,8 +3,7 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
3
3
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
6
|
-
import {
|
|
7
|
-
import type { UInt32 } from '../types/index.js';
|
|
6
|
+
import type { ZodFor } from '../schemas/index.js';
|
|
8
7
|
import { ConsensusPayload } from './consensus_payload.js';
|
|
9
8
|
import { Gossipable } from './gossipable.js';
|
|
10
9
|
import { TopicType } from './topic_type.js';
|
|
@@ -18,35 +17,36 @@ export declare class BlockAttestationHash extends Buffer32 {
|
|
|
18
17
|
* will produce a block attestation over the header of the block
|
|
19
18
|
*/
|
|
20
19
|
export declare class BlockAttestation extends Gossipable {
|
|
21
|
-
/** The block number of the attestation. */
|
|
22
|
-
readonly blockNumber: UInt32;
|
|
23
20
|
/** The payload of the message, and what the signature is over */
|
|
24
21
|
readonly payload: ConsensusPayload;
|
|
25
22
|
/** The signature of the block attester */
|
|
26
23
|
readonly signature: Signature;
|
|
24
|
+
/** The signature from the block proposer */
|
|
25
|
+
readonly proposerSignature: Signature;
|
|
27
26
|
static p2pTopic: TopicType;
|
|
28
27
|
private sender;
|
|
28
|
+
private proposer;
|
|
29
29
|
constructor(
|
|
30
|
-
/** The block number of the attestation. */
|
|
31
|
-
blockNumber: UInt32,
|
|
32
30
|
/** The payload of the message, and what the signature is over */
|
|
33
31
|
payload: ConsensusPayload,
|
|
34
32
|
/** The signature of the block attester */
|
|
35
|
-
signature: Signature
|
|
33
|
+
signature: Signature,
|
|
34
|
+
/** The signature from the block proposer */
|
|
35
|
+
proposerSignature: Signature);
|
|
36
36
|
static get schema(): ZodFor<BlockAttestation>;
|
|
37
37
|
generateP2PMessageIdentifier(): Promise<Buffer32>;
|
|
38
38
|
get archive(): Fr;
|
|
39
39
|
get slotNumber(): Fr;
|
|
40
40
|
/**
|
|
41
41
|
* Lazily evaluate and cache the signer of the attestation
|
|
42
|
-
* @returns The signer of the attestation
|
|
42
|
+
* @returns The signer of the attestation, or undefined if signature recovery fails
|
|
43
43
|
*/
|
|
44
|
-
getSender(): EthAddress;
|
|
44
|
+
getSender(): EthAddress | undefined;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
* @returns The
|
|
46
|
+
* Lazily evaluate and cache the proposer of the block
|
|
47
|
+
* @returns The proposer of the block
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
getProposer(): EthAddress | undefined;
|
|
50
50
|
getPayload(): Buffer;
|
|
51
51
|
toBuffer(): Buffer;
|
|
52
52
|
static fromBuffer(buf: Buffer | BufferReader): BlockAttestation;
|
|
@@ -54,7 +54,6 @@ export declare class BlockAttestation extends Gossipable {
|
|
|
54
54
|
static random(): BlockAttestation;
|
|
55
55
|
getSize(): number;
|
|
56
56
|
toInspect(): {
|
|
57
|
-
blockNumber: number;
|
|
58
57
|
payload: {
|
|
59
58
|
header: {
|
|
60
59
|
lastArchive: `0x${string}`;
|
|
@@ -82,6 +81,7 @@ export declare class BlockAttestation extends Gossipable {
|
|
|
82
81
|
};
|
|
83
82
|
};
|
|
84
83
|
signature: `0x${string}`;
|
|
84
|
+
proposerSignature: `0x${string}`;
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
//# sourceMappingURL=block_attestation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_attestation.d.ts","sourceRoot":"","sources":["../../src/p2p/block_attestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAI9E,OAAO,
|
|
1
|
+
{"version":3,"file":"block_attestation.d.ts","sourceRoot":"","sources":["../../src/p2p/block_attestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,EAAE,EAAE,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,IAAI,gBAAgB;IAIjC,OAAO,IAAI,MAAM;IAIjB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOV"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { keccak256,
|
|
2
|
+
import { keccak256, tryRecoverAddress } from '@aztec/foundation/crypto';
|
|
3
3
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
4
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { schemas } from '../schemas/index.js';
|
|
7
6
|
import { ConsensusPayload } from './consensus_payload.js';
|
|
8
7
|
import { Gossipable } from './gossipable.js';
|
|
9
8
|
import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js';
|
|
@@ -19,20 +18,21 @@ export class BlockAttestationHash extends Buffer32 {
|
|
|
19
18
|
* A validator that has attested to seeing the contents of a block
|
|
20
19
|
* will produce a block attestation over the header of the block
|
|
21
20
|
*/ export class BlockAttestation extends Gossipable {
|
|
22
|
-
blockNumber;
|
|
23
21
|
payload;
|
|
24
22
|
signature;
|
|
23
|
+
proposerSignature;
|
|
25
24
|
static p2pTopic = TopicType.block_attestation;
|
|
26
25
|
sender;
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
proposer;
|
|
27
|
+
constructor(/** The payload of the message, and what the signature is over */ payload, /** The signature of the block attester */ signature, /** The signature from the block proposer */ proposerSignature){
|
|
28
|
+
super(), this.payload = payload, this.signature = signature, this.proposerSignature = proposerSignature;
|
|
29
29
|
}
|
|
30
30
|
static get schema() {
|
|
31
31
|
return z.object({
|
|
32
|
-
blockNumber: schemas.UInt32,
|
|
33
32
|
payload: ConsensusPayload.schema,
|
|
34
|
-
signature: Signature.schema
|
|
35
|
-
|
|
33
|
+
signature: Signature.schema,
|
|
34
|
+
proposerSignature: Signature.schema
|
|
35
|
+
}).transform((obj)=>new BlockAttestation(obj.payload, obj.signature, obj.proposerSignature));
|
|
36
36
|
}
|
|
37
37
|
generateP2PMessageIdentifier() {
|
|
38
38
|
return Promise.resolve(new BlockAttestationHash(keccak256(this.signature.toBuffer())));
|
|
@@ -45,54 +45,56 @@ export class BlockAttestationHash extends Buffer32 {
|
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Lazily evaluate and cache the signer of the attestation
|
|
48
|
-
* @returns The signer of the attestation
|
|
48
|
+
* @returns The signer of the attestation, or undefined if signature recovery fails
|
|
49
49
|
*/ getSender() {
|
|
50
50
|
if (!this.sender) {
|
|
51
51
|
// Recover the sender from the attestation
|
|
52
52
|
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockAttestation);
|
|
53
53
|
// Cache the sender for later use
|
|
54
|
-
this.sender =
|
|
54
|
+
this.sender = tryRecoverAddress(hashed, this.signature);
|
|
55
55
|
}
|
|
56
56
|
return this.sender;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @returns The
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
* Lazily evaluate and cache the proposer of the block
|
|
60
|
+
* @returns The proposer of the block
|
|
61
|
+
*/ getProposer() {
|
|
62
|
+
if (!this.proposer) {
|
|
63
|
+
// Recover the proposer from the proposal signature
|
|
64
|
+
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
|
|
65
|
+
// Cache the proposer for later use
|
|
66
|
+
this.proposer = tryRecoverAddress(hashed, this.proposerSignature);
|
|
66
67
|
}
|
|
68
|
+
return this.proposer;
|
|
67
69
|
}
|
|
68
70
|
getPayload() {
|
|
69
71
|
return this.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation);
|
|
70
72
|
}
|
|
71
73
|
toBuffer() {
|
|
72
74
|
return serializeToBuffer([
|
|
73
|
-
this.blockNumber,
|
|
74
75
|
this.payload,
|
|
75
|
-
this.signature
|
|
76
|
+
this.signature,
|
|
77
|
+
this.proposerSignature
|
|
76
78
|
]);
|
|
77
79
|
}
|
|
78
80
|
static fromBuffer(buf) {
|
|
79
81
|
const reader = BufferReader.asReader(buf);
|
|
80
|
-
return new BlockAttestation(reader.
|
|
82
|
+
return new BlockAttestation(reader.readObject(ConsensusPayload), reader.readObject(Signature), reader.readObject(Signature));
|
|
81
83
|
}
|
|
82
84
|
static empty() {
|
|
83
|
-
return new BlockAttestation(
|
|
85
|
+
return new BlockAttestation(ConsensusPayload.empty(), Signature.empty(), Signature.empty());
|
|
84
86
|
}
|
|
85
87
|
static random() {
|
|
86
|
-
return new BlockAttestation(
|
|
88
|
+
return new BlockAttestation(ConsensusPayload.random(), Signature.random(), Signature.random());
|
|
87
89
|
}
|
|
88
90
|
getSize() {
|
|
89
|
-
return
|
|
91
|
+
return this.payload.getSize() + this.signature.getSize() + this.proposerSignature.getSize();
|
|
90
92
|
}
|
|
91
93
|
toInspect() {
|
|
92
94
|
return {
|
|
93
|
-
blockNumber: this.blockNumber,
|
|
94
95
|
payload: this.payload.toInspect(),
|
|
95
|
-
signature: this.signature.toString()
|
|
96
|
+
signature: this.signature.toString(),
|
|
97
|
+
proposerSignature: this.proposerSignature.toString()
|
|
96
98
|
};
|
|
97
99
|
}
|
|
98
100
|
}
|
|
@@ -6,7 +6,6 @@ import { BufferReader } from '@aztec/foundation/serialize';
|
|
|
6
6
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
7
7
|
import { TxHash } from '../tx/index.js';
|
|
8
8
|
import { Tx } from '../tx/tx.js';
|
|
9
|
-
import type { UInt32 } from '../types/index.js';
|
|
10
9
|
import { ConsensusPayload } from './consensus_payload.js';
|
|
11
10
|
import { Gossipable } from './gossipable.js';
|
|
12
11
|
import { TopicType } from './topic_type.js';
|
|
@@ -23,8 +22,6 @@ export type BlockProposalOptions = {
|
|
|
23
22
|
* be included in the head of the chain
|
|
24
23
|
*/
|
|
25
24
|
export declare class BlockProposal extends Gossipable {
|
|
26
|
-
/** The number of the block */
|
|
27
|
-
readonly blockNumber: UInt32;
|
|
28
25
|
/** The payload of the message, and what the signature is over */
|
|
29
26
|
readonly payload: ConsensusPayload;
|
|
30
27
|
/** The signer of the BlockProposal over the header of the new block*/
|
|
@@ -36,8 +33,6 @@ export declare class BlockProposal extends Gossipable {
|
|
|
36
33
|
static p2pTopic: TopicType;
|
|
37
34
|
private sender;
|
|
38
35
|
constructor(
|
|
39
|
-
/** The number of the block */
|
|
40
|
-
blockNumber: UInt32,
|
|
41
36
|
/** The payload of the message, and what the signature is over */
|
|
42
37
|
payload: ConsensusPayload,
|
|
43
38
|
/** The signer of the BlockProposal over the header of the new block*/
|
|
@@ -49,12 +44,13 @@ export declare class BlockProposal extends Gossipable {
|
|
|
49
44
|
generateP2PMessageIdentifier(): Promise<Buffer32>;
|
|
50
45
|
get archive(): Fr;
|
|
51
46
|
get slotNumber(): Fr;
|
|
52
|
-
toBlockInfo(): L2BlockInfo
|
|
53
|
-
static createProposalFromSigner(
|
|
47
|
+
toBlockInfo(): Omit<L2BlockInfo, 'blockNumber'>;
|
|
48
|
+
static createProposalFromSigner(payload: ConsensusPayload, txHashes: TxHash[], txs: Tx[] | undefined, payloadSigner: (payload: Buffer32) => Promise<Signature>): Promise<BlockProposal>;
|
|
54
49
|
/**Get Sender
|
|
55
50
|
* Lazily evaluate the sender of the proposal; result is cached
|
|
51
|
+
* @returns The sender address, or undefined if signature recovery fails
|
|
56
52
|
*/
|
|
57
|
-
getSender(): EthAddress;
|
|
53
|
+
getSender(): EthAddress | undefined;
|
|
58
54
|
getPayload(): Buffer<ArrayBufferLike>;
|
|
59
55
|
toBuffer(): Buffer;
|
|
60
56
|
static fromBuffer(buf: Buffer | BufferReader): BlockProposal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_proposal.d.ts","sourceRoot":"","sources":["../../src/p2p/block_proposal.ts"],"names":[],"mappings":"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;CACzB,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,UAAU;IAMzC,iEAAiE;aACjD,OAAO,EAAE,gBAAgB;IAEzC,sEAAsE;aACtD,SAAS,EAAE,SAAS;IAEpC,gDAAgD;aAChC,QAAQ,EAAE,MAAM,EAAE;IAGlC,oCAAoC;aACpB,GAAG,CAAC,EAAE,EAAE,EAAE;IAhB5B,OAAgB,QAAQ,YAA4B;IAEpD,OAAO,CAAC,MAAM,CAAyB;;IAGrC,iEAAiE;IACjD,OAAO,EAAE,gBAAgB;IAEzC,sEAAsE;IACtD,SAAS,EAAE,SAAS;IAEpC,gDAAgD;IAChC,QAAQ,EAAE,MAAM,EAAE;IAGlC,oCAAoC;IACpB,GAAG,CAAC,EAAE,EAAE,EAAE,YAAA;IAKnB,4BAA4B,IAAI,OAAO,CAAC,QAAQ,CAAC;IAI1D,IAAI,OAAO,IAAI,EAAE,CAEhB;IAED,IAAI,UAAU,IAAI,EAAE,CAEnB;IAED,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC;WAUlC,wBAAwB,CACnC,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,MAAM,EAAE,EAElB,GAAG,EAAE,EAAE,EAAE,GAAG,SAAS,EACrB,aAAa,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,SAAS,CAAC;IAQ1D;;;OAGG;IACH,SAAS,IAAI,UAAU,GAAG,SAAS;IAUnC,UAAU;IAIV,QAAQ,IAAI,MAAM;IASlB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa;IAe5D,OAAO,IAAI,MAAM;CASlB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { keccak256,
|
|
2
|
+
import { keccak256, tryRecoverAddress } from '@aztec/foundation/crypto';
|
|
3
3
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
4
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
5
|
import { TxHash } from '../tx/index.js';
|
|
@@ -19,16 +19,15 @@ export class BlockProposalHash extends Buffer32 {
|
|
|
19
19
|
* A block proposal is created by the leader of the chain proposing a sequence of transactions to
|
|
20
20
|
* be included in the head of the chain
|
|
21
21
|
*/ export class BlockProposal extends Gossipable {
|
|
22
|
-
blockNumber;
|
|
23
22
|
payload;
|
|
24
23
|
signature;
|
|
25
24
|
txHashes;
|
|
26
25
|
txs;
|
|
27
26
|
static p2pTopic = TopicType.block_proposal;
|
|
28
27
|
sender;
|
|
29
|
-
constructor(/** The
|
|
28
|
+
constructor(/** The payload of the message, and what the signature is over */ payload, /** The signer of the BlockProposal over the header of the new block*/ signature, /** The sequence of transactions in the block */ txHashes, // Note(md): this is placed after the txs payload in order to be backwards compatible with previous versions
|
|
30
29
|
/** The transactions in the block */ txs){
|
|
31
|
-
super(), this.
|
|
30
|
+
super(), this.payload = payload, this.signature = signature, this.txHashes = txHashes, this.txs = txs;
|
|
32
31
|
}
|
|
33
32
|
generateP2PMessageIdentifier() {
|
|
34
33
|
return Promise.resolve(new BlockProposalHash(keccak256(this.signature.toBuffer())));
|
|
@@ -41,7 +40,6 @@ export class BlockProposalHash extends Buffer32 {
|
|
|
41
40
|
}
|
|
42
41
|
toBlockInfo() {
|
|
43
42
|
return {
|
|
44
|
-
blockNumber: this.blockNumber,
|
|
45
43
|
slotNumber: this.slotNumber.toNumber(),
|
|
46
44
|
lastArchive: this.payload.header.lastArchiveRoot,
|
|
47
45
|
timestamp: this.payload.header.timestamp,
|
|
@@ -49,19 +47,20 @@ export class BlockProposalHash extends Buffer32 {
|
|
|
49
47
|
txCount: this.txHashes.length
|
|
50
48
|
};
|
|
51
49
|
}
|
|
52
|
-
static async createProposalFromSigner(
|
|
50
|
+
static async createProposalFromSigner(payload, txHashes, // Note(md): Provided separately to tx hashes such that this function can be optional
|
|
53
51
|
txs, payloadSigner) {
|
|
54
52
|
const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal);
|
|
55
53
|
const sig = await payloadSigner(hashed);
|
|
56
|
-
return new BlockProposal(
|
|
54
|
+
return new BlockProposal(payload, sig, txHashes, txs);
|
|
57
55
|
}
|
|
58
56
|
/**Get Sender
|
|
59
57
|
* Lazily evaluate the sender of the proposal; result is cached
|
|
58
|
+
* @returns The sender address, or undefined if signature recovery fails
|
|
60
59
|
*/ getSender() {
|
|
61
60
|
if (!this.sender) {
|
|
62
61
|
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
|
|
63
62
|
// Cache the sender for later use
|
|
64
|
-
this.sender =
|
|
63
|
+
this.sender = tryRecoverAddress(hashed, this.signature);
|
|
65
64
|
}
|
|
66
65
|
return this.sender;
|
|
67
66
|
}
|
|
@@ -70,7 +69,6 @@ export class BlockProposalHash extends Buffer32 {
|
|
|
70
69
|
}
|
|
71
70
|
toBuffer() {
|
|
72
71
|
const buffer = [
|
|
73
|
-
this.blockNumber,
|
|
74
72
|
this.payload,
|
|
75
73
|
this.signature,
|
|
76
74
|
this.txHashes.length,
|
|
@@ -84,17 +82,16 @@ export class BlockProposalHash extends Buffer32 {
|
|
|
84
82
|
}
|
|
85
83
|
static fromBuffer(buf) {
|
|
86
84
|
const reader = BufferReader.asReader(buf);
|
|
87
|
-
const blockNumber = reader.readNumber();
|
|
88
85
|
const payload = reader.readObject(ConsensusPayload);
|
|
89
86
|
const sig = reader.readObject(Signature);
|
|
90
87
|
const txHashes = reader.readArray(reader.readNumber(), TxHash);
|
|
91
88
|
if (!reader.isEmpty()) {
|
|
92
89
|
const txs = reader.readArray(reader.readNumber(), Tx);
|
|
93
|
-
return new BlockProposal(
|
|
90
|
+
return new BlockProposal(payload, sig, txHashes, txs);
|
|
94
91
|
}
|
|
95
|
-
return new BlockProposal(
|
|
92
|
+
return new BlockProposal(payload, sig, txHashes);
|
|
96
93
|
}
|
|
97
94
|
getSize() {
|
|
98
|
-
return
|
|
95
|
+
return this.payload.getSize() + this.signature.getSize() + 4 /* txHashes.length */ + this.txHashes.length * TxHash.SIZE + (this.txs ? 4 /* txs.length */ + this.txs.reduce((acc, tx)=>acc + tx.getSize(), 0) : 0);
|
|
99
96
|
}
|
|
100
97
|
}
|
package/dest/p2p/gossipable.d.ts
CHANGED
|
@@ -14,26 +14,18 @@ export declare class P2PMessage {
|
|
|
14
14
|
*/
|
|
15
15
|
export declare abstract class Gossipable {
|
|
16
16
|
private cachedId;
|
|
17
|
-
/** p2p
|
|
18
|
-
*
|
|
19
|
-
* - The p2p topic identifier, this determines how the message is handled
|
|
20
|
-
*/
|
|
17
|
+
/** The p2p topic identifier, this determines how the message is handled */
|
|
21
18
|
static p2pTopic: TopicType;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
19
|
+
/**
|
|
20
|
+
* A digest of the message information **used for logging only**.
|
|
21
|
+
* The identifier used for deduplication is `getMsgIdFn` as defined in `encoding.ts` which is a hash over topic and data.
|
|
25
22
|
*/
|
|
26
23
|
p2pMessageIdentifier(): Promise<Buffer32>;
|
|
27
24
|
abstract generateP2PMessageIdentifier(): Promise<Buffer32>;
|
|
28
|
-
/** To Buffer
|
|
29
|
-
*
|
|
30
|
-
* - Serialization method
|
|
31
|
-
*/
|
|
32
25
|
abstract toBuffer(): Buffer;
|
|
33
26
|
toMessage(): Buffer;
|
|
34
27
|
/**
|
|
35
28
|
* Get the size of the gossipable object.
|
|
36
|
-
*
|
|
37
29
|
* This is used for metrics recording.
|
|
38
30
|
*/
|
|
39
31
|
abstract getSize(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gossipable.d.ts","sourceRoot":"","sources":["../../src/p2p/gossipable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,qBAAa,UAAU;aACO,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAE3C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;IAItD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;IAMvD,aAAa,IAAI,MAAM;CAGxB;AAED;;;;GAIG;AACH,8BAAsB,UAAU;IAC9B,OAAO,CAAC,QAAQ,CAAuB;IACvC
|
|
1
|
+
{"version":3,"file":"gossipable.d.ts","sourceRoot":"","sources":["../../src/p2p/gossipable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,qBAAa,UAAU;aACO,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAE3C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;IAItD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;IAMvD,aAAa,IAAI,MAAM;CAGxB;AAED;;;;GAIG;AACH,8BAAsB,UAAU;IAC9B,OAAO,CAAC,QAAQ,CAAuB;IACvC,2EAA2E;IAC3E,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC;IAE3B;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAQ/C,QAAQ,CAAC,4BAA4B,IAAI,OAAO,CAAC,QAAQ,CAAC;IAE1D,QAAQ,CAAC,QAAQ,IAAI,MAAM;IAE3B,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,QAAQ,CAAC,OAAO,IAAI,MAAM;CAC3B"}
|
package/dest/p2p/gossipable.js
CHANGED
|
@@ -24,13 +24,10 @@ export class P2PMessage {
|
|
|
24
24
|
* Any class which extends gossipable will be able to be Gossiped over the p2p network
|
|
25
25
|
*/ export class Gossipable {
|
|
26
26
|
cachedId;
|
|
27
|
-
/** p2p
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
/** p2p Message Identifier
|
|
32
|
-
*
|
|
33
|
-
* - A digest of the message information, this key is used for deduplication
|
|
27
|
+
/** The p2p topic identifier, this determines how the message is handled */ static p2pTopic;
|
|
28
|
+
/**
|
|
29
|
+
* A digest of the message information **used for logging only**.
|
|
30
|
+
* The identifier used for deduplication is `getMsgIdFn` as defined in `encoding.ts` which is a hash over topic and data.
|
|
34
31
|
*/ async p2pMessageIdentifier() {
|
|
35
32
|
if (this.cachedId) {
|
|
36
33
|
return this.cachedId;
|
package/dest/p2p/topic_type.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { P2PClientType } from './client_type.js';
|
|
2
|
-
/** Create Topic String
|
|
3
|
-
*
|
|
4
|
-
* The topic channel identifier
|
|
5
|
-
* @param topicType
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare function createTopicString(topicType: TopicType, protocolVersion: string): string;
|
|
9
2
|
/**
|
|
10
|
-
*
|
|
3
|
+
* Creates the topic channel identifier string from a given topic type
|
|
11
4
|
*/
|
|
5
|
+
export declare function createTopicString(topicType: TopicType, protocolVersion: string): string;
|
|
6
|
+
/** Extracts the topic type from a topic string */
|
|
7
|
+
export declare function getTopicFromString(topicStr: string): TopicType | undefined;
|
|
12
8
|
export declare enum TopicType {
|
|
13
9
|
tx = "tx",
|
|
14
10
|
block_proposal = "block_proposal",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic_type.d.ts","sourceRoot":"","sources":["../../src/p2p/topic_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"topic_type.d.ts","sourceRoot":"","sources":["../../src/p2p/topic_type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAE9E;AAED,kDAAkD;AAClD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAU1E;AAED,oBAAY,SAAS;IACnB,EAAE,OAAO;IACT,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;CACxC;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,aAAa,eASlE;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAE,OAAO,eAMlG;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,MAAM,uBAO9D"}
|
package/dest/p2p/topic_type.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { P2PClientType } from './client_type.js';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* The topic channel identifier
|
|
5
|
-
* @param topicType
|
|
6
|
-
* @returns
|
|
2
|
+
/**
|
|
3
|
+
* Creates the topic channel identifier string from a given topic type
|
|
7
4
|
*/ export function createTopicString(topicType, protocolVersion) {
|
|
8
5
|
return `/aztec/${TopicType[topicType]}/${protocolVersion}`;
|
|
9
6
|
}
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
/** Extracts the topic type from a topic string */ export function getTopicFromString(topicStr) {
|
|
8
|
+
const parts = topicStr.split('/');
|
|
9
|
+
if (parts.length < 4 || parts[1] !== 'aztec') {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const topic = parts[2];
|
|
13
|
+
if (Object.values(TopicType).includes(topic)) {
|
|
14
|
+
return topic;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
export var TopicType = /*#__PURE__*/ function(TopicType) {
|
|
13
19
|
TopicType["tx"] = "tx";
|
|
14
20
|
TopicType["block_proposal"] = "block_proposal";
|
|
15
21
|
TopicType["block_attestation"] = "block_attestation";
|
|
@@ -339,7 +339,7 @@ export declare function makeVector<T extends Bufferable>(length: number, fn: (i:
|
|
|
339
339
|
export declare function makeVectorAsync<T extends Bufferable>(length: number, fn: (i: number) => Promise<T>, offset?: number): Promise<Vector<Awaited<T>>>;
|
|
340
340
|
export declare function makeMap<T>(size: number, fn: (i: number) => [string, T], offset?: number): Map<string, T>;
|
|
341
341
|
export declare function makeMapAsync<T>(size: number, fn: (i: number) => Promise<[string, T]>, offset?: number): Promise<Map<string, T>>;
|
|
342
|
-
export declare function makePublicKeys(seed?: number): PublicKeys
|
|
342
|
+
export declare function makePublicKeys(seed?: number): Promise<PublicKeys>;
|
|
343
343
|
export declare function makeContractInstanceFromClassId(classId: Fr, seed?: number, overrides?: {
|
|
344
344
|
deployer?: AztecAddress;
|
|
345
345
|
initializationHash?: Fr;
|