@@ -243,6 +243,33 @@ func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderRea
243243 }
244244 }
245245 }
246+
247+ if s .config .IsBasel (header .Number ) && header .Number .Cmp (new (big.Int ).Add (s .config .BaselBlock .Block , big .NewInt (1 ))) == 0 {
248+ posBytes := header .Extra [extraVanity : len (header .Extra )- extraSeal ]
249+ if len (posBytes ) < contractBytesLength {
250+ log .Error ("posBytes error" , "bytes" , posBytes )
251+ }
252+ addressBytes := posBytes [len (posBytes )- contractBytesLength :]
253+ contracts , err := ParseAddressBytes (addressBytes )
254+ if err != nil {
255+ log .Error ("posBytes error" , "posBytes" , posBytes , "addressBytes" , addressBytes )
256+ }
257+ snap .SystemContracts .OfficialNode = common.Address {}
258+ snap .SystemContracts .SuperNode = * contracts [2 ]
259+ }
260+
261+ if s .config .IsChaophraya (header .Number ) && (s .config .IsBasel (header .Number ) && header .Number .Cmp (s .config .BaselBlock .Block ) == 0 ) {
262+ if _ , ok := snap .Signers [signer ]; ! ok && signer != snap .SystemContracts .OfficialNode {
263+ return nil , errUnauthorizedSigner
264+ }
265+ }
266+
267+ if s .config .IsBasel (header .Number ) && header .Number .Cmp (new (big.Int ).Add (s .config .BaselBlock .Block , big .NewInt (1 ))) >= 0 {
268+ if _ , ok := snap .Signers [signer ]; ! ok && signer != snap .SystemContracts .OfficialNode && signer != snap .SystemContracts .SuperNode {
269+ return nil , errUnauthorizedSigner
270+ }
271+ }
272+
246273 if isNextBlockPoS (s .config , header .Number ) {
247274 if number > 0 && needToUpdateValidatorList (s .config , header .Number ) {
248275 posBytes := header .Extra [extraVanity : len (header .Extra )- extraSeal ]
@@ -294,34 +321,6 @@ func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderRea
294321 }
295322 }
296323
297- if s .config .IsBasel (header .Number ) && header .Number .Cmp (new (big.Int ).Add (s .config .BaselBlock .Block , big .NewInt (1 ))) == 0 {
298- posBytes := header .Extra [extraVanity : len (header .Extra )- extraSeal ]
299- if len (posBytes ) < contractBytesLength {
300- log .Error ("posBytes error" , "bytes" , posBytes )
301- // panic("invalid consensus bytes")
302- }
303- addressBytes := posBytes [len (posBytes )- contractBytesLength :]
304- contracts , err := ParseAddressBytes (addressBytes )
305- if err != nil {
306- log .Error ("posBytes error" , "posBytes" , posBytes , "addressBytes" , addressBytes )
307- // panic(err)
308- }
309- snap .SystemContracts .OfficialNode = common.Address {}
310- snap .SystemContracts .SuperNode = * contracts [2 ]
311- }
312-
313- if s .config .IsChaophraya (header .Number ) && (s .config .IsBasel (header .Number ) && header .Number .Cmp (s .config .BaselBlock .Block ) == 0 ) {
314- if _ , ok := snap .Signers [signer ]; ! ok && signer != snap .SystemContracts .OfficialNode {
315- return nil , errUnauthorizedSigner
316- }
317- }
318-
319- if s .config .IsBasel (header .Number ) && header .Number .Cmp (new (big.Int ).Add (s .config .BaselBlock .Block , big .NewInt (1 ))) >= 0 {
320- if _ , ok := snap .Signers [signer ]; ! ok && signer != snap .SystemContracts .OfficialNode && signer != snap .SystemContracts .SuperNode {
321- return nil , errUnauthorizedSigner
322- }
323- }
324-
325324 snap .Recents [number ] = signer
326325
327326 // Tally up the new vote from the signer
0 commit comments