@@ -112,10 +112,31 @@ func deriveBlockHash(spork *config.Spork, hdr flowHeader) flow.Identifier {
112112 return deriveBlockHashV3 (hdr )
113113 case 5 , 6 , 7 :
114114 return deriveBlockHashV5 (hdr )
115+ case 8 :
116+ return deriveBlockHashV8 (hdr )
115117 }
116118 panic ("unreachable code" )
117119}
118120
121+ func deriveTimeoutCertificateHashV5 (tc * flow.TimeoutCertificate ) flow.Identifier {
122+ if tc == nil {
123+ return flow .ZeroID
124+ }
125+ return flow .MakeID (struct {
126+ View uint64
127+ NewestQCViews []uint64
128+ NewestQCID flow.Identifier
129+ SignerIndices []byte
130+ SigData crypto.Signature
131+ }{
132+ View : tc .View ,
133+ NewestQCViews : tc .NewestQCViews ,
134+ NewestQCID : tc .NewestQC .ID (),
135+ SignerIndices : tc .SignerIndices ,
136+ SigData : tc .SigData ,
137+ })
138+ }
139+
119140func deriveBlockHashV1 (hdr flowHeader ) flow.Identifier {
120141 dst := struct {
121142 ChainID flow.ChainID
@@ -190,6 +211,35 @@ func deriveBlockHashV5(hdr flowHeader) flow.Identifier {
190211 ParentVoterIndices : hdr .ParentVoterIndices ,
191212 ParentVoterSigData : hdr .ParentVoterSigData ,
192213 ProposerID : hdr .ProposerID ,
214+ LastViewTCID : deriveTimeoutCertificateHashV5 (hdr .LastViewTC ),
215+ }
216+ return flow .MakeID (dst )
217+ }
218+
219+ func deriveBlockHashV8 (hdr flowHeader ) flow.Identifier {
220+ dst := struct {
221+ ChainID flow.ChainID
222+ ParentID flow.Identifier
223+ Height uint64
224+ PayloadHash flow.Identifier
225+ Timestamp uint64
226+ View uint64
227+ ParentView uint64
228+ ParentVoterIndices []byte
229+ ParentVoterSigData []byte
230+ ProposerID flow.Identifier
231+ LastViewTCID flow.Identifier
232+ }{
233+ ChainID : hdr .ChainID ,
234+ ParentID : hdr .ParentID ,
235+ Height : hdr .Height ,
236+ PayloadHash : hdr .PayloadHash ,
237+ Timestamp : uint64 (hdr .Timestamp .UnixMilli ()),
238+ View : hdr .View ,
239+ ParentView : hdr .ParentView ,
240+ ParentVoterIndices : hdr .ParentVoterIndices ,
241+ ParentVoterSigData : hdr .ParentVoterSigData ,
242+ ProposerID : hdr .ProposerID ,
193243 LastViewTCID : hdr .LastViewTC .ID (),
194244 }
195245 return flow .MakeID (dst )
0 commit comments