mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Introduce VerifyAbsenceOfCancunHeaderFields (#7953)
This commit is contained in:
parent
3e5b9d7490
commit
50579425d2
@ -122,11 +122,9 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
|
||||
// Verify the header's EIP-1559 attributes.
|
||||
return err
|
||||
}
|
||||
if header.BlobGasUsed != nil {
|
||||
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
|
||||
}
|
||||
if header.ExcessBlobGas != nil {
|
||||
return fmt.Errorf("invalid excessBlobGas before fork: have %v, expected 'nil'", header.ExcessBlobGas)
|
||||
|
||||
if err := misc.VerifyAbsenceOfCancunHeaderFields(header); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Retrieve the snapshot needed to verify this header and cache it
|
||||
|
@ -235,11 +235,9 @@ func VerifyHeaderBasics(chain consensus.ChainHeaderReader, header, parent *types
|
||||
// Verify the header's EIP-1559 attributes.
|
||||
return err
|
||||
}
|
||||
if header.BlobGasUsed != nil {
|
||||
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
|
||||
}
|
||||
if header.ExcessBlobGas != nil {
|
||||
return fmt.Errorf("invalid excessBlobGas before fork: have %v, expected 'nil'", header.ExcessBlobGas)
|
||||
|
||||
if err := misc.VerifyAbsenceOfCancunHeaderFields(header); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Verify that the block number is parent's +1
|
||||
|
@ -243,29 +243,11 @@ func (s *Merge) verifyHeader(chain consensus.ChainHeaderReader, header, parent *
|
||||
}
|
||||
|
||||
cancun := chain.Config().IsCancun(header.Time)
|
||||
|
||||
if !cancun {
|
||||
if header.BlobGasUsed != nil {
|
||||
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
|
||||
}
|
||||
if header.ExcessBlobGas != nil {
|
||||
return fmt.Errorf("invalid excessBlobGas before fork: have %v, expected 'nil'", header.ExcessBlobGas)
|
||||
}
|
||||
}
|
||||
|
||||
if cancun {
|
||||
if err := misc.VerifyEip4844Header(chain.Config(), parent, header); err != nil {
|
||||
// Verify the header's EIP-4844 attributes.
|
||||
return err
|
||||
}
|
||||
if header.ParentBeaconBlockRoot == nil {
|
||||
return fmt.Errorf("missing parentBeaconBlockRoot")
|
||||
}
|
||||
if header.ParentBeaconBlockRoot != chain.CurrentHeader().ParentBeaconBlockRoot {
|
||||
return fmt.Errorf("parentBeaconBlockRoot mismatch")
|
||||
}
|
||||
return misc.VerifyPresenceOfCancunHeaderFields(header)
|
||||
} else {
|
||||
return misc.VerifyAbsenceOfCancunHeaderFields(header)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Merge) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
|
||||
|
@ -21,7 +21,6 @@ import (
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
@ -72,14 +71,31 @@ func FakeExponential(factor, denom *uint256.Int, excessBlobGas uint64) (*uint256
|
||||
return output.Div(output, denom), nil
|
||||
}
|
||||
|
||||
// VerifyEip4844Header verifies that the header is not malformed
|
||||
func VerifyEip4844Header(config *chain.Config, parent, header *types.Header) error {
|
||||
// VerifyPresenceOfCancunHeaderFields checks that the fields introduced in Cancun (EIP-4844, EIP-4788) are present.
|
||||
func VerifyPresenceOfCancunHeaderFields(header *types.Header) error {
|
||||
if header.BlobGasUsed == nil {
|
||||
return fmt.Errorf("header is missing blobGasUsed")
|
||||
}
|
||||
if header.ExcessBlobGas == nil {
|
||||
return fmt.Errorf("header is missing excessBlobGas")
|
||||
}
|
||||
if header.ParentBeaconBlockRoot == nil {
|
||||
return fmt.Errorf("header is missing parentBeaconBlockRoot")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// VerifyAbsenceOfCancunHeaderFields checks that the header doesn't have any fields added in Cancun (EIP-4844, EIP-4788).
|
||||
func VerifyAbsenceOfCancunHeaderFields(header *types.Header) error {
|
||||
if header.BlobGasUsed != nil {
|
||||
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
|
||||
}
|
||||
if header.ExcessBlobGas != nil {
|
||||
return fmt.Errorf("invalid excessBlobGas before fork: have %v, expected 'nil'", header.ExcessBlobGas)
|
||||
}
|
||||
if header.ParentBeaconBlockRoot != nil {
|
||||
return fmt.Errorf("invalid parentBeaconBlockRoot before fork: have %v, expected 'nil'", header.ParentBeaconBlockRoot)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user