Skip to content

Commit 91faf2c

Browse files
authored
consensus, core/typer: add 4844 excessDataGas to header, tie it to Cancun (#27046)
1 parent 9b1a82c commit 91faf2c

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

consensus/beacon/consensus.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,19 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
263263
// Verify existence / non-existence of withdrawalsHash.
264264
shanghai := chain.Config().IsShanghai(header.Time)
265265
if shanghai && header.WithdrawalsHash == nil {
266-
return fmt.Errorf("missing withdrawalsHash")
266+
return errors.New("missing withdrawalsHash")
267267
}
268268
if !shanghai && header.WithdrawalsHash != nil {
269269
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
270270
}
271+
// Verify the existence / non-existence of excessDataGas
272+
cancun := chain.Config().IsCancun(header.Time)
273+
if cancun && header.ExcessDataGas == nil {
274+
return errors.New("missing excessDataGas")
275+
}
276+
if !cancun && header.ExcessDataGas != nil {
277+
return fmt.Errorf("invalid excessDataGas: have %d, expected nil", header.ExcessDataGas)
278+
}
271279
return nil
272280
}
273281

consensus/clique/clique.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
301301
if chain.Config().IsShanghai(header.Time) {
302302
return fmt.Errorf("clique does not support shanghai fork")
303303
}
304+
if chain.Config().IsCancun(header.Time) {
305+
return fmt.Errorf("clique does not support cancun fork")
306+
}
304307
// If all checks passed, validate any special fields for hard forks
305308
if err := misc.VerifyForkHashes(chain.Config(), header, false); err != nil {
306309
return err

consensus/ethash/consensus.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
313313
if chain.Config().IsShanghai(header.Time) {
314314
return fmt.Errorf("ethash does not support shanghai fork")
315315
}
316+
if chain.Config().IsCancun(header.Time) {
317+
return fmt.Errorf("ethash does not support cancun fork")
318+
}
316319
// Verify the engine specific seal securing the block
317320
if seal {
318321
if err := ethash.verifySeal(chain, header, false); err != nil {

core/types/block.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ type Header struct {
8585
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
8686
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
8787

88+
// ExcessDataGas was added by EIP-4844 and is ignored in legacy headers.
89+
ExcessDataGas *big.Int `json:"excessDataGas" rlp:"optional"`
90+
8891
/*
8992
TODO (MariusVanDerWijden) Add this field once needed
9093
// Random was added during the merge and contains the BeaconState randomness

0 commit comments

Comments
 (0)