Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into lint-all-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Aug 6, 2023
2 parents e9dbf9c + 962220f commit 7aa9f0c
Show file tree
Hide file tree
Showing 33 changed files with 1,175 additions and 150 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#5883](https://github.com/osmosis-labs/osmosis/pull/5883) feat: Uninitialize empty ticks
* [#5874](https://github.com/osmosis-labs/osmosis/pull/5874) Remove Partial Migration from superfluid migration to CL
* [#5901](https://github.com/osmosis-labs/osmosis/pull/5901) Adding support for CW pools in ProtoRev
* [#5937](https://github.com/osmosis-labs/osmosis/pull/5937) feat: add SetScalingFactorController gov prop

### BugFix

* [#5831](https://github.com/osmosis-labs/osmosis/pull/5831) Fix superfluid_delegations query
* [#5835](https://github.com/osmosis-labs/osmosis/pull/5835) Fix println's for "amountZeroInRemainingBigDec before fee" making it into production
* [#5841] (https://github.com/osmosis-labs/osmosis/pull/5841) Fix protorev's out of gas erroring of the user's transcation.
* [#5930] (https://github.com/osmosis-labs/osmosis/pull/5930) Updating Protorev Binary Search Range Logic with CL Pools

### Misc Improvements

Expand All @@ -70,6 +72,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#5923] (https://github.com/osmosis-labs/osmosis/pull/5923) CL: Lower gas for initializing ticks
* [#5927] (https://github.com/osmosis-labs/osmosis/pull/5927) Add gas metering to x/tokenfactory trackBeforeSend hook
* [#5890](https://github.com/osmosis-labs/osmosis/pull/5890) feat: CreateCLPool & LinkCFMMtoCL pool into one gov-prop
* [#5964](https://github.com/osmosis-labs/osmosis/pull/5964) fix e2e test concurrency bugs

### Minor improvements & Bug Fixes

Expand Down
10 changes: 8 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,13 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
protorevKeeper := protorevkeeper.NewKeeper(
appCodec, appKeepers.keys[protorevtypes.StoreKey],
appKeepers.GetSubspace(protorevtypes.ModuleName),
appKeepers.AccountKeeper, appKeepers.BankKeeper, appKeepers.GAMMKeeper, appKeepers.EpochsKeeper, appKeepers.PoolManagerKeeper)
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.GAMMKeeper,
appKeepers.EpochsKeeper,
appKeepers.PoolManagerKeeper,
appKeepers.ConcentratedLiquidityKeeper,
)
appKeepers.ProtoRevKeeper = &protorevKeeper

txFeesKeeper := txfeeskeeper.NewKeeper(
Expand Down Expand Up @@ -493,7 +499,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
AddRoute(txfeestypes.RouterKey, txfees.NewUpdateFeeTokenProposalHandler(*appKeepers.TxFeesKeeper)).
AddRoute(superfluidtypes.RouterKey, superfluid.NewSuperfluidProposalHandler(*appKeepers.SuperfluidKeeper, *appKeepers.EpochsKeeper, *appKeepers.GAMMKeeper)).
AddRoute(protorevtypes.RouterKey, protorev.NewProtoRevProposalHandler(*appKeepers.ProtoRevKeeper)).
AddRoute(gammtypes.RouterKey, gamm.NewMigrationRecordHandler(*appKeepers.GAMMKeeper)).
AddRoute(gammtypes.RouterKey, gamm.NewGammProposalHandler(*appKeepers.GAMMKeeper)).
AddRoute(concentratedliquiditytypes.RouterKey, concentratedliquidity.NewConcentratedLiquidityProposalHandler(*appKeepers.ConcentratedLiquidityKeeper)).
AddRoute(cosmwasmpooltypes.RouterKey, cosmwasmpool.NewCosmWasmPoolProposalHandler(*appKeepers.CosmwasmPoolKeeper))

Expand Down
1 change: 1 addition & 0 deletions app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var AppModuleBasics = []module.AppModuleBasic{
gammclient.ReplaceMigrationRecordsProposalHandler,
gammclient.UpdateMigrationRecordsProposalHandler,
gammclient.CreateCLPoolAndLinkToCFMMProposalHandler,
gammclient.SetScalingFactorControllerProposalHandler,
clclient.CreateConcentratedLiquidityPoolProposalHandler,
clclient.TickSpacingDecreaseProposalHandler,
cwpoolclient.UploadCodeIdAndWhitelistProposalHandler,
Expand Down
16 changes: 15 additions & 1 deletion proto/osmosis/gamm/v1beta1/gov.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ message UpdateMigrationRecordsProposal {
repeated BalancerToConcentratedPoolLink records = 3
[ (gogoproto.nullable) = false ];
}

message PoolRecordWithCFMMLink {
option (gogoproto.equal) = true;

Expand Down Expand Up @@ -96,4 +95,19 @@ message CreateConcentratedLiquidityPoolsAndLinktoCFMMProposal {
(gogoproto.moretags) = "yaml:\"create_cl_pool_and_link_to_cfmm\"",
(gogoproto.nullable) = false
];
}

// SetScalingFactorControllerProposal is a gov Content type for updating the
// scaling factor controller address of a stableswap pool
message SetScalingFactorControllerProposal {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (amino.name) = "osmosis/SetScalingFactorControllerProposal";
option (cosmos_proto.implements_interface) = "cosmos.gov.v1beta1.Content";

string title = 1;
string description = 2;
uint64 pool_id = 3;
string controller_address = 4;
}
76 changes: 52 additions & 24 deletions tests/e2e/configurer/chain/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,63 @@ func NewNodeConfig(t *testing.T, initNode *initialization.Node, initConfig *init
// The node configuration must be already added to the chain config prior to calling this
// method.
func (n *NodeConfig) Run() error {
n.t.Logf("starting node container: %s", n.Name)
resource, err := n.containerManager.RunNodeResource(n.chainId, n.Name, n.ConfigDir)
if err != nil {
return err
}
maxRetries := 3
currentRetry := 0

for currentRetry < maxRetries {
n.t.Logf("starting node container: %s", n.Name)
resource, err := n.containerManager.RunNodeResource(n.chainId, n.Name, n.ConfigDir)
if err != nil {
return err
}

hostPort := resource.GetHostPort("26657/tcp")
rpcClient, err := rpchttp.New("tcp://"+hostPort, "/websocket")
if err != nil {
return err
}
hostPort := resource.GetHostPort("26657/tcp")
rpcClient, err := rpchttp.New("tcp://"+hostPort, "/websocket")
if err != nil {
return err
}

n.rpcClient = rpcClient
n.rpcClient = rpcClient

success := false
timeout := time.After(time.Second * 20)
ticker := time.NewTicker(10 * time.Millisecond)
defer ticker.Stop()

for {
select {
case <-timeout:
n.t.Logf("Osmosis node failed to produce blocks")
break
case <-ticker.C:
_, err := n.QueryCurrentHeight()
if err == nil {
n.t.Logf("started node container: %s", n.Name)
success = true
break
}
}

if success {
break
}
}

require.Eventually(
n.t,
func() bool {
// This fails if unsuccessful.
_, err := n.QueryCurrentHeight()
if success {
break
} else {
n.t.Logf("failed to start node container, retrying... (%d/%d)", currentRetry+1, maxRetries)
err := n.containerManager.RemoveNodeResource(n.Name)
if err != nil {
return false
return err
}
n.t.Logf("started node container: %s", n.Name)
return true
},
time.Minute,
10*time.Millisecond,
"Osmosis node failed to produce blocks",
)
currentRetry++
}
}

if currentRetry >= maxRetries {
return fmt.Errorf("failed to start node container after %d retries", maxRetries)
}

if err := n.extractOperatorAddressIfValidator(); err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"regexp"
"strconv"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -49,6 +50,7 @@ type Manager struct {
pool *dockertest.Pool
network *dockertest.Network
resources map[string]*dockertest.Resource
resourcesMutex sync.RWMutex
isDebugLogEnabled bool
}

Expand Down Expand Up @@ -297,7 +299,9 @@ func (m *Manager) RunNodeResource(chainId string, containerName, valCondifDir st
return nil, err
}

m.resourcesMutex.Lock()
m.resources[containerName] = resource
m.resourcesMutex.Unlock()

return resource, nil
}
Expand Down
Binary file modified tests/ibc-hooks/bytecode/swaprouter.wasm
Binary file not shown.
9 changes: 9 additions & 0 deletions x/concentrated-liquidity/position_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,15 @@ func (s *KeeperTestSuite) TestMultipleRanges() {
},
rangeTestParams: DefaultRangeTestParams,
},
"two adjacent ranges (flipped order)": {
// Note: this setup covers both edge cases where initial interval accumulation is negative
// for spread rewards and incentives
tickRanges: [][]int64{
{10000, 20000},
{-10000, 10000},
},
rangeTestParams: DefaultRangeTestParams,
},
"two adjacent ranges with current tick smaller than both": {
tickRanges: [][]int64{
{-10000, 10000},
Expand Down
3 changes: 2 additions & 1 deletion x/gamm/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const (
// Will be parsed to []string.
FlagSwapRouteDenoms = "swap-route-denoms"
// FlagScalingFactors represents the flag name for the scaling factors.
FlagScalingFactors = "scaling-factors"
FlagScalingFactors = "scaling-factors"
FlagScalingFactorControllerAddress = "scaling-factor-controller-address"

FlagMigrationRecords = "migration-records"

Expand Down
123 changes: 123 additions & 0 deletions x/gamm/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package cli

import (
"encoding/json"
"errors"
"fmt"
"os"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -346,6 +348,78 @@ func NewCmdSubmitCreateCLPoolAndLinkToCFMMProposal() *cobra.Command {
return cmd
}

// NewCmdSubmitSetScalingFactorControllerProposal implements a command handler for the set scaling factor controller proposal
func NewCmdSubmitSetScalingFactorControllerProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "set-scaling-factor-controller-proposal [flags]",
Args: cobra.ExactArgs(0),
Short: "Submit a set scaling factor controller proposal",
Long: strings.TrimSpace(`Submit a set scaling factor controller proposal.
Sample proposal file:
{
"title": "Set Scaling Factor Controller Proposal",
"description": "Change scaling factor controller address from osmoXXX to osmoYYY"
"pool-id": 1,
"controller-address": "osmoYYY"
}
>>> osmosisd tx gov submit-proposal set-scaling-factor-controller-proposal \
--proposal proposal.json \
--deposit 1600000000uosmo \
Sample proposal with flags
>>> osmosisd tx gov submit-proposal set-scaling-factor-controller-proposal \
--title "Set Scaling Factor Controller Proposal" \
--description "Change scaling factor controller address from osmoXXX to osmoYYY"
--deposit 1600000000uosmo
--pool-id 1
--controller-address osmoYYY
`),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
content, err := parseSetScalingFactorControllerArgsToContent(cmd)
if err != nil {
return err
}

from := clientCtx.GetFromAddress()

depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(depositStr)
if err != nil {
return err
}

msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}

if err = msg.ValidateBasic(); err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

cmd.Flags().String(govcli.FlagTitle, "", "title of proposal")
cmd.Flags().String(govcli.FlagDescription, "", "description of proposal")
cmd.Flags().String(govcli.FlagDeposit, "", "deposit of proposal")
cmd.Flags().Uint64(FlagPoolId, 0, "stableswap pool-id")
cmd.Flags().String(FlagScalingFactorControllerAddress, "", "target scaling factor controller address")
cmd.Flags().Bool(govcli.FlagIsExpedited, false, "If true, makes the proposal an expedited one")
cmd.Flags().String(govcli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)")

return cmd
}

func BuildCreatePoolCmd(clientCtx client.Context, args []string, fs *flag.FlagSet) (sdk.Msg, error) {
poolType, err := fs.GetString(FlagPoolType)
if err != nil {
Expand Down Expand Up @@ -846,3 +920,52 @@ func parsePoolRecordsWithCFMMLink(cmd *cobra.Command) ([]types.PoolRecordWithCFM

return finalPoolRecords, nil
}

func parseSetScalingFactorControllerArgsToContent(cmd *cobra.Command) (govtypes.Content, error) {
proposalFile, err := cmd.Flags().GetString(govcli.FlagProposal)
if err != nil {
return nil, err
}

if proposalFile != "" {
contents, err := os.ReadFile(proposalFile)
if err != nil {
return nil, err
}

var proposal types.SetScalingFactorControllerProposal
if err := json.Unmarshal(contents, &proposal); err != nil {
return nil, err
}
return &proposal, nil
}

title, err := cmd.Flags().GetString(govcli.FlagTitle)
if err != nil {
return nil, err
}

description, err := cmd.Flags().GetString(govcli.FlagDescription)
if err != nil {
return nil, err
}

poolId, err := cmd.Flags().GetUint64(FlagPoolId)
if err != nil {
return nil, err
}

controllerAddress, err := cmd.Flags().GetString(FlagScalingFactorControllerAddress)
if err != nil {
return nil, err
}

content := &types.SetScalingFactorControllerProposal{
Title: title,
Description: description,
PoolId: poolId,
ControllerAddress: controllerAddress,
}

return content, nil
}
7 changes: 4 additions & 3 deletions x/gamm/client/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
)

var (
ReplaceMigrationRecordsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitReplaceMigrationRecordsProposal, rest.ProposalReplaceMigrationRecordsRESTHandler)
UpdateMigrationRecordsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdateMigrationRecordsProposal, rest.ProposalUpdateMigrationRecordsRESTHandler)
CreateCLPoolAndLinkToCFMMProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitCreateCLPoolAndLinkToCFMMProposal, rest.ProposalCreateConcentratedLiquidityPoolAndLinkToCFMMHandler)
ReplaceMigrationRecordsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitReplaceMigrationRecordsProposal, rest.ProposalReplaceMigrationRecordsRESTHandler)
UpdateMigrationRecordsProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitUpdateMigrationRecordsProposal, rest.ProposalUpdateMigrationRecordsRESTHandler)
CreateCLPoolAndLinkToCFMMProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitCreateCLPoolAndLinkToCFMMProposal, rest.ProposalCreateConcentratedLiquidityPoolAndLinkToCFMMHandler)
SetScalingFactorControllerProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitSetScalingFactorControllerProposal, rest.ProposalSetScalingFactorController)
)
7 changes: 7 additions & 0 deletions x/gamm/client/rest/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ func ProposalCreateConcentratedLiquidityPoolAndLinkToCFMMHandler(clientCtx clien
}
}

func ProposalSetScalingFactorController(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "set-scaling-factor-controller",
Handler: emptyHandler(clientCtx),
}
}

func emptyHandler(clientCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
}
Expand Down
Loading

0 comments on commit 7aa9f0c

Please sign in to comment.