Skip to content

Commit

Permalink
Merge pull request #3765 from oasisprotocol/kostko/fix/upgrader-check…
Browse files Browse the repository at this point in the history
…s-perblk

go/consensus/tendermint/governance: Move upgrader checks
  • Loading branch information
kostko authored Mar 8, 2021
2 parents 1434dd0 + b3c2034 commit c0493a0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Empty file added .changelog/3764.trivial.md
Empty file.
13 changes: 8 additions & 5 deletions go/consensus/tendermint/apps/governance/governance.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ func (app *governanceApplication) ExecuteMessage(ctx *api.Context, kind, msg int
func (app *governanceApplication) BeginBlock(ctx *api.Context, request types.RequestBeginBlock) error {
// Check if epoch has changed.
epochChanged, epoch := app.state.EpochChanged(ctx)
if !epochChanged {
// Nothing to do.
return nil
}

// Check if there are any upgrades pending or if we need to halt for an upgrade.
// Check if there are any upgrades pending or if we need to halt for an upgrade. Note that these
// checks must run on each block to make sure that any pending upgrade descriptors are cleared
// after consensus upgrade is performed.
if upgrader := ctx.AppState().Upgrader(); upgrader != nil {
switch err := upgrader.ConsensusUpgrade(ctx, epoch, ctx.BlockHeight()); err {
case nil:
Expand All @@ -105,6 +103,11 @@ func (app *governanceApplication) BeginBlock(ctx *api.Context, request types.Req
}
}

if !epochChanged {
// Nothing to do.
return nil
}

// Check if a pending upgrade is scheduled for current epoch.
state := governanceState.NewMutableState(ctx.State())
pendingUpgrades, err := state.PendingUpgrades(ctx)
Expand Down
2 changes: 0 additions & 2 deletions go/consensus/tendermint/full/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -1367,8 +1367,6 @@ func (t *fullService) syncWorker() {
return
}
if !isFastSyncing {
t.Logger.Info("Tendermint Node finished fast-sync")

// Check latest block time.
tmBlock, err := t.GetTendermintBlock(t.ctx, consensusAPI.HeightLatest)
if err != nil {
Expand Down

0 comments on commit c0493a0

Please sign in to comment.