Skip to content

Commit

Permalink
Merge branch 'main' into kirill/1171-add-gauge-fee
Browse files Browse the repository at this point in the history
  • Loading branch information
keruch committed Sep 10, 2024
2 parents 21117b4 + 7326f78 commit 6b03791
Show file tree
Hide file tree
Showing 43 changed files with 777 additions and 198 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN go install github.com/go-delve/delve/cmd/dlv@latest
RUN make build-debug

# Use a small base image
FROM alpine:3.16.1
FROM alpine:3.17

# Install runtime dependencies
RUN apk add curl jq bash vim
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/decred/dcrd/dcrec/edwards v1.0.0
github.com/dustin/go-humanize v1.0.1
github.com/dymensionxyz/gerr-cosmos v1.0.0
github.com/dymensionxyz/sdk-utils v0.2.8-0.20240823083607-ea6d7a482d69
github.com/dymensionxyz/sdk-utils v0.2.8
github.com/ethereum/go-ethereum v1.10.26
github.com/evmos/ethermint v0.22.0
github.com/gogo/protobuf v1.3.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212-
github.com/dymensionxyz/osmosis/osmomath v0.0.6-dymension-v0.1.0.20240820121212-c0e21fa21e43/go.mod h1:SdGCL9CZb14twRAJUSzb7bRE0OoopRpF2Hnd1UhJpFU=
github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20240820121212-c0e21fa21e43 h1:ugbpHwwlckB4W/aNXUTEsxaakPFgXi+LAsCtvfJ200Q=
github.com/dymensionxyz/osmosis/v15 v15.2.1-0.20240820121212-c0e21fa21e43/go.mod h1:2rsnXAdjYfXtyEw0mNwAdOiAccALYjAPvINGUf9Qg7Y=
github.com/dymensionxyz/sdk-utils v0.2.8-0.20240823083607-ea6d7a482d69 h1:gecl8M1LJpyfInzTfFFlD48u419jBm0BKNHf/b6ZElc=
github.com/dymensionxyz/sdk-utils v0.2.8-0.20240823083607-ea6d7a482d69/go.mod h1:it9owYOpnIe17+ftTATQNDN4z+mBQx20/2Jm8SK15Rk=
github.com/dymensionxyz/sdk-utils v0.2.8 h1:ZX5NSLd0DyGVUqucHnyI14zkeYaD7hVn7v44MQOYFUU=
github.com/dymensionxyz/sdk-utils v0.2.8/go.mod h1:it9owYOpnIe17+ftTATQNDN4z+mBQx20/2Jm8SK15Rk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
Expand Down
3 changes: 2 additions & 1 deletion ibctesting/eibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/dymensionxyz/sdk-utils/utils/uevent"
"github.com/stretchr/testify/suite"

"github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
Expand Down Expand Up @@ -419,7 +420,7 @@ func (s *eibcSuite) TestTimeoutEIBCDemandOrderFulfillment() {
// 4. Finalize the rollapp state and validate the demand order fulfiller balance is updated with the amount.

// return an err ack
ack := channeltypes.NewErrorAcknowledgement(errors.New("foobar"))
ack := uevent.NewErrorAcknowledgement(s.hubCtx(), errors.New("foobar"))
err := rollappEndpoint.WriteAcknowledgement(ack, packet)
s.Require().NoError(err)
err = hubEndpoint.AcknowledgePacket(packet, ack.Acknowledgement())
Expand Down
19 changes: 10 additions & 9 deletions ibctesting/genesis_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ import (
"testing"

"cosmossdk.io/math"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
"github.com/dymensionxyz/dymension/v3/x/rollapp/transfergenesis"
rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dymensionxyz/dymension/v3/app/apptesting"
"github.com/stretchr/testify/suite"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
"github.com/stretchr/testify/suite"

"github.com/dymensionxyz/sdk-utils/utils/uevent"

"github.com/dymensionxyz/dymension/v3/app/apptesting"
"github.com/dymensionxyz/dymension/v3/x/rollapp/transfergenesis"
rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
)

type transferGenesisSuite struct {
Expand Down Expand Up @@ -110,7 +111,7 @@ func (s *transferGenesisSuite) TestCannotDoGenesisTransferAfterBridgeEnabled() {

if i == 2 {

expect := channeltypes.NewErrorAcknowledgement(transfergenesis.ErrDisabled)
expect := uevent.NewErrorAcknowledgement(s.hubCtx(), transfergenesis.ErrDisabled)
bz, _ := s.hubApp().IBCKeeper.ChannelKeeper.GetPacketAcknowledgement(s.hubCtx(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence())
s.Require().Equal(channeltypes.CommitAcknowledgement(expect.Acknowledgement()), bz)
}
Expand Down
12 changes: 11 additions & 1 deletion proto/dymensionxyz/dymension/lightclient/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package dymensionxyz.dymension.lightclient;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/dymensionxyz/dymension/v3/x/lightclient/types";

message QueryGetLightClientRequest {
option (gogoproto.equal) = false;
option (gogoproto.equal) = false;
string rollapp_id = 1;
}
message QueryGetLightClientResponse {
Expand All @@ -20,5 +21,14 @@ service Query {
rpc LightClient(QueryGetLightClientRequest) returns (QueryGetLightClientResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/lightclient/lightclient/{rollapp_id}";
}
rpc ExpectedClientState(QueryExpectedClientStateRequest) returns (QueryExpectedClientStateResponse) {
option (google.api.http).get = "/dymensionxyz/dymension/lightclient/expectedclientstate";
}
}

message QueryExpectedClientStateRequest {}

message QueryExpectedClientStateResponse {
// client state
google.protobuf.Any client_state = 2 [(gogoproto.moretags) = "yaml:\"client_state\""];
}
16 changes: 11 additions & 5 deletions proto/dymensionxyz/dymension/sponsorship/sponsorship.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ option go_package = "github.com/dymensionxyz/dymension/v3/x/sponsorship/types";
// Params is a module parameters.
message Params {
// MinAllocationWeight is a minimum portion of the user's voting power that
// one can allocate to a single gauge. The value must fall between 0 and 100,
// inclusively. For example, if this parameter is 20%, then the min allocation
// is 20%, and consequently, the user can vote on a max of 5 gauges (100 / 20
// = 5).
// one can allocate to a single gauge. The value is measured in percentages
// and must fall between 1 and 100 * 10^18, inclusive. The base unit is 10^-18%,
// so
// * 1 --> 10^-18%
// * 10^18 --> 1%
// * 100 * 10^18 --> 100%.
//
// Example! If this parameter is 20 * 10^18, which implies 20%, then the min
// allocation is 20%, and consequently, one can vote on a max of 5 gauges:
// 100 / 20 = 5.
string min_allocation_weight = 1 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
// MinVotingPower is a minimum voting power a user must have in order to be
// able to vote.
// able to vote. Denominated in aDYM.
string min_voting_power = 2 [
(gogoproto.nullable) = false,
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
Expand Down
3 changes: 2 additions & 1 deletion x/bridgingfee/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/dymensionxyz/sdk-utils/utils/uevent"

commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
delayedackkeeper "github.com/dymensionxyz/dymension/v3/x/delayedack/keeper"
Expand Down Expand Up @@ -72,7 +73,7 @@ func (w *IBCModule) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, re
if err != nil {
l.Error("Get valid transfer.", "err", err)
err = errorsmod.Wrapf(err, "%s: get valid transfer", ModuleName)
return channeltypes.NewErrorAcknowledgement(err)
return uevent.NewErrorAcknowledgement(ctx, err)
}

if !transfer.IsRollapp() {
Expand Down
42 changes: 24 additions & 18 deletions x/delayedack/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package cli

import (
"context"
"fmt"
"strings"

// "strings"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"

commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
"github.com/dymensionxyz/dymension/v3/x/delayedack/types"
Expand Down Expand Up @@ -41,11 +37,13 @@ func CmdQueryParams() *cobra.Command {
Short: "shows the parameters of the module",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}
Expand All @@ -70,10 +68,6 @@ func CmdGetPacketsByRollapp() *cobra.Command {
packets rollapp1 PENDING RECV`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)

rollappId := args[0]

req := &types.QueryRollappPacketsRequest{
Expand Down Expand Up @@ -105,6 +99,12 @@ func CmdGetPacketsByRollapp() *cobra.Command {
req.Type = commontypes.RollappPacket_Type(dtype)
}

clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.GetPackets(cmd.Context(), req)
if err != nil {
return err
Expand All @@ -129,9 +129,6 @@ func CmdGetPacketsByStatus() *cobra.Command {
packets-by-status finalized recv`,
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
queryClient := types.NewQueryClient(clientCtx)

statusStr := strings.ToUpper(args[0])
status, ok := commontypes.Status_value[statusStr]
if !ok {
Expand All @@ -155,6 +152,12 @@ func CmdGetPacketsByStatus() *cobra.Command {
req.Type = commontypes.RollappPacket_Type(dtype)
}

clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.GetPackets(cmd.Context(), req)
if err != nil {
return err
Expand All @@ -179,9 +182,6 @@ func CmdGetPacketsByType() *cobra.Command {
packets-by-type on_timeout`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)
queryClient := types.NewQueryClient(clientCtx)

typeStr := strings.ToUpper(args[0])

if !strings.HasPrefix(typeStr, "ON_") {
Expand All @@ -198,6 +198,12 @@ func CmdGetPacketsByType() *cobra.Command {
Status: commontypes.Status_PENDING, // get pending packets by default
}

clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.GetPackets(cmd.Context(), req)
if err != nil {
return err
Expand Down
6 changes: 4 additions & 2 deletions x/delayedack/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"

"github.com/dymensionxyz/sdk-utils/utils/uevent"

commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
"github.com/dymensionxyz/dymension/v3/x/delayedack/keeper"
"github.com/dymensionxyz/dymension/v3/x/delayedack/types"
Expand Down Expand Up @@ -89,7 +91,7 @@ func (w IBCMiddleware) OnRecvPacket(
transfer, err := w.GetValidTransferWithFinalizationInfo(ctx, packet, commontypes.RollappPacket_ON_RECV)
if err != nil {
l.Error("Get valid rollapp and transfer.", "err", err)
return channeltypes.NewErrorAcknowledgement(errorsmod.Wrap(err, "delayed ack: get valid transfer with finalization info"))
return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "delayed ack: get valid transfer with finalization info"))
}

if !transfer.IsRollapp() || transfer.Finalized {
Expand All @@ -100,7 +102,7 @@ func (w IBCMiddleware) OnRecvPacket(

err = w.EIBCDemandOrderHandler(ctx, rollappPacket, transfer.FungibleTokenPacketData)
if err != nil {
return channeltypes.NewErrorAcknowledgement(errorsmod.Wrap(err, "delayed ack"))
return uevent.NewErrorAcknowledgement(ctx, errorsmod.Wrap(err, "delayed ack"))
}

return nil
Expand Down
12 changes: 7 additions & 5 deletions x/denommetadata/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
"github.com/dymensionxyz/gerr-cosmos/gerrc"

"github.com/dymensionxyz/sdk-utils/utils/uevent"
"github.com/dymensionxyz/sdk-utils/utils/uibc"

commontypes "github.com/dymensionxyz/dymension/v3/x/common/types"
Expand Down Expand Up @@ -57,7 +59,7 @@ func (im IBCModule) OnRecvPacket(

transferData, err := im.rollappKeeper.GetValidTransfer(ctx, packet.Data, packet.DestinationPort, packet.DestinationChannel)
if err != nil {
return channeltypes.NewErrorAcknowledgement(err)
return uevent.NewErrorAcknowledgement(ctx, err)
}

rollapp, packetData := transferData.Rollapp, transferData.FungibleTokenPacketData
Expand All @@ -76,16 +78,16 @@ func (im IBCModule) OnRecvPacket(
}

if err = dm.Validate(); err != nil {
return channeltypes.NewErrorAcknowledgement(err)
return uevent.NewErrorAcknowledgement(ctx, err)
}

if dm.Base != packetData.Denom {
return channeltypes.NewErrorAcknowledgement(gerrc.ErrInvalidArgument)
return uevent.NewErrorAcknowledgement(ctx, gerrc.ErrInvalidArgument)
}

// if denom metadata was found in the memo, it means we should have the rollapp record
if rollapp == nil {
return channeltypes.NewErrorAcknowledgement(gerrc.ErrNotFound)
return uevent.NewErrorAcknowledgement(ctx, gerrc.ErrNotFound)
}

dm.Base = ibcDenom
Expand All @@ -95,7 +97,7 @@ func (im IBCModule) OnRecvPacket(
if errorsmod.IsOf(err, gerrc.ErrAlreadyExists) {
return im.IBCModule.OnRecvPacket(ctx, packet, relayer)
}
return channeltypes.NewErrorAcknowledgement(err)
return uevent.NewErrorAcknowledgement(ctx, err)
}

return im.IBCModule.OnRecvPacket(ctx, packet, relayer)
Expand Down
8 changes: 6 additions & 2 deletions x/dymns/client/cli/query_alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
dymnsutils "github.com/dymensionxyz/dymension/v3/x/dymns/utils"
"github.com/spf13/cobra"

dymnsutils "github.com/dymensionxyz/dymension/v3/x/dymns/utils"

dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types"
)

Expand All @@ -26,7 +27,10 @@ func CmdQueryAlias() *cobra.Command {
return fmt.Errorf("input is not a valid alias: %s", alias)
}

clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := dymnstypes.NewQueryClient(clientCtx)

res, err := queryClient.Alias(cmd.Context(), &dymnstypes.QueryAliasRequest{
Expand Down
8 changes: 6 additions & 2 deletions x/dymns/client/cli/query_buy_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
dymnsutils "github.com/dymensionxyz/dymension/v3/x/dymns/utils"
"github.com/spf13/cobra"

dymnsutils "github.com/dymensionxyz/dymension/v3/x/dymns/utils"

dymnstypes "github.com/dymensionxyz/dymension/v3/x/dymns/types"
)

Expand Down Expand Up @@ -58,7 +59,10 @@ func CmdQueryBuyOrder() *cobra.Command {

var offers []dymnstypes.BuyOrder

clientCtx := client.GetClientContextFromCmd(cmd)
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := dymnstypes.NewQueryClient(clientCtx)
queryCtx := cmd.Context()

Expand Down
Loading

0 comments on commit 6b03791

Please sign in to comment.