mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Rename Serenity consensus engine to Merge (#7475)
[EIP-2982](https://eips.ethereum.org/EIPS/eip-2982) "Serenity Phase 0" was superseded by [EIP-3675](https://eips.ethereum.org/EIPS/eip-3675) "Upgrade consensus to Proof-of-Stake"
This commit is contained in:
parent
42e8db3958
commit
771c6fc202
@ -10,7 +10,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/cl/cltypes/ssz"
|
||||
"github.com/ledgerwatch/erigon/cl/merkle_tree"
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
)
|
||||
|
||||
@ -359,14 +359,14 @@ func (b *Eth1Block) RlpHeader() (*types.Header, error) {
|
||||
TxHash: types.DeriveSha(types.BinaryTransactions(b.Transactions)),
|
||||
ReceiptHash: b.ReceiptsRoot,
|
||||
Bloom: b.LogsBloom,
|
||||
Difficulty: serenity.SerenityDifficulty,
|
||||
Difficulty: merge.ProofOfStakeDifficulty,
|
||||
Number: big.NewInt(int64(b.BlockNumber)),
|
||||
GasLimit: b.GasLimit,
|
||||
GasUsed: b.GasUsed,
|
||||
Time: b.Time,
|
||||
Extra: b.Extra,
|
||||
MixDigest: b.PrevRandao,
|
||||
Nonce: serenity.SerenityNonce,
|
||||
Nonce: merge.ProofOfStakeNonce,
|
||||
BaseFee: baseFee,
|
||||
WithdrawalsHash: withdrawalsHash,
|
||||
ExcessDataGas: excessDataGas,
|
||||
|
@ -56,7 +56,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/consensus/bor"
|
||||
"github.com/ledgerwatch/erigon/consensus/clique"
|
||||
"github.com/ledgerwatch/erigon/consensus/ethash"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||
"github.com/ledgerwatch/erigon/core/state/historyv2read"
|
||||
@ -706,7 +706,7 @@ func (s *Ethereum) StartMining(ctx context.Context, db kv.RwDB, mining *stagedsy
|
||||
var clq *clique.Clique
|
||||
if c, ok := s.engine.(*clique.Clique); ok {
|
||||
clq = c
|
||||
} else if cl, ok := s.engine.(*serenity.Serenity); ok {
|
||||
} else if cl, ok := s.engine.(*merge.Merge); ok {
|
||||
if c, ok := cl.InnerEngine().(*clique.Clique); ok {
|
||||
clq = c
|
||||
}
|
||||
@ -725,7 +725,7 @@ func (s *Ethereum) StartMining(ctx context.Context, db kv.RwDB, mining *stagedsy
|
||||
var borcfg *bor.Bor
|
||||
if b, ok := s.engine.(*bor.Bor); ok {
|
||||
borcfg = b
|
||||
} else if br, ok := s.engine.(*serenity.Serenity); ok {
|
||||
} else if br, ok := s.engine.(*merge.Merge); ok {
|
||||
if b, ok := br.InnerEngine().(*bor.Bor); ok {
|
||||
borcfg = b
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/common/math"
|
||||
"github.com/ledgerwatch/erigon/consensus/ethash"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/core/state"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
@ -303,9 +303,9 @@ func Main(ctx *cli.Context) error {
|
||||
defer tx.Rollback()
|
||||
|
||||
reader, writer := MakePreState(chainConfig.Rules(0, 0), tx, prestate.Pre)
|
||||
// serenity engine can be used for pre-merge blocks as well, as it
|
||||
// Merge engine can be used for pre-merge blocks as well, as it
|
||||
// redirects to the ethash engine based on the block number
|
||||
engine := serenity.New(ðash.FakeEthash{})
|
||||
engine := merge.New(ðash.FakeEthash{})
|
||||
|
||||
result, err := core.ExecuteBlockEphemerally(chainConfig, &vmConfig, getHash, engine, block, reader, writer, nil, getTracer)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package serenity
|
||||
package merge
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
|
||||
@ -19,11 +20,10 @@ import (
|
||||
"github.com/ledgerwatch/erigon/rpc"
|
||||
)
|
||||
|
||||
// Constants for Serenity as specified into https://eips.ethereum.org/EIPS/eip-2982
|
||||
// Constants for The Merge as specified by EIP-3675: Upgrade consensus to Proof-of-Stake
|
||||
var (
|
||||
SerenityDifficulty = libcommon.Big0 // Serenity block's difficulty is always 0.
|
||||
SerenityNonce = types.BlockNonce{} // Serenity chain's nonces are 0.
|
||||
RewardSerenity = big.NewInt(300000000000000000)
|
||||
ProofOfStakeDifficulty = libcommon.Big0 // PoS block's difficulty is always 0
|
||||
ProofOfStakeNonce = types.BlockNonce{} // PoS block's have all-zero nonces
|
||||
)
|
||||
|
||||
var (
|
||||
@ -39,47 +39,45 @@ var (
|
||||
errOlderBlockTime = errors.New("timestamp older than parent")
|
||||
)
|
||||
|
||||
// Serenity Consensus Engine for the Execution Layer.
|
||||
// Serenity is a consensus engine that combines the eth1 consensus and proof-of-stake
|
||||
// Merge Consensus Engine for the Execution Layer.
|
||||
// Merge is a consensus engine that combines the eth1 consensus and proof-of-stake
|
||||
// algorithm. The transition rule is described in the eth1/2 merge spec:
|
||||
// https://eips.ethereum.org/EIPS/eip-3675
|
||||
//
|
||||
// Note: After the Merge the work is mostly done on the Consensus Layer, so nothing much is to be added on this side.
|
||||
type Serenity struct {
|
||||
type Merge struct {
|
||||
eth1Engine consensus.Engine // Original consensus engine used in eth1, e.g. ethash or clique
|
||||
}
|
||||
|
||||
// New creates a new instance of the Serenity Engine with the given embedded eth1 engine.
|
||||
func New(eth1Engine consensus.Engine) *Serenity {
|
||||
if _, ok := eth1Engine.(*Serenity); ok {
|
||||
// New creates a new instance of the Merge Engine with the given embedded eth1 engine.
|
||||
func New(eth1Engine consensus.Engine) *Merge {
|
||||
if _, ok := eth1Engine.(*Merge); ok {
|
||||
panic("nested consensus engine")
|
||||
}
|
||||
return &Serenity{eth1Engine: eth1Engine}
|
||||
return &Merge{eth1Engine: eth1Engine}
|
||||
}
|
||||
|
||||
// InnerEngine returns the embedded eth1 consensus engine.
|
||||
func (s *Serenity) InnerEngine() consensus.Engine {
|
||||
func (s *Merge) InnerEngine() consensus.Engine {
|
||||
return s.eth1Engine
|
||||
}
|
||||
|
||||
// Type returns the type of the underlying consensus engine.
|
||||
func (s *Serenity) Type() chain.ConsensusName {
|
||||
func (s *Merge) Type() chain.ConsensusName {
|
||||
return s.eth1Engine.Type()
|
||||
}
|
||||
|
||||
// Author implements consensus.Engine, returning the header's coinbase as the
|
||||
// proof-of-stake verified author of the block.
|
||||
// This is thread-safe (only access the header.Coinbase or the underlying engine's thread-safe method)
|
||||
func (s *Serenity) Author(header *types.Header) (libcommon.Address, error) {
|
||||
func (s *Merge) Author(header *types.Header) (libcommon.Address, error) {
|
||||
if !IsPoSHeader(header) {
|
||||
return s.eth1Engine.Author(header)
|
||||
}
|
||||
return header.Coinbase, nil
|
||||
}
|
||||
|
||||
// VerifyHeader checks whether a header conforms to the consensus rules of the
|
||||
// stock Ethereum serenity engine.
|
||||
func (s *Serenity) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error {
|
||||
func (s *Merge) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error {
|
||||
reached, err := IsTTDReached(chain, header.ParentHash, header.Number.Uint64()-1)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -99,7 +97,7 @@ func (s *Serenity) VerifyHeader(chain consensus.ChainHeaderReader, header *types
|
||||
|
||||
// VerifyUncles implements consensus.Engine, always returning an error for any
|
||||
// uncles as this consensus mechanism doesn't permit uncles.
|
||||
func (s *Serenity) VerifyUncles(chain consensus.ChainReader, header *types.Header, uncles []*types.Header) error {
|
||||
func (s *Merge) VerifyUncles(chain consensus.ChainReader, header *types.Header, uncles []*types.Header) error {
|
||||
if !IsPoSHeader(header) {
|
||||
return s.eth1Engine.VerifyUncles(chain, header, uncles)
|
||||
}
|
||||
@ -110,7 +108,7 @@ func (s *Serenity) VerifyUncles(chain consensus.ChainReader, header *types.Heade
|
||||
}
|
||||
|
||||
// Prepare makes sure difficulty and nonce are correct
|
||||
func (s *Serenity) Prepare(chain consensus.ChainHeaderReader, header *types.Header, state *state.IntraBlockState) error {
|
||||
func (s *Merge) Prepare(chain consensus.ChainHeaderReader, header *types.Header, state *state.IntraBlockState) error {
|
||||
reached, err := IsTTDReached(chain, header.ParentHash, header.Number.Uint64()-1)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -118,12 +116,12 @@ func (s *Serenity) Prepare(chain consensus.ChainHeaderReader, header *types.Head
|
||||
if !reached {
|
||||
return s.eth1Engine.Prepare(chain, header, state)
|
||||
}
|
||||
header.Difficulty = SerenityDifficulty
|
||||
header.Nonce = SerenityNonce
|
||||
header.Difficulty = ProofOfStakeDifficulty
|
||||
header.Nonce = ProofOfStakeNonce
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Serenity) CalculateRewards(config *chain.Config, header *types.Header, uncles []*types.Header, syscall consensus.SystemCall,
|
||||
func (s *Merge) CalculateRewards(config *chain.Config, header *types.Header, uncles []*types.Header, syscall consensus.SystemCall,
|
||||
) ([]consensus.Reward, error) {
|
||||
_, isAura := s.eth1Engine.(*aura.AuRa)
|
||||
if !IsPoSHeader(header) || isAura {
|
||||
@ -132,7 +130,7 @@ func (s *Serenity) CalculateRewards(config *chain.Config, header *types.Header,
|
||||
return []consensus.Reward{}, nil
|
||||
}
|
||||
|
||||
func (s *Serenity) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState,
|
||||
func (s *Merge) Finalize(config *chain.Config, header *types.Header, state *state.IntraBlockState,
|
||||
txs types.Transactions, uncles []*types.Header, r types.Receipts, withdrawals []*types.Withdrawal,
|
||||
chain consensus.ChainHeaderReader, syscall consensus.SystemCall,
|
||||
) (types.Transactions, types.Receipts, error) {
|
||||
@ -172,7 +170,7 @@ func (s *Serenity) Finalize(config *chain.Config, header *types.Header, state *s
|
||||
return txs, r, nil
|
||||
}
|
||||
|
||||
func (s *Serenity) FinalizeAndAssemble(config *chain.Config, header *types.Header, state *state.IntraBlockState,
|
||||
func (s *Merge) FinalizeAndAssemble(config *chain.Config, header *types.Header, state *state.IntraBlockState,
|
||||
txs types.Transactions, uncles []*types.Header, receipts types.Receipts, withdrawals []*types.Withdrawal,
|
||||
chain consensus.ChainHeaderReader, syscall consensus.SystemCall, call consensus.Call,
|
||||
) (*types.Block, types.Transactions, types.Receipts, error) {
|
||||
@ -186,11 +184,11 @@ func (s *Serenity) FinalizeAndAssemble(config *chain.Config, header *types.Heade
|
||||
return types.NewBlock(header, outTxs, uncles, outReceipts, withdrawals), outTxs, outReceipts, nil
|
||||
}
|
||||
|
||||
func (s *Serenity) SealHash(header *types.Header) (hash libcommon.Hash) {
|
||||
func (s *Merge) SealHash(header *types.Header) (hash libcommon.Hash) {
|
||||
return s.eth1Engine.SealHash(header)
|
||||
}
|
||||
|
||||
func (s *Serenity) CalcDifficulty(chain consensus.ChainHeaderReader, time, parentTime uint64, parentDifficulty *big.Int, parentNumber uint64, parentHash, parentUncleHash libcommon.Hash, parentAuRaStep uint64) *big.Int {
|
||||
func (s *Merge) CalcDifficulty(chain consensus.ChainHeaderReader, time, parentTime uint64, parentDifficulty *big.Int, parentNumber uint64, parentHash, parentUncleHash libcommon.Hash, parentAuRaStep uint64) *big.Int {
|
||||
reached, err := IsTTDReached(chain, parentHash, parentNumber)
|
||||
if err != nil {
|
||||
return nil
|
||||
@ -198,12 +196,12 @@ func (s *Serenity) CalcDifficulty(chain consensus.ChainHeaderReader, time, paren
|
||||
if !reached {
|
||||
return s.eth1Engine.CalcDifficulty(chain, time, parentTime, parentDifficulty, parentNumber, parentHash, parentUncleHash, parentAuRaStep)
|
||||
}
|
||||
return SerenityDifficulty
|
||||
return ProofOfStakeDifficulty
|
||||
}
|
||||
|
||||
// verifyHeader checks whether a Proof-of-Stake header conforms to the consensus rules of the
|
||||
// stock Ethereum consensus engine with EIP-3675 modifications.
|
||||
func (s *Serenity) verifyHeader(chain consensus.ChainHeaderReader, header, parent *types.Header) error {
|
||||
func (s *Merge) verifyHeader(chain consensus.ChainHeaderReader, header, parent *types.Header) error {
|
||||
|
||||
if uint64(len(header.Extra)) > params.MaximumExtraDataSize {
|
||||
return fmt.Errorf("extra-data longer than %d bytes (%d)", params.MaximumExtraDataSize, len(header.Extra))
|
||||
@ -213,11 +211,11 @@ func (s *Serenity) verifyHeader(chain consensus.ChainHeaderReader, header, paren
|
||||
return errOlderBlockTime
|
||||
}
|
||||
|
||||
if header.Difficulty.Cmp(SerenityDifficulty) != 0 {
|
||||
if header.Difficulty.Cmp(ProofOfStakeDifficulty) != 0 {
|
||||
return errInvalidDifficulty
|
||||
}
|
||||
|
||||
if !bytes.Equal(header.Nonce[:], SerenityNonce[:]) {
|
||||
if !bytes.Equal(header.Nonce[:], ProofOfStakeNonce[:]) {
|
||||
return errInvalidNonce
|
||||
}
|
||||
|
||||
@ -263,30 +261,30 @@ func (s *Serenity) verifyHeader(chain consensus.ChainHeaderReader, header, paren
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Serenity) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
|
||||
func (s *Merge) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
|
||||
if !IsPoSHeader(block.Header()) {
|
||||
return s.eth1Engine.Seal(chain, block, results, stop)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Serenity) GenerateSeal(chain consensus.ChainHeaderReader, currnt, parent *types.Header, call consensus.Call) []byte {
|
||||
func (s *Merge) GenerateSeal(chain consensus.ChainHeaderReader, currnt, parent *types.Header, call consensus.Call) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Serenity) IsServiceTransaction(sender libcommon.Address, syscall consensus.SystemCall) bool {
|
||||
func (s *Merge) IsServiceTransaction(sender libcommon.Address, syscall consensus.SystemCall) bool {
|
||||
return s.eth1Engine.IsServiceTransaction(sender, syscall)
|
||||
}
|
||||
|
||||
func (s *Serenity) Initialize(config *chain.Config, chain consensus.ChainHeaderReader, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, syscall consensus.SystemCall) {
|
||||
func (s *Merge) Initialize(config *chain.Config, chain consensus.ChainHeaderReader, header *types.Header, state *state.IntraBlockState, txs []types.Transaction, uncles []*types.Header, syscall consensus.SystemCall) {
|
||||
s.eth1Engine.Initialize(config, chain, header, state, txs, uncles, syscall)
|
||||
}
|
||||
|
||||
func (s *Serenity) APIs(chain consensus.ChainHeaderReader) []rpc.API {
|
||||
func (s *Merge) APIs(chain consensus.ChainHeaderReader) []rpc.API {
|
||||
return s.eth1Engine.APIs(chain)
|
||||
}
|
||||
|
||||
func (s *Serenity) Close() error {
|
||||
func (s *Merge) Close() error {
|
||||
return s.eth1Engine.Close()
|
||||
}
|
||||
|
||||
@ -297,7 +295,7 @@ func IsPoSHeader(header *types.Header) bool {
|
||||
if header.Difficulty == nil {
|
||||
panic("IsPoSHeader called with invalid difficulty")
|
||||
}
|
||||
return header.Difficulty.Cmp(SerenityDifficulty) == 0
|
||||
return header.Difficulty.Cmp(ProofOfStakeDifficulty) == 0
|
||||
}
|
||||
|
||||
// IsTTDReached checks if the TotalTerminalDifficulty has been surpassed on the `parentHash` block.
|
@ -1,4 +1,4 @@
|
||||
package serenity
|
||||
package merge
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
@ -48,14 +48,14 @@ func TestVerifyHeaderDifficulty(t *testing.T) {
|
||||
parent := &types.Header{}
|
||||
|
||||
var eth1Engine consensus.Engine
|
||||
serenity := New(eth1Engine)
|
||||
mergeEngine := New(eth1Engine)
|
||||
|
||||
err := serenity.verifyHeader(readerMock{}, header, parent)
|
||||
err := mergeEngine.verifyHeader(readerMock{}, header, parent)
|
||||
if err != errInvalidDifficulty {
|
||||
if err != nil {
|
||||
t.Fatalf("Serenity should not accept non-zero difficulty, got %s", err.Error())
|
||||
t.Fatalf("Merge engine should not accept non-zero difficulty, got %s", err.Error())
|
||||
} else {
|
||||
t.Fatalf("Serenity should not accept non-zero difficulty")
|
||||
t.Fatalf("Merge engine should not accept non-zero difficulty")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,14 +70,14 @@ func TestVerifyHeaderNonce(t *testing.T) {
|
||||
parent := &types.Header{}
|
||||
|
||||
var eth1Engine consensus.Engine
|
||||
serenity := New(eth1Engine)
|
||||
mergeEngine := New(eth1Engine)
|
||||
|
||||
err := serenity.verifyHeader(readerMock{}, header, parent)
|
||||
err := mergeEngine.verifyHeader(readerMock{}, header, parent)
|
||||
if err != errInvalidNonce {
|
||||
if err != nil {
|
||||
t.Fatalf("Serenity should not accept non-zero difficulty, got %s", err.Error())
|
||||
t.Fatalf("Merge engine should not accept non-zero difficulty, got %s", err.Error())
|
||||
} else {
|
||||
t.Fatalf("Serenity should not accept non-zero difficulty")
|
||||
t.Fatalf("Merge engine should not accept non-zero difficulty")
|
||||
}
|
||||
}
|
||||
}
|
@ -24,15 +24,14 @@ import (
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/length"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon/core/systemcontracts"
|
||||
"github.com/ledgerwatch/erigon/eth/ethconfig"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/consensus"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/consensus/misc"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/core/state"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
"github.com/ledgerwatch/erigon/core/vm"
|
||||
@ -277,7 +276,7 @@ func (cp *ChainPack) Copy() *ChainPack {
|
||||
|
||||
func (cp *ChainPack) NumberOfPoWBlocks() int {
|
||||
for i, header := range cp.Headers {
|
||||
if header.Difficulty.Cmp(serenity.SerenityDifficulty) == 0 {
|
||||
if header.Difficulty.Cmp(merge.ProofOfStakeDifficulty) == 0 {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,12 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/holiman/uint256"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
|
||||
"github.com/ledgerwatch/erigon/consensus"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
"github.com/ledgerwatch/erigon/core/vm/evmtypes"
|
||||
)
|
||||
@ -50,8 +51,8 @@ func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libco
|
||||
}
|
||||
|
||||
var prevRandDao *libcommon.Hash
|
||||
if header.Difficulty.Cmp(serenity.SerenityDifficulty) == 0 {
|
||||
// EIP-4399. We use SerenityDifficulty (i.e. 0) as a telltale of Proof-of-Stake blocks.
|
||||
if header.Difficulty.Cmp(merge.ProofOfStakeDifficulty) == 0 {
|
||||
// EIP-4399. We use ProofOfStakeDifficulty (i.e. 0) as a telltale of Proof-of-Stake blocks.
|
||||
prevRandDao = &header.MixDigest
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/common/hexutil"
|
||||
"github.com/ledgerwatch/erigon/consensus/ethash"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||
"github.com/ledgerwatch/erigon/core/state"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
@ -271,7 +271,7 @@ func write(tx kv.RwTx, g *types.Genesis, tmpDir string) (*types.Block, *state.In
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// We support ethash/serenity for issuance (for now)
|
||||
// We support ethash/merge for issuance (for now)
|
||||
if g.Config.Consensus != chain.EtHashConsensus {
|
||||
return block, statedb, nil
|
||||
}
|
||||
@ -282,9 +282,7 @@ func write(tx kv.RwTx, g *types.Genesis, tmpDir string) (*types.Block, *state.In
|
||||
}
|
||||
|
||||
// BlockReward can be present at genesis
|
||||
if block.Header().Difficulty.Cmp(serenity.SerenityDifficulty) == 0 {
|
||||
genesisIssuance.Add(genesisIssuance, serenity.RewardSerenity)
|
||||
} else {
|
||||
if block.Header().Difficulty.Cmp(merge.ProofOfStakeDifficulty) != 0 {
|
||||
blockReward, _ := ethash.AccumulateRewards(g.Config, block.Header(), nil)
|
||||
// Set BlockReward
|
||||
genesisIssuance.Add(genesisIssuance, blockReward.ToBig())
|
||||
|
@ -77,7 +77,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/consensus/bor"
|
||||
"github.com/ledgerwatch/erigon/consensus/clique"
|
||||
"github.com/ledgerwatch/erigon/consensus/ethash"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||
"github.com/ledgerwatch/erigon/core/state/historyv2read"
|
||||
@ -826,7 +826,7 @@ func (s *Ethereum) StartMining(ctx context.Context, db kv.RwDB, mining *stagedsy
|
||||
var clq *clique.Clique
|
||||
if c, ok := s.engine.(*clique.Clique); ok {
|
||||
clq = c
|
||||
} else if cl, ok := s.engine.(*serenity.Serenity); ok {
|
||||
} else if cl, ok := s.engine.(*merge.Merge); ok {
|
||||
if c, ok := cl.InnerEngine().(*clique.Clique); ok {
|
||||
clq = c
|
||||
}
|
||||
@ -845,7 +845,7 @@ func (s *Ethereum) StartMining(ctx context.Context, db kv.RwDB, mining *stagedsy
|
||||
var borcfg *bor.Bor
|
||||
if b, ok := s.engine.(*bor.Bor); ok {
|
||||
borcfg = b
|
||||
} else if br, ok := s.engine.(*serenity.Serenity); ok {
|
||||
} else if br, ok := s.engine.(*merge.Merge); ok {
|
||||
if b, ok := br.InnerEngine().(*bor.Bor); ok {
|
||||
borcfg = b
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/consensus/db"
|
||||
"github.com/ledgerwatch/erigon/consensus/ethash"
|
||||
"github.com/ledgerwatch/erigon/consensus/ethash/ethashcfg"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/params"
|
||||
)
|
||||
|
||||
@ -97,7 +97,7 @@ func CreateConsensusEngine(chainConfig *chain.Config, config interface{}, notify
|
||||
if chainConfig.TerminalTotalDifficulty == nil {
|
||||
return eng
|
||||
} else {
|
||||
return serenity.New(eng) // the Merge
|
||||
return merge.New(eng) // the Merge
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
"github.com/ledgerwatch/erigon/consensus/serenity"
|
||||
"github.com/ledgerwatch/erigon/consensus/merge"
|
||||
"github.com/ledgerwatch/erigon/core"
|
||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
@ -365,8 +365,8 @@ func (s *EthBackendServer) EngineNewPayload(ctx context.Context, req *types2.Exe
|
||||
Time: req.Timestamp,
|
||||
MixDigest: gointerfaces.ConvertH256ToHash(req.PrevRandao),
|
||||
UncleHash: types.EmptyUncleHash,
|
||||
Difficulty: serenity.SerenityDifficulty,
|
||||
Nonce: serenity.SerenityNonce,
|
||||
Difficulty: merge.ProofOfStakeDifficulty,
|
||||
Nonce: merge.ProofOfStakeNonce,
|
||||
ReceiptHash: gointerfaces.ConvertH256ToHash(req.ReceiptRoot),
|
||||
TxHash: types.DeriveSha(types.BinaryTransactions(req.Transactions)),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user