Skip to content

Commit

Permalink
fix: ensure EIP-4788 not supported with Parlia Engine (#2268)
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 authored Mar 11, 2024
1 parent def3512 commit 16c6e46
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
12 changes: 0 additions & 12 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,18 +605,6 @@ func (p *Parlia) verifyHeader(chain consensus.ChainHeaderReader, header *types.H
}
}

if !cancun && header.ExcessBlobGas != nil {
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
}
if !cancun && header.BlobGasUsed != nil {
return fmt.Errorf("invalid blobGasUsed: have %d, expected nil", header.BlobGasUsed)
}
if cancun {
if err := eip4844.VerifyEIP4844Header(parent, header); err != nil {
return err
}
}

// All basic checks passed, verify cascading fields
return p.verifyCascadingFields(chain, header, parents)
}
Expand Down
4 changes: 3 additions & 1 deletion core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ func (cm *chainMaker) makeHeader(parent *types.Block, state *state.StateDB, engi
excessBlobGas := eip4844.CalcExcessBlobGas(parentExcessBlobGas, parentBlobGasUsed)
header.ExcessBlobGas = &excessBlobGas
header.BlobGasUsed = new(uint64)
header.ParentBeaconRoot = new(common.Hash)
if cm.config.Parlia == nil {
header.ParentBeaconRoot = new(common.Hash)
}
}
return header
}
Expand Down
5 changes: 4 additions & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,10 @@ func (g *Genesis) ToBlock() *types.Block {
// EIP-4788: The parentBeaconBlockRoot of the genesis block is always
// the zero hash. This is because the genesis block does not have a parent
// by definition.
head.ParentBeaconRoot = new(common.Hash)
if conf.Parlia == nil {
head.ParentBeaconRoot = new(common.Hash)
}

// EIP-4844 fields
head.ExcessBlobGas = g.ExcessBlobGas
head.BlobGasUsed = g.BlobGasUsed
Expand Down
4 changes: 3 additions & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,9 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
header.BlobGasUsed = &used

beaconRoot := common.HexToHash("0xbeac00")
header.ParentBeaconRoot = &beaconRoot
if config.Parlia == nil {
header.ParentBeaconRoot = &beaconRoot
}
}
// Assemble and return the final block for sealing
if config.IsShanghai(header.Number, header.Time) {
Expand Down
4 changes: 3 additions & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,9 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
}
header.BlobGasUsed = new(uint64)
header.ExcessBlobGas = &excessBlobGas
header.ParentBeaconRoot = genParams.beaconRoot
if w.chainConfig.Parlia == nil {
header.ParentBeaconRoot = genParams.beaconRoot
}
}
// Run the consensus preparation with the default or customized consensus engine.
if err := w.engine.Prepare(w.chain, header); err != nil {
Expand Down

0 comments on commit 16c6e46

Please sign in to comment.