Skip to content

Commit

Permalink
core/vote: fix TestValidVotePool
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 committed Feb 18, 2025
1 parent a93e1ff commit 2915384
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions core/vote/vote_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/parlia"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth/downloader"
Expand Down Expand Up @@ -146,13 +147,15 @@ func (voteManager *VoteManager) loop() {
}

curHead := cHead.Header
parentHeader := voteManager.chain.GetHeaderByHash(curHead.ParentHash)
blockInterval, _ := voteManager.engine.BlockInterval(voteManager.chain, parentHeader)
nextBlockMinedTime := time.UnixMilli(int64((curHead.TimeInMilliseconds() + blockInterval)))
timeForBroadcast := 50 * time.Millisecond // enough to broadcast a vote
if time.Now().Add(timeForBroadcast).After(nextBlockMinedTime) {
log.Warn("too late to vote", "Head.Time(Second)", curHead.Time, "Now(Millisecond)", time.Now().UnixMilli())
continue
if p, ok := voteManager.engine.(*parlia.Parlia); ok {
parentHeader := voteManager.chain.GetHeaderByHash(curHead.ParentHash)
blockInterval, _ := p.BlockInterval(voteManager.chain, parentHeader)
nextBlockMinedTime := time.UnixMilli(int64((curHead.TimeInMilliseconds() + blockInterval)))
timeForBroadcast := 50 * time.Millisecond // enough to broadcast a vote
if time.Now().Add(timeForBroadcast).After(nextBlockMinedTime) {
log.Warn("too late to vote", "Head.Time(Second)", curHead.Time, "Now(Millisecond)", time.Now().UnixMilli())
continue
}
}

// Check if cur validator is within the validatorSet at curHead
Expand Down

0 comments on commit 2915384

Please sign in to comment.