-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consensus: handle legacy pre-bedrock header verification
- Loading branch information
1 parent
8e15470
commit 07b934f
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package beacon | ||
|
||
import ( | ||
"fmt" | ||
"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 { | ||
} | ||
|
||
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 | ||
} | ||
|
||
func (o *OpLegacy) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) (chan<- struct{}, <-chan error) { | ||
quit := make(chan struct{}, 1) | ||
result := make(chan error, len(headers)) | ||
for range headers { | ||
result <- nil | ||
} | ||
return quit, result | ||
} | ||
|
||
func (o *OpLegacy) VerifyUncles(chain consensus.ChainReader, block *types.Block) error { | ||
return nil | ||
} | ||
|
||
func (o *OpLegacy) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error { | ||
return fmt.Errorf("cannot prepare for legacy block header: %s (num %d)", header.Hash(), header.Number) | ||
} | ||
|
||
func (o *OpLegacy) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, withdrawals []*types.Withdrawal) { | ||
panic(fmt.Errorf("cannot finalize legacy block header: %s (num %d)", header.Hash(), header.Number)) | ||
} | ||
|
||
func (o *OpLegacy) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt, withdrawals []*types.Withdrawal) (*types.Block, error) { | ||
return nil, fmt.Errorf("cannot finalize and assemble for legacy block header: %s (num %d)", header.Hash(), header.Number) | ||
} | ||
|
||
func (o *OpLegacy) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error { | ||
return fmt.Errorf("cannot seal legacy block header: %s (num %d)", block.Hash(), block.Number()) | ||
} | ||
|
||
func (o *OpLegacy) SealHash(header *types.Header) common.Hash { | ||
panic(fmt.Errorf("cannot compute pow/poa seal-hash for legacy block header: %s (num %d)", header.Hash(), header.Number)) | ||
} | ||
|
||
func (o *OpLegacy) CalcDifficulty(chain consensus.ChainHeaderReader, time uint64, parent *types.Header) *big.Int { | ||
return big.NewInt(0) | ||
} | ||
|
||
func (o *OpLegacy) APIs(chain consensus.ChainHeaderReader) []rpc.API { | ||
return nil | ||
} | ||
|
||
func (o *OpLegacy) Close() error { | ||
return nil | ||
} | ||
|
||
var _ consensus.Engine = (*OpLegacy)(nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters