@@ -756,7 +756,7 @@ func (c *DBFT) verifyCommitCb(p dbft.ConsensusPayload[common.Hash]) error {
756756 switch v {
757757 case dbftutil .ExtraV0 :
758758 expectedLen = crypto .SignatureLength
759- case dbftutil .ExtraV1 :
759+ case dbftutil .ExtraV1 , dbftutil . ExtraV2 :
760760 if c .config .enforceECDSASignatures || (! isAMEV && c .chain .Config ().IsNeoXAMEV (new (big.Int ).Add (h , bigOne ))) {
761761 expectedLen = crypto .SignatureLength
762762 } else {
@@ -801,7 +801,7 @@ func (c *DBFT) verifyPrepareRequestCb(p dbft.ConsensusPayload[common.Hash]) erro
801801 // A separate check for post-NeoXAMEV block signing scheme since it depends
802802 // on runtime node configuration.
803803 extra := dbftutil .Extra (req .SealingProposal .Extra )
804- if c .chain .Config ().IsNeoXAMEV (req .SealingProposal .Number ) && extra .Version () == dbftutil .ExtraV1 {
804+ if c .chain .Config ().IsNeoXAMEV (req .SealingProposal .Number ) && ( extra .Version () == dbftutil .ExtraV1 || extra . Version () == dbftutil . ExtraV2 ) {
805805 var expected = dbftutil .ExtraV1ThresholdScheme
806806 if c .config .enforceECDSASignatures {
807807 expected = dbftutil .ExtraV1ECDSAScheme
@@ -1367,7 +1367,7 @@ func (c *DBFT) getBlockWitness(pub *tpke.PublicKey, block *Block) ([]byte, error
13671367 switch v := dbftutil .Extra (block .header .Extra ).Version (); v {
13681368 case dbftutil .ExtraV0 :
13691369 return res , nil
1370- case dbftutil .ExtraV1 :
1370+ case dbftutil .ExtraV1 , dbftutil . ExtraV2 :
13711371 // Enforce multisignature-based signing scheme for NeoXAMEV-1 height or if
13721372 // enforcing configured.
13731373 cfg := c .chain .Config ()
@@ -1403,7 +1403,7 @@ func (c *DBFT) getBlockWitness(pub *tpke.PublicKey, block *Block) ([]byte, error
14031403 c .lock .RLock ()
14041404 ks := c .amevKeystore
14051405 c .lock .RUnlock ()
1406- sig , err := ks .AggregateAndVerifySig (msg , shares )
1406+ sig , err := ks .AggregateAndVerifySig (msg , shares , v == dbftutil . ExtraV1 )
14071407 if err != nil {
14081408 return nil , fmt .Errorf ("failed to aggregate signature: %w" , err )
14091409 }
@@ -1638,20 +1638,25 @@ func (c *DBFT) verifyHeader(chain consensus.ChainHeaderReader, header *types.Hea
16381638 var (
16391639 cfg = chain .Config ()
16401640 isAMEV = cfg .IsNeoXAMEV (header .Number )
1641+ isEthSig = cfg .IsNeoXEthSig (header .Number )
16411642 isV1Extra = isAMEV || cfg .IsNeoXAMEV (new (big.Int ).Add (header .Number , bigOne ))
1643+ isV2Extra = isEthSig || cfg .IsNeoXEthSig (new (big.Int ).Add (header .Number , bigOne ))
16421644 expectedExtra = dbftutil .ExtraV0
16431645 extra = dbftutil .Extra (header .Extra )
16441646 )
16451647 if isV1Extra {
16461648 expectedExtra = dbftutil .ExtraV1
16471649 }
1650+ if isV2Extra {
1651+ expectedExtra = dbftutil .ExtraV2
1652+ }
16481653 if v := extra .Version (); v != expectedExtra {
16491654 return fmt .Errorf ("%w: expected %d, got %d" , dbftutil .ErrUnexpectedExtraVersion , expectedExtra , v )
16501655 }
16511656
16521657 // Check that extra-data contains hashable part filled.
16531658 var expectedHashableExtraLen = dbftutil .HashableExtraV0Len
1654- if isV1Extra {
1659+ if isV1Extra || isV2Extra {
16551660 expectedHashableExtraLen = dbftutil .HashableExtraV1Len
16561661 }
16571662 if len (header .Extra ) < expectedHashableExtraLen {
@@ -1664,7 +1669,7 @@ func (c *DBFT) verifyHeader(chain consensus.ChainHeaderReader, header *types.Hea
16641669 m = crypto .GetBFTHonestNodeCount (n )
16651670 expected int
16661671 )
1667- if isV1Extra {
1672+ if isV1Extra || isV2Extra {
16681673 if ! isAMEV && extra .SignatureScheme () != dbftutil .ExtraV1ECDSAScheme {
16691674 return fmt .Errorf ("%w for pre-NeoXAMEV block: expected %d, got %d" , dbftutil .ErrUnexpectedBlockSignatureScheme , dbftutil .ExtraV1ECDSAScheme , extra .SignatureScheme ())
16701675 }
@@ -1843,7 +1848,7 @@ func (c *DBFT) verifyExtra(sealHashBytes []byte, extra dbftutil.Extra, parentNex
18431848 return fmt .Errorf ("%w: %s" , errUnauthorizedSigner , err )
18441849 }
18451850 return nil
1846- case dbftutil .ExtraV1 :
1851+ case dbftutil .ExtraV1 , dbftutil . ExtraV2 :
18471852 switch ss := extra .SignatureScheme (); ss {
18481853 case dbftutil .ExtraV1ECDSAScheme :
18491854 vals , sigs , err := extra .ECDSASigners (len (c .config .StandByValidators ))
@@ -1857,7 +1862,7 @@ func (c *DBFT) verifyExtra(sealHashBytes []byte, extra dbftutil.Extra, parentNex
18571862 switch pv := parentExtra .Version (); pv {
18581863 case dbftutil .ExtraV0 :
18591864 expected = parentNextConsensus
1860- case dbftutil .ExtraV1 :
1865+ case dbftutil .ExtraV1 , dbftutil . ExtraV2 :
18611866 var offset = dbftutil .ExtraVersionLen + dbftutil .ExtraV1SignatureSchemeLen
18621867 expected .SetBytes (parentExtra [offset : offset + common .HashLength ])
18631868 default :
@@ -1887,8 +1892,7 @@ func (c *DBFT) verifyExtra(sealHashBytes []byte, extra dbftutil.Extra, parentNex
18871892 if err != nil {
18881893 return fmt .Errorf ("seal hash is not a G2 point on BLS12-381: %w" , err )
18891894 }
1890-
1891- return pub .Verify (hash , sig )
1895+ return pub .Verify (hash , sig , v == dbftutil .ExtraV1 )
18921896 default :
18931897 return fmt .Errorf ("%w: %d" , dbftutil .ErrUnexpectedBlockSignatureScheme , ss )
18941898 }
@@ -1913,14 +1917,20 @@ func (c *DBFT) Prepare(chain consensus.ChainHeaderReader, header *types.Header)
19131917 // Header's Extra (validators addresses / global TPKE pub and validators
19141918 // signatures) are treated as changeable and are not filled in during Prepare.
19151919 if chain .Config ().IsNeoXAMEV (new (big.Int ).Add (header .Number , bigOne )) {
1920+ var extraVersion dbftutil.ExtraVersion
1921+ if chain .Config ().IsNeoXEthSig (new (big.Int ).Add (header .Number , bigOne )) {
1922+ extraVersion = dbftutil .ExtraV2
1923+ } else {
1924+ extraVersion = dbftutil .ExtraV1
1925+ }
19161926 var sigScheme dbftutil.ExtraV1SignatureScheme
19171927 // Enforce multisignature block signing if we're not at NeoXAMEV yet.
19181928 if c .config .enforceECDSASignatures || ! chain .Config ().IsNeoXAMEV (header .Number ) {
19191929 sigScheme = dbftutil .ExtraV1ECDSAScheme
19201930 } else {
19211931 sigScheme = dbftutil .ExtraV1ThresholdScheme
19221932 }
1923- header .Extra = []byte {byte (dbftutil . ExtraV1 ), byte (sigScheme )}
1933+ header .Extra = []byte {byte (extraVersion ), byte (sigScheme )}
19241934 } else {
19251935 header .Extra = []byte {byte (dbftutil .ExtraV0 )}
19261936 }
@@ -2343,6 +2353,9 @@ func (c *DBFT) OnPayload(cp *dbftproto.Message) error {
23432353}
23442354
23452355func (c * DBFT ) getBlockExtraVersion (height * big.Int ) dbftutil.ExtraVersion {
2356+ if c .chain .Config ().IsNeoXEthSig (height ) || c .chain .Config ().IsNeoXEthSig (new (big.Int ).Add (height , bigOne )) {
2357+ return dbftutil .ExtraV2
2358+ }
23462359 if c .chain .Config ().IsNeoXAMEV (height ) || c .chain .Config ().IsNeoXAMEV (new (big.Int ).Add (height , bigOne )) {
23472360 return dbftutil .ExtraV1
23482361 }
@@ -2560,7 +2573,7 @@ func honestSealHash(header *types.Header) ([]byte, error) {
25602573 switch v := extra .Version (); v {
25612574 case dbftutil .ExtraV0 :
25622575 sealHash = HonestSealHashV0 (header ).Bytes ()
2563- case dbftutil .ExtraV1 :
2576+ case dbftutil .ExtraV1 , dbftutil . ExtraV2 :
25642577 switch ss := extra .SignatureScheme (); ss {
25652578 case dbftutil .ExtraV1ECDSAScheme :
25662579 sealHash = HonestSealHashV0 (header ).Bytes ()
@@ -2612,7 +2625,7 @@ func encodeSigHeader(w io.Writer, header *types.Header) {
26122625 switch v := dbftutil .Extra (header .Extra ).Version (); v {
26132626 case dbftutil .ExtraV0 :
26142627 hashableExtraLen = dbftutil .HashableExtraV0Len
2615- case dbftutil .ExtraV1 :
2628+ case dbftutil .ExtraV1 , dbftutil . ExtraV2 :
26162629 hashableExtraLen = dbftutil .HashableExtraV1Len
26172630 default :
26182631 panic (fmt .Errorf ("%w: %d" , dbftutil .ErrUnexpectedExtraVersion , v )) // a dangerous program bug
0 commit comments