Skip to content

Commit

Permalink
consensus/beacon: Add parent hash check to OpLegacy.VerifyHeader
Browse files Browse the repository at this point in the history
VerifyHeaders will be dealt with in a follow-up.
  • Loading branch information
sebastianst committed Jan 11, 2024
1 parent d2b034e commit fb9c707
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions consensus/beacon/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var (
// is only used for necessary consensus checks. The legacy consensus engine can be any
// engine implements the consensus interface (except the beacon itself).
type Beacon struct {
// For migrated OP chains (OP mainnet, OP Goerli), ethone is a dummy legacy pre-Bedrock consensus
ethone consensus.Engine // Original consensus engine used in eth1, e.g. ethash or clique
}

Expand Down
13 changes: 9 additions & 4 deletions consensus/beacon/oplegacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@ package beacon

import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc"
"math/big"
)

type OpLegacy struct {
}
type OpLegacy struct{}

func (o *OpLegacy) Author(header *types.Header) (common.Address, error) {
return header.Coinbase, nil
}

func (o *OpLegacy) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header) error {
return nil // legacy chain is verified by block-hash reverse sync
// redundant check to guarantee DB consistency
parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1)
if parent == nil {
return consensus.ErrUnknownAncestor
}
return nil // legacy chain is verified by block-hash reverse sync otherwise
}

func (o *OpLegacy) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) (chan<- struct{}, <-chan error) {
Expand Down

0 comments on commit fb9c707

Please sign in to comment.