Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cmd/integration/commands/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -1497,10 +1497,6 @@ func newSync(ctx context.Context, db kv.TemporalRwDB, miningConfig *params.Minin
}
//logger.Info("Initialised chain configuration", "config", chainConfig)

// Apply special hacks for BSC params
if chainConfig.Parlia != nil {
params.ApplyBinanceSmartChainParams()
}
var batchSize datasize.ByteSize
must(batchSize.UnmarshalText([]byte(batchSizeStr)))

Expand Down
4 changes: 0 additions & 4 deletions cmd/state/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ var rootCmd = &cobra.Command{
utils.Fatalf("provided genesis.json chain configuration is invalid: expected chainId to be %v, got %v",
chainConfig.ChainID.String(), genesis.Config.ChainID.String())
}
// Apply special hacks for BSC params
if chainConfig.Parlia != nil {
params.ApplyBinanceSmartChainParams()
}

if chaindata == "" {
chaindata = filepath.Join(datadirCli, "chaindata")
Expand Down
23 changes: 16 additions & 7 deletions cmd/state/exec3/historical_trace_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,7 @@ func (rw *HistoricalTraceWorker) RunTxTask(txTask *state.TxTask) {
rules := txTask.Rules
var err error
header := txTask.Header
var lastBlockTime uint64
_, isPoSA := rw.execArgs.Engine.(consensus.PoSA)
if isPoSA {
lastBlockTime = header.Time - rw.execArgs.ChainConfig.Parlia.Period
}
switch {
case txTask.TxIndex == -1:
if txTask.BlockNum == 0 {
Expand All @@ -178,10 +174,10 @@ func (rw *HistoricalTraceWorker) RunTxTask(txTask *state.TxTask) {
}
if isPoSA {
if !rw.execArgs.ChainConfig.IsFeynman(header.Number.Uint64(), header.Time) {
systemcontracts.UpgradeBuildInSystemContract(rw.execArgs.ChainConfig, header.Number, lastBlockTime, header.Time, ibs, rw.logger)
systemcontracts.UpgradeBuildInSystemContract(rw.execArgs.ChainConfig, header.Number, txTask.LastBlockTime, header.Time, ibs, rw.logger)
}
// HistoryStorageAddress is a special system contract in bsc, which can't be upgraded
if rw.execArgs.ChainConfig.IsOnPrague(header.Number, lastBlockTime, header.Time) {
if rw.execArgs.ChainConfig.IsOnPrague(header.Number, txTask.LastBlockTime, header.Time) {
misc.InitializeBlockHashesEip2935(ibs)
log.Info("Set code for HistoryStorageAddress", "blockNumber", header.Number.Uint64(), "blockTime", header.Time)
}
Expand All @@ -199,7 +195,7 @@ func (rw *HistoricalTraceWorker) RunTxTask(txTask *state.TxTask) {
if _, isPoSa := rw.execArgs.Engine.(consensus.PoSA); isPoSa {
// Is an empty block
if rw.execArgs.ChainConfig.IsFeynman(header.Number.Uint64(), header.Time) && txTask.TxIndex == 0 {
systemcontracts.UpgradeBuildInSystemContract(rw.execArgs.ChainConfig, header.Number, lastBlockTime, header.Time, ibs, rw.logger)
systemcontracts.UpgradeBuildInSystemContract(rw.execArgs.ChainConfig, header.Number, txTask.LastBlockTime, header.Time, ibs, rw.logger)
}
break
}
Expand Down Expand Up @@ -510,6 +506,18 @@ func CustomTraceMapReduce(fromBlock, toBlock uint64, consumer TraceConsumer, ctx
// TODO: panic here and see that overall process deadlock
return fmt.Errorf("nil block %d", blockNum)
}
var lastBlockTime uint64
var parent *types.Block
if blockNum > 0 {
parent, err = blockWithSenders(ctx, nil, tx, br, blockNum-1)
if err != nil {
return err
}
if parent == nil {
return fmt.Errorf("nil parent block %d", blockNum-1)
}
lastBlockTime = parent.Time()
}
txs := b.Transactions()
header := b.HeaderNoCopy()
skipAnalysis := core.SkipAnalysis(chainConfig, blockNum)
Expand Down Expand Up @@ -544,6 +552,7 @@ func CustomTraceMapReduce(fromBlock, toBlock uint64, consumer TraceConsumer, ctx
GetHashFn: getHashFn,
EvmBlockContext: blockContext,
Withdrawals: b.Withdrawals(),
LastBlockTime: lastBlockTime,

// use history reader instead of state reader to catch up to the tx where we left off
HistoryExecution: true,
Expand Down
10 changes: 3 additions & 7 deletions cmd/state/exec3/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,6 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining bool) {
rules := txTask.Rules
var err error
header := txTask.Header
var lastBlockTime uint64
if rw.isPoSA {
lastBlockTime = header.Time - rw.chainConfig.Parlia.Period
}
//fmt.Printf("txNum=%d blockNum=%d history=%t\n", txTask.TxNum, txTask.BlockNum, txTask.HistoryExecution)

switch {
Expand All @@ -243,10 +239,10 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining bool) {
}
if rw.isPoSA {
if !rw.chainConfig.IsFeynman(header.Number.Uint64(), header.Time) {
systemcontracts.UpgradeBuildInSystemContract(rw.chainConfig, header.Number, lastBlockTime, header.Time, ibs, rw.logger)
systemcontracts.UpgradeBuildInSystemContract(rw.chainConfig, header.Number, txTask.LastBlockTime, header.Time, ibs, rw.logger)
}
// HistoryStorageAddress is a special system contract in bsc, which can't be upgraded
if rw.chainConfig.IsOnPrague(header.Number, lastBlockTime, header.Time) {
if rw.chainConfig.IsOnPrague(header.Number, txTask.LastBlockTime, header.Time) {
misc.InitializeBlockHashesEip2935(ibs)
log.Info("Set code for HistoryStorageAddress", "blockNumber", header.Number.Uint64(), "blockTime", header.Time)
}
Expand All @@ -264,7 +260,7 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask, isMining bool) {
if _, isPoSa := rw.engine.(consensus.PoSA); isPoSa {
// Is an empty block
if rw.chainConfig.IsFeynman(header.Number.Uint64(), header.Time) && txTask.TxIndex == 0 {
systemcontracts.UpgradeBuildInSystemContract(rw.chainConfig, header.Number, lastBlockTime, header.Time, ibs, rw.logger)
systemcontracts.UpgradeBuildInSystemContract(rw.chainConfig, header.Number, txTask.LastBlockTime, header.Time, ibs, rw.logger)
}
break
}
Expand Down
4 changes: 2 additions & 2 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ package consensus

import (
"context"
"math/big"

"github.com/holiman/uint256"
"math/big"

"github.com/erigontech/erigon-lib/chain"
libcommon "github.com/erigontech/erigon-lib/common"
Expand Down Expand Up @@ -223,6 +222,7 @@ type PoSA interface {
GetFinalizedHeader(chain ChainHeaderReader, header *types.Header) *types.Header
ResetSnapshot(chain ChainHeaderReader, headers []*types.Header) error
GetLatestSnapshotHeight() (uint64, error)
BlockInterval(chain ChainHeaderReader, header *types.Header) (uint64, error)
}

type AsyncEngine interface {
Expand Down
13 changes: 0 additions & 13 deletions consensus/parlia/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1501,19 +1501,6 @@ const validatorSetABI = `
],
"stateMutability": "view"
},
{
"type": "function",
"name": "EPOCH",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "ERROR_FAIL_CHECK_VALIDATORS",
Expand Down
5 changes: 2 additions & 3 deletions consensus/parlia/feynmanfork.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package parlia
import (
"container/heap"
"errors"
"github.com/erigontech/erigon/params"
"math/big"

"github.com/erigontech/erigon-lib/common"
Expand All @@ -15,11 +16,9 @@ import (
"github.com/erigontech/erigon/core/types"
)

const SecondsPerDay uint64 = 86400

// the params should be two blocks' time(timestamp)
func sameDayInUTC(first, second uint64) bool {
return first/SecondsPerDay == second/SecondsPerDay
return first/params.BreatheBlockInterval == second/params.BreatheBlockInterval
}

func isBreatheBlock(lastBlockTime, blockTime uint64) bool {
Expand Down
Loading