diff --git a/CHANGELOG.md b/CHANGELOG.md index 17af456cf..d02d36d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,7 +103,6 @@ Zenith](https://code4rena.com/zenith) Audit, running from 2024-10-07 until period. This section describes code changes that occurred after that audit in preparation for a second audit starting in November 2024. -- [#2068](https://github.com/NibiruChain/nibiru/pull/2068) - feat: enable wasm light clients on IBC (08-wasm) - [#2074](https://github.com/NibiruChain/nibiru/pull/2074) - fix(evm-keeper): better utilize ERC20 metadata during FunToken creation. The bank metadata for a new FunToken mapping ties a connection between the Bank Coin's `DenomUnit` and the ERC20 contract metadata like the name, decimals, and symbol. This change brings parity between EVM wallets, such as MetaMask, and Interchain wallets like Keplr and Leap. - [#2076](https://github.com/NibiruChain/nibiru/pull/2076) - fix(evm-gas-fees): Use effective gas price in RefundGas and make sure that units are properly @@ -151,6 +150,12 @@ preparation for a second audit starting in November 2024. - [#2098](https://github.com/NibiruChain/nibiru/pull/2098) - test(evm): statedb tests for race conditions within funtoken precompile - [#2100](https://github.com/NibiruChain/nibiru/pull/2100) - refactor: cleanup statedb and precompile sections +- [#2098](https://github.com/NibiruChain/nibiru/pull/2098) - test(evm): statedb tests for race conditions within funtoken precompile +- [#2090](https://github.com/NibiruChain/nibiru/pull/2090) - fix(evm): Account +for (1) ERC20 transfers with tokens that return false success values instead of +throwing an error and (2) ERC20 transfers with other operations that don't bring +about the expected resulting balance for the transfer recipient. +- [#2092](https://github.com/NibiruChain/nibiru/pull/2092) - feat(evm): add validation for wasm multi message execution - [#2101](https://github.com/NibiruChain/nibiru/pull/2101) - fix(evm): tx receipt proper marshalling - [#2105](https://github.com/NibiruChain/nibiru/pull/2105) - test(evm): precompile call with revert - [#2106](https://github.com/NibiruChain/nibiru/pull/2106) - chore: scheduled basic e2e tests for evm testnet endpoint diff --git a/Dockerfile b/Dockerfile index af7149c3b..b81262b7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,4 +25,4 @@ RUN apk --no-cache add \ COPY --from=builder /nibiru/build/nibid /usr/local/bin/nibid ENTRYPOINT ["nibid"] -CMD [ "start" ] +CMD [ "start" ] \ No newline at end of file diff --git a/app/app.go b/app/app.go index e2ecc8013..992f8e775 100644 --- a/app/app.go +++ b/app/app.go @@ -10,19 +10,10 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - cmtos "github.com/cometbft/cometbft/libs/os" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" - - "github.com/NibiruChain/nibiru/v2/app/ante" - "github.com/NibiruChain/nibiru/v2/app/wasmext" - "github.com/NibiruChain/nibiru/v2/x/evm/precompile" - dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" _ "github.com/cosmos/cosmos-sdk/client/docs/statik" @@ -46,16 +37,18 @@ import ( capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" "github.com/cosmos/cosmos-sdk/x/crisis" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" - ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/cosmos/ibc-go/v7/testing/types" - "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus" "github.com/rakyll/statik/fs" "github.com/spf13/cast" + "github.com/NibiruChain/nibiru/v2/app/ante" + "github.com/NibiruChain/nibiru/v2/app/wasmext" + "github.com/NibiruChain/nibiru/v2/x/evm/precompile" + // force call init() of the geth tracers _ "github.com/ethereum/go-ethereum/eth/tracers/native" ) @@ -202,7 +195,6 @@ func NewNibiruApp( app.initModuleManager(encodingConfig, skipGenesisInvariants) app.setupUpgrades() - // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. @@ -248,10 +240,6 @@ func NewNibiruApp( app.CommitMultiStore(), &app.WasmKeeper, ), - ibcwasmkeeper.NewWasmSnapshotter( - app.CommitMultiStore(), - &app.WasmClientKeeper, - ), ); err != nil { panic("failed to add wasm snapshot extension.") } @@ -262,13 +250,6 @@ func NewNibiruApp( tmos.Exit(err.Error()) } - ctx := app.BaseApp.NewUncachedContext(true, cmtproto.Header{}) - - // Initialize pinned codes in wasmvm as they are not persisted there - if err := ibcwasmkeeper.InitializePinnedCodes(ctx, app.appCodec); err != nil { - cmtos.Exit(fmt.Sprintf("failed to initialize pinned codes %s", err)) - } - /* Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating their scoped modules in `NewApp` with `capabilityKeeper.ScopeToModule`. diff --git a/app/keepers.go b/app/keepers.go index 1138bc540..fc24f561e 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -4,8 +4,6 @@ import ( "path/filepath" "strings" - ibcwasm "github.com/cosmos/ibc-go/modules/light-clients/08-wasm" - ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" ica "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts" icacontroller "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller" icacontrollerkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/keeper" @@ -18,7 +16,6 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - wasmvm "github.com/CosmWasm/wasmvm" _ "github.com/cosmos/cosmos-sdk/client/docs/statik" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" @@ -85,7 +82,6 @@ import ( // --------------------------------------------------------------- // IBC imports - ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" icahostkeeper "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/keeper" ibcfee "github.com/cosmos/ibc-go/v7/modules/apps/29-fee" ibcfeekeeper "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/keeper" @@ -124,7 +120,7 @@ import ( "github.com/NibiruChain/nibiru/v2/x/inflation" inflationkeeper "github.com/NibiruChain/nibiru/v2/x/inflation/keeper" inflationtypes "github.com/NibiruChain/nibiru/v2/x/inflation/types" - "github.com/NibiruChain/nibiru/v2/x/oracle" + oracle "github.com/NibiruChain/nibiru/v2/x/oracle" oraclekeeper "github.com/NibiruChain/nibiru/v2/x/oracle/keeper" oracletypes "github.com/NibiruChain/nibiru/v2/x/oracle/types" @@ -132,13 +128,11 @@ import ( "github.com/NibiruChain/nibiru/v2/x/sudo/keeper" sudotypes "github.com/NibiruChain/nibiru/v2/x/sudo/types" - "github.com/NibiruChain/nibiru/v2/x/tokenfactory" + tokenfactory "github.com/NibiruChain/nibiru/v2/x/tokenfactory" tokenfactorykeeper "github.com/NibiruChain/nibiru/v2/x/tokenfactory/keeper" tokenfactorytypes "github.com/NibiruChain/nibiru/v2/x/tokenfactory/types" ) -const wasmVmContractMemoryLimit = 32 - type AppKeepers struct { keepers.PublicKeepers privateKeepers @@ -197,7 +191,6 @@ func initStoreKeys() ( ibcexported.StoreKey, icahosttypes.StoreKey, icacontrollertypes.StoreKey, - ibcwasmtypes.StoreKey, // nibiru x/ keys oracletypes.StoreKey, @@ -258,7 +251,7 @@ func (app *NibiruApp) InitKeepers( // seal capability keeper after scoping modules // app.capabilityKeeper.Seal() - // TODO: chore(upgrade): Potential breaking change on AccountKeeper due + // TODO: chore(upgrade): Potential breaking change on AccountKeeper dur // to ProtoBaseAccount replacement. app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, @@ -460,12 +453,6 @@ func (app *NibiruApp) InitKeepers( // passed to GetWasmOpts must already have a non-nil InflationKeeper. supportedFeatures := strings.Join(wasmdapp.AllCapabilities(), ",") - // Create wasm VM outside keeper so it can be re-used in client keeper - wasmVM, err := wasmvm.NewVM(filepath.Join(wasmDir, "wasm"), supportedFeatures, wasmVmContractMemoryLimit, wasmConfig.ContractDebugMode, wasmConfig.MemoryCacheSize) - if err != nil { - panic(err) - } - wmha := wasmext.MsgHandlerArgs{ Router: app.MsgServiceRouter(), Ics4Wrapper: app.ibcFeeKeeper, @@ -494,16 +481,7 @@ func (app *NibiruApp) InitKeepers( wasmConfig, supportedFeatures, govModuleAddr, - append(GetWasmOpts(*app, appOpts, wmha), wasmkeeper.WithWasmEngine(wasmVM))..., - ) - - app.WasmClientKeeper = ibcwasmkeeper.NewKeeperWithVM( - appCodec, - keys[ibcwasmtypes.StoreKey], - app.ibcKeeper.ClientKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - wasmVM, - app.GRPCQueryRouter(), + GetWasmOpts(*app, appOpts, wmha)..., ) // DevGas uses WasmKeeper @@ -654,7 +632,7 @@ func (app *NibiruApp) initAppModules( authzmodule.NewAppModule(appCodec, app.authzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), // Nibiru modules - oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper), + oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.SudoKeeper), epochs.NewAppModule(appCodec, app.EpochsKeeper), inflation.NewAppModule(app.InflationKeeper, app.AccountKeeper, *app.StakingKeeper), sudo.NewAppModule(appCodec, app.SudoKeeper), @@ -666,7 +644,6 @@ func (app *NibiruApp) initAppModules( ibctransfer.NewAppModule(app.ibcTransferKeeper), ibcfee.NewAppModule(app.ibcFeeKeeper), ica.NewAppModule(&app.icaControllerKeeper, &app.icaHostKeeper), - ibcwasm.NewAppModule(app.WasmClientKeeper), evmmodule.NewAppModule(app.EvmKeeper, app.AccountKeeper), @@ -737,7 +714,6 @@ func orderedModuleNames() []string { ibcexported.ModuleName, ibcfeetypes.ModuleName, icatypes.ModuleName, - ibcwasmtypes.ModuleName, // -------------------------------------------------------------------- evm.ModuleName, @@ -843,7 +819,6 @@ func ModuleBasicManager() module.BasicManager { ibctransfer.AppModuleBasic{}, ibctm.AppModuleBasic{}, ica.AppModuleBasic{}, - ibcwasm.AppModuleBasic{}, // native x/ evmmodule.AppModuleBasic{}, oracle.AppModuleBasic{}, diff --git a/app/keepers/all_keepers.go b/app/keepers/all_keepers.go index 06d08655c..43278e3d5 100644 --- a/app/keepers/all_keepers.go +++ b/app/keepers/all_keepers.go @@ -10,7 +10,6 @@ import ( distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" - ibcwasmkeeper "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -72,5 +71,4 @@ type PublicKeepers struct { WasmMsgHandlerArgs wasmext.MsgHandlerArgs ScopedWasmKeeper capabilitykeeper.ScopedKeeper - WasmClientKeeper ibcwasmkeeper.Keeper } diff --git a/app/upgrades.go b/app/upgrades.go index 6c547c390..9cc83f588 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -6,19 +6,27 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/NibiruChain/nibiru/v2/app/upgrades" + "github.com/NibiruChain/nibiru/v2/app/upgrades/v1_0_1" + "github.com/NibiruChain/nibiru/v2/app/upgrades/v1_0_2" + "github.com/NibiruChain/nibiru/v2/app/upgrades/v1_0_3" "github.com/NibiruChain/nibiru/v2/app/upgrades/v1_1_0" "github.com/NibiruChain/nibiru/v2/app/upgrades/v1_2_0" "github.com/NibiruChain/nibiru/v2/app/upgrades/v1_3_0" "github.com/NibiruChain/nibiru/v2/app/upgrades/v1_4_0" - "github.com/NibiruChain/nibiru/v2/app/upgrades/v2_1_0" + "github.com/NibiruChain/nibiru/v2/app/upgrades/v1_5_0" + "github.com/NibiruChain/nibiru/v2/app/upgrades/v2_0_0" ) var Upgrades = []upgrades.Upgrade{ + v1_0_1.Upgrade, + v1_0_2.Upgrade, + v1_0_3.Upgrade, v1_1_0.Upgrade, v1_2_0.Upgrade, v1_3_0.Upgrade, v1_4_0.Upgrade, - v2_1_0.Upgrade, + v1_5_0.Upgrade, + v2_0_0.Upgrade, } func (app *NibiruApp) setupUpgrades() { @@ -28,7 +36,7 @@ func (app *NibiruApp) setupUpgrades() { func (app *NibiruApp) setUpgradeHandlers() { for _, u := range Upgrades { - app.upgradeKeeper.SetUpgradeHandler(u.UpgradeName, u.CreateUpgradeHandler(app.ModuleManager, app.configurator, app.ibcKeeper.ClientKeeper)) + app.upgradeKeeper.SetUpgradeHandler(u.UpgradeName, u.CreateUpgradeHandler(app.ModuleManager, app.configurator)) } } diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 88dd83c13..a2cdde4b5 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -4,14 +4,12 @@ import ( store "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" ) type Upgrade struct { UpgradeName string - CreateUpgradeHandler func(*module.Manager, module.Configurator, clientkeeper.Keeper) types.UpgradeHandler + CreateUpgradeHandler func(*module.Manager, module.Configurator) types.UpgradeHandler StoreUpgrades store.StoreUpgrades } diff --git a/app/upgrades/v1_0_1/constants.go b/app/upgrades/v1_0_1/constants.go new file mode 100644 index 000000000..1548161da --- /dev/null +++ b/app/upgrades/v1_0_1/constants.go @@ -0,0 +1,23 @@ +package v1_0_1 + +import ( + "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/NibiruChain/nibiru/v2/app/upgrades" +) + +const UpgradeName = "v1.0.1" + +// pretty much a no-op store upgrade to test the upgrade process and include the newer version of rocksdb +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, cfg, fromVM) + } + }, + StoreUpgrades: types.StoreUpgrades{}, +} diff --git a/app/upgrades/v1_0_2/constants.go b/app/upgrades/v1_0_2/constants.go new file mode 100644 index 000000000..5333497fc --- /dev/null +++ b/app/upgrades/v1_0_2/constants.go @@ -0,0 +1,23 @@ +package v1_0_2 + +import ( + "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/NibiruChain/nibiru/v2/app/upgrades" +) + +const UpgradeName = "v1.0.2" + +// a no-op store upgrade to test the upgrade process and include the newer version cosmos-sdk +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, cfg, fromVM) + } + }, + StoreUpgrades: types.StoreUpgrades{}, +} diff --git a/app/upgrades/v1_0_3/constants.go b/app/upgrades/v1_0_3/constants.go new file mode 100644 index 000000000..acec556b6 --- /dev/null +++ b/app/upgrades/v1_0_3/constants.go @@ -0,0 +1,23 @@ +package v1_0_3 + +import ( + "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/NibiruChain/nibiru/v2/app/upgrades" +) + +const UpgradeName = "v1.0.3" + +// a no-op store upgrade to test the upgrade process and include the newer version cosmos-sdk +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, cfg, fromVM) + } + }, + StoreUpgrades: types.StoreUpgrades{}, +} diff --git a/app/upgrades/v1_1_0/constants.go b/app/upgrades/v1_1_0/constants.go index bd119eb7a..4fdebdf6c 100644 --- a/app/upgrades/v1_1_0/constants.go +++ b/app/upgrades/v1_1_0/constants.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" "github.com/NibiruChain/nibiru/v2/app/upgrades" inflationtypes "github.com/NibiruChain/nibiru/v2/x/inflation/types" @@ -15,7 +14,7 @@ const UpgradeName = "v1.1.0" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, - CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, clientKeeper clientkeeper.Keeper) upgradetypes.UpgradeHandler { + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { return mm.RunMigrations(ctx, cfg, fromVM) } diff --git a/app/upgrades/v1_2_0/constants.go b/app/upgrades/v1_2_0/constants.go index 0805d4b66..63718c21d 100644 --- a/app/upgrades/v1_2_0/constants.go +++ b/app/upgrades/v1_2_0/constants.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" "github.com/NibiruChain/nibiru/v2/app/upgrades" ) @@ -14,7 +13,7 @@ const UpgradeName = "v1.2.0" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, - CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, clientKeeper clientkeeper.Keeper) upgradetypes.UpgradeHandler { + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { return mm.RunMigrations(ctx, cfg, fromVM) } diff --git a/app/upgrades/v1_3_0/constants.go b/app/upgrades/v1_3_0/constants.go index 263817ac0..320bdae7c 100644 --- a/app/upgrades/v1_3_0/constants.go +++ b/app/upgrades/v1_3_0/constants.go @@ -14,7 +14,6 @@ import ( icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" "github.com/NibiruChain/nibiru/v2/app/upgrades" ) @@ -23,7 +22,7 @@ const UpgradeName = "v1.3.0" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, - CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, clientKeeper clientkeeper.Keeper) upgradetypes.UpgradeHandler { + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { // set the ICS27 consensus version so InitGenesis is not run fromVM[icatypes.ModuleName] = mm.GetVersionMap()[icatypes.ModuleName] diff --git a/app/upgrades/v1_4_0/constants.go b/app/upgrades/v1_4_0/constants.go index 28d53df22..fbfa766ea 100644 --- a/app/upgrades/v1_4_0/constants.go +++ b/app/upgrades/v1_4_0/constants.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" "github.com/NibiruChain/nibiru/v2/app/upgrades" ) @@ -14,7 +13,7 @@ const UpgradeName = "v1.4.0" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, - CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, clientKeeper clientkeeper.Keeper) upgradetypes.UpgradeHandler { + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { return mm.RunMigrations(ctx, cfg, fromVM) } diff --git a/app/upgrades/v1_5_0/constants.go b/app/upgrades/v1_5_0/constants.go new file mode 100644 index 000000000..71e4aa827 --- /dev/null +++ b/app/upgrades/v1_5_0/constants.go @@ -0,0 +1,22 @@ +package v1_5_0 + +import ( + "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/NibiruChain/nibiru/v2/app/upgrades" +) + +const UpgradeName = "v1.5.0" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, cfg, fromVM) + } + }, + StoreUpgrades: types.StoreUpgrades{}, +} diff --git a/app/upgrades/v2_0_0/constants.go b/app/upgrades/v2_0_0/constants.go new file mode 100644 index 000000000..cc4c5eaf2 --- /dev/null +++ b/app/upgrades/v2_0_0/constants.go @@ -0,0 +1,25 @@ +package v2_0_0 + +import ( + "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/NibiruChain/nibiru/v2/app/upgrades" + evmtypes "github.com/NibiruChain/nibiru/v2/x/evm" +) + +const UpgradeName = "v2.0.0" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, cfg, fromVM) + } + }, + StoreUpgrades: types.StoreUpgrades{ + Added: []string{evmtypes.ModuleName}, + }, +} diff --git a/app/upgrades/v2_1_0/constants.go b/app/upgrades/v2_1_0/constants.go deleted file mode 100644 index f294c66a4..000000000 --- a/app/upgrades/v2_1_0/constants.go +++ /dev/null @@ -1,42 +0,0 @@ -package v2_1_0 - -import ( - "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" - clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper" - - "github.com/NibiruChain/nibiru/v2/app/upgrades" -) - -const UpgradeName = "v2.1.0" - -var Upgrade = upgrades.Upgrade{ - UpgradeName: UpgradeName, - CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, clientKeeper clientkeeper.Keeper) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // explicitly update the IBC 02-client params, adding the wasm client type if it is not there - params := clientKeeper.GetParams(ctx) - - hasWasmClient := false - for _, client := range params.AllowedClients { - if client == ibcwasmtypes.Wasm { - hasWasmClient = true - break - } - } - - if !hasWasmClient { - params.AllowedClients = append(params.AllowedClients, ibcwasmtypes.Wasm) - clientKeeper.SetParams(ctx, params) - } - - return mm.RunMigrations(ctx, cfg, fromVM) - } - }, - StoreUpgrades: types.StoreUpgrades{ - Added: []string{ibcwasmtypes.ModuleName}, - }, -} diff --git a/cmd/nibid/cmd/init.go b/cmd/nibid/cmd/init.go index 13de92198..1d8c439a9 100644 --- a/cmd/nibid/cmd/init.go +++ b/cmd/nibid/cmd/init.go @@ -8,7 +8,6 @@ import ( "path/filepath" tmcfg "github.com/cometbft/cometbft/config" - ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" "github.com/NibiruChain/nibiru/v2/app/appconst" @@ -26,9 +25,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/genutil" - - ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibctypes "github.com/cosmos/ibc-go/v7/modules/core/types" ) const ( @@ -133,11 +129,6 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { } appGenState := mbm.DefaultGenesis(cdc) - // add 08-wasm to AllowedClients - ibcState := ibctypes.DefaultGenesisState() - ibcState.ClientGenesis.Params.AllowedClients = append(ibcState.ClientGenesis.Params.AllowedClients, ibcwasmtypes.Wasm) - appGenState[ibcexported.ModuleName] = cdc.MustMarshalJSON(ibcState) - appState, err := json.MarshalIndent(appGenState, "", " ") if err != nil { return errors.Wrap(err, "Failed to marshal default genesis state") diff --git a/contrib/docker/chaosnet.Dockerfile b/contrib/docker/chaosnet.Dockerfile index 5fc847028..db9cea315 100644 --- a/contrib/docker/chaosnet.Dockerfile +++ b/contrib/docker/chaosnet.Dockerfile @@ -25,6 +25,7 @@ RUN apk --no-cache add \ COPY --from=builder /nibiru/build/nibid /usr/local/bin/nibid COPY ./contrib/scripts/chaosnet.sh ./ +COPY ./contrib/scripts/feat-perp.sh ./ RUN chmod +x ./chaosnet.sh ARG MNEMONIC ARG CHAIN_ID diff --git a/contrib/scripts/release_pre_linux.sh b/contrib/scripts/release_pre_linux.sh index a13983f5d..16602a174 100755 --- a/contrib/scripts/release_pre_linux.sh +++ b/contrib/scripts/release_pre_linux.sh @@ -32,4 +32,4 @@ else wget -c https://github.com/NibiruChain/gorocksdb/releases/download/v${ROCKSDB_VERSION}/librocksdb_${ROCKSDB_VERSION}_linux_arm64.tar.gz -O /tmp/librocksdb_${ROCKSDB_VERSION}_linux_arm64.tar.gz tar -xvf /tmp/librocksdb_${ROCKSDB_VERSION}_linux_arm64.tar.gz -C /usr/lib/aarch64-linux-gnu/ -fi \ No newline at end of file +fi diff --git a/go.mod b/go.mod index 3dc5c3b51..270b09c5a 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( // Cosmos-SDK and IBC github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/cosmos-sdk v0.47.11 - github.com/cosmos/ibc-go/v7 v7.4.0 + github.com/cosmos/ibc-go/v7 v7.3.2 github.com/ethereum/go-ethereum v1.10.17 ) @@ -57,7 +57,6 @@ require ( require ( cosmossdk.io/collections v0.4.0 cosmossdk.io/tools/rosetta v0.2.1 - github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.3.2-0.20240730185603-13c071f0b34d github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/gorilla/websocket v1.5.0 github.com/rs/cors v1.8.3 diff --git a/go.sum b/go.sum index 71154baa5..f4364ff51 100644 --- a/go.sum +++ b/go.sum @@ -438,10 +438,8 @@ github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoK github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38= github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= -github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.3.2-0.20240730185603-13c071f0b34d h1:QJK/Zr0HblNx6z1x5LXIHEblY7DCCftMkUBcjpKe1qY= -github.com/cosmos/ibc-go/modules/light-clients/08-wasm v0.3.2-0.20240730185603-13c071f0b34d/go.mod h1:5oIHokzX6RJ6q93tLcWZ7Thkrt9vrMGIz3He9HFE660= -github.com/cosmos/ibc-go/v7 v7.4.0 h1:8FqYMptvksgMvlbN4UW9jFxTXzsPyfAzEZurujXac8M= -github.com/cosmos/ibc-go/v7 v7.4.0/go.mod h1:L/KaEhzV5TGUCTfGysVgMBQtl5Dm7hHitfpk+GIeoAo= +github.com/cosmos/ibc-go/v7 v7.3.2 h1:FeUDcBX7VYY0e0iRmcVkPPUjYfAqIc//QuHXo8JHz9c= +github.com/cosmos/ibc-go/v7 v7.3.2/go.mod h1:IMeOXb7gwpZ+/nOG5BuUkdW4weM1ezvN4PQPws4uzOI= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= diff --git a/proto/nibiru/oracle/v1/tx.proto b/proto/nibiru/oracle/v1/tx.proto index 4baa5402e..8fa0175e0 100644 --- a/proto/nibiru/oracle/v1/tx.proto +++ b/proto/nibiru/oracle/v1/tx.proto @@ -3,6 +3,7 @@ package nibiru.oracle.v1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "google/protobuf/duration.proto"; import "nibiru/oracle/v1/oracle.proto"; option go_package = "github.com/NibiruChain/nibiru/v2/x/oracle/types"; @@ -33,7 +34,7 @@ service Msg { rpc EditOracleParams(MsgEditOracleParams) returns (MsgEditOracleParamsResponse) { - option (google.api.http).post = "/nibiru/oracle/edit-oracle-params"; + option (google.api.http).post = "/nibiru/oracle/params"; } } @@ -91,64 +92,100 @@ message MsgDelegateFeedConsent { // type. message MsgDelegateFeedConsentResponse {} -// MsgEditOracleParams: gRPC tx message for updating the x/oracle module params -// [SUDO] Only callable by sudoers. message MsgEditOracleParams { - string sender = 1; + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + + OracleParamsMsg params = 2 [ (gogoproto.moretags) = "yaml:\"params\"" ]; +} - string vote_period = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", +message MsgEditOracleParamsResponse {} + +message OracleParamsMsg { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = true; + + // VotePeriod defines the number of blocks during which voting takes place. + uint64 vote_period = 1 [ + (gogoproto.moretags) = "yaml:\"vote_period\"", (gogoproto.nullable) = true ]; - // vote_threshold: [cosmossdk.io/math.LegacyDec] TODO: - string vote_threshold = 3 [ + // VoteThreshold specifies the minimum proportion of votes that must be + // received for a ballot to pass. + string vote_threshold = 2 [ + (gogoproto.moretags) = "yaml:\"vote_threshold\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = true ]; - - // reward_band: [cosmossdk.io/math.LegacyDec] TODO: - string reward_band = 4 [ + // RewardBand defines a maxium divergence that a price vote can have from the + // weighted median in the ballot. If a vote lies within the valid range + // defined by: + // μ := weightedMedian, + // validRange := μ ± (μ * rewardBand / 2), + // then rewards are added to the validator performance. + // Note that if the reward band is smaller than 1 standard + // deviation, the band is taken to be 1 standard deviation.a price + string reward_band = 3 [ + (gogoproto.moretags) = "yaml:\"reward_band\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = true ]; - - repeated string whitelist = 5 [ (gogoproto.nullable) = true ]; - - // slash_fraction: [cosmossdk.io/math.LegacyDec] TODO: - string slash_fraction = 6 [ + // The set of whitelisted markets, or asset pairs, for the module. + // Ex. '["unibi:uusd","ubtc:uusd"]' + repeated string whitelist = 4 [ + (gogoproto.moretags) = "yaml:\"whitelist\"", + (gogoproto.customtype) = "github.com/NibiruChain/nibiru/v2/x/common/asset.Pair", + (gogoproto.nullable) = true + ]; + // SlashFraction returns the proportion of an oracle's stake that gets + // slashed in the event of slashing. `SlashFraction` specifies the exact + // penalty for failing a voting period. + string slash_fraction = 5 [ + (gogoproto.moretags) = "yaml:\"slash_fraction\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = true ]; - - string slash_window = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + // SlashWindow returns the number of voting periods that specify a + // "slash window". After each slash window, all oracles that have missed more + // than the penalty threshold are slashed. Missing the penalty threshold is + // synonymous with submitting fewer valid votes than `MinValidPerWindow`. + uint64 slash_window = 6 [ + (gogoproto.moretags) = "yaml:\"slash_window\"", (gogoproto.nullable) = true ]; - - // min_valid_per_window: [cosmossdk.io/math.LegacyDec] TODO: - string min_valid_per_window = 8 [ + string min_valid_per_window = 7 [ + (gogoproto.moretags) = "yaml:\"min_valid_per_window\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = true ]; - string twap_lookback_window = 9 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = true + // Amount of time to look back for TWAP calculations + google.protobuf.Duration twap_lookback_window = 8 [ + (gogoproto.nullable) = true, + (gogoproto.stdduration) = true, + (gogoproto.jsontag) = "twap_lookback_window,omitempty", + (gogoproto.moretags) = "yaml:\"twap_lookback_window\"" ]; - string min_voters = 10 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + // The minimum number of voters (i.e. oracle validators) per pair for it to be + // considered a passing ballot. Recommended at least 4. + uint64 min_voters = 9 [ + (gogoproto.moretags) = "yaml:\"min_voters\"", (gogoproto.nullable) = true ]; - // VoteThreshold: [cosmossdk.io/math.LegacyDec] TODO: - string validator_fee_ratio = 11 [ + // The validator fee ratio that is given to validators every epoch. + string validator_fee_ratio = 10 [ + (gogoproto.moretags) = "yaml:\"validator_fee_ratio\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = true ]; -} -// MsgEditOracleParamsResponse defines the Msg/EditOracleParams response -// type. -message MsgEditOracleParamsResponse { nibiru.oracle.v1.Params new_params = 1; } + uint64 expiration_blocks = 11 [ + (gogoproto.moretags) = "yaml:\"expiration_blocks\"", + (gogoproto.nullable) = true + ]; +} \ No newline at end of file diff --git a/x/devgas/v1/module.go b/x/devgas/v1/module.go index 6f3ca969e..8176c0360 100644 --- a/x/devgas/v1/module.go +++ b/x/devgas/v1/module.go @@ -31,7 +31,7 @@ var ( ) // ConsensusVersion defines the current module consensus version. -const ConsensusVersion = 2 +const ConsensusVersion = 1 // AppModuleBasic type for the fees module type AppModuleBasic struct{} diff --git a/x/epochs/genesis_test.go b/x/epochs/genesis_test.go index d35c31db9..f861f3ea7 100644 --- a/x/epochs/genesis_test.go +++ b/x/epochs/genesis_test.go @@ -26,7 +26,7 @@ func TestEpochsExportGenesis(t *testing.T) { ctx := testapp.NewContext(app).WithBlockTime(chainStartTime) genesis := epochs.ExportGenesis(ctx, app.EpochsKeeper) - require.Len(t, genesis.Epochs, 3) + require.Len(t, genesis.Epochs, 4) errMsg := fmt.Sprintf("app.EpochsKeeper.AllEpochInfos(ctx): %v\n", app.EpochsKeeper.AllEpochInfos(ctx)) require.Equal(t, genesis.Epochs[0].Identifier, "30 min") @@ -45,13 +45,21 @@ func TestEpochsExportGenesis(t *testing.T) { require.Equal(t, genesis.Epochs[1].CurrentEpochStartTime, chainStartTime, errMsg) require.Equal(t, genesis.Epochs[1].EpochCountingStarted, false) - require.Equal(t, genesis.Epochs[2].Identifier, "week") + require.Equal(t, genesis.Epochs[2].Identifier, "month") require.Equal(t, genesis.Epochs[2].StartTime, chainStartTime, errMsg) - require.Equal(t, genesis.Epochs[2].Duration, time.Hour*24*7) + require.Equal(t, genesis.Epochs[2].Duration, time.Hour*24*30) require.Equal(t, genesis.Epochs[2].CurrentEpoch, uint64(0)) require.Equal(t, genesis.Epochs[2].CurrentEpochStartHeight, int64(0)) require.Equal(t, genesis.Epochs[2].CurrentEpochStartTime, chainStartTime, errMsg) require.Equal(t, genesis.Epochs[2].EpochCountingStarted, false) + + require.Equal(t, genesis.Epochs[3].Identifier, "week") + require.Equal(t, genesis.Epochs[3].StartTime, chainStartTime, errMsg) + require.Equal(t, genesis.Epochs[3].Duration, time.Hour*24*7) + require.Equal(t, genesis.Epochs[3].CurrentEpoch, uint64(0)) + require.Equal(t, genesis.Epochs[3].CurrentEpochStartHeight, int64(0)) + require.Equal(t, genesis.Epochs[3].CurrentEpochStartTime, chainStartTime, errMsg) + require.Equal(t, genesis.Epochs[3].EpochCountingStarted, false) } func TestEpochsInitGenesis(t *testing.T) { diff --git a/x/epochs/keeper/grpc_query_test.go b/x/epochs/keeper/grpc_query_test.go index 00cf0e69e..23f9e6c9d 100644 --- a/x/epochs/keeper/grpc_query_test.go +++ b/x/epochs/keeper/grpc_query_test.go @@ -31,7 +31,7 @@ func TestQueryEpochInfos(t *testing.T) { gocontext.Background(), &epochstypes.QueryEpochInfosRequest{}, ) require.NoError(t, err, errMsg) - require.Len(t, epochInfosResponse.Epochs, 3) + require.Len(t, epochInfosResponse.Epochs, 4) // check if EpochInfos are correct require.Equal(t, epochInfosResponse.Epochs[0].StartTime, chainStartTime, errMsg) diff --git a/x/epochs/keeper/keeper_test.go b/x/epochs/keeper/keeper_test.go index 7fa8120d2..43c9b38bf 100644 --- a/x/epochs/keeper/keeper_test.go +++ b/x/epochs/keeper/keeper_test.go @@ -14,9 +14,9 @@ func TestUpsertEpochInfo_HappyPath(t *testing.T) { nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() epochInfo := types.EpochInfo{ - Identifier: "monthly", + Identifier: "bi-monthly", StartTime: time.Time{}, - Duration: time.Hour * 24 * 30, + Duration: time.Hour * 24 * 30 * 2, CurrentEpoch: 0, CurrentEpochStartHeight: 0, CurrentEpochStartTime: time.Time{}, @@ -25,18 +25,19 @@ func TestUpsertEpochInfo_HappyPath(t *testing.T) { nibiruApp.EpochsKeeper.Epochs.Insert(ctx, epochInfo.Identifier, epochInfo) - epochInfoSaved, err := nibiruApp.EpochsKeeper.GetEpochInfo(ctx, "monthly") + epochInfoSaved, err := nibiruApp.EpochsKeeper.GetEpochInfo(ctx, "bi-monthly") require.NoError(t, err) require.Equal(t, epochInfo, epochInfoSaved) allEpochs := nibiruApp.EpochsKeeper.AllEpochInfos(ctx) - require.Len(t, allEpochs, 4) + require.Len(t, allEpochs, 5) // Epochs are ordered in alphabetical order require.Equal(t, "30 min", allEpochs[0].Identifier) - require.Equal(t, "day", allEpochs[1].Identifier) - require.Equal(t, "monthly", allEpochs[2].Identifier) - require.Equal(t, "week", allEpochs[3].Identifier) + require.Equal(t, "bi-monthly", allEpochs[1].Identifier) + require.Equal(t, "day", allEpochs[2].Identifier) + require.Equal(t, "month", allEpochs[3].Identifier) + require.Equal(t, "week", allEpochs[4].Identifier) } func TestEpochExists(t *testing.T) { diff --git a/x/epochs/types/epochinfo_test.go b/x/epochs/types/epochinfo_test.go index f6e5d3d6f..a3624337a 100644 --- a/x/epochs/types/epochinfo_test.go +++ b/x/epochs/types/epochinfo_test.go @@ -38,6 +38,15 @@ func TestDefaultGenesis(t *testing.T) { CurrentEpochStartTime: time.Time{}, EpochCountingStarted: false, }, + { + Identifier: MonthEpochID, + StartTime: time.Time{}, + Duration: 30 * 24 * time.Hour, + CurrentEpoch: 0, + CurrentEpochStartHeight: 0, + CurrentEpochStartTime: time.Time{}, + EpochCountingStarted: false, + }, } // Ensure that genState and expectedEpochs are the same diff --git a/x/epochs/types/genesis.go b/x/epochs/types/genesis.go index 2c1aea11d..903485fb6 100644 --- a/x/epochs/types/genesis.go +++ b/x/epochs/types/genesis.go @@ -44,6 +44,15 @@ func DefaultGenesisFromTime(startTime time.Time) *GenesisState { CurrentEpochStartTime: startTime, EpochCountingStarted: false, }, + { + Identifier: MonthEpochID, + StartTime: startTime, + Duration: 30 * 24 * time.Hour, + CurrentEpoch: 0, + CurrentEpochStartHeight: 0, + CurrentEpochStartTime: startTime, + EpochCountingStarted: false, + }, } return NewGenesisState(epochs) diff --git a/x/epochs/types/identifier.go b/x/epochs/types/identifier.go index 714b9dd66..9baf59c13 100644 --- a/x/epochs/types/identifier.go +++ b/x/epochs/types/identifier.go @@ -6,16 +6,18 @@ import ( ) const ( + // WeekEpochID defines the identifier for weekly epochs + MonthEpochID = "month" // WeekEpochID defines the identifier for weekly epochs WeekEpochID = "week" // DayEpochID defines the identifier for daily epochs DayEpochID = "day" // HourEpochID defines the identifier for hourly epochs HourEpochID = "hour" - // FifteenMinuteEpochID defines the identifier for 15 minute epochs - FifteenMinuteEpochID = "15 min" // ThirtyMinuteEpochID defines the identifier for 30 minute epochs ThirtyMinuteEpochID = "30 min" + // FifteenMinuteEpochID defines the identifier for 15 minute epochs + FifteenMinuteEpochID = "15 min" ) // ValidateEpochIdentifierInterface performs a stateless diff --git a/x/oracle/cli/tx.go b/x/oracle/cli/tx.go index 567c15980..50d26b944 100644 --- a/x/oracle/cli/tx.go +++ b/x/oracle/cli/tx.go @@ -3,6 +3,9 @@ package cli import ( "fmt" "strings" + "time" + + "github.com/NibiruChain/nibiru/v2/x/common/asset" "github.com/pkg/errors" @@ -30,6 +33,7 @@ func GetTxCmd() *cobra.Command { GetCmdDelegateFeederPermission(), GetCmdAggregateExchangeRatePrevote(), GetCmdAggregateExchangeRateVote(), + GetCmdEditOracleParams(), ) return oracleTxCmd @@ -205,3 +209,144 @@ $ nibid tx oracle aggregate-vote 1234 (40000.0,BTC:USD)|(1.243,NIBI:USD) nibival return cmd } + +func GetCmdEditOracleParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "edit-params --vote-period [vote-period] --vote-threshold [vote-threshold] --reward-band [reward-band] --slash-fraction [slash-fraction] --slash-window [slash-window] --min-valid-per-window [min-valid-per-window] --whitelist [whitelist]", + Args: cobra.ExactArgs(0), + Short: "Edit the oracle module parameters", + Long: strings.TrimSpace(` +Edit the oracle module parameters. + +Requires sudo permissions. + +--vote-period: the period of oracle vote +--vote-threshold: the threshold of oracle vote +--reward-band: the reward band of oracle vote +--slash-fraction: the slash fraction of oracle vote +--slash-window: the slash window of oracle vote +--min-valid-per-window: the min valid per window of oracle vote +--twap-lookback-window: the twap lookback window of oracle vote in seconds +--min-voters: the min voters of oracle vote +--validator-fee-ratio: the validator fee ratio of oracle vote +--expiration-blocks: the expiration blocks of oracle vote +--whitelist: the whitelist of oracle vote + +$ nibid tx oracle edit-params --vote-period 10 --vote-threshold 0.5 --reward-band 0.1 --slash-fraction 0.01 --slash-window 100 --min-valid-per-window 0.6 --whitelist BTC:USD,NIBI:USD +`), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := &types.MsgEditOracleParams{ + Sender: clientCtx.GetFromAddress().String(), + Params: &types.OracleParamsMsg{}, + } + + if votePeriod, _ := cmd.Flags().GetUint64("vote-period"); votePeriod != 0 { + msg.Params.VotePeriod = votePeriod + } + + if voteThreshold, _ := cmd.Flags().GetString("vote-threshold"); voteThreshold != "" { + voteThresholdDec, err := sdk.NewDecFromStr(voteThreshold) + if err != nil { + return err + } + + msg.Params.VoteThreshold = &voteThresholdDec + } + + if rewardBand, _ := cmd.Flags().GetString("reward-band"); rewardBand != "" { + rewardBandDec, err := sdk.NewDecFromStr(rewardBand) + if err != nil { + return err + } + + msg.Params.RewardBand = &rewardBandDec + } + + if slashFraction, _ := cmd.Flags().GetString("slash-fraction"); slashFraction != "" { + slashFractionDec, err := sdk.NewDecFromStr(slashFraction) + if err != nil { + return err + } + + msg.Params.SlashFraction = &slashFractionDec + } + + if slashWindow, _ := cmd.Flags().GetUint64("slash-window"); slashWindow != 0 { + msg.Params.SlashWindow = slashWindow + } + + if minValidPerWindow, _ := cmd.Flags().GetString("min-valid-per-window"); minValidPerWindow != "" { + minValidPerWindowDec, err := sdk.NewDecFromStr(minValidPerWindow) + if err != nil { + return err + } + + msg.Params.MinValidPerWindow = &minValidPerWindowDec + } + + if twapLookbackWindow, _ := cmd.Flags().GetUint64("twap-lookback-window"); twapLookbackWindow != 0 { + duration := time.Duration(twapLookbackWindow) * time.Second + msg.Params.TwapLookbackWindow = &duration + } + + if minVoters, _ := cmd.Flags().GetUint64("min-voters"); minVoters != 0 { + msg.Params.MinVoters = minVoters + } + + if validatorFeeRatio, _ := cmd.Flags().GetString("validator-fee-ratio"); validatorFeeRatio != "" { + validatorFeeRatioDec, err := sdk.NewDecFromStr(validatorFeeRatio) + if err != nil { + return err + } + + msg.Params.ValidatorFeeRatio = &validatorFeeRatioDec + } + + if expirationBlocks, _ := cmd.Flags().GetUint64("expiration-blocks"); expirationBlocks != 0 { + msg.Params.ExpirationBlocks = expirationBlocks + } + + if whitelist, _ := cmd.Flags().GetString("whitelist"); whitelist != "" { + whitelistArr := strings.Split(whitelist, ",") + realWhitelist := make([]asset.Pair, len(whitelistArr)) + for i, pair := range whitelistArr { + p, err := asset.TryNewPair(pair) + if err != nil { + return fmt.Errorf("invalid pair %s", p) + } + + realWhitelist[i] = p + } + + msg.Params.Whitelist = realWhitelist + } + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + cmd.Flags().Uint64("vote-period", 0, "the period of oracle vote") + cmd.Flags().String("vote-threshold", "", "the threshold of oracle vote") + cmd.Flags().String("reward-band", "", "the reward band of oracle vote") + cmd.Flags().String("slash-fraction", "", "the slash fraction of oracle vote") + cmd.Flags().Uint64("slash-window", 0, "the slash window of oracle vote") + cmd.Flags().String("min-valid-per-window", "", "the min valid per window of oracle vote") + cmd.Flags().Uint64("twap-lookback-window", 0, "the twap lookback window of oracle vote") + cmd.Flags().Uint64("min-voters", 0, "the min voters of oracle vote") + cmd.Flags().String("validator-fee-ratio", "", "the validator fee ratio of oracle vote") + cmd.Flags().Uint64("expiration-blocks", 0, "the expiration blocks of oracle vote") + cmd.Flags().String("whitelist", "", "the whitelist of oracle vote") + + return cmd +} diff --git a/x/oracle/keeper/edit_params_test.go b/x/oracle/keeper/edit_params_test.go new file mode 100644 index 000000000..2e2bf702a --- /dev/null +++ b/x/oracle/keeper/edit_params_test.go @@ -0,0 +1,54 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/NibiruChain/nibiru/v2/x/common/testutil" + "github.com/NibiruChain/nibiru/v2/x/common/testutil/testapp" + "github.com/NibiruChain/nibiru/v2/x/oracle/keeper" + "github.com/NibiruChain/nibiru/v2/x/oracle/types" + sudotypes "github.com/NibiruChain/nibiru/v2/x/sudo/types" +) + +func TestMsgServer_EditOracleParams(t *testing.T) { + app, ctx := testapp.NewNibiruTestAppAndContext() + goCtx := sdk.WrapSDKContext(ctx) + + msgServer := keeper.NewMsgServerImpl(app.OracleKeeper, app.SudoKeeper) + + alice := testutil.AccAddress() + bob := testutil.AccAddress() + + // Case 1: user is not authorized to edit oracle params + msg := types.MsgEditOracleParams{ + Sender: alice.String(), + Params: &types.OracleParamsMsg{ + VotePeriod: 100, + }, + } + + _, err := msgServer.EditOracleParams(goCtx, &msg) + require.Error(t, err) + require.EqualError(t, sudotypes.ErrUnauthorized, err.Error()) + + // Case 2: user is authorized to edit oracle params + app.SudoKeeper.Sudoers.Set(ctx, sudotypes.Sudoers{ + Root: bob.String(), + Contracts: []string{ + alice.String(), + }, + }) + + msg = types.MsgEditOracleParams{ + Sender: alice.String(), + Params: &types.OracleParamsMsg{ + VotePeriod: 100, + }, + } + + _, err = msgServer.EditOracleParams(goCtx, &msg) + require.NoError(t, err) +} diff --git a/x/oracle/keeper/msg_server.go b/x/oracle/keeper/msg_server.go index 056340772..7e91bafaf 100644 --- a/x/oracle/keeper/msg_server.go +++ b/x/oracle/keeper/msg_server.go @@ -2,24 +2,27 @@ package keeper import ( "context" - - "github.com/cosmos/cosmos-sdk/types/errors" + "fmt" sdkerrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/errors" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/NibiruChain/nibiru/v2/x/oracle/types" + sudokeeper "github.com/NibiruChain/nibiru/v2/x/sudo/keeper" + sudotypes "github.com/NibiruChain/nibiru/v2/x/sudo/types" ) type msgServer struct { Keeper + SudoKeeper sudokeeper.Keeper } // NewMsgServerImpl returns an implementation of the oracle MsgServer interface // for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{Keeper: keeper} +func NewMsgServerImpl(keeper Keeper, sudoKeeper sudokeeper.Keeper) types.MsgServer { + return &msgServer{Keeper: keeper, SudoKeeper: sudoKeeper} } func (ms msgServer) AggregateExchangeRatePrevote( @@ -170,18 +173,27 @@ func (ms msgServer) DelegateFeedConsent( // EditOracleParams: gRPC tx msg for editing the oracle module params. // [SUDO] Only callable by sudoers. -func (ms msgServer) EditOracleParams( - goCtx context.Context, msg *types.MsgEditOracleParams, -) (resp *types.MsgEditOracleParamsResponse, err error) { +func (ms msgServer) EditOracleParams(goCtx context.Context, msg *types.MsgEditOracleParams) (*types.MsgEditOracleParamsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // Stateless field validation is already performed in msg.ValidateBasic() - // before the current scope is reached. - sender, _ := sdk.AccAddressFromBech32(msg.Sender) - newParams, err := ms.Sudo().EditOracleParams( - ctx, *msg, sender, - ) - resp = &types.MsgEditOracleParamsResponse{ - NewParams: &newParams, + + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, fmt.Errorf("invalid address") + } + + err = ms.SudoKeeper.CheckPermissions(sender, ctx) + if err != nil { + return nil, sudotypes.ErrUnauthorized + } + + params, err := ms.Keeper.Params.Get(ctx) + if err != nil { + return nil, fmt.Errorf("get oracle params error: %s", err.Error()) } - return resp, err + + mergedParams := mergeOracleParams(msg, params) + + ms.Keeper.UpdateParams(ctx, mergedParams) + + return &types.MsgEditOracleParamsResponse{}, nil } diff --git a/x/oracle/keeper/params.go b/x/oracle/keeper/params.go index 17a0d2003..5da6d0ead 100644 --- a/x/oracle/keeper/params.go +++ b/x/oracle/keeper/params.go @@ -71,3 +71,53 @@ func (k Keeper) MinValidPerWindow(ctx sdk.Context) (res sdk.Dec) { params, _ := k.Params.Get(ctx) return params.MinValidPerWindow } + +// mergeOracleParams takes the oracle params from the wasm msg and merges them into the existing params +// keeping any existing values if not set in the wasm msg +func mergeOracleParams(msg *types.MsgEditOracleParams, oracleParams types.Params) types.Params { + if msg.Params.VotePeriod != 0 { + oracleParams.VotePeriod = msg.Params.VotePeriod + } + + if msg.Params.VoteThreshold != nil && !msg.Params.VoteThreshold.IsNil() { + oracleParams.VoteThreshold = *msg.Params.VoteThreshold + } + + if msg.Params.RewardBand != nil && !msg.Params.RewardBand.IsNil() { + oracleParams.RewardBand = *msg.Params.RewardBand + } + + if msg.Params.Whitelist != nil && len(msg.Params.Whitelist) != 0 { + oracleParams.Whitelist = msg.Params.Whitelist + } + + if msg.Params.SlashFraction != nil && !msg.Params.SlashFraction.IsNil() { + oracleParams.SlashFraction = *msg.Params.SlashFraction + } + + if msg.Params.SlashWindow != 0 { + oracleParams.SlashWindow = msg.Params.SlashWindow + } + + if msg.Params.MinValidPerWindow != nil && !msg.Params.MinValidPerWindow.IsNil() { + oracleParams.MinValidPerWindow = *msg.Params.MinValidPerWindow + } + + if msg.Params.TwapLookbackWindow != nil { + oracleParams.TwapLookbackWindow = *msg.Params.TwapLookbackWindow + } + + if msg.Params.MinVoters != 0 { + oracleParams.MinVoters = msg.Params.MinVoters + } + + if msg.Params.ValidatorFeeRatio != nil && !msg.Params.ValidatorFeeRatio.IsNil() { + oracleParams.ValidatorFeeRatio = *msg.Params.ValidatorFeeRatio + } + + if msg.Params.ExpirationBlocks != 0 { + oracleParams.ExpirationBlocks = msg.Params.ExpirationBlocks + } + + return oracleParams +} diff --git a/x/oracle/keeper/params_test.go b/x/oracle/keeper/params_test.go index 869afe972..5b31887c2 100644 --- a/x/oracle/keeper/params_test.go +++ b/x/oracle/keeper/params_test.go @@ -2,8 +2,10 @@ package keeper import ( "testing" + "time" "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/NibiruChain/nibiru/v2/x/common/asset" @@ -53,3 +55,381 @@ func TestParams(t *testing.T) { require.NotNil(t, storedParams) require.Equal(t, storedParams, newParams) } + +func TestMergeOracleParams(t *testing.T) { + // baseParams + votePeriod := uint64(10) + + voteThreshold := sdk.NewDecWithPrec(33, 2) + changedVoteThreshold := sdk.NewDecWithPrec(50, 2) + + oracleRewardBand := sdk.NewDecWithPrec(1, 2) + changedRewardBand := sdk.NewDecWithPrec(2, 2) + + whitelist := []asset.Pair{ + asset.Registry.Pair(denoms.BTC, denoms.NUSD), + asset.Registry.Pair(denoms.ETH, denoms.NUSD), + } + chagedWhitelist := []asset.Pair{ + asset.Registry.Pair(denoms.ATOM, denoms.NUSD), + asset.Registry.Pair(denoms.ADA, denoms.NUSD), + } + + slashFraction := sdk.NewDecWithPrec(1, 2) + changedSlashFraction := sdk.NewDecWithPrec(2, 2) + + slashWindow := uint64(1000) + changedSlashWindow := uint64(2000) + + minValidPerWindow := sdk.NewDecWithPrec(1, 4) + changedMinValidPerWindow := sdk.NewDecWithPrec(2, 4) + + twapLoopbackWindow := time.Duration(1000) + changedTwapLoopbackWindow := time.Duration(2000) + + minVoters := uint64(4) + chagedMinVoters := uint64(5) + + minFeeRatio := sdk.NewDecWithPrec(1, 2) + changedMinFeeRatio := sdk.NewDecWithPrec(2, 2) + + expirationBlocks := uint64(100) + changedExpirationBlocks := uint64(200) + + initialParams := types.Params{ + VotePeriod: votePeriod, + VoteThreshold: voteThreshold, + MinVoters: minVoters, + RewardBand: oracleRewardBand, + Whitelist: whitelist, + SlashFraction: slashFraction, + SlashWindow: slashWindow, + MinValidPerWindow: minValidPerWindow, + ValidatorFeeRatio: minFeeRatio, + TwapLookbackWindow: twapLoopbackWindow, + ExpirationBlocks: expirationBlocks, + } + + tests := []struct { + name string + msg *types.MsgEditOracleParams + require func(params types.Params) + }{ + { + name: "votePeriod", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + VotePeriod: 20, + }, + }, + require: func(params types.Params) { + require.Equal(t, uint64(20), params.VotePeriod) + }, + }, + { + name: "votePeriod zero not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + VotePeriod: 0, + }, + }, + require: func(params types.Params) { + require.Equal(t, uint64(10), params.VotePeriod) + }, + }, + { + name: "voteThreshold", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + VoteThreshold: &changedVoteThreshold, + }, + }, + require: func(params types.Params) { + require.Equal(t, changedVoteThreshold, params.VoteThreshold) + }, + }, + { + name: "voteThreshold nil not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + VoteThreshold: nil, + }, + }, + require: func(params types.Params) { + require.Equal(t, voteThreshold, params.VoteThreshold) + }, + }, + { + name: "empty voteThreshold not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + VoteThreshold: &sdk.Dec{}, + }, + }, + require: func(params types.Params) { + require.Equal(t, voteThreshold, params.VoteThreshold) + }, + }, + { + name: "rewardBand", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + RewardBand: &changedRewardBand, + }, + }, + require: func(params types.Params) { + require.Equal(t, changedRewardBand, params.RewardBand) + }, + }, + { + name: "rewardBand nil not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + RewardBand: nil, + }, + }, + require: func(params types.Params) { + require.Equal(t, oracleRewardBand, params.RewardBand) + }, + }, + { + name: "empty rewardBand not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + RewardBand: &sdk.Dec{}, + }, + }, + require: func(params types.Params) { + require.Equal(t, oracleRewardBand, params.RewardBand) + }, + }, + { + name: "whitelist", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + Whitelist: chagedWhitelist, + }, + }, + require: func(params types.Params) { + require.Equal(t, chagedWhitelist, params.Whitelist) + }, + }, + { + name: "whitelist nil not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + Whitelist: nil, + }, + }, + require: func(params types.Params) { + require.Equal(t, whitelist, params.Whitelist) + }, + }, + { + name: "empty whitelist not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + Whitelist: []asset.Pair{}, + }, + }, + require: func(params types.Params) { + require.Equal(t, whitelist, params.Whitelist) + }, + }, + { + name: "slashFraction", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + SlashFraction: &changedSlashFraction, + }, + }, + require: func(params types.Params) { + require.Equal(t, changedSlashFraction, params.SlashFraction) + }, + }, + { + name: "slashFraction nil not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + SlashFraction: nil, + }, + }, + require: func(params types.Params) { + require.Equal(t, slashFraction, params.SlashFraction) + }, + }, + { + name: "empty slashFraction not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + SlashFraction: &sdk.Dec{}, + }, + }, + require: func(params types.Params) { + require.Equal(t, slashFraction, params.SlashFraction) + }, + }, + { + name: "slashWindow", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + SlashWindow: changedSlashWindow, + }, + }, + require: func(params types.Params) { + require.Equal(t, changedSlashWindow, params.SlashWindow) + }, + }, + { + name: "slashWindow zero not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + SlashWindow: 0, + }, + }, + require: func(params types.Params) { + require.Equal(t, slashWindow, params.SlashWindow) + }, + }, + { + name: "minValidPerWindow", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + MinValidPerWindow: &changedMinValidPerWindow, + }, + }, + require: func(params types.Params) { + require.Equal(t, changedMinValidPerWindow, params.MinValidPerWindow) + }, + }, + { + name: "minValidPerWindow nil not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + MinValidPerWindow: nil, + }, + }, + require: func(params types.Params) { + require.Equal(t, minValidPerWindow, params.MinValidPerWindow) + }, + }, + { + name: "empty minValidPerWindow not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + MinValidPerWindow: &sdk.Dec{}, + }, + }, + require: func(params types.Params) { + require.Equal(t, minValidPerWindow, params.MinValidPerWindow) + }, + }, + { + name: "twapLookbackWindow", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + TwapLookbackWindow: &changedTwapLoopbackWindow, + }, + }, + require: func(params types.Params) { + require.Equal(t, changedTwapLoopbackWindow, params.TwapLookbackWindow) + }, + }, + { + name: "twapLookbackWindow nil not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + TwapLookbackWindow: nil, + }, + }, + require: func(params types.Params) { + require.Equal(t, twapLoopbackWindow, params.TwapLookbackWindow) + }, + }, + { + name: "minVoters", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + MinVoters: chagedMinVoters, + }, + }, + require: func(params types.Params) { + require.Equal(t, chagedMinVoters, params.MinVoters) + }, + }, + { + name: "minVoters zero not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + MinVoters: 0, + }, + }, + require: func(params types.Params) { + require.Equal(t, minVoters, params.MinVoters) + }, + }, + { + name: "validatorFeeRatio", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + ValidatorFeeRatio: &changedMinFeeRatio, + }, + }, + require: func(params types.Params) { + require.Equal(t, changedMinFeeRatio, params.ValidatorFeeRatio) + }, + }, + { + name: "validatorFeeRatio nil not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + ValidatorFeeRatio: nil, + }, + }, + require: func(params types.Params) { + require.Equal(t, minFeeRatio, params.ValidatorFeeRatio) + }, + }, + { + name: "empty validatorFeeRatio not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + ValidatorFeeRatio: &sdk.Dec{}, + }, + }, + require: func(params types.Params) { + require.Equal(t, minFeeRatio, params.ValidatorFeeRatio) + }, + }, + { + name: "expirationTime", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + ExpirationBlocks: changedExpirationBlocks, + }, + }, + require: func(params types.Params) { + require.Equal(t, changedExpirationBlocks, params.ExpirationBlocks) + }, + }, + { + name: "expirationTime zero not updated", + msg: &types.MsgEditOracleParams{ + Params: &types.OracleParamsMsg{ + ExpirationBlocks: 0, + }, + }, + require: func(params types.Params) { + require.Equal(t, expirationBlocks, params.ExpirationBlocks) + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt := tt + newParams := mergeOracleParams(tt.msg, initialParams) + tt.require(newParams) + }) + } +} diff --git a/x/oracle/keeper/sudo.go b/x/oracle/keeper/sudo.go deleted file mode 100644 index 8af7dbf09..000000000 --- a/x/oracle/keeper/sudo.go +++ /dev/null @@ -1,100 +0,0 @@ -package keeper - -import ( - "fmt" - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/NibiruChain/nibiru/v2/x/common/asset" - oracletypes "github.com/NibiruChain/nibiru/v2/x/oracle/types" -) - -// Sudo extends the Keeper with sudo functions. See sudo.go. Sudo is syntactic -// sugar to separate admin calls off from the other Keeper methods. -// -// These Sudo functions should: -// 1. Not be called in other methods in the x/perp module. -// 2. Only be callable by the x/sudo root or sudo contracts. -// -// The intention behind "Keeper.Sudo()" is to make it more obvious to the -// developer that an unsafe function is being used when it's called. -func (k Keeper) Sudo() sudoExtension { return sudoExtension{k} } - -type sudoExtension struct{ Keeper } - -// ------------------------------------------------------------------ -// Admin.EditOracleParams - -func (k sudoExtension) EditOracleParams( - ctx sdk.Context, newParams oracletypes.MsgEditOracleParams, - sender sdk.AccAddress, -) (paramsAfter oracletypes.Params, err error) { - if err := k.sudoKeeper.CheckPermissions(sender, ctx); err != nil { - return paramsAfter, err - } - - params, err := k.Params.Get(ctx) - if err != nil { - return paramsAfter, fmt.Errorf("%w: failed to read oracle params", err) - } - - paramsAfter = MergeOracleParams(newParams, params) - k.UpdateParams(ctx, paramsAfter) - return paramsAfter, paramsAfter.Validate() -} - -// MergeOracleParams: Takes the given oracle params and merges them into the -// existing partial params, keeping any existing values that are not set in the -// partial. -func MergeOracleParams( - partial oracletypes.MsgEditOracleParams, - oracleParams oracletypes.Params, -) oracletypes.Params { - if partial.VotePeriod != nil { - oracleParams.VotePeriod = partial.VotePeriod.Uint64() - } - - if partial.VoteThreshold != nil { - oracleParams.VoteThreshold = *partial.VoteThreshold - } - - if partial.RewardBand != nil { - oracleParams.RewardBand = *partial.RewardBand - } - - if partial.Whitelist != nil { - whitelist := make([]asset.Pair, len(partial.Whitelist)) - for i, pair := range partial.Whitelist { - whitelist[i] = asset.MustNewPair(pair) - } - - oracleParams.Whitelist = whitelist - } - - if partial.SlashFraction != nil { - oracleParams.SlashFraction = *partial.SlashFraction - } - - if partial.SlashWindow != nil { - oracleParams.SlashWindow = partial.SlashWindow.Uint64() - } - - if partial.MinValidPerWindow != nil { - oracleParams.MinValidPerWindow = *partial.MinValidPerWindow - } - - if partial.TwapLookbackWindow != nil { - oracleParams.TwapLookbackWindow = time.Duration(partial.TwapLookbackWindow.Int64()) - } - - if partial.MinVoters != nil { - oracleParams.MinVoters = partial.MinVoters.Uint64() - } - - if partial.ValidatorFeeRatio != nil { - oracleParams.ValidatorFeeRatio = *partial.ValidatorFeeRatio - } - - return oracleParams -} diff --git a/x/oracle/keeper/sudo_test.go b/x/oracle/keeper/sudo_test.go deleted file mode 100644 index f52d7f427..000000000 --- a/x/oracle/keeper/sudo_test.go +++ /dev/null @@ -1,95 +0,0 @@ -package keeper_test - -import ( - "testing" - "time" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/suite" - - "github.com/NibiruChain/nibiru/v2/x/common/testutil" - "github.com/NibiruChain/nibiru/v2/x/common/testutil/testapp" - oraclekeeper "github.com/NibiruChain/nibiru/v2/x/oracle/keeper" - oracletypes "github.com/NibiruChain/nibiru/v2/x/oracle/types" -) - -// TestSuiteOracleSudo tests sudo-only functions in the oracle module. -func TestSuiteOracleSudo(t *testing.T) { - suite.Run(t, new(SuiteOracleSudo)) -} - -type SuiteOracleSudo struct { - suite.Suite -} - -// TestEditOracleParams tests the business logic for -// "oraclekeeper.Keeper.Sudo().EditOracleParams" -func (s *SuiteOracleSudo) TestEditOracleParams() { - nibiru, ctx := testapp.NewNibiruTestAppAndContext() - - // Change to all non-defaults to test EditOracleParams as a setter . - votePeriod := math.NewInt(1_234) - voteThreshold := math.LegacyMustNewDecFromStr("0.4") - rewardBand := math.LegacyMustNewDecFromStr("0.5") - whitelist := []string{"aave:usdc", "sol:usdc"} - slashFraction := math.LegacyMustNewDecFromStr("0.5") - slashWindow := math.NewInt(2_000) - minValidPerWindow := math.LegacyMustNewDecFromStr("0.5") - twapLookbackWindow := math.NewInt(int64(time.Second * 30)) - minVoters := math.NewInt(2) - validatorFeeRatio := math.LegacyMustNewDecFromStr("0.7") - msgEditParams := oracletypes.MsgEditOracleParams{ - VotePeriod: &votePeriod, - VoteThreshold: &voteThreshold, - RewardBand: &rewardBand, - Whitelist: whitelist, - SlashFraction: &slashFraction, - SlashWindow: &slashWindow, - MinValidPerWindow: &minValidPerWindow, - TwapLookbackWindow: &twapLookbackWindow, - MinVoters: &minVoters, - ValidatorFeeRatio: &validatorFeeRatio, - } - - s.T().Log("Params before MUST NOT be equal to default") - defaultParams := oracletypes.DefaultParams() - currParams, err := nibiru.OracleKeeper.Params.Get(ctx) - s.NoError(err) - s.Equal(currParams, defaultParams, - "Current params should be eqaul to defaults") - partialParams := msgEditParams - fullParams := oraclekeeper.MergeOracleParams(partialParams, defaultParams) - s.NotEqual(defaultParams, fullParams, - "new params after merge should not be defaults") - - invalidSender := testutil.AccAddress() - oracleMsgServer := oraclekeeper.NewMsgServerImpl(nibiru.OracleKeeper) - goCtx := sdk.WrapSDKContext(ctx) - msgEditParams.Sender = invalidSender.String() - _, err = oracleMsgServer.EditOracleParams( - goCtx, &msgEditParams, - ) - s.Error(err) - - s.T().Log("Params after MUST be equal to new ones with partialParams") - okSender := testapp.DefaultSudoRoot() - msgEditParams.Sender = okSender.String() - resp, err := oracleMsgServer.EditOracleParams( - goCtx, &msgEditParams, - ) - s.Require().NoError(err) - s.EqualValues(resp.NewParams.String(), fullParams.String()) - - s.T().Log("Changing to invalid params MUST fail") - slashWindow = math.NewInt(1_233) // slashWindow < vote period is not allowed. - msgEditParams = oracletypes.MsgEditOracleParams{ - Sender: okSender.String(), - SlashWindow: &slashWindow, - } - _, err = oracleMsgServer.EditOracleParams( - goCtx, &msgEditParams, - ) - s.Require().Error(err) - s.ErrorContains(err, "oracle parameter SlashWindow must be greater") -} diff --git a/x/oracle/keeper/test_utils.go b/x/oracle/keeper/test_utils.go index 5b42f40f7..50b65e8ba 100644 --- a/x/oracle/keeper/test_utils.go +++ b/x/oracle/keeper/test_utils.go @@ -129,7 +129,7 @@ type TestFixture struct { OracleKeeper Keeper StakingKeeper stakingkeeper.Keeper DistrKeeper distrkeeper.Keeper - SudoKeeper types.SudoKeeper + SudoKeeper sudokeeper.Keeper } // CreateTestFixture nolint @@ -324,7 +324,7 @@ func Setup(t *testing.T) (TestFixture, types.MsgServer) { params, _ = fixture.OracleKeeper.Params.Get(fixture.Ctx) - h := NewMsgServerImpl(fixture.OracleKeeper) + h := NewMsgServerImpl(fixture.OracleKeeper, fixture.SudoKeeper) sh := stakingkeeper.NewMsgServerImpl(&fixture.StakingKeeper) // Validator created diff --git a/x/oracle/keeper/update_exchange_rates_test.go b/x/oracle/keeper/update_exchange_rates_test.go index 9c3ed2c95..77f10ce39 100644 --- a/x/oracle/keeper/update_exchange_rates_test.go +++ b/x/oracle/keeper/update_exchange_rates_test.go @@ -135,7 +135,7 @@ func TestOracleTally(t *testing.T) { votes := types.ExchangeRateVotes{} rates, valAddrs, stakingKeeper := types.GenerateRandomTestCase() fixture.OracleKeeper.StakingKeeper = stakingKeeper - h := NewMsgServerImpl(fixture.OracleKeeper) + h := NewMsgServerImpl(fixture.OracleKeeper, fixture.SudoKeeper) for i, rate := range rates { decExchangeRate := sdkmath.LegacyNewDecWithPrec(int64(rate*math.Pow10(OracleDecPrecision)), int64(OracleDecPrecision)) diff --git a/x/oracle/module.go b/x/oracle/module.go index 55ba76ea5..6bd34f484 100644 --- a/x/oracle/module.go +++ b/x/oracle/module.go @@ -5,6 +5,8 @@ import ( "encoding/json" "fmt" + sudokeeper "github.com/NibiruChain/nibiru/v2/x/sudo/keeper" + "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -90,9 +92,11 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { // AppModule implements an application module for the oracle module. type AppModule struct { AppModuleBasic + keeper keeper.Keeper accountKeeper types.AccountKeeper bankKeeper types.BankKeeper + sudoKeeper sudokeeper.Keeper } // NewAppModule creates a new AppModule object @@ -101,12 +105,14 @@ func NewAppModule( keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, + sudoKeeper sudokeeper.Keeper, ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc}, keeper: keeper, accountKeeper: accountKeeper, bankKeeper: bankKeeper, + sudoKeeper: sudoKeeper, } } @@ -118,7 +124,7 @@ func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper, am.sudoKeeper)) querier := keeper.NewQuerier(am.keeper) types.RegisterQueryServer(cfg.QueryServer(), querier) } diff --git a/x/oracle/types/params.go b/x/oracle/types/params.go index a7221ff03..67334aeda 100644 --- a/x/oracle/types/params.go +++ b/x/oracle/types/params.go @@ -42,9 +42,9 @@ var ( asset.Registry.Pair(denoms.BTC, denoms.USD), asset.Registry.Pair(denoms.ETH, denoms.USD), asset.Registry.Pair(denoms.ATOM, denoms.USD), - asset.Registry.Pair(denoms.BNB, denoms.USD), asset.Registry.Pair(denoms.USDC, denoms.USD), asset.Registry.Pair(denoms.USDT, denoms.USD), + // asset.Registry.Pair(denoms.BNB, denoms.USD), // asset.Registry.Pair(denoms.OSMO, denoms.USD), // asset.Registry.Pair(denoms.AVAX, denoms.USD), // asset.Registry.Pair(denoms.SOL, denoms.USD), diff --git a/x/oracle/types/tx.pb.go b/x/oracle/types/tx.pb.go index 9c33a0e7f..aac5d9c01 100644 --- a/x/oracle/types/tx.pb.go +++ b/x/oracle/types/tx.pb.go @@ -6,23 +6,28 @@ package types import ( context "context" fmt "fmt" + github_com_NibiruChain_nibiru_v2_x_common_asset "github.com/NibiruChain/nibiru/v2/x/common/asset" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/durationpb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -277,25 +282,9 @@ func (m *MsgDelegateFeedConsentResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDelegateFeedConsentResponse proto.InternalMessageInfo -// MsgEditOracleParams: gRPC tx message for updating the x/oracle module params -// [SUDO] Only callable by sudoers. type MsgEditOracleParams struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - VotePeriod *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=vote_period,json=votePeriod,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"vote_period,omitempty"` - // vote_threshold: [cosmossdk.io/math.LegacyDec] TODO: - VoteThreshold *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=vote_threshold,json=voteThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"vote_threshold,omitempty"` - // reward_band: [cosmossdk.io/math.LegacyDec] TODO: - RewardBand *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=reward_band,json=rewardBand,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_band,omitempty"` - Whitelist []string `protobuf:"bytes,5,rep,name=whitelist,proto3" json:"whitelist,omitempty"` - // slash_fraction: [cosmossdk.io/math.LegacyDec] TODO: - SlashFraction *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=slash_fraction,json=slashFraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction,omitempty"` - SlashWindow *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=slash_window,json=slashWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"slash_window,omitempty"` - // min_valid_per_window: [cosmossdk.io/math.LegacyDec] TODO: - MinValidPerWindow *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_valid_per_window,omitempty"` - TwapLookbackWindow *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=twap_lookback_window,json=twapLookbackWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"twap_lookback_window,omitempty"` - MinVoters *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=min_voters,json=minVoters,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_voters,omitempty"` - // VoteThreshold: [cosmossdk.io/math.LegacyDec] TODO: - ValidatorFeeRatio *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=validator_fee_ratio,json=validatorFeeRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validator_fee_ratio,omitempty"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Params *OracleParamsMsg `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty" yaml:"params"` } func (m *MsgEditOracleParams) Reset() { *m = MsgEditOracleParams{} } @@ -331,24 +320,7 @@ func (m *MsgEditOracleParams) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEditOracleParams proto.InternalMessageInfo -func (m *MsgEditOracleParams) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -func (m *MsgEditOracleParams) GetWhitelist() []string { - if m != nil { - return m.Whitelist - } - return nil -} - -// MsgEditOracleParamsResponse defines the Msg/EditOracleParams response -// type. type MsgEditOracleParamsResponse struct { - NewParams *Params `protobuf:"bytes,1,opt,name=new_params,json=newParams,proto3" json:"new_params,omitempty"` } func (m *MsgEditOracleParamsResponse) Reset() { *m = MsgEditOracleParamsResponse{} } @@ -384,13 +356,112 @@ func (m *MsgEditOracleParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEditOracleParamsResponse proto.InternalMessageInfo -func (m *MsgEditOracleParamsResponse) GetNewParams() *Params { +type OracleParamsMsg struct { + // VotePeriod defines the number of blocks during which voting takes place. + VotePeriod uint64 `protobuf:"varint,1,opt,name=vote_period,json=votePeriod,proto3" json:"vote_period,omitempty" yaml:"vote_period"` + // VoteThreshold specifies the minimum proportion of votes that must be + // received for a ballot to pass. + VoteThreshold *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=vote_threshold,json=voteThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"vote_threshold,omitempty" yaml:"vote_threshold"` + // RewardBand defines a maxium divergence that a price vote can have from the + // weighted median in the ballot. If a vote lies within the valid range + // defined by: + // μ := weightedMedian, + // validRange := μ ± (μ * rewardBand / 2), + // then rewards are added to the validator performance. + // Note that if the reward band is smaller than 1 standard + // deviation, the band is taken to be 1 standard deviation.a price + RewardBand *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=reward_band,json=rewardBand,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reward_band,omitempty" yaml:"reward_band"` + // The set of whitelisted markets, or asset pairs, for the module. + // Ex. '["unibi:uusd","ubtc:uusd"]' + Whitelist []github_com_NibiruChain_nibiru_v2_x_common_asset.Pair `protobuf:"bytes,4,rep,name=whitelist,proto3,customtype=github.com/NibiruChain/nibiru/v2/x/common/asset.Pair" json:"whitelist,omitempty" yaml:"whitelist"` + // SlashFraction returns the proportion of an oracle's stake that gets + // slashed in the event of slashing. `SlashFraction` specifies the exact + // penalty for failing a voting period. + SlashFraction *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=slash_fraction,json=slashFraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slash_fraction,omitempty" yaml:"slash_fraction"` + // SlashWindow returns the number of voting periods that specify a + // "slash window". After each slash window, all oracles that have missed more + // than the penalty threshold are slashed. Missing the penalty threshold is + // synonymous with submitting fewer valid votes than `MinValidPerWindow`. + SlashWindow uint64 `protobuf:"varint,6,opt,name=slash_window,json=slashWindow,proto3" json:"slash_window,omitempty" yaml:"slash_window"` + MinValidPerWindow *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=min_valid_per_window,json=minValidPerWindow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_valid_per_window,omitempty" yaml:"min_valid_per_window"` + // Amount of time to look back for TWAP calculations + TwapLookbackWindow *time.Duration `protobuf:"bytes,8,opt,name=twap_lookback_window,json=twapLookbackWindow,proto3,stdduration" json:"twap_lookback_window,omitempty" yaml:"twap_lookback_window"` + // The minimum number of voters (i.e. oracle validators) per pair for it to be + // considered a passing ballot. Recommended at least 4. + MinVoters uint64 `protobuf:"varint,9,opt,name=min_voters,json=minVoters,proto3" json:"min_voters,omitempty" yaml:"min_voters"` + // The validator fee ratio that is given to validators every epoch. + ValidatorFeeRatio *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=validator_fee_ratio,json=validatorFeeRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"validator_fee_ratio,omitempty" yaml:"validator_fee_ratio"` + ExpirationBlocks uint64 `protobuf:"varint,11,opt,name=expiration_blocks,json=expirationBlocks,proto3" json:"expiration_blocks,omitempty" yaml:"expiration_blocks"` +} + +func (m *OracleParamsMsg) Reset() { *m = OracleParamsMsg{} } +func (m *OracleParamsMsg) String() string { return proto.CompactTextString(m) } +func (*OracleParamsMsg) ProtoMessage() {} +func (*OracleParamsMsg) Descriptor() ([]byte, []int) { + return fileDescriptor_11e362c65eb610f4, []int{8} +} +func (m *OracleParamsMsg) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleParamsMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleParamsMsg.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleParamsMsg) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleParamsMsg.Merge(m, src) +} +func (m *OracleParamsMsg) XXX_Size() int { + return m.Size() +} +func (m *OracleParamsMsg) XXX_DiscardUnknown() { + xxx_messageInfo_OracleParamsMsg.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleParamsMsg proto.InternalMessageInfo + +func (m *OracleParamsMsg) GetVotePeriod() uint64 { if m != nil { - return m.NewParams + return m.VotePeriod + } + return 0 +} + +func (m *OracleParamsMsg) GetSlashWindow() uint64 { + if m != nil { + return m.SlashWindow + } + return 0 +} + +func (m *OracleParamsMsg) GetTwapLookbackWindow() *time.Duration { + if m != nil { + return m.TwapLookbackWindow } return nil } +func (m *OracleParamsMsg) GetMinVoters() uint64 { + if m != nil { + return m.MinVoters + } + return 0 +} + +func (m *OracleParamsMsg) GetExpirationBlocks() uint64 { + if m != nil { + return m.ExpirationBlocks + } + return 0 +} + func init() { proto.RegisterType((*MsgAggregateExchangeRatePrevote)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRatePrevote") proto.RegisterType((*MsgAggregateExchangeRatePrevoteResponse)(nil), "nibiru.oracle.v1.MsgAggregateExchangeRatePrevoteResponse") @@ -400,70 +471,168 @@ func init() { proto.RegisterType((*MsgDelegateFeedConsentResponse)(nil), "nibiru.oracle.v1.MsgDelegateFeedConsentResponse") proto.RegisterType((*MsgEditOracleParams)(nil), "nibiru.oracle.v1.MsgEditOracleParams") proto.RegisterType((*MsgEditOracleParamsResponse)(nil), "nibiru.oracle.v1.MsgEditOracleParamsResponse") + proto.RegisterType((*OracleParamsMsg)(nil), "nibiru.oracle.v1.OracleParamsMsg") } func init() { proto.RegisterFile("nibiru/oracle/v1/tx.proto", fileDescriptor_11e362c65eb610f4) } var fileDescriptor_11e362c65eb610f4 = []byte{ - // 917 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x96, 0x41, 0x6f, 0xdc, 0x44, - 0x14, 0xc7, 0xe3, 0x26, 0x5d, 0xb2, 0xb3, 0xa4, 0x4d, 0xbd, 0x69, 0xe4, 0x6c, 0x83, 0x1d, 0x5c, - 0x08, 0xc9, 0x61, 0x6d, 0x12, 0x24, 0x10, 0x3d, 0x41, 0xda, 0x46, 0xaa, 0xc4, 0xd2, 0x60, 0x41, - 0x90, 0x38, 0x60, 0x66, 0xd7, 0x2f, 0xb6, 0x15, 0xaf, 0xc7, 0x9a, 0x99, 0xee, 0xa6, 0x57, 0xc4, - 0x01, 0x6e, 0x48, 0x3d, 0x71, 0xcb, 0x07, 0x40, 0xe2, 0x6b, 0xf4, 0x58, 0x89, 0x0b, 0xe2, 0xb0, - 0x42, 0x09, 0x42, 0x9c, 0x38, 0xec, 0x27, 0x40, 0x33, 0x1e, 0xbb, 0xdb, 0xcd, 0xb6, 0xcd, 0xee, - 0x29, 0xce, 0xbc, 0xff, 0xfc, 0xde, 0xff, 0x3d, 0x7b, 0xde, 0x2c, 0x5a, 0x4b, 0xe3, 0x76, 0x4c, - 0x1f, 0xb9, 0x84, 0xe2, 0x4e, 0x02, 0x6e, 0x6f, 0xc7, 0xe5, 0x27, 0x4e, 0x46, 0x09, 0x27, 0xfa, - 0x72, 0x1e, 0x72, 0xf2, 0x90, 0xd3, 0xdb, 0x69, 0xac, 0x84, 0x24, 0x24, 0x32, 0xe8, 0x8a, 0xa7, - 0x5c, 0xd7, 0x58, 0x0f, 0x09, 0x09, 0x13, 0x70, 0x71, 0x16, 0xbb, 0x38, 0x4d, 0x09, 0xc7, 0x3c, - 0x26, 0x29, 0x53, 0xd1, 0xb7, 0x2e, 0x24, 0x50, 0x3c, 0x19, 0xb6, 0x7f, 0xd3, 0x90, 0xd5, 0x62, - 0xe1, 0xa7, 0x61, 0x48, 0x21, 0xc4, 0x1c, 0xee, 0x9f, 0x74, 0x22, 0x9c, 0x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gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x41, 0x6b, 0x24, 0x45, + 0x14, 0x4e, 0x6f, 0x62, 0xcc, 0xd4, 0x98, 0xdd, 0xa4, 0x27, 0x59, 0x3b, 0x93, 0xa4, 0x3b, 0x96, + 0x1a, 0xb3, 0x60, 0xba, 0x4d, 0x14, 0xd1, 0x08, 0xa2, 0xb3, 0xd9, 0xc8, 0x42, 0x46, 0x87, 0x42, + 0x56, 0xf0, 0x32, 0xd4, 0x4c, 0x57, 0x7a, 0x9a, 0x74, 0x77, 0x35, 0x5d, 0x95, 0x4c, 0x02, 0xe2, + 0x41, 0x04, 0x3d, 0x0a, 0x82, 0xc4, 0xdb, 0xfc, 0x00, 0xc1, 0xbf, 0xb1, 0xc7, 0x05, 0x2f, 0xe2, + 0x61, 0x94, 0xc4, 0xc3, 0xe2, 0x41, 0x61, 0xee, 0x82, 0x54, 0x75, 0x4d, 0x4f, 0x67, 0x32, 0xbb, + 0x9b, 0xc1, 0xd3, 0x4c, 0xbd, 0xef, 0xab, 0xf7, 0xbe, 0xf7, 0xaa, 0xea, 0xbd, 0x06, 0x4b, 0x91, + 0xdf, 0xf0, 0x93, 0x23, 0x87, 0x26, 0xb8, 0x19, 0x10, 0xe7, 0x78, 0xcb, 0xe1, 0x27, 0x76, 0x9c, + 0x50, 0x4e, 0xf5, 0xb9, 0x14, 0xb2, 0x53, 0xc8, 0x3e, 0xde, 0x2a, 0x2f, 0x78, 0xd4, 0xa3, 0x12, + 0x74, 0xc4, 0xbf, 0x94, 0x57, 0x5e, 0xf1, 0x28, 0xf5, 0x02, 0xe2, 0xe0, 0xd8, 0x77, 0x70, 0x14, + 0x51, 0x8e, 0xb9, 0x4f, 0x23, 0xa6, 0x50, 0x53, 0xa1, 0x72, 0xd5, 0x38, 0x3a, 0x70, 0xdc, 0xa3, + 0x44, 0x12, 0x14, 0xbe, 0x7a, 0x45, 0x80, 0x8a, 0x27, 0x61, 0xf8, 0xb3, 0x06, 0xac, 0x2a, 0xf3, + 0x3e, 0xf4, 0xbc, 0x84, 0x78, 0x98, 0x93, 0x7b, 0x27, 0xcd, 0x16, 0x8e, 0x3c, 0x82, 0x30, 0x27, + 0xb5, 0x84, 0x1c, 0x53, 0x4e, 0xf4, 0x97, 0xc1, 0x54, 0x0b, 0xb3, 0x96, 0xa1, 0xad, 0x69, 0x1b, + 0x85, 0xca, 0xad, 0x5e, 0xd7, 0x2a, 0x9e, 0xe2, 0x30, 0xd8, 0x81, 0xc2, 0x0a, 0x91, 0x04, 0xf5, + 0x3b, 0x60, 0xfa, 0x80, 0x10, 0x97, 0x24, 0xc6, 0x0d, 0x49, 0x9b, 0xef, 0x75, 0xad, 0xd9, 0x94, + 0x96, 0xda, 0x21, 0x52, 0x04, 0x7d, 0x1b, 0x14, 0x8e, 0x71, 0xe0, 0xbb, 0x98, 0xd3, 0xc4, 0x98, + 0x94, 0xec, 0x85, 0x5e, 0xd7, 0x9a, 0x4b, 0xd9, 0x19, 0x04, 0xd1, 0x80, 0xb6, 0x33, 0xf3, 0x6d, + 0xc7, 0x9a, 0x78, 0xdc, 0xb1, 0x26, 0xe0, 0x1d, 0xf0, 0xda, 0x33, 0x04, 0x23, 0xc2, 0x62, 0x1a, + 0x31, 0x02, 0xff, 0xd6, 0xc0, 0xca, 0x93, 0xb8, 0x0f, 0x54, 0x66, 0x0c, 0x07, 0xfc, 0x6a, 0x66, + 0xc2, 0x0a, 0x91, 0x04, 0xf5, 0x0f, 0xc0, 0x4d, 0xa2, 0x36, 0xd6, 0x13, 0xcc, 0x09, 0x53, 0x19, + 0x2e, 0xf5, 0xba, 0xd6, 0x62, 0x4a, 0xbf, 0x8c, 0x43, 0x34, 0x4b, 0x72, 0x91, 0x58, 0xae, 0x36, + 0x93, 0x63, 0xd5, 0x66, 0x6a, 0xdc, 0xda, 0xac, 0x83, 0x57, 0x9e, 0x96, 0x6f, 0x56, 0x98, 0xaf, + 0x35, 0x70, 0xbb, 0xca, 0xbc, 0x5d, 0x12, 0x48, 0xde, 0x1e, 0x21, 0xee, 0x5d, 0x01, 0x44, 0x5c, + 0x77, 0xc0, 0x0c, 0x8d, 0x49, 0x22, 0xe3, 0xa7, 0x65, 0x29, 0xf5, 0xba, 0xd6, 0xad, 0x34, 0x7e, + 0x1f, 0x81, 0x28, 0x23, 0x89, 0x0d, 0xae, 0xf2, 0xa3, 0x0a, 0x93, 0xdb, 0xd0, 0x47, 0x20, 0xca, + 0x48, 0x39, 0xb9, 0x6b, 0xc0, 0x1c, 0xad, 0x22, 0x13, 0x7a, 0xa6, 0x81, 0x52, 0x95, 0x79, 0xf7, + 0x5c, 0x9f, 0x7f, 0x22, 0xaf, 0x6d, 0x0d, 0x27, 0x38, 0x94, 0x15, 0x65, 0x24, 0x12, 0x15, 0xd5, + 0x86, 0x2b, 0x9a, 0xda, 0x21, 0x52, 0x04, 0x7d, 0x1f, 0x4c, 0xc7, 0x72, 0x93, 0x54, 0x57, 0xdc, + 0x7e, 0xc9, 0x1e, 0x7e, 0x77, 0x76, 0xde, 0x75, 0x95, 0x79, 0x79, 0x6f, 0xe9, 0x56, 0x88, 0x94, + 0x8f, 0x9c, 0xf8, 0x55, 0xb0, 0x3c, 0x42, 0x59, 0xa6, 0xfc, 0x9f, 0x19, 0x70, 0x6b, 0xc8, 0xaf, + 0xfe, 0x1e, 0x28, 0x8a, 0xfb, 0x59, 0x8f, 0x49, 0xe2, 0x53, 0x57, 0x4a, 0x9f, 0xaa, 0x94, 0x1f, + 0x76, 0x2d, 0xad, 0xd7, 0xb5, 0x74, 0x75, 0xc4, 0x03, 0x02, 0x44, 0x40, 0xac, 0x6a, 0x72, 0xa1, + 0x47, 0xe0, 0xa6, 0xc4, 0x78, 0x2b, 0x21, 0xac, 0x45, 0x03, 0x57, 0x55, 0xfb, 0x23, 0xb1, 0xff, + 0xb7, 0xae, 0xb5, 0xee, 0xf9, 0xbc, 0x75, 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0x0b, 0x00, 0x00, +} + +func (this *OracleParamsMsg) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OracleParamsMsg) + if !ok { + that2, ok := that.(OracleParamsMsg) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.VotePeriod != that1.VotePeriod { + return false + } + if that1.VoteThreshold == nil { + if this.VoteThreshold != nil { + return false + } + } else if !this.VoteThreshold.Equal(*that1.VoteThreshold) { + return false + } + if that1.RewardBand == nil { + if this.RewardBand != nil { + return false + } + } else if !this.RewardBand.Equal(*that1.RewardBand) { + return false + } + if len(this.Whitelist) != len(that1.Whitelist) { + return false + } + for i := range this.Whitelist { + if !this.Whitelist[i].Equal(that1.Whitelist[i]) { + return false + } + } + if that1.SlashFraction == nil { + if this.SlashFraction != nil { + return false + } + } else if !this.SlashFraction.Equal(*that1.SlashFraction) { + return false + } + if this.SlashWindow != that1.SlashWindow { + return false + } + if that1.MinValidPerWindow == nil { + if this.MinValidPerWindow != nil { + return false + } + } else if !this.MinValidPerWindow.Equal(*that1.MinValidPerWindow) { + return false + } + if this.TwapLookbackWindow != nil && that1.TwapLookbackWindow != nil { + if *this.TwapLookbackWindow != *that1.TwapLookbackWindow { + return false + } + } else if this.TwapLookbackWindow != nil { + return false + } else if that1.TwapLookbackWindow != nil { + return false + } + if this.MinVoters != that1.MinVoters { + return false + } + if that1.ValidatorFeeRatio == nil { + if this.ValidatorFeeRatio != nil { + return false + } + } else if !this.ValidatorFeeRatio.Equal(*that1.ValidatorFeeRatio) { + return false + } + if this.ExpirationBlocks != that1.ExpirationBlocks { + return false + } + return true } // Reference imports to suppress errors if they are not otherwise used. @@ -889,23 +1058,81 @@ func (m *MsgEditOracleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.ValidatorFeeRatio != nil { + if m.Params != nil { { - size := m.ValidatorFeeRatio.Size() - i -= size - if _, err := m.ValidatorFeeRatio.MarshalTo(dAtA[i:]); err != nil { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x5a + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgEditOracleParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgEditOracleParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEditOracleParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *OracleParamsMsg) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleParamsMsg) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleParamsMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExpirationBlocks != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExpirationBlocks)) + i-- + dAtA[i] = 0x58 } - if m.MinVoters != nil { + if m.ValidatorFeeRatio != nil { { - size := m.MinVoters.Size() + size := m.ValidatorFeeRatio.Size() i -= size - if _, err := m.MinVoters.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.ValidatorFeeRatio.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintTx(dAtA, i, uint64(size)) @@ -913,17 +1140,20 @@ func (m *MsgEditOracleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x52 } + if m.MinVoters != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.MinVoters)) + i-- + dAtA[i] = 0x48 + } if m.TwapLookbackWindow != nil { - { - size := m.TwapLookbackWindow.Size() - i -= size - if _, err := m.TwapLookbackWindow.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) + n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(*m.TwapLookbackWindow, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(*m.TwapLookbackWindow):]) + if err2 != nil { + return 0, err2 } + i -= n2 + i = encodeVarintTx(dAtA, i, uint64(n2)) i-- - dAtA[i] = 0x4a + dAtA[i] = 0x42 } if m.MinValidPerWindow != nil { { @@ -935,19 +1165,12 @@ func (m *MsgEditOracleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x3a } - if m.SlashWindow != nil { - { - size := m.SlashWindow.Size() - i -= size - if _, err := m.SlashWindow.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } + if m.SlashWindow != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.SlashWindow)) i-- - dAtA[i] = 0x3a + dAtA[i] = 0x30 } if m.SlashFraction != nil { { @@ -959,15 +1182,20 @@ func (m *MsgEditOracleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a } if len(m.Whitelist) > 0 { for iNdEx := len(m.Whitelist) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Whitelist[iNdEx]) - copy(dAtA[i:], m.Whitelist[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Whitelist[iNdEx]))) + { + size := m.Whitelist[iNdEx].Size() + i -= size + if _, err := m.Whitelist[iNdEx].MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } } if m.RewardBand != nil { @@ -980,7 +1208,7 @@ func (m *MsgEditOracleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a } if m.VoteThreshold != nil { { @@ -992,61 +1220,12 @@ func (m *MsgEditOracleParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - } - if m.VotePeriod != nil { - { - size := m.VotePeriod.Size() - i -= size - if _, err := m.VotePeriod.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0x12 } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + if m.VotePeriod != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.VotePeriod)) i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgEditOracleParamsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgEditOracleParamsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgEditOracleParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.NewParams != nil { - { - size, err := m.NewParams.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -1162,10 +1341,31 @@ func (m *MsgEditOracleParams) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.VotePeriod != nil { - l = m.VotePeriod.Size() + if m.Params != nil { + l = m.Params.Size() n += 1 + l + sovTx(uint64(l)) } + return n +} + +func (m *MsgEditOracleParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *OracleParamsMsg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.VotePeriod != 0 { + n += 1 + sovTx(uint64(m.VotePeriod)) + } if m.VoteThreshold != nil { l = m.VoteThreshold.Size() n += 1 + l + sovTx(uint64(l)) @@ -1175,8 +1375,8 @@ func (m *MsgEditOracleParams) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } if len(m.Whitelist) > 0 { - for _, s := range m.Whitelist { - l = len(s) + for _, e := range m.Whitelist { + l = e.Size() n += 1 + l + sovTx(uint64(l)) } } @@ -1184,38 +1384,26 @@ func (m *MsgEditOracleParams) Size() (n int) { l = m.SlashFraction.Size() n += 1 + l + sovTx(uint64(l)) } - if m.SlashWindow != nil { - l = m.SlashWindow.Size() - n += 1 + l + sovTx(uint64(l)) + if m.SlashWindow != 0 { + n += 1 + sovTx(uint64(m.SlashWindow)) } if m.MinValidPerWindow != nil { l = m.MinValidPerWindow.Size() n += 1 + l + sovTx(uint64(l)) } if m.TwapLookbackWindow != nil { - l = m.TwapLookbackWindow.Size() + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(*m.TwapLookbackWindow) n += 1 + l + sovTx(uint64(l)) } - if m.MinVoters != nil { - l = m.MinVoters.Size() - n += 1 + l + sovTx(uint64(l)) + if m.MinVoters != 0 { + n += 1 + sovTx(uint64(m.MinVoters)) } if m.ValidatorFeeRatio != nil { l = m.ValidatorFeeRatio.Size() n += 1 + l + sovTx(uint64(l)) } - return n -} - -func (m *MsgEditOracleParamsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.NewParams != nil { - l = m.NewParams.Size() - n += 1 + l + sovTx(uint64(l)) + if m.ExpirationBlocks != 0 { + n += 1 + sovTx(uint64(m.ExpirationBlocks)) } return n } @@ -1877,9 +2065,9 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1889,29 +2077,148 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int - m.VotePeriod = &v - if err := m.VotePeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Params == nil { + m.Params = &OracleParamsMsg{} + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEditOracleParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgEditOracleParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditOracleParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleParamsMsg) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleParamsMsg: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleParamsMsg: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VotePeriod", wireType) + } + m.VotePeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VotePeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field VoteThreshold", wireType) } @@ -1947,7 +2254,7 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RewardBand", wireType) } @@ -1983,7 +2290,7 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Whitelist", wireType) } @@ -2013,9 +2320,13 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Whitelist = append(m.Whitelist, string(dAtA[iNdEx:postIndex])) + var v github_com_NibiruChain_nibiru_v2_x_common_asset.Pair + m.Whitelist = append(m.Whitelist, v) + if err := m.Whitelist[len(m.Whitelist)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 6: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SlashFraction", wireType) } @@ -2051,11 +2362,11 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: - if wireType != 2 { + case 6: + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SlashWindow", wireType) } - var stringLen uint64 + m.SlashWindow = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2065,29 +2376,12 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.SlashWindow |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_cosmos_cosmos_sdk_types.Int - m.SlashWindow = &v - if err := m.SlashWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinValidPerWindow", wireType) } @@ -2123,11 +2417,11 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TwapLookbackWindow", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2137,33 +2431,33 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Int - m.TwapLookbackWindow = &v - if err := m.TwapLookbackWindow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.TwapLookbackWindow == nil { + m.TwapLookbackWindow = new(time.Duration) + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(m.TwapLookbackWindow, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 10: - if wireType != 2 { + case 9: + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MinVoters", wireType) } - var stringLen uint64 + m.MinVoters = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2173,29 +2467,12 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.MinVoters |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var v github_com_cosmos_cosmos_sdk_types.Int - m.MinVoters = &v - if err := m.MinVoters.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ValidatorFeeRatio", wireType) } @@ -2231,61 +2508,11 @@ func (m *MsgEditOracleParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgEditOracleParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgEditOracleParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgEditOracleParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewParams", wireType) + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpirationBlocks", wireType) } - var msglen int + m.ExpirationBlocks = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2295,28 +2522,11 @@ func (m *MsgEditOracleParamsResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.ExpirationBlocks |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.NewParams == nil { - m.NewParams = &Params{} - } - if err := m.NewParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/oracle/types/tx.pb.gw.go b/x/oracle/types/tx.pb.gw.go index 5c9ddb424..46515660b 100644 --- a/x/oracle/types/tx.pb.gw.go +++ b/x/oracle/types/tx.pb.gw.go @@ -406,7 +406,7 @@ var ( pattern_Msg_DelegateFeedConsent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "feeder-delegate"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Msg_EditOracleParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "edit-oracle-params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Msg_EditOracleParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nibiru", "oracle", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/sudo/keeper/keeper_test.go b/x/sudo/keeper/keeper_test.go index 35927dae3..6f1f7fbb1 100644 --- a/x/sudo/keeper/keeper_test.go +++ b/x/sudo/keeper/keeper_test.go @@ -25,7 +25,7 @@ func TestCheckPermissions(t *testing.T) { Contracts: mockContractAddrStrs, }) - err := nibiru.SudoKeeper.CheckPermissions(sdk.AccAddress([]byte("addrbbb")), ctx) + err := nibiru.SudoKeeper.CheckPermissions(sdk.AccAddress("addrbbb"), ctx) require.Error(t, err) for _, mockAddr := range mockContractAddrs { err := nibiru.SudoKeeper.CheckPermissions(mockAddr, ctx) diff --git a/x/sudo/module.go b/x/sudo/module.go index 18d93dc8a..27131c732 100644 --- a/x/sudo/module.go +++ b/x/sudo/module.go @@ -143,7 +143,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 3 } +func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index ba8799f58..8bdc247ef 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -41,7 +41,7 @@ var ( ) // ConsensusVersion defines the current module consensus version. -const ConsensusVersion = 2 +const ConsensusVersion = 1 // AppModuleBasic type for the fees module type AppModuleBasic struct{}