@@ -20,20 +20,21 @@ func (x *XDPoS_v2) VerifyTimeoutMessage(chain consensus.ChainReader, timeoutMsg
2020 log .Debug ("[VerifyTimeoutMessage] Disqualified timeout message as the proposed round does not match currentRound" , "timeoutHash" , timeoutMsg .Hash (), "timeoutRound" , timeoutMsg .Round , "currentRound" , x .currentRound )
2121 return false , nil
2222 }
23- snap , err := x . getSnapshot ( chain , timeoutMsg . GapNumber , true )
24- if err != nil || snap == nil {
25- log . Error ( "[VerifyTimeoutMessage] Fail to get snapshot when verifying timeout message!" , "messageGapNumber" , timeoutMsg . GapNumber , "err" , err )
23+
24+ epochInfo , err := x . getEpochSwitchInfo ( chain , chain . CurrentHeader (), chain . CurrentHeader (). Hash ())
25+ if err != nil {
2626 return false , err
2727 }
28- if len (snap .NextEpochCandidates ) == 0 {
28+
29+ if len (epochInfo .Masternodes ) == 0 {
2930 log .Error ("[VerifyTimeoutMessage] cannot find NextEpochCandidates from snapshot" , "messageGapNumber" , timeoutMsg .GapNumber )
3031 return false , errors .New ("empty master node lists from snapshot" )
3132 }
3233
3334 verified , signer , err := x .verifyMsgSignature (types .TimeoutSigHash (& types.TimeoutForSign {
3435 Round : timeoutMsg .Round ,
3536 GapNumber : timeoutMsg .GapNumber ,
36- }), timeoutMsg .Signature , snap . NextEpochCandidates )
37+ }), timeoutMsg .Signature , epochInfo . Masternodes )
3738
3839 if err != nil {
3940 log .Warn ("[VerifyTimeoutMessage] cannot verify timeout signature" , "err" , err )
@@ -157,16 +158,6 @@ func (x *XDPoS_v2) verifyTC(chain consensus.ChainReader, timeoutCert *types.Time
157158 return utils .ErrInvalidTC
158159 }
159160
160- snap , err := x .getSnapshot (chain , timeoutCert .GapNumber , true )
161- if err != nil {
162- log .Error ("[verifyTC] Fail to get snapshot when verifying TC!" , "tcGapNumber" , timeoutCert .GapNumber )
163- return fmt .Errorf ("[verifyTC] Unable to get snapshot, %s" , err )
164- }
165- if snap == nil || len (snap .NextEpochCandidates ) == 0 {
166- log .Error ("[verifyTC] Something wrong with the snapshot from gapNumber" , "messageGapNumber" , timeoutCert .GapNumber , "snapshot" , snap )
167- return errors .New ("empty master node lists from snapshot" )
168- }
169-
170161 signatures , duplicates := UniqueSignatures (timeoutCert .Signatures )
171162 if len (duplicates ) != 0 {
172163 for _ , d := range duplicates {
@@ -199,7 +190,7 @@ func (x *XDPoS_v2) verifyTC(chain consensus.ChainReader, timeoutCert *types.Time
199190 for _ , signature := range signatures {
200191 go func (sig types.Signature ) {
201192 defer wg .Done ()
202- verified , _ , err := x .verifyMsgSignature (signedTimeoutObj , sig , snap . NextEpochCandidates )
193+ verified , _ , err := x .verifyMsgSignature (signedTimeoutObj , sig , epochInfo . Masternodes )
203194 if err != nil || ! verified {
204195 log .Error ("[verifyTC] Error or verification failure" , "signature" , sig , "error" , err )
205196 mutex .Lock () // Lock before accessing haveError
0 commit comments