Skip to content

Commit

Permalink
Merge branch 'main' into dev/refine_spam_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic authored Jan 9, 2024
2 parents 23ab392 + 875a12a commit 424c6f5
Show file tree
Hide file tree
Showing 115 changed files with 3,469 additions and 11,500 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### State Breaking

* [#7272](https://github.com/osmosis-labs/osmosis/pull/7272 Upgrade go 1.20 -> 1.21

### API

* [#6991](https://github.com/osmosis-labs/osmosis/pull/6991) Fix: total liquidity poolmanager grpc gateway query
Expand All @@ -51,23 +55,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Features

* [#6993](https://github.com/osmosis-labs/osmosis/pull/6993) feat(math): add mutative api for BigDec.BigInt()
* [#7270](https://github.com/osmosis-labs/osmosis/pull/7270) feat: eip target gas from consensus params

### Misc Improvements

* [#7106](https://github.com/osmosis-labs/osmosis/pull/7106) Halve the time of log2 calculation (speeds up TWAP code)
* [#7093](https://github.com/osmosis-labs/osmosis/pull/7093),[#7100](https://github.com/osmosis-labs/osmosis/pull/7100),[#7172](https://github.com/osmosis-labs/osmosis/pull/7172) Lower CPU overheads of the Osmosis epoch.
* [#7203](https://github.com/osmosis-labs/osmosis/pull/7203) Make a maximum number of pools of 100 billion.
* [#7250](https://github.com/osmosis-labs/osmosis/pull/7250) Further filter spam gauges from epoch distribution.
* [#7220](https://github.com/osmosis-labs/osmosis/pull/7220) Register consensus params; Set MaxGas to 300m and MaxBytes to 5mb.
* [#7249](https://github.com/osmosis-labs/osmosis/pull/7249) Double auth tx size cost per byte from 10 to 20
* [#7259](https://github.com/osmosis-labs/osmosis/pull/7259) Lower gas and CPU overhead of chargeTakerFee (in every swap)
* [#7253](https://github.com/osmosis-labs/osmosis/pull/7253) Extended app hash logs (includes module hashes for easier debugging)
* [#7258](https://github.com/osmosis-labs/osmosis/pull/7258) Remove an iterator call in CL swaps and spot price calls.

### Bug Fixes

* [#7245](https://github.com/osmosis-labs/osmosis/pull/7245) fix: correcting json tag value for `SwapAmountOutSplitRouteWrapper.OutDenom`
* [#7233](https://github.com/osmosis-labs/osmosis/pull/7233) fix: config overwrite ignores app.toml values
* [#7233](https://github.com/osmosis-labs/osmosis/pull/7233) fix: config overwrite ignores app.toml values
* [#7243](https://github.com/osmosis-labs/osmosis/pull/7243) fix: chore: update gov metadata length from 256 to 10200
* [#7246](https://github.com/osmosis-labs/osmosis/pull/7246) fix: config overwrite fails with exit code 1 if wrong permissions
* [#7267](https://github.com/osmosis-labs/osmosis/pull/7267) fix: support CL pools in tx fee module

## v21.1.5

Expand Down
9 changes: 4 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import (
"github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"

"github.com/osmosis-labs/osmosis/v21/ingest/sqs"
"github.com/osmosis-labs/osmosis/v21/ingest/sqs/domain"

"github.com/osmosis-labs/osmosis/osmoutils"

nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
Expand Down Expand Up @@ -96,10 +99,6 @@ import (
_ "github.com/osmosis-labs/osmosis/v21/client/docs/statik"
"github.com/osmosis-labs/osmosis/v21/ingest"
"github.com/osmosis-labs/osmosis/v21/x/mint"

"github.com/osmosis-labs/osmosis/v21/ingest/sqs"

"github.com/osmosis-labs/osmosis/v21/ingest/sqs/pools/common"
)

const appName = "OsmosisApp"
Expand Down Expand Up @@ -260,7 +259,7 @@ func NewOsmosisApp(

// Initialize the SQS ingester if it is enabled.
if sqsConfig.IsEnabled {
sqsKeepers := common.SQSIngestKeepers{
sqsKeepers := domain.SQSIngestKeepers{
GammKeeper: app.GAMMKeeper,
CosmWasmPoolKeeper: app.CosmwasmPoolKeeper,
BankKeeper: app.BankKeeper,
Expand Down
35 changes: 29 additions & 6 deletions app/apptesting/cosmwasmpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apptesting

import (
"encoding/json"
"fmt"
"os"
"strings"

Expand All @@ -22,20 +23,31 @@ const (
TransmuterContractName = "transmuter"
TransmuterMigrateContractName = "transmuter_migrate"
DefaultCodeId = 1

osmosisRepository = "osmosis"
osmosisRepoTransmuterPath = "x/cosmwasmpool/bytecode"
)

// PrepareCosmWasmPool sets up a cosmwasm pool with the default parameters.
func (s *KeeperTestHelper) PrepareCosmWasmPool() cosmwasmpooltypes.CosmWasmExtension {
return s.PrepareCustomTransmuterPool(s.TestAccs[0], []string{DefaultTransmuterDenomA, DefaultTransmuterDenomB})
}

// PrepareCustomTransmuterPool sets up a transmuter pool with the custom parameters.
// PrepareCustomTransmuterPool sets up a transmuter pool with the default parameters assuming that
// the transmuter contract is stored under x/cosmwasmpool/bytecode in the Osmosis repository.
func (s *KeeperTestHelper) PrepareCustomTransmuterPool(owner sdk.AccAddress, denoms []string) cosmwasmpooltypes.CosmWasmExtension {
return s.PrepareCustomTransmuterPoolCustomProject(owner, denoms, osmosisRepository, osmosisRepoTransmuterPath)
}

// PrepareCustomTransmuterPoolCustomProject sets up a transmuter pool with the custom parameters.
// Gives flexibility for the helper to be reused outside of the Osmosis repository by providing custom
// project name and bytecode path.
func (s *KeeperTestHelper) PrepareCustomTransmuterPoolCustomProject(owner sdk.AccAddress, denoms []string, projectName, byteCodePath string) cosmwasmpooltypes.CosmWasmExtension {
// Mint some assets to the account.
s.FundAcc(s.TestAccs[0], DefaultAcctFunds)

// Upload contract code and get the code id.
codeId := s.StoreCosmWasmPoolContractCode(TransmuterContractName)
codeId := s.StoreCosmWasmPoolContractCodeCustomProject(TransmuterContractName, projectName, byteCodePath)

// Add code id to the whitelist.
s.App.CosmwasmPoolKeeper.WhitelistCodeId(s.Ctx, codeId)
Expand Down Expand Up @@ -79,6 +91,13 @@ func (s *KeeperTestHelper) GetTransmuterInstantiateMsgBytes(poolAssetDenoms []st
// StoreCosmWasmPoolContractCode stores the cosmwasm pool contract code in the wasm keeper and returns the code id.
// contractName is the name of the contract file in the x/cosmwasmpool/bytecode directory without the .wasm extension.
func (s *KeeperTestHelper) StoreCosmWasmPoolContractCode(contractName string) uint64 {
return s.StoreCosmWasmPoolContractCodeCustomProject(contractName, osmosisRepository, osmosisRepoTransmuterPath)
}

// StoreCosmWasmPoolContractCodeCustomProject stores the cosmwasm pool contract code in the wasm keeper and returns the code id.
// contractName is the name of the contract file in the x/cosmwasmpool/bytecode directory without the .wasm extension.
// It has the flexibility of being used from outside the Osmosis repository by providing custom project name and bytecode path.
func (s *KeeperTestHelper) StoreCosmWasmPoolContractCodeCustomProject(contractName, projectName, byteCodePath string) uint64 {
cosmwasmpoolModuleAddr := s.App.AccountKeeper.GetModuleAddress(cosmwasmpooltypes.ModuleName)
s.Require().NotNil(cosmwasmpoolModuleAddr)

Expand All @@ -93,7 +112,7 @@ func (s *KeeperTestHelper) StoreCosmWasmPoolContractCode(contractName string) ui
})
s.Require().NoError(err)

code := s.GetContractCode(contractName)
code := s.GetContractCodeCustomProject(contractName, projectName, byteCodePath)

instantiateConfig := wasmtypes.AccessConfig{Permission: wasmtypes.AccessTypeAnyOfAddresses, Addresses: []string{cosmwasmpoolModuleAddr.String()}}
codeID, _, err := s.App.ContractKeeper.Create(s.Ctx, cosmwasmpoolModuleAddr, code, &instantiateConfig)
Expand All @@ -102,16 +121,20 @@ func (s *KeeperTestHelper) StoreCosmWasmPoolContractCode(contractName string) ui
return codeID
}

func (s *KeeperTestHelper) GetContractCode(contractName string) []byte {
return s.GetContractCodeCustomProject(contractName, "osmosis", "x/cosmwasmpool/bytecode")
}

// GetContractCode returns the contract code for the given contract name.
// Assumes that the contract code is stored under x/cosmwasmpool/bytecode.
func (s *KeeperTestHelper) GetContractCode(contractName string) []byte {
func (s *KeeperTestHelper) GetContractCodeCustomProject(contractName string, projectName string, path string) []byte {
workingDir, err := os.Getwd()
s.Require().NoError(err)

projectRootPath := "/osmosis/"
projectRootPath := fmt.Sprintf("/%s/", projectName)
projectRootIndex := strings.LastIndex(workingDir, projectRootPath) + len(projectRootPath)
workingDir = workingDir[:projectRootIndex]
code, err := os.ReadFile(workingDir + "x/cosmwasmpool/bytecode/" + contractName + ".wasm")
code, err := os.ReadFile(workingDir + path + "/" + contractName + ".wasm")
s.Require().NoError(err)

return code
Expand Down
9 changes: 8 additions & 1 deletion app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ func (s *KeeperTestHelper) SetupWithCustomChainId(chainId string) {
// PrepareAllSupportedPools creates all supported pools and returns their IDs.
// Additionally, attaches an internal gauge ID for each pool.
func (s *KeeperTestHelper) PrepareAllSupportedPools() SupportedPoolAndGaugeInfo {
return s.PrepareAllSupportedPoolsCustomProject(osmosisRepository, osmosisRepoTransmuterPath)
}

// PrepareAllSupportedPoolsCustomProject creates all supported pools and returns their IDs.
// Additionally, attaches an internal gauge ID for each pool.
// Allows the flexibility of being used from outside the Osmosis repository by providing custom project name and transmuter bytecode path.
func (s *KeeperTestHelper) PrepareAllSupportedPoolsCustomProject(projectName, transmuterPath string) SupportedPoolAndGaugeInfo {
// This is the ID of the first gauge created next (concentrated).
nextGaugeID := s.App.IncentivesKeeper.GetLastGaugeID(s.Ctx) + 1

Expand All @@ -156,7 +163,7 @@ func (s *KeeperTestHelper) PrepareAllSupportedPools() SupportedPoolAndGaugeInfo
concentratedPoolID = concentratedPool.GetId()
balancerPoolID = s.PrepareBalancerPool()
stableswapPoolID = s.PrepareBasicStableswapPool()
cosmWasmPool = s.PrepareCosmWasmPool()
cosmWasmPool = s.PrepareCustomTransmuterPoolCustomProject(s.TestAccs[0], []string{DefaultTransmuterDenomA, DefaultTransmuterDenomB}, projectName, transmuterPath)
cosmWasmPoolID = cosmWasmPool.GetId()
)
return SupportedPoolAndGaugeInfo{
Expand Down
2 changes: 1 addition & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,9 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appKeepers.BankKeeper,
appKeepers.keys[txfeestypes.StoreKey],
appKeepers.PoolManagerKeeper,
appKeepers.GAMMKeeper,
appKeepers.ProtoRevKeeper,
appKeepers.DistrKeeper,
appKeepers.ConsensusParamsKeeper,
dataDir,
)
appKeepers.TxFeesKeeper = &txFeesKeeper
Expand Down
2 changes: 2 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
"github.com/cosmos/cosmos-sdk/x/consensus"
consensusparamtypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
icq "github.com/cosmos/ibc-apps/modules/async-icq/v7"
Expand Down Expand Up @@ -161,6 +162,7 @@ func appModules(
ibc.NewAppModule(app.IBCKeeper),
ica.NewAppModule(nil, app.ICAHostKeeper),
params.NewAppModule(*app.ParamsKeeper),
consensus.NewAppModule(appCodec, *app.AppKeepers.ConsensusParamsKeeper),
app.RawIcs20TransferAppModule,
gamm.NewAppModule(appCodec, *app.GAMMKeeper, app.AccountKeeper, app.BankKeeper),
poolmanager.NewAppModule(*app.PoolManagerKeeper, app.GAMMKeeper),
Expand Down
9 changes: 9 additions & 0 deletions app/upgrades/v22/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

tmtypes "github.com/cometbft/cometbft/types"

"github.com/osmosis-labs/osmosis/v21/app/keepers"
"github.com/osmosis-labs/osmosis/v21/app/upgrades"
)
Expand All @@ -23,6 +25,13 @@ func CreateUpgradeHandler(
return nil, err
}

// Properly register consensus params. In the process, change params as per:
// https://www.mintscan.io/osmosis/proposals/705
defaultConsensusParams := tmtypes.DefaultConsensusParams().ToProto()
defaultConsensusParams.Block.MaxBytes = 5000000 // previously 10485760
defaultConsensusParams.Block.MaxGas = 300000000 // previously 120000000
keepers.ConsensusParamsKeeper.Set(ctx, &defaultConsensusParams)

// Increase the tx size cost per byte to 20 to reduce the exploitability of bandwidth amplification problems.
accountParams := keepers.AccountKeeper.GetParams(ctx)
accountParams.TxSizeCostPerByte = 20 // Double from the default value of 10
Expand Down
43 changes: 0 additions & 43 deletions cmd/osmosisd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,49 +559,6 @@ is-enabled = "false"
db-host = "{{ .SidecarQueryServerConfig.StorageHost }}"
db-port = "{{ .SidecarQueryServerConfig.StoragePort }}"
# Defines the web server configuration.
server-address = "{{ .SidecarQueryServerConfig.ServerAddress }}"
timeout-duration-secs = "{{ .SidecarQueryServerConfig.ServerTimeoutDurationSecs }}"
# Defines the logger configuration.
logger-filename = "{{ .SidecarQueryServerConfig.LoggerFilename }}"
logger-is-production = "{{ .SidecarQueryServerConfig.LoggerIsProduction }}"
logger-level = "{{ .SidecarQueryServerConfig.LoggerLevel }}"
# Defines the gRPC gateway endpoint of the chain.
grpc-gateway-endpoint = "{{ .SidecarQueryServerConfig.ChainGRPCGatewayEndpoint }}"
# The list of preferred poold IDs in the router.
# These pools will be prioritized in the candidate route selection, ignoring all other
# heuristics such as TVL.
preferred-pool-ids = "{{ .SidecarQueryServerConfig.Router.PreferredPoolIDs }}"
# The maximum number of pools to be included in a single route.
max-pools-per-route = "{{ .SidecarQueryServerConfig.Router.MaxPoolsPerRoute }}"
# The maximum number of routes to be returned in candidate route search.
max-routes = "{{ .SidecarQueryServerConfig.Router.MaxRoutes }}"
# The maximum number of routes to be split across. Must be smaller than or
# equal to max-routes.
max-split-routes = "{{ .SidecarQueryServerConfig.Router.MaxSplitRoutes }}"
# The maximum number of iterations to split a route across.
max-split-iterations = "{{ .SidecarQueryServerConfig.Router.MaxSplitIterations }}"
# The minimum liquidity of a pool to be included in a route.
min-osmo-liquidity = "{{ .SidecarQueryServerConfig.Router.MinOSMOLiquidity }}"
# The height interval at which the candidate routes are recomputed and updated in
# Redis
route-update-height-interval = "{{ .SidecarQueryServerConfig.Router.RouteUpdateHeightInterval }}"
# Whether to enable candidate route caching in Redis.
route-cache-enabled = "{{ .SidecarQueryServerConfig.Router.RouteCacheEnabled }}"
# The number of seconds to cache routes for before expiry.
route-cache-expiry-seconds = "{{ .SidecarQueryServerConfig.Router.RouteCacheExpirySeconds }}"
###############################################################################
### Wasm Configuration ###
###############################################################################
Expand Down
Loading

0 comments on commit 424c6f5

Please sign in to comment.