@@ -33,6 +33,7 @@ import (
3333 "github.com/ethereum/go-ethereum/crypto"
3434 "github.com/ethereum/go-ethereum/rlp"
3535 "github.com/polynetwork/poly/common"
36+ "github.com/polynetwork/poly/common/config"
3637 "github.com/polynetwork/poly/common/log"
3738 cstates "github.com/polynetwork/poly/core/states"
3839 "github.com/polynetwork/poly/native"
@@ -608,7 +609,13 @@ func validateHeaderExtraFieldWithSpan(native *native.NativeService, headerWOP *H
608609 return nil
609610}
610611
612+ // only used for test
613+ var skipVerifySpan bool
614+
611615func validateHeaderExtraField (native * native.NativeService , headerWOP * HeaderWithOptionalProof , ctx * Context ) (err error ) {
616+ if skipVerifySpan {
617+ return
618+ }
612619 if headerWOP .Proof == nil {
613620 var span * Span
614621 span , err = getSpan (native , ctx )
@@ -715,9 +722,17 @@ func validatorContains(a []*Validator, x *Validator) (*Validator, bool) {
715722 return nil , false
716723}
717724
725+ func shouldApplyFix (currentChainID uint64 ) bool {
726+ chainID := config .GetPolygonSnapChainID (config .DefConfig .P2PNode .NetworkId )
727+ return uint32 (currentChainID ) != chainID
728+ }
729+
718730func getSnapshot (native * native.NativeService , parent * HeaderWithDifficultySum , ctx * Context ) (s * Snapshot , err error ) {
719731 if parent .HeaderWithOptionalSnap .Snapshot != nil {
720732 s = parent .HeaderWithOptionalSnap .Snapshot
733+ if shouldApplyFix (ctx .ChainID ) {
734+ err = s .ValidatorSet .updateTotalVotingPower ()
735+ }
721736 return
722737 }
723738
@@ -736,6 +751,9 @@ func getSnapshot(native *native.NativeService, parent *HeaderWithDifficultySum,
736751 }
737752
738753 s = snapHeader .HeaderWithOptionalSnap .Snapshot
754+ if shouldApplyFix (ctx .ChainID ) {
755+ err = s .ValidatorSet .updateTotalVotingPower ()
756+ }
739757 return
740758}
741759
0 commit comments