From d35fe48a006a6e386396e2f261a61194f5bbf281 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sat, 1 Oct 2022 03:36:47 +0200 Subject: [PATCH 1/3] Stop returning error logs + stack trace when out of gas in ApplyFuncIfNoErr (#2914) * Stop returning error logs + stack trace when theres an out of gas in ApplyFuncIfNoErr * Fix import * Changelog (cherry picked from commit 1ec86587e464e63cb3634e27b7b3ff42f11c6663) # Conflicts: # CHANGELOG.md # osmoutils/cache_ctx.go --- CHANGELOG.md | 114 +++++++++++++++++++++++++++++++++++++++++ osmoutils/cache_ctx.go | 27 ++++++++++ 2 files changed, 141 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb10089c01f..336ea235a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,121 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +<<<<<<< HEAD * [2261](https://github.com/osmosis-labs/osmosis/pull/2261) feat: speedup epoch distribution, superfluid component (backport #2214) +======= +### Features + +* [#2739](https://github.com/osmosis-labs/osmosis/pull/2739) Add pool type query + +### Bug fixes + +* [#2803](https://github.com/osmosis-labs/osmosis/pull/2803) Fix total pool liquidity CLI query. +* [#2914](https://github.com/osmosis-labs/osmosis/pull/2914) Remove out of gas panics from node logs + +### Misc Improvements + +* [#2804](https://github.com/osmosis-labs/osmosis/pull/2804) Improve error handling and messages when parsing pool assets. + +## v12.0.0 + +This release includes several cosmwasm-developer and appchain-ecosystem affecting upgrades: + +* TWAP - Time weighted average prices for all AMM pools +* Cosmwasm contract developer facing features + * Enabling select queries for cosmwasm contracts + * Add message responses to gamm messages, to remove the neccessity of bindings + * Allow specifying denom metadata from tokenfactory +* Enabling Interchain accounts (for real this time) +* Upgrading IBC to v3.3.0 +* Consistently makes authz work with ledger for all messages + +The release also contains the following changes affecting Osmosis users and node operators + +* Fixing State Sync +* Enabling expedited proposals + +This upgrade also adds a number of safety and API boundary improving changes to the codebase. +While not state machine breaking, this release also includes the revamped Osmosis simulator, +which acts as a fuzz testing tool tailored for the SDK state machine. + +### Breaking Changes + +* [#2477](https://github.com/osmosis-labs/osmosis/pull/2477) Tokenfactory burn msg clash with sdk + * TypeMsgBurn: from "burn" to "tf_burn" + * TypeMsgMint: from "mint" to "tf_mint" +* [#2222](https://github.com/osmosis-labs/osmosis/pull/2222) Add scaling factors to MsgCreateStableswapPool +* [#1889](https://github.com/osmosis-labs/osmosis/pull/1825) Add proto responses to gamm LP messages: + * MsgJoinPoolResponse: share_out_amount and token_in fields + * MsgExitPoolResponse: token_out field +* [#1825](https://github.com/osmosis-labs/osmosis/pull/1825) Fixes Interchain Accounts (host side) by adding it to AppModuleBasics +* [#1994](https://github.com/osmosis-labs/osmosis/pull/1994) Removed bech32ibc module +* [#2016](https://github.com/osmosis-labs/osmosis/pull/2016) Add fixed 10000 gas cost for each Balancer swap +* [#2193](https://github.com/osmosis-labs/osmosis/pull/2193) Add TwapKeeper to the Osmosis app +* [#2227](https://github.com/osmosis-labs/osmosis/pull/2227) Enable charging fee in base denom for `CreateGauge` and `AddToGauge`. +* [#2283](https://github.com/osmosis-labs/osmosis/pull/2283) x/incentives: refactor `CreateGauge` and `AddToGauge` fees to use txfees denom +* [#2206](https://github.com/osmosis-labs/osmosis/pull/2283) Register all Amino interfaces and concrete types on the authz Amino codec. This will allow the authz module to properly serialize and de-serializes instances using Amino. +* [#2405](https://github.com/osmosis-labs/osmosis/pull/2405) Make SpotPrice have a max value of 2^160, and no longer be able to panic +* [#2473](https://github.com/osmosis-labs/osmosis/pull/2473) x/superfluid `AddNewSuperfluidAsset` now returns error, if any occurs instead of ignoring it. +* [#2714](https://github.com/osmosis-labs/osmosis/pull/2714) Upgrade wasmd to v0.28.0. +* Remove x/Bech32IBC + +#### Golang API breaks + +* [#2160](https://github.com/osmosis-labs/osmosis/pull/2160) Clean up GAMM keeper (move `x/gamm/keeper/params.go` contents into `x/gamm/keeper/keeper.go`, replace all uses of `PoolNumber` with `PoolId`, move `SetStableSwapScalingFactors` to stableswap package, and delete marshal_bench_test.go and grpc_query_internal_test.go) +* [#1987](https://github.com/osmosis-labs/osmosis/pull/1987) Remove `GammKeeper.GetNextPoolNumberAndIncrement` in favor of the non-mutative `GammKeeper.GetNextPoolNumber`. +* [#1667](https://github.com/osmosis-labs/osmosis/pull/1673) Move wasm-bindings code out of app package into its own root level package. +* [#2013](https://github.com/osmosis-labs/osmosis/pull/2013) Make `SetParams`, `SetPool`, `SetTotalLiquidity`, and `SetDenomLiquidity` GAMM APIs private +* [#1857](https://github.com/osmosis-labs/osmosis/pull/1857) x/mint rename GetLastHalvenEpochNum to GetLastReductionEpochNum +* [#2133](https://github.com/osmosis-labs/osmosis/pull/2133) Add `JoinPoolNoSwap` and `CalcJoinPoolNoSwapShares` to GAMM pool interface and route `JoinPoolNoSwap` in pool_service.go to new method in pool interface +* [#2353](https://github.com/osmosis-labs/osmosis/pull/2353) Re-enable stargate query via whitelsit +* [#2394](https://github.com/osmosis-labs/osmosis/pull/2394) Remove unused interface methods from expected keepers of each module +* [#2390](https://github.com/osmosis-labs/osmosis/pull/2390) x/mint remove unused mintCoins parameter from AfterDistributeMintedCoin +* [#2418](https://github.com/osmosis-labs/osmosis/pull/2418) x/mint remove SetInitialSupplyOffsetDuringMigration from keeper +* [#2417](https://github.com/osmosis-labs/osmosis/pull/2417) x/mint unexport keeper `SetLastReductionEpochNum`, `getLastReductionEpochNum`, `CreateDeveloperVestingModuleAccount`, and `MintCoins` +* [#2587](https://github.com/osmosis-labs/osmosis/pull/2587) remove encoding config argument from NewOsmosisApp +x + +### Features + +* [#2387](https://github.com/osmosis-labs/osmosis/pull/2387) Upgrade to IBC v3.2.0, which allows for sending/receiving IBC tokens with slashes. +* [#1312] Stableswap: Createpool logic +* [#1230] Stableswap CFMM equations +* [#1429] solver for multi-asset CFMM +* [#1539] Superfluid: Combine superfluid and staking query on querying delegation by delegator +* [#2223] Tokenfactory: Add SetMetadata functionality + +### Bug Fixes + +* [#2086](https://github.com/osmosis-labs/osmosis/pull/2086) `ReplacePoolIncentivesProposal` ProposalType() returns correct value of `ProposalTypeReplacePoolIncentives` instead of `ProposalTypeUpdatePoolIncentives` +* [1930](https://github.com/osmosis-labs/osmosis/pull/1930) Ensure you can't `JoinPoolNoSwap` tokens that are not in the pool +* [2186](https://github.com/osmosis-labs/osmosis/pull/2186) Remove liquidity event that was emitted twice per message. + +### Improvements +* [#2515](https://github.com/osmosis-labs/osmosis/pull/2515) Emit events from functions implementing epoch hooks' `panicCatchingEpochHook` cacheCtx +* [#2526](https://github.com/osmosis-labs/osmosis/pull/2526) EpochHooks interface methods (and hence modules implementing the hooks) return error instead of panic + +## v11.0.1 + +#### Golang API breaks +* [#1893](https://github.com/osmosis-labs/osmosis/pull/1893) Change `EpochsKeeper.SetEpochInfo` to `AddEpochInfo`, which has more safety checks with it. (Makes it suitable to be called within upgrades) +* [#2396](https://github.com/osmosis-labs/osmosis/pull/2396) x/mint remove unused mintCoins parameter from AfterDistributeMintedCoin +* [#2399](https://github.com/osmosis-labs/osmosis/pull/2399) Remove unused interface methods from expected keepers of each module +* [#2401](https://github.com/osmosis-labs/osmosis/pull/2401) Update Go import paths to v11 + +#### Bug Fixes +* [2291](https://github.com/osmosis-labs/osmosis/pull/2291) Remove liquidity event that was emitted twice per message +* [2288](https://github.com/osmosis-labs/osmosis/pull/2288) Fix swagger docs and swagger generation + +## v11 + +#### Improvements +* [#2237](https://github.com/osmosis-labs/osmosis/pull/2237) Enable charging fee in base denom for `CreateGauge` and `AddToGauge`. + +#### SDK Upgrades +* [#2245](https://github.com/osmosis-labs/osmosis/pull/2245) Upgrade SDK for to v0.45.0x-osmo-v9.2. Major changes: + * Minimum deposit on proposer at submission time: https://github.com/osmosis-labs/cosmos-sdk/pull/302 +>>>>>>> 1ec86587 (Stop returning error logs + stack trace when out of gas in ApplyFuncIfNoErr (#2914)) ## [v7.3.0](https://github.com/osmosis-labs/osmosis/releases/tag/v7.3.0) diff --git a/osmoutils/cache_ctx.go b/osmoutils/cache_ctx.go index f2a63eacad9..a09d6d5ebc0 100644 --- a/osmoutils/cache_ctx.go +++ b/osmoutils/cache_ctx.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -30,3 +31,29 @@ func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err err } return err } +<<<<<<< HEAD +======= + +// PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. +// If not emits them to stdout. +func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{}) { + errStackTrace := string(debug.Stack()) + switch e := recoveryError.(type) { + case types.ErrorOutOfGas: + ctx.Logger().Debug("out of gas error inside panic recovery block: " + e.Descriptor) + return + case string: + ctx.Logger().Error("Recovering from (string) panic: " + e) + case runtime.Error: + ctx.Logger().Error("recovered (runtime.Error) panic: " + e.Error()) + case error: + ctx.Logger().Error("recovered (error) panic: " + e.Error()) + default: + ctx.Logger().Error("recovered (default) panic. Could not capture logs in ctx, see stdout") + fmt.Println("Recovering from panic ", recoveryError) + debug.PrintStack() + return + } + ctx.Logger().Error("stack trace: " + errStackTrace) +} +>>>>>>> 1ec86587 (Stop returning error logs + stack trace when out of gas in ApplyFuncIfNoErr (#2914)) From 95fcd31407684393c0d0d382b510399cc6a207f9 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Tue, 4 Oct 2022 18:27:01 +0200 Subject: [PATCH 2/3] add gitiginore and changelog --- .gitignore | 33 ++++++++++++++- CHANGELOG.md | 113 --------------------------------------------------- 2 files changed, 32 insertions(+), 114 deletions(-) diff --git a/.gitignore b/.gitignore index cb20dfd7638..713ac5a1033 100644 --- a/.gitignore +++ b/.gitignore @@ -197,5 +197,36 @@ $RECYCLE.BIN/ /.idea/ /artifacts/ /.vscode/ +/.VSCodeCounter/ /scripts/local/ -/x/incentives/keeper/osmosis_testing/ \ No newline at end of file +/x/incentives/keeper/osmosis_testing/ +tools-stamp +/tests/localosmosis/.osmosisd/* +*.save +*.save.* + +mutation_test_result.txt +go_mutation_test_result.txt + +# Rust ignores. Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Generated by rust-optimizer +artifacts/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Ignores beaker state +.beaker +blocks.db +**/blocks.db* diff --git a/CHANGELOG.md b/CHANGELOG.md index 336ea235a6c..8344a586cc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,122 +41,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -<<<<<<< HEAD * [2261](https://github.com/osmosis-labs/osmosis/pull/2261) feat: speedup epoch distribution, superfluid component (backport #2214) -======= -### Features - -* [#2739](https://github.com/osmosis-labs/osmosis/pull/2739) Add pool type query - -### Bug fixes - -* [#2803](https://github.com/osmosis-labs/osmosis/pull/2803) Fix total pool liquidity CLI query. * [#2914](https://github.com/osmosis-labs/osmosis/pull/2914) Remove out of gas panics from node logs -### Misc Improvements - -* [#2804](https://github.com/osmosis-labs/osmosis/pull/2804) Improve error handling and messages when parsing pool assets. - -## v12.0.0 - -This release includes several cosmwasm-developer and appchain-ecosystem affecting upgrades: - -* TWAP - Time weighted average prices for all AMM pools -* Cosmwasm contract developer facing features - * Enabling select queries for cosmwasm contracts - * Add message responses to gamm messages, to remove the neccessity of bindings - * Allow specifying denom metadata from tokenfactory -* Enabling Interchain accounts (for real this time) -* Upgrading IBC to v3.3.0 -* Consistently makes authz work with ledger for all messages - -The release also contains the following changes affecting Osmosis users and node operators - -* Fixing State Sync -* Enabling expedited proposals - -This upgrade also adds a number of safety and API boundary improving changes to the codebase. -While not state machine breaking, this release also includes the revamped Osmosis simulator, -which acts as a fuzz testing tool tailored for the SDK state machine. - -### Breaking Changes - -* [#2477](https://github.com/osmosis-labs/osmosis/pull/2477) Tokenfactory burn msg clash with sdk - * TypeMsgBurn: from "burn" to "tf_burn" - * TypeMsgMint: from "mint" to "tf_mint" -* [#2222](https://github.com/osmosis-labs/osmosis/pull/2222) Add scaling factors to MsgCreateStableswapPool -* [#1889](https://github.com/osmosis-labs/osmosis/pull/1825) Add proto responses to gamm LP messages: - * MsgJoinPoolResponse: share_out_amount and token_in fields - * MsgExitPoolResponse: token_out field -* [#1825](https://github.com/osmosis-labs/osmosis/pull/1825) Fixes Interchain Accounts (host side) by adding it to AppModuleBasics -* [#1994](https://github.com/osmosis-labs/osmosis/pull/1994) Removed bech32ibc module -* [#2016](https://github.com/osmosis-labs/osmosis/pull/2016) Add fixed 10000 gas cost for each Balancer swap -* [#2193](https://github.com/osmosis-labs/osmosis/pull/2193) Add TwapKeeper to the Osmosis app -* [#2227](https://github.com/osmosis-labs/osmosis/pull/2227) Enable charging fee in base denom for `CreateGauge` and `AddToGauge`. -* [#2283](https://github.com/osmosis-labs/osmosis/pull/2283) x/incentives: refactor `CreateGauge` and `AddToGauge` fees to use txfees denom -* [#2206](https://github.com/osmosis-labs/osmosis/pull/2283) Register all Amino interfaces and concrete types on the authz Amino codec. This will allow the authz module to properly serialize and de-serializes instances using Amino. -* [#2405](https://github.com/osmosis-labs/osmosis/pull/2405) Make SpotPrice have a max value of 2^160, and no longer be able to panic -* [#2473](https://github.com/osmosis-labs/osmosis/pull/2473) x/superfluid `AddNewSuperfluidAsset` now returns error, if any occurs instead of ignoring it. -* [#2714](https://github.com/osmosis-labs/osmosis/pull/2714) Upgrade wasmd to v0.28.0. -* Remove x/Bech32IBC - -#### Golang API breaks - -* [#2160](https://github.com/osmosis-labs/osmosis/pull/2160) Clean up GAMM keeper (move `x/gamm/keeper/params.go` contents into `x/gamm/keeper/keeper.go`, replace all uses of `PoolNumber` with `PoolId`, move `SetStableSwapScalingFactors` to stableswap package, and delete marshal_bench_test.go and grpc_query_internal_test.go) -* [#1987](https://github.com/osmosis-labs/osmosis/pull/1987) Remove `GammKeeper.GetNextPoolNumberAndIncrement` in favor of the non-mutative `GammKeeper.GetNextPoolNumber`. -* [#1667](https://github.com/osmosis-labs/osmosis/pull/1673) Move wasm-bindings code out of app package into its own root level package. -* [#2013](https://github.com/osmosis-labs/osmosis/pull/2013) Make `SetParams`, `SetPool`, `SetTotalLiquidity`, and `SetDenomLiquidity` GAMM APIs private -* [#1857](https://github.com/osmosis-labs/osmosis/pull/1857) x/mint rename GetLastHalvenEpochNum to GetLastReductionEpochNum -* [#2133](https://github.com/osmosis-labs/osmosis/pull/2133) Add `JoinPoolNoSwap` and `CalcJoinPoolNoSwapShares` to GAMM pool interface and route `JoinPoolNoSwap` in pool_service.go to new method in pool interface -* [#2353](https://github.com/osmosis-labs/osmosis/pull/2353) Re-enable stargate query via whitelsit -* [#2394](https://github.com/osmosis-labs/osmosis/pull/2394) Remove unused interface methods from expected keepers of each module -* [#2390](https://github.com/osmosis-labs/osmosis/pull/2390) x/mint remove unused mintCoins parameter from AfterDistributeMintedCoin -* [#2418](https://github.com/osmosis-labs/osmosis/pull/2418) x/mint remove SetInitialSupplyOffsetDuringMigration from keeper -* [#2417](https://github.com/osmosis-labs/osmosis/pull/2417) x/mint unexport keeper `SetLastReductionEpochNum`, `getLastReductionEpochNum`, `CreateDeveloperVestingModuleAccount`, and `MintCoins` -* [#2587](https://github.com/osmosis-labs/osmosis/pull/2587) remove encoding config argument from NewOsmosisApp -x - -### Features - -* [#2387](https://github.com/osmosis-labs/osmosis/pull/2387) Upgrade to IBC v3.2.0, which allows for sending/receiving IBC tokens with slashes. -* [#1312] Stableswap: Createpool logic -* [#1230] Stableswap CFMM equations -* [#1429] solver for multi-asset CFMM -* [#1539] Superfluid: Combine superfluid and staking query on querying delegation by delegator -* [#2223] Tokenfactory: Add SetMetadata functionality - -### Bug Fixes - -* [#2086](https://github.com/osmosis-labs/osmosis/pull/2086) `ReplacePoolIncentivesProposal` ProposalType() returns correct value of `ProposalTypeReplacePoolIncentives` instead of `ProposalTypeUpdatePoolIncentives` -* [1930](https://github.com/osmosis-labs/osmosis/pull/1930) Ensure you can't `JoinPoolNoSwap` tokens that are not in the pool -* [2186](https://github.com/osmosis-labs/osmosis/pull/2186) Remove liquidity event that was emitted twice per message. - -### Improvements -* [#2515](https://github.com/osmosis-labs/osmosis/pull/2515) Emit events from functions implementing epoch hooks' `panicCatchingEpochHook` cacheCtx -* [#2526](https://github.com/osmosis-labs/osmosis/pull/2526) EpochHooks interface methods (and hence modules implementing the hooks) return error instead of panic - -## v11.0.1 - -#### Golang API breaks -* [#1893](https://github.com/osmosis-labs/osmosis/pull/1893) Change `EpochsKeeper.SetEpochInfo` to `AddEpochInfo`, which has more safety checks with it. (Makes it suitable to be called within upgrades) -* [#2396](https://github.com/osmosis-labs/osmosis/pull/2396) x/mint remove unused mintCoins parameter from AfterDistributeMintedCoin -* [#2399](https://github.com/osmosis-labs/osmosis/pull/2399) Remove unused interface methods from expected keepers of each module -* [#2401](https://github.com/osmosis-labs/osmosis/pull/2401) Update Go import paths to v11 - -#### Bug Fixes -* [2291](https://github.com/osmosis-labs/osmosis/pull/2291) Remove liquidity event that was emitted twice per message -* [2288](https://github.com/osmosis-labs/osmosis/pull/2288) Fix swagger docs and swagger generation - -## v11 - -#### Improvements -* [#2237](https://github.com/osmosis-labs/osmosis/pull/2237) Enable charging fee in base denom for `CreateGauge` and `AddToGauge`. - -#### SDK Upgrades -* [#2245](https://github.com/osmosis-labs/osmosis/pull/2245) Upgrade SDK for to v0.45.0x-osmo-v9.2. Major changes: - * Minimum deposit on proposer at submission time: https://github.com/osmosis-labs/cosmos-sdk/pull/302 ->>>>>>> 1ec86587 (Stop returning error logs + stack trace when out of gas in ApplyFuncIfNoErr (#2914)) - ## [v7.3.0](https://github.com/osmosis-labs/osmosis/releases/tag/v7.3.0) ### Bug Fixes From 22235d17f932e4522adf077523e41c7ac7773236 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Tue, 4 Oct 2022 18:30:07 +0200 Subject: [PATCH 3/3] merge conflict fix --- osmoutils/cache_ctx.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osmoutils/cache_ctx.go b/osmoutils/cache_ctx.go index a09d6d5ebc0..0802ddd8eec 100644 --- a/osmoutils/cache_ctx.go +++ b/osmoutils/cache_ctx.go @@ -3,6 +3,8 @@ package osmoutils import ( "errors" "fmt" + "runtime" + "runtime/debug" "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,9 +17,9 @@ import ( func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err error) { // Add a panic safeguard defer func() { - if recovErr := recover(); recovErr != nil { - fmt.Println(recovErr) - err = errors.New("panic occured during execution") + if recoveryError := recover(); recoveryError != nil { + PrintPanicRecoveryError(ctx, recoveryError) + err = errors.New("panic occurred during execution") } }() // makes a new cache context, which all state changes get wrapped inside of. @@ -31,8 +33,6 @@ func ApplyFuncIfNoError(ctx sdk.Context, f func(ctx sdk.Context) error) (err err } return err } -<<<<<<< HEAD -======= // PrintPanicRecoveryError error logs the recoveryError, along with the stacktrace, if it can be parsed. // If not emits them to stdout. @@ -56,4 +56,3 @@ func PrintPanicRecoveryError(ctx sdk.Context, recoveryError interface{}) { } ctx.Logger().Error("stack trace: " + errStackTrace) } ->>>>>>> 1ec86587 (Stop returning error logs + stack trace when out of gas in ApplyFuncIfNoErr (#2914))