From 0c2d21a62ab5489cf9002c666d14847f9567753b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 4 Apr 2023 09:07:37 +0300 Subject: [PATCH] consensus, core/typer: add 4844 excessDataGas to header, tie it to Cancun --- consensus/beacon/consensus.go | 10 +++++++++- consensus/clique/clique.go | 3 +++ consensus/ethash/consensus.go | 3 +++ core/types/block.go | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index b4da9b553a7b..1129ac06c8e4 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -263,11 +263,19 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa // Verify existence / non-existence of withdrawalsHash. shanghai := chain.Config().IsShanghai(header.Time) if shanghai && header.WithdrawalsHash == nil { - return fmt.Errorf("missing withdrawalsHash") + return errors.New("missing withdrawalsHash") } if !shanghai && header.WithdrawalsHash != nil { return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash) } + // Verify the existence / non-existence of excessDataGas + cancun := chain.Config().IsCancun(header.Time) + if cancun && header.ExcessDataGas == nil { + return errors.New("missing excessDataGas") + } + if !cancun && header.ExcessDataGas != nil { + return fmt.Errorf("invalid excessDataGas: have %d, expected nil", header.ExcessDataGas) + } return nil } diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go index 6c20803b2a11..1b9a1d923690 100644 --- a/consensus/clique/clique.go +++ b/consensus/clique/clique.go @@ -301,6 +301,9 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H if chain.Config().IsShanghai(header.Time) { return fmt.Errorf("clique does not support shanghai fork") } + if chain.Config().IsCancun(header.Time) { + return fmt.Errorf("clique does not support cancun fork") + } // If all checks passed, validate any special fields for hard forks if err := misc.VerifyForkHashes(chain.Config(), header, false); err != nil { return err diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index c3c06c541cab..8f1b497cbdfb 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -313,6 +313,9 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa if chain.Config().IsShanghai(header.Time) { return fmt.Errorf("ethash does not support shanghai fork") } + if chain.Config().IsCancun(header.Time) { + return fmt.Errorf("ethash does not support cancun fork") + } // Verify the engine specific seal securing the block if seal { if err := ethash.verifySeal(chain, header, false); err != nil { diff --git a/core/types/block.go b/core/types/block.go index e2c71abebd70..a1a14f5b1657 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -85,6 +85,9 @@ type Header struct { // WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers. WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"` + // ExcessDataGas was added by EIP-4844 and is ignored in legacy headers. + ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"` + /* TODO (MariusVanDerWijden) Add this field once needed // Random was added during the merge and contains the BeaconState randomness