Skip to content

Commit

Permalink
fix: init parlia after upgrade of system contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusKysel committed Dec 4, 2024
1 parent e01b15d commit 92d8bb2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions consensus/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"bytes"
"errors"
"fmt"
"math/big"

"github.com/erigontech/erigon-lib/kv"
"github.com/holiman/uint256"
"math/big"

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
Expand Down Expand Up @@ -353,7 +354,7 @@ func (s *Merge) Initialize(config *chain.Config, chain consensus.ChainHeaderRead
}, tracer)
}
if chain.Config().IsPrague(header.Time) {
misc.StoreBlockHashesEip2935(header, state, config, chain)
misc.StoreBlockHashesEip2935(header, state)
}
return nil
}
Expand Down
4 changes: 1 addition & 3 deletions consensus/misc/eip2935.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ package misc
import (
"github.com/holiman/uint256"

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
"github.com/erigontech/erigon-lib/log/v3"

"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/core/state"
"github.com/erigontech/erigon/core/types"
"github.com/erigontech/erigon/params"
)

func StoreBlockHashesEip2935(header *types.Header, state *state.IntraBlockState, config *chain.Config, headerReader consensus.ChainHeaderReader) {
func StoreBlockHashesEip2935(header *types.Header, state *state.IntraBlockState) {
if state.GetCodeSize(params.HistoryStorageAddress) == 0 {
log.Debug("[EIP-2935] No code deployed to HistoryStorageAddress before call to store EIP-2935 history")
return
Expand Down
13 changes: 10 additions & 3 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/erigontech/erigon/consensus/parlia/finality"
"github.com/erigontech/erigon/core/tracing"
"github.com/erigontech/erigon/core/vm/evmtypes"
"io"
"math/big"
"sort"
"strings"
"sync"
"time"

"github.com/erigontech/erigon/consensus/parlia/finality"
"github.com/erigontech/erigon/core/tracing"
"github.com/erigontech/erigon/core/vm/evmtypes"

"github.com/erigontech/erigon/crypto/cryptopool"
"github.com/erigontech/erigon/turbo/services"

Expand Down Expand Up @@ -892,6 +893,12 @@ func (p *Parlia) Initialize(config *chain.Config, chain consensus.ChainHeaderRea
if err = p.verifyTurnLength(chain, header, state); err != nil {
return err
}

// store block hashes for EIP-2935 (BEP440) upgrade
if config.IsPrague(header.Time) {
misc.StoreBlockHashesEip2935(header, state)
}

// update validators every day
if p.chainConfig.IsFeynman(header.Number.Uint64(), header.Time) && isBreatheBlock(parentHeader.Time, header.Time) {
// we should avoid update validators in the Feynman upgrade block
Expand Down
5 changes: 0 additions & 5 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/erigontech/erigon/common/math"
"github.com/erigontech/erigon/common/u256"
"github.com/erigontech/erigon/consensus"
"github.com/erigontech/erigon/consensus/misc"
"github.com/erigontech/erigon/core/state"
"github.com/erigontech/erigon/core/tracing"
"github.com/erigontech/erigon/core/types"
Expand Down Expand Up @@ -508,10 +507,6 @@ func InitializeBlockExecution(engine consensus.Engine, chain consensus.ChainHead
return SysCallContract(contract, data, cc, ibState, header, engine, constCall)
}, logger, tracer)

if cc.IsPrague(header.Time) {
misc.StoreBlockHashesEip2935(header, ibs, cc, chain)
}

noop := state.NewNoopWriter()
ibs.FinalizeTx(cc.Rules(header.Number.Uint64(), header.Time), noop)
return nil
Expand Down

0 comments on commit 92d8bb2

Please sign in to comment.