-
Notifications
You must be signed in to change notification settings - Fork 458
/
schemas.ts
207 lines (195 loc) · 4.93 KB
/
schemas.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
* Copyright © 2021 Lisk Foundation
*
* See the LICENSE file at the top-level directory of this distribution
* for licensing information.
*
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
* no part of this software, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE file.
*
* Removal or modification of this copyright notice is prohibited.
*/
import { Validator } from '../../abi';
import { BLS_PUBLIC_KEY_LENGTH, ED25519_PUBLIC_KEY_LENGTH } from './constants';
export interface BFTParameters {
prevoteThreshold: bigint;
precommitThreshold: bigint;
certificateThreshold: bigint;
validators: Validator[];
validatorsHash: Buffer;
}
export const bftParametersSchema = {
$id: '/modules/bft/bftParameters',
type: 'object',
required: [
'prevoteThreshold',
'precommitThreshold',
'certificateThreshold',
'validators',
'validatorsHash',
],
properties: {
prevoteThreshold: {
dataType: 'uint64',
fieldNumber: 1,
},
precommitThreshold: {
dataType: 'uint64',
fieldNumber: 2,
},
certificateThreshold: {
dataType: 'uint64',
fieldNumber: 3,
},
validators: {
type: 'array',
fieldNumber: 4,
items: {
type: 'object',
required: ['address', 'bftWeight', 'generatorKey', 'blsKey'],
properties: {
address: {
dataType: 'bytes',
format: 'lisk32',
fieldNumber: 1,
},
bftWeight: {
dataType: 'uint64',
fieldNumber: 2,
},
generatorKey: {
dataType: 'bytes',
fieldNumber: 3,
minLength: ED25519_PUBLIC_KEY_LENGTH,
maxLength: ED25519_PUBLIC_KEY_LENGTH,
},
blsKey: {
dataType: 'bytes',
fieldNumber: 4,
minLength: BLS_PUBLIC_KEY_LENGTH,
maxLength: BLS_PUBLIC_KEY_LENGTH,
},
},
},
},
validatorsHash: {
dataType: 'bytes',
fieldNumber: 5,
},
},
};
export interface BFTVotesBlockInfo {
height: number;
generatorAddress: Buffer;
maxHeightGenerated: number;
maxHeightPrevoted: number;
prevoteWeight: bigint;
precommitWeight: bigint;
}
export interface BFTVotesActiveValidatorsVoteInfo {
address: Buffer;
minActiveHeight: number;
largestHeightPrecommit: number;
}
export interface BFTVotes {
maxHeightPrevoted: number;
maxHeightPrecommitted: number;
maxHeightCertified: number;
blockBFTInfos: BFTVotesBlockInfo[];
activeValidatorsVoteInfo: BFTVotesActiveValidatorsVoteInfo[];
}
export const bftVotesSchema = {
$id: '/modules/bft/bftVotes',
type: 'object',
required: [
'maxHeightPrevoted',
'maxHeightPrecommitted',
'maxHeightCertified',
'blockBFTInfos',
'activeValidatorsVoteInfo',
],
properties: {
maxHeightPrevoted: { dataType: 'uint32', fieldNumber: 1 },
maxHeightPrecommitted: { dataType: 'uint32', fieldNumber: 2 },
maxHeightCertified: { dataType: 'uint32', fieldNumber: 3 },
blockBFTInfos: {
type: 'array',
fieldNumber: 4,
items: {
type: 'object',
required: [
'height',
'generatorAddress',
'maxHeightGenerated',
'maxHeightPrevoted',
'prevoteWeight',
'precommitWeight',
],
properties: {
height: { dataType: 'uint32', fieldNumber: 1 },
generatorAddress: { dataType: 'bytes', fieldNumber: 2 },
maxHeightGenerated: { dataType: 'uint32', fieldNumber: 3 },
maxHeightPrevoted: { dataType: 'uint32', fieldNumber: 4 },
prevoteWeight: { dataType: 'uint64', fieldNumber: 5 },
precommitWeight: { dataType: 'uint64', fieldNumber: 6 },
},
},
},
activeValidatorsVoteInfo: {
type: 'array',
fieldNumber: 5,
items: {
type: 'object',
required: ['address', 'minActiveHeight', 'largestHeightPrecommit'],
properties: {
address: { dataType: 'bytes', fieldNumber: 1 },
minActiveHeight: { dataType: 'uint32', fieldNumber: 2 },
largestHeightPrecommit: { dataType: 'uint32', fieldNumber: 3 },
},
},
},
},
};
export interface ValidatorsHashInfo {
blsKey: Buffer;
bftWeight: bigint;
}
export interface ValidatorsHashInput {
activeValidators: ValidatorsHashInfo[];
certificateThreshold: bigint;
}
export const validatorsHashInputSchema = {
$id: '/modules/bft/validatorsHashInput',
type: 'object',
required: ['activeValidators', 'certificateThreshold'],
properties: {
activeValidators: {
type: 'array',
fieldNumber: 1,
items: {
type: 'object',
required: ['blsKey', 'bftWeight'],
properties: {
blsKey: { dataType: 'bytes', fieldNumber: 1 },
bftWeight: { dataType: 'uint64', fieldNumber: 2 },
},
},
},
certificateThreshold: { dataType: 'uint64', fieldNumber: 2 },
},
};
export interface AreHeadersContradictingRequest {
header1: string;
header2: string;
}
export const areHeadersContradictingRequestSchema = {
$id: '/modules/bft/areHeadersContradictingRequest',
type: 'object',
required: ['header1', 'header2'],
properties: {
header1: { type: 'string', format: 'hex' },
header2: { type: 'string', format: 'hex' },
},
};