Skip to content

Commit

Permalink
Feat/add update params (#197)
Browse files Browse the repository at this point in the history
* bring changes from #193

* add MsgUpdateParams to x/feeabs

* add test for param.String()

* add keeper test

* update params

* fix and add custom fee test

* fix failing test due to adjust Default Params

* linting
  • Loading branch information
tuantran1702 authored May 29, 2024
1 parent 9dacec5 commit 11340fb
Show file tree
Hide file tree
Showing 38 changed files with 3,136 additions and 1,024 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ func NewFeeApp(
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
scopedFeeabsKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

// register the proposal types
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ require (
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.1.2 // indirect
Expand Down Expand Up @@ -352,7 +352,4 @@ replace (
// following versions might cause unexpected behavior
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7

// latest grpc doesn't work with our modified proto compiler, so we need to enforce
// the following version across all dependencies.
google.golang.org/grpc => google.golang.org/grpc v1.54.0
)
341 changes: 72 additions & 269 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion proto/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

FROM bufbuild/buf:1.7.0 as BUILDER

FROM golang:1.19-alpine
FROM golang:1.21-alpine


RUN apk add --no-cache \
Expand Down
9 changes: 2 additions & 7 deletions proto/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ deps:
- remote: buf.build
owner: cosmos
repository: cosmos-sdk
commit: 954f7b05f38440fc8250134b15adec47
digest: shake256:2ab4404fd04a7d1d52df0e2d0f2d477a3d83ffd88d876957bf3fedfd702c8e52833d65b3ce1d89a3c5adf2aab512616b0e4f51d8463f07eda9a8a3317ee3ac54
commit: 5a6ab7bc14314acaa912d5e53aef1c2f
digest: shake256:02c00c73493720055f9b57553a35b5550023a3c1914123b247956288a78fb913aff70e66552777ae14d759467e119079d484af081264a5dd607a94d9fbc8116b
- remote: buf.build
owner: cosmos
repository: gogo-proto
commit: 34d970b699f84aa382f3c29773a60836
digest: shake256:3d3bee5229ba579e7d19ffe6e140986a228b48a8c7fe74348f308537ab95e9135210e81812489d42cd8941d33ff71f11583174ccc5972e86e6112924b6ce9f04
- remote: buf.build
owner: cosmos
repository: ics23
commit: 55085f7c710a45f58fa09947208eb70b
digest: shake256:9bf0bc495b5a11c88d163d39ef521bc4b00bc1374a05758c91d82821bdc61f09e8c2c51dda8452529bf80137f34d852561eacbe9550a59015d51cecb0dacb628
- remote: buf.build
owner: googleapis
repository: googleapis
Expand Down
3 changes: 1 addition & 2 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ deps:
- buf.build/cosmos/cosmos-proto:1935555c206d4afb9e94615dfd0fad31
- buf.build/cosmos/gogo-proto:a14993478f40695898ed8a86931094b6656e8a5d
- buf.build/googleapis/googleapis:8d7204855ec14631a499bd7393ce1970
- buf.build/cosmos/ics23:b1abd8678aab07165efd453c96796a179eb3131f
breaking:
use:
- FILE
Expand All @@ -20,4 +19,4 @@ lint:
- SERVICE_SUFFIX
- PACKAGE_VERSION_SUFFIX
- RPC_REQUEST_STANDARD_NAME
- PACKAGE_DIRECTORY_MATCH
- PACKAGE_DIRECTORY_MATCH
28 changes: 27 additions & 1 deletion proto/feeabstraction/feeabs/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ package feeabstraction.feeabs.v1beta1;
import "gogoproto/gogo.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "feeabstraction/feeabs/v1beta1/params.proto";
import "amino/amino.proto";

option go_package = "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/types";

Expand All @@ -15,6 +18,9 @@ service Msg {
rpc SwapCrossChain(MsgSwapCrossChain) returns (MsgSwapCrossChainResponse);
rpc FundFeeAbsModuleAccount(MsgFundFeeAbsModuleAccount)
returns (MsgFundFeeAbsModuleAccountResponse);

rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse) {
}
}

message MsgFundFeeAbsModuleAccount {
Expand All @@ -36,4 +42,24 @@ message MsgSwapCrossChain {
string from_address = 1;
string ibc_denom = 2;
}
message MsgSwapCrossChainResponse {}
message MsgSwapCrossChainResponse {}

// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
option (amino.name) = "cosmos-sdk/x/bank/MsgUpdateParams";

// params defines the x/bank parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {
}

15 changes: 8 additions & 7 deletions tests/interchaintest/feeabs/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ import (
"time"

"github.com/avast/retry-go/v4"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/testutil"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/types"
authTx "github.com/cosmos/cosmos-sdk/x/auth/tx"
paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
)

func getFullNode(c *cosmos.CosmosChain) *cosmos.ChainNode {
Expand Down Expand Up @@ -50,6 +49,7 @@ func CrossChainSwap(c *cosmos.CosmosChain, ctx context.Context, keyName string,
"feeabs", "swap", ibcDenom,
"--gas", "auto",
)

if err != nil {
return tx, fmt.Errorf("executing transaction failed: %w", err)
}
Expand All @@ -76,7 +76,7 @@ func CrossChainSwap(c *cosmos.CosmosChain, ctx context.Context, keyName string,
dstPort, _ = AttributeValue(txResp, evType, "packet_dst_port")
dstChan, _ = AttributeValue(txResp, evType, "packet_dst_channel")
timeoutHeight, _ = AttributeValue(txResp, evType, "packet_timeout_height")
timeoutTS, _ = AttributeValue(txResp, evType, "packet_timeout_timestamp")
timeoutTs, _ = AttributeValue(txResp, evType, "packet_timeout_timestamp")
data, _ = AttributeValue(txResp, evType, "packet_data")
)

Expand All @@ -93,9 +93,9 @@ func CrossChainSwap(c *cosmos.CosmosChain, ctx context.Context, keyName string,
}
tx.Packet.Sequence = uint64(seqNum)

timeoutNano, err := strconv.ParseUint(timeoutTS, 10, 64)
timeoutNano, err := strconv.ParseUint(timeoutTs, 10, 64)
if err != nil {
return tx, fmt.Errorf("invalid packet timestamp timeout %s: %w", timeoutTS, err)
return tx, fmt.Errorf("invalid packet timestamp timeout %s: %w", timeoutTs, err)
}
tx.Packet.TimeoutTimestamp = ibc.Nanoseconds(timeoutNano)

Expand Down Expand Up @@ -195,6 +195,7 @@ func ParamChangeProposal(c *cosmos.CosmosChain, ctx context.Context, keyName str
"param-change",
proposalPath,
"--gas", "auto",
"--gas-adjustment", "1.5", "--type", "param-change",
}

txHash, err := tn.ExecTx(ctx, keyName, command...)
Expand Down
21 changes: 21 additions & 0 deletions tests/interchaintest/feeabs/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package feeabs
import (
"context"
"encoding/json"
"fmt"
"time"

"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"

Expand Down Expand Up @@ -59,6 +61,7 @@ func QueryModuleAccountBalances(c *cosmos.CosmosChain, ctx context.Context) (*fe
return &response, nil
}

// QueryOsmosisArithmeticTwap queries the arithmetic twap of ibc denom stored in fee abstraction module
func QueryOsmosisArithmeticTwap(c *cosmos.CosmosChain, ctx context.Context, ibcDenom string) (*feeabstypes.QueryOsmosisArithmeticTwapResponse, error) {
node := getFullNode(c)
cmd := []string{"feeabs", "osmo-arithmetic-twap", ibcDenom}
Expand All @@ -73,3 +76,21 @@ func QueryOsmosisArithmeticTwap(c *cosmos.CosmosChain, ctx context.Context, ibcD
}
return &response, nil
}

// QueryOsmosisArithmeticTwapOsmosis queries the arithmetic twap of a pool on osmosis chain
func QueryOsmosisArithmeticTwapOsmosis(c *cosmos.CosmosChain, ctx context.Context, poolID, ibcDenom string) (*feeabstypes.QueryOsmosisArithmeticTwapResponse, error) {
node := getFullNode(c)
currentEpoch := time.Now().Unix()

cmd := []string{"twap", "arithmetic", poolID, ibcDenom, fmt.Sprintf("%d", currentEpoch-20), fmt.Sprintf("%d", currentEpoch-10)}
stdout, _, err := node.ExecQuery(ctx, cmd...)
if err != nil {
return &feeabstypes.QueryOsmosisArithmeticTwapResponse{}, err
}

var response feeabstypes.QueryOsmosisArithmeticTwapResponse
if err = json.Unmarshal(stdout, &response); err != nil {
return &feeabstypes.QueryOsmosisArithmeticTwapResponse{}, err
}
return &response, nil
}
2 changes: 1 addition & 1 deletion tests/interchaintest/feeabs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils"

feeabsCli "github.com/osmosis-labs/fee-abstraction/tests/interchaintest/feeabs"
feeabsCli "github.com/osmosis-labs/fee-abstraction/v8/tests/interchaintest/feeabs"
)

func TestFeeAbs(t *testing.T) {
Expand Down
Loading

0 comments on commit 11340fb

Please sign in to comment.