consensus: verify the nonexistence of shanghai- and cancun-specific header fields (#28605)
This commit is contained in:
parent
34dcd74935
commit
e0c7ad01ab
|
@ -302,9 +302,22 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
|
|||
if chain.Config().IsShanghai(header.Number, header.Time) {
|
||||
return errors.New("clique does not support shanghai fork")
|
||||
}
|
||||
// Verify the non-existence of withdrawalsHash.
|
||||
if header.WithdrawalsHash != nil {
|
||||
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
|
||||
}
|
||||
if chain.Config().IsCancun(header.Number, header.Time) {
|
||||
return errors.New("clique does not support cancun fork")
|
||||
}
|
||||
// Verify the non-existence of cancun-specific header fields
|
||||
switch {
|
||||
case header.ExcessBlobGas != nil:
|
||||
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
|
||||
case header.BlobGasUsed != nil:
|
||||
return fmt.Errorf("invalid blobGasUsed: have %d, expected nil", header.BlobGasUsed)
|
||||
case header.ParentBeaconRoot != nil:
|
||||
return fmt.Errorf("invalid parentBeaconRoot, have %#x, expected nil", header.ParentBeaconRoot)
|
||||
}
|
||||
// All basic checks passed, verify cascading fields
|
||||
return c.verifyCascadingFields(chain, header, parents)
|
||||
}
|
||||
|
@ -753,6 +766,15 @@ func encodeSigHeader(w io.Writer, header *types.Header) {
|
|||
if header.WithdrawalsHash != nil {
|
||||
panic("unexpected withdrawal hash value in clique")
|
||||
}
|
||||
if header.ExcessBlobGas != nil {
|
||||
panic("unexpected excess blob gas value in clique")
|
||||
}
|
||||
if header.BlobGasUsed != nil {
|
||||
panic("unexpected blob gas used value in clique")
|
||||
}
|
||||
if header.ParentBeaconRoot != nil {
|
||||
panic("unexpected parent beacon root value in clique")
|
||||
}
|
||||
if err := rlp.Encode(w, enc); err != nil {
|
||||
panic("can't encode: " + err.Error())
|
||||
}
|
||||
|
|
|
@ -266,9 +266,22 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
|
|||
if chain.Config().IsShanghai(header.Number, header.Time) {
|
||||
return errors.New("ethash does not support shanghai fork")
|
||||
}
|
||||
// Verify the non-existence of withdrawalsHash.
|
||||
if header.WithdrawalsHash != nil {
|
||||
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
|
||||
}
|
||||
if chain.Config().IsCancun(header.Number, header.Time) {
|
||||
return errors.New("ethash does not support cancun fork")
|
||||
}
|
||||
// Verify the non-existence of cancun-specific header fields
|
||||
switch {
|
||||
case header.ExcessBlobGas != nil:
|
||||
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
|
||||
case header.BlobGasUsed != nil:
|
||||
return fmt.Errorf("invalid blobGasUsed: have %d, expected nil", header.BlobGasUsed)
|
||||
case header.ParentBeaconRoot != nil:
|
||||
return fmt.Errorf("invalid parentBeaconRoot, have %#x, expected nil", header.ParentBeaconRoot)
|
||||
}
|
||||
// Add some fake checks for tests
|
||||
if ethash.fakeDelay != nil {
|
||||
time.Sleep(*ethash.fakeDelay)
|
||||
|
@ -533,6 +546,15 @@ func (ethash *Ethash) SealHash(header *types.Header) (hash common.Hash) {
|
|||
if header.WithdrawalsHash != nil {
|
||||
panic("withdrawal hash set on ethash")
|
||||
}
|
||||
if header.ExcessBlobGas != nil {
|
||||
panic("excess blob gas set on ethash")
|
||||
}
|
||||
if header.BlobGasUsed != nil {
|
||||
panic("blob gas used set on ethash")
|
||||
}
|
||||
if header.ParentBeaconRoot != nil {
|
||||
panic("parent beacon root set on ethash")
|
||||
}
|
||||
rlp.Encode(hasher, enc)
|
||||
hasher.Sum(hash[:0])
|
||||
return hash
|
||||
|
|
Loading…
Reference in New Issue