@@ -44,6 +44,19 @@ interface VoteStep {
44
44
step : Step ;
45
45
}
46
46
47
+ interface SortitionRound {
48
+ height : number ;
49
+ view : number ;
50
+ }
51
+
52
+ interface PriorityInfo {
53
+ signerIdx : number ;
54
+ priority : H256 ;
55
+ subUserIdx : number ;
56
+ numberOfElections : number ;
57
+ vrfProof : Buffer ;
58
+ }
59
+
47
60
export interface ConsensusMessage {
48
61
type : "consensusmessage" ;
49
62
messages : Array < {
@@ -59,14 +72,20 @@ export interface ConsensusMessage {
59
72
export interface ProposalBlock {
60
73
type : "proposalblock" ;
61
74
signature : string ;
75
+ priorityInfo : PriorityInfo ;
62
76
view : number ;
63
77
message : Buffer ;
64
78
}
65
79
80
+ interface ProposalSummary {
81
+ priorityInfo : PriorityInfo ;
82
+ blockHash : H256 ;
83
+ }
84
+
66
85
export interface StepState {
67
86
type : "stepstate" ;
68
87
voteStep : VoteStep ;
69
- proposal : H256 | null ;
88
+ proposal : ProposalSummary | null ;
70
89
lockView : number | null ;
71
90
knownVotes : Buffer ;
72
91
}
@@ -79,8 +98,7 @@ export interface RequestMessage {
79
98
80
99
export interface RequestProposal {
81
100
type : "requestproposal" ;
82
- height : number ;
83
- view : number ;
101
+ round : SortitionRound ;
84
102
}
85
103
86
104
type MessageBody =
@@ -124,8 +142,15 @@ export class TendermintMessage {
124
142
message = {
125
143
type : "proposalblock" ,
126
144
signature : decoded [ 1 ] . toString ( "hex" ) ,
127
- view : readUIntRLP ( decoded [ 2 ] ) ,
128
- message : uncompressSync ( decoded [ 3 ] )
145
+ priorityInfo : {
146
+ signerIdx : readUIntRLP ( decoded [ 2 ] [ 0 ] ) ,
147
+ priority : new H256 ( decoded [ 2 ] [ 1 ] . toString ( "hex" ) ) ,
148
+ subUserIdx : readUIntRLP ( decoded [ 2 ] [ 2 ] ) ,
149
+ numberOfElections : readUIntRLP ( decoded [ 2 ] [ 3 ] ) ,
150
+ vrfProof : decoded [ 2 ] [ 4 ]
151
+ } ,
152
+ view : readUIntRLP ( decoded [ 3 ] ) ,
153
+ message : uncompressSync ( decoded [ 4 ] )
129
154
} ;
130
155
break ;
131
156
}
@@ -137,10 +162,20 @@ export class TendermintMessage {
137
162
view : readUIntRLP ( decoded [ 1 ] [ 1 ] ) ,
138
163
step : readUIntRLP ( decoded [ 1 ] [ 2 ] ) as Step
139
164
} ,
140
- proposal : readOptionalRlp (
141
- decoded [ 2 ] ,
142
- buffer => new H256 ( buffer . toString ( "hex" ) )
143
- ) ,
165
+ proposal : readOptionalRlp ( decoded [ 2 ] , ( buffer : any ) => {
166
+ return {
167
+ priorityInfo : {
168
+ signerIdx : readUIntRLP ( buffer [ 0 ] [ 0 ] ) ,
169
+ priority : new H256 (
170
+ buffer [ 0 ] [ 1 ] . toString ( "hex" )
171
+ ) ,
172
+ subUserIdx : readUIntRLP ( buffer [ 0 ] [ 2 ] ) ,
173
+ numberOfElections : readUIntRLP ( buffer [ 0 ] [ 3 ] ) ,
174
+ vrfProof : buffer [ 0 ] [ 4 ]
175
+ } ,
176
+ blockHash : new H256 ( buffer [ 1 ] . toString ( "hex" ) )
177
+ } ;
178
+ } ) ,
144
179
lockView : readOptionalRlp ( decoded [ 3 ] , readUIntRLP ) ,
145
180
knownVotes : decoded [ 4 ]
146
181
} ;
@@ -161,8 +196,10 @@ export class TendermintMessage {
161
196
case MessageType . MESSAGE_ID_REQUEST_PROPOSAL : {
162
197
message = {
163
198
type : "requestproposal" ,
164
- height : readUIntRLP ( decoded [ 1 ] ) ,
165
- view : readUIntRLP ( decoded [ 2 ] )
199
+ round : {
200
+ height : readUIntRLP ( decoded [ 1 ] [ 0 ] ) ,
201
+ view : readUIntRLP ( decoded [ 1 ] [ 1 ] )
202
+ }
166
203
} ;
167
204
break ;
168
205
}
@@ -210,6 +247,19 @@ export class TendermintMessage {
210
247
return [
211
248
MessageType . MESSAGE_ID_PROPOSAL_BLOCK ,
212
249
Buffer . from ( this . body . signature , "hex" ) ,
250
+ [
251
+ new U64 (
252
+ this . body . priorityInfo . signerIdx
253
+ ) . toEncodeObject ( ) ,
254
+ this . body . priorityInfo . priority . toEncodeObject ( ) ,
255
+ new U64 (
256
+ this . body . priorityInfo . subUserIdx
257
+ ) . toEncodeObject ( ) ,
258
+ new U64 (
259
+ this . body . priorityInfo . numberOfElections
260
+ ) . toEncodeObject ( ) ,
261
+ this . body . priorityInfo . vrfProof
262
+ ] ,
213
263
new U64 ( this . body . view ) . toEncodeObject ( ) ,
214
264
compressSync ( this . body . message )
215
265
] ;
@@ -224,7 +274,22 @@ export class TendermintMessage {
224
274
] ,
225
275
this . body . proposal == null
226
276
? [ ]
227
- : [ this . body . proposal . toEncodeObject ( ) ] ,
277
+ : [
278
+ [
279
+ new U64 (
280
+ this . body . proposal . priorityInfo . signerIdx
281
+ ) . toEncodeObject ( ) ,
282
+ this . body . proposal . priorityInfo . priority . toEncodeObject ( ) ,
283
+ new U64 (
284
+ this . body . proposal . priorityInfo . subUserIdx
285
+ ) . toEncodeObject ( ) ,
286
+ new U64 (
287
+ this . body . proposal . priorityInfo . numberOfElections
288
+ ) . toEncodeObject ( ) ,
289
+ this . body . proposal . priorityInfo . vrfProof
290
+ ] ,
291
+ this . body . proposal . blockHash . toEncodeObject ( )
292
+ ] ,
228
293
this . body . lockView == null
229
294
? [ ]
230
295
: [ new U64 ( this . body . lockView ) . toEncodeObject ( ) ] ,
@@ -245,8 +310,10 @@ export class TendermintMessage {
245
310
case "requestproposal" : {
246
311
return [
247
312
MessageType . MESSAGE_ID_REQUEST_PROPOSAL ,
248
- new U64 ( this . body . height ) . toEncodeObject ( ) ,
249
- new U64 ( this . body . view ) . toEncodeObject ( )
313
+ [
314
+ new U64 ( this . body . round . height ) . toEncodeObject ( ) ,
315
+ new U64 ( this . body . round . view ) . toEncodeObject ( )
316
+ ]
250
317
] ;
251
318
}
252
319
}
0 commit comments