Skip to content

Commit 9fabab4

Browse files
committed
update TimeoutCertificate and Header/Block ID
1 parent dc9a3c9 commit 9fabab4

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

state/convert.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
119140
func 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)

state/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ func (i *Indexer) nextBackoff(d time.Duration) time.Duration {
626626
func (i *Indexer) onBlockFinalized(f *hotstuff.Block) {
627627
log.Infof(
628628
"Got finalized block via consensus follower: %x (block timestamp: %s)",
629-
f.BlockID[:], f.Timestamp.Format(time.RFC3339),
629+
f.BlockID[:], time.UnixMilli(int64(f.Timestamp)).Format(time.RFC3339),
630630
)
631631
}
632632

0 commit comments

Comments
 (0)