@@ -29,30 +29,6 @@ func (k Keeper) PreBlocker(ctx context.Context) error {
2929 }
3030 found := err == nil
3131
32- if ! k .DowngradeVerified () {
33- k .SetDowngradeVerified (true )
34- // This check will make sure that we are using a valid binary.
35- // It'll panic in these cases if there is no upgrade handler registered for the last applied upgrade.
36- // 1. If there is no scheduled upgrade.
37- // 2. If the plan is not ready.
38- // 3. If the plan is ready and skip upgrade height is set for current height.
39- if ! found || ! plan .ShouldExecute (blockHeight ) || (plan .ShouldExecute (blockHeight ) && k .IsSkipHeight (blockHeight )) {
40- lastAppliedPlan , _ , err := k .GetLastCompletedUpgrade (ctx )
41- if err != nil {
42- return err
43- }
44-
45- if lastAppliedPlan != "" && ! k .HasHandler (lastAppliedPlan ) {
46- appVersion , err := k .consensusKeeper .AppVersion (ctx )
47- if err != nil {
48- return err
49- }
50-
51- return fmt .Errorf ("wrong app version %d, upgrade handler is missing for %s upgrade plan" , appVersion , lastAppliedPlan )
52- }
53- }
54- }
55-
5632 if ! found {
5733 return nil
5834 }
@@ -104,7 +80,28 @@ func (k Keeper) PreBlocker(ctx context.Context) error {
10480 // Returning an error will end up in a panic
10581 return errors .New (downgradeMsg )
10682 }
107- return nil
83+
84+ if ! k .DowngradeVerified () {
85+ k .SetDowngradeVerified (true )
86+ lastAppliedPlan , _ := k .GetLastCompletedUpgrade (ctx )
87+ // This check will make sure that we are using a valid binary.
88+ // It'll panic in these cases if there is no upgrade handler registered for the last applied upgrade.
89+ // 1. If there is no scheduled upgrade.
90+ // 2. If the plan is not ready.
91+ // 3. If the plan is ready and skip upgrade height is set for current height.
92+ if ! found || ! plan .ShouldExecute (ctx ) || (plan .ShouldExecute (ctx ) && k .IsSkipHeight (ctx .BlockHeight ())) {
93+ if lastAppliedPlan != "" && ! k .HasHandler (lastAppliedPlan ) {
94+ var appVersion uint64
95+
96+ cp := ctx .ConsensusParams ()
97+ if cp != nil && cp .Version != nil {
98+ appVersion = cp .Version .AppVersion
99+ }
100+
101+ panic (fmt .Sprintf ("Wrong app version %d, upgrade handler is missing for %s upgrade plan" , appVersion , lastAppliedPlan ))
102+ }
103+ }
104+ }
108105}
109106
110107// BuildUpgradeNeededMsg prints the message that notifies that an upgrade is needed.
0 commit comments