-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Upgrade handler for v0.4.0 (#459)
* fix: Register ibcclient gov route * ibc param keytable * set ibc client in upgrade handler * nolint space * register param set in initParamsKeeper * initgensis in upgrade handler * set params in upgrade handler with logs * set ibc client params in app.go * move client setting to end of NewApp * update consensus params in upgrade handler * fix updating consensus params * try rc12 handler * remove registerUpgrade0_4_0Rc12 * ibc client update in handler * put ibc client param setting back in app.go * move client setting * move client setting again * move preblocker setting * init restructure * ibc param after initchain * ibc param and preblock at end * mm.PreBlock in oracle PreBlocker * update preblocker * move setpreblocker * move preblocker in app package * ibc client params in upgrade keeper * update ibc params in both upgrade handler amd app.go * initparamskeeper * fix initparamskeeper * vote period handler * fix unit tests with vote period as 1 * comment
- Loading branch information
1 parent
ea3355b
commit 2195260
Showing
13 changed files
with
144 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package app | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"cosmossdk.io/core/appmodule" | ||
cometabci "github.com/cometbft/cometbft/abci/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/ojo-network/ojo/x/oracle/abci" | ||
) | ||
|
||
// PreBlocker is run before finalize block to update the aggregrate exchange rate votes on the oracle module | ||
// that were verified by the vote etension handler so that the exchange rate votes are available during the | ||
// entire block execution (from BeginBlock). It will execute the preblockers of the other modules set in | ||
// SetOrderPreBlockers as well. | ||
func (app *App) PreBlocker(ctx sdk.Context, req *cometabci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { | ||
if req == nil { | ||
err := fmt.Errorf("preblocker received a nil request") | ||
app.Logger().Error(err.Error()) | ||
return nil, err | ||
} | ||
|
||
// execute preblockers of modules in OrderPreBlockers first. | ||
ctx = ctx.WithEventManager(sdk.NewEventManager()) | ||
paramsChanged := false | ||
for _, moduleName := range app.mm.OrderPreBlockers { | ||
if module, ok := app.mm.Modules[moduleName].(appmodule.HasPreBlocker); ok { | ||
rsp, err := module.PreBlock(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if rsp.IsConsensusParamsChanged() { | ||
paramsChanged = true | ||
} | ||
} | ||
} | ||
|
||
res := &sdk.ResponsePreBlock{ | ||
ConsensusParamsChanged: paramsChanged, | ||
} | ||
|
||
if len(req.Txs) == 0 { | ||
return res, nil | ||
} | ||
voteExtensionsEnabled := abci.VoteExtensionsEnabled(ctx) | ||
if voteExtensionsEnabled { | ||
var injectedVoteExtTx abci.AggregateExchangeRateVotes | ||
if err := json.Unmarshal(req.Txs[0], &injectedVoteExtTx); err != nil { | ||
app.Logger().Error("failed to decode injected vote extension tx", "err", err) | ||
return nil, err | ||
} | ||
|
||
// set oracle exchange rate votes using the passed in context, which will make | ||
// these votes available in the current block. | ||
for _, exchangeRateVote := range injectedVoteExtTx.ExchangeRateVotes { | ||
valAddr, err := sdk.ValAddressFromBech32(exchangeRateVote.Voter) | ||
if err != nil { | ||
app.Logger().Error("failed to get voter address", "err", err) | ||
continue | ||
} | ||
app.OracleKeeper.SetAggregateExchangeRateVote(ctx, valAddr, exchangeRateVote) | ||
} | ||
} | ||
|
||
app.Logger().Info( | ||
"oracle preblocker executed", | ||
"vote_extensions_enabled", voteExtensionsEnabled, | ||
) | ||
|
||
return res, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.