@@ -53,7 +53,10 @@ type CompactBlock struct {
53
53
Blobs []TxMetaData `json:"blobs,omitempty"`
54
54
Signature []byte `json:"signature,omitempty"`
55
55
Proposal types.Proposal `json:"proposal,omitempty"`
56
- LastLen uint32 // length of the last part
56
+ // length of the last part
57
+ LastLen uint32 `json:"last_len,omitempty"`
58
+ // the original part set parts hashes.
59
+ PartsHashes [][]byte `json:"parts_hashes,omitempty"`
57
60
}
58
61
59
62
// ValidateBasic checks if the CompactBlock is valid. It fails if the height is
@@ -71,6 +74,11 @@ func (c *CompactBlock) ValidateBasic() error {
71
74
if len (c .Signature ) > types .MaxSignatureSize {
72
75
return errors .New ("CompactBlock: Signature is too big" )
73
76
}
77
+ for index , partHash := range c .PartsHashes {
78
+ if err := types .ValidateHash (partHash ); err != nil {
79
+ return fmt .Errorf ("invalid part hash height %d round %d index %d: %w" , c .Proposal .Height , c .Proposal .Round , index , err )
80
+ }
81
+ }
74
82
return nil
75
83
}
76
84
@@ -81,11 +89,12 @@ func (c *CompactBlock) ToProto() *protoprop.CompactBlock {
81
89
blobs [i ] = blob .ToProto ()
82
90
}
83
91
return & protoprop.CompactBlock {
84
- BpHash : c .BpHash ,
85
- Blobs : blobs ,
86
- Signature : c .Signature ,
87
- Proposal : c .Proposal .ToProto (),
88
- LastLength : c .LastLen ,
92
+ BpHash : c .BpHash ,
93
+ Blobs : blobs ,
94
+ Signature : c .Signature ,
95
+ Proposal : c .Proposal .ToProto (),
96
+ LastLength : c .LastLen ,
97
+ PartsHashes : c .PartsHashes ,
89
98
}
90
99
}
91
100
@@ -102,10 +111,12 @@ func CompactBlockFromProto(c *protoprop.CompactBlock) (*CompactBlock, error) {
102
111
}
103
112
104
113
cb := & CompactBlock {
105
- BpHash : c .BpHash ,
106
- Blobs : blobs ,
107
- Signature : c .Signature ,
108
- Proposal : * prop ,
114
+ BpHash : c .BpHash ,
115
+ Blobs : blobs ,
116
+ Signature : c .Signature ,
117
+ Proposal : * prop ,
118
+ LastLen : c .LastLength ,
119
+ PartsHashes : c .PartsHashes ,
109
120
}
110
121
return cb , cb .ValidateBasic ()
111
122
}
@@ -312,11 +323,12 @@ func MsgFromProto(p *protoprop.Message) (Message, error) {
312
323
return nil , err
313
324
}
314
325
pb = & CompactBlock {
315
- BpHash : msg .BpHash ,
316
- Blobs : blobs ,
317
- Signature : msg .Signature ,
318
- Proposal : * prop ,
319
- LastLen : msg .LastLength ,
326
+ BpHash : msg .BpHash ,
327
+ Blobs : blobs ,
328
+ Signature : msg .Signature ,
329
+ Proposal : * prop ,
330
+ LastLen : msg .LastLength ,
331
+ PartsHashes : msg .PartsHashes ,
320
332
}
321
333
case * protoprop.PartMetaData :
322
334
pb = & PartMetaData {
0 commit comments