fix: context and finalizeBlockReq block time (sims) (#16286)
This commit is contained in:
parent
fac0395d8d
commit
b6088abf33
@ -187,11 +187,11 @@ func RandomRequestFinalizeBlock(
|
||||
for r.Float64() < params.EvidenceFraction() {
|
||||
vals := voteInfos
|
||||
height := blockHeight
|
||||
|
||||
misbehaviorTime := time
|
||||
if r.Float64() < params.PastEvidenceFraction() && height > 1 {
|
||||
height = int64(r.Intn(int(height)-1)) + 1 // CometBFT starts at height 1
|
||||
// array indices offset by one
|
||||
time = pastTimes[height-1]
|
||||
misbehaviorTime = pastTimes[height-1]
|
||||
vals = pastVoteInfos[height-1]
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ func RandomRequestFinalizeBlock(
|
||||
Type: abci.MisbehaviorType_DUPLICATE_VOTE,
|
||||
Validator: validator,
|
||||
Height: height,
|
||||
Time: time,
|
||||
Time: misbehaviorTime,
|
||||
TotalVotingPower: totalVotingPower,
|
||||
},
|
||||
)
|
||||
|
||||
@ -76,7 +76,7 @@ func SimulateFromSeed(
|
||||
|
||||
// Second variable to keep pending validator set (delayed one block since
|
||||
// TM 0.24) Initially this is the same as the initial validator set
|
||||
validators, genesisTimestamp, accs, chainID := initChain(r, params, accs, app, appStateFn, config, cdc)
|
||||
validators, blockTime, accs, chainID := initChain(r, params, accs, app, appStateFn, config, cdc)
|
||||
if len(accs) == 0 {
|
||||
return true, params, fmt.Errorf("must have greater than zero genesis accounts")
|
||||
}
|
||||
@ -85,7 +85,7 @@ func SimulateFromSeed(
|
||||
|
||||
fmt.Printf(
|
||||
"Starting the simulation from time %v (unixtime %v)\n",
|
||||
genesisTimestamp.UTC().Format(time.UnixDate), genesisTimestamp.Unix(),
|
||||
blockTime.UTC().Format(time.UnixDate), blockTime.Unix(),
|
||||
)
|
||||
|
||||
// remove module account address if they exist in accs
|
||||
@ -105,10 +105,9 @@ func SimulateFromSeed(
|
||||
pastVoteInfos [][]abci.VoteInfo
|
||||
timeOperationQueue []simulation.FutureOperation
|
||||
|
||||
blockHeight int64 = 1
|
||||
blockTime = genesisTimestamp
|
||||
proposerAddress = validators.randomProposer(r)
|
||||
opCount = 0
|
||||
blockHeight = int64(config.InitialBlockHeight)
|
||||
proposerAddress = validators.randomProposer(r)
|
||||
opCount = 0
|
||||
)
|
||||
|
||||
// Setup code to catch SIGTERM's
|
||||
@ -129,8 +128,8 @@ func SimulateFromSeed(
|
||||
pastTimes,
|
||||
pastVoteInfos,
|
||||
eventStats.Tally,
|
||||
1,
|
||||
genesisTimestamp,
|
||||
blockHeight,
|
||||
blockTime,
|
||||
validators.randomProposer(r),
|
||||
)
|
||||
|
||||
@ -169,12 +168,12 @@ func SimulateFromSeed(
|
||||
exportedParams = params
|
||||
}
|
||||
|
||||
for height := config.InitialBlockHeight; height < config.NumBlocks+config.InitialBlockHeight && !stopEarly; height++ {
|
||||
for blockHeight < int64(config.NumBlocks+config.InitialBlockHeight) && !stopEarly {
|
||||
pastTimes = append(pastTimes, blockTime)
|
||||
pastVoteInfos = append(pastVoteInfos, finalizeBlockReq.DecidedLastCommit.Votes)
|
||||
|
||||
// Run the BeginBlock handler
|
||||
logWriter.AddEntry(BeginBlockEntry(int64(height)))
|
||||
logWriter.AddEntry(BeginBlockEntry(blockHeight))
|
||||
|
||||
res, err := app.FinalizeBlock(finalizeBlockReq)
|
||||
if err != nil {
|
||||
@ -183,7 +182,7 @@ func SimulateFromSeed(
|
||||
|
||||
ctx := app.NewContext(false, cmtproto.Header{
|
||||
Height: blockHeight,
|
||||
Time: genesisTimestamp,
|
||||
Time: blockTime,
|
||||
ProposerAddress: proposerAddress,
|
||||
ChainID: config.ChainID,
|
||||
})
|
||||
@ -206,7 +205,7 @@ func SimulateFromSeed(
|
||||
// run standard operations
|
||||
operations := blockSimulator(r, app, ctx, accs, cmtproto.Header{
|
||||
Height: blockHeight,
|
||||
Time: genesisTimestamp,
|
||||
Time: blockTime,
|
||||
ProposerAddress: proposerAddress,
|
||||
ChainID: config.ChainID,
|
||||
})
|
||||
@ -218,7 +217,7 @@ func SimulateFromSeed(
|
||||
blockTime = blockTime.Add(time.Duration(int64(r.Intn(int(timeDiff)))) * time.Second)
|
||||
proposerAddress = validators.randomProposer(r)
|
||||
|
||||
logWriter.AddEntry(EndBlockEntry(int64(height)))
|
||||
logWriter.AddEntry(EndBlockEntry(blockHeight))
|
||||
|
||||
if config.Commit {
|
||||
app.Commit()
|
||||
@ -232,7 +231,7 @@ func SimulateFromSeed(
|
||||
|
||||
// Generate a random RequestBeginBlock with the current validator set
|
||||
// for the next block
|
||||
finalizeBlockReq = RandomRequestFinalizeBlock(r, params, validators, pastTimes, pastVoteInfos, eventStats.Tally, blockHeight, genesisTimestamp, proposerAddress)
|
||||
finalizeBlockReq = RandomRequestFinalizeBlock(r, params, validators, pastTimes, pastVoteInfos, eventStats.Tally, blockHeight, blockTime, proposerAddress)
|
||||
|
||||
// Update the validator set, which will be reflected in the application
|
||||
// on the next block
|
||||
@ -240,7 +239,7 @@ func SimulateFromSeed(
|
||||
nextValidators = updateValidators(tb, r, params, validators, res.ValidatorUpdates, eventStats.Tally)
|
||||
|
||||
// update the exported params
|
||||
if config.ExportParamsPath != "" && config.ExportParamsHeight == height {
|
||||
if config.ExportParamsPath != "" && int64(config.ExportParamsHeight) == blockHeight {
|
||||
exportedParams = params
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user