Skip to content

Commit

Permalink
state.go: fix the hf block is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx committed Jul 26, 2024
1 parent 25849fa commit 786085b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions cmd/state/exec3/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask) {
rules := txTask.Rules
var err error
header := txTask.Header
lastBlockTime := header.Time - rw.chainConfig.Parlia.Period
parent, _ := rw.blockReader.HeaderByHash(rw.ctx, rw.chainTx, header.ParentHash)
if parent != nil {
lastBlockTime = parent.Time
}
//fmt.Printf("txNum=%d blockNum=%d history=%t\n", txTask.TxNum, txTask.BlockNum, txTask.HistoryExecution)

switch {
Expand All @@ -215,11 +220,6 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask) {
return core.SysCallContract(contract, data, rw.chainConfig, ibs, header, rw.engine, constCall /* constCall */)
}
if rw.isPoSA && !rw.chainConfig.IsFeynman(header.Number.Uint64(), header.Time) {
lastBlockTime := header.Time - rw.chainConfig.Parlia.Period
parent, _ := rw.blockReader.HeaderByHash(rw.ctx, rw.chainTx, header.ParentHash)
if parent != nil {
lastBlockTime = parent.Time
}
systemcontracts.UpgradeBuildInSystemContract(rw.chainConfig, header.Number, lastBlockTime, header.Time, ibs, rw.logger)
}
if err := rw.engine.Initialize(rw.chainConfig, rw.chain, header, ibs, syscall, rw.logger, nil); err != nil {
Expand All @@ -233,11 +233,13 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask) {
}

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)
}
break
}

//fmt.Printf("txNum=%d, blockNum=%d, finalisation of the block\n", txTask.TxNum, txTask.BlockNum)
// End of block transaction in a block
syscall := func(contract libcommon.Address, data []byte) ([]byte, error) {
return core.SysCallContract(contract, data, rw.chainConfig, ibs, header, rw.engine, false /* constCall */)
}
Expand All @@ -257,13 +259,11 @@ func (rw *Worker) RunTxTaskNoLock(txTask *state.TxTask) {
}
}
case txTask.SystemTxIndex > 0:

syscall := func(contract libcommon.Address, data []byte) ([]byte, error) {
return core.SysCallContract(contract, data, rw.chainConfig, ibs, header, rw.engine, false /* constCall */)
}

systemCall := func(ibs *state.IntraBlockState, index int) ([]byte, bool, error) {

rw.taskGasPool.Reset(txTask.Tx.GetGas(), rw.chainConfig.GetMaxBlobGasPerBlock())
rw.callTracer.Reset()
rw.vmCfg.SkipAnalysis = txTask.SkipAnalysis
Expand Down
4 changes: 2 additions & 2 deletions consensus/parlia/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderRea
}
if turnLength != nil {
snap.TurnLength = *turnLength
log.Debug("validator set switch", "turnLength", *turnLength)
log.Trace("validator set switch", "turnLength", *turnLength)
}

// get validators from headers and use that for new validator set
Expand All @@ -342,7 +342,7 @@ func (s *Snapshot) apply(headers []*types.Header, chain consensus.ChainHeaderRea
// BEP-404: Clear Miner History when Switching Validators Set
snap.Recents = make(map[uint64]common.Address)
snap.Recents[epochKey] = common.Address{}
log.Debug("Recents are cleared up", "blockNumber", number)
log.Trace("Recents are cleared up", "blockNumber", number)
} else {
oldLimit := len(snap.Validators)/2 + 1
newLimit := len(newVals)/2 + 1
Expand Down
2 changes: 1 addition & 1 deletion consensus/parlia/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func backOffTime(snap *Snapshot, header *types.Header, val libcommon.Address, chainConfig *chain.Config) uint64 {
if snap.inturn(val) {
log.Debug("backOffTime", "blockNumber", header.Number, "in turn validator", val)
log.Trace("backOffTime", "blockNumber", header.Number, "in turn validator", val)
return 0
} else {
delay := initialBackOffTime
Expand Down

0 comments on commit 786085b

Please sign in to comment.