Skip to content

Commit

Permalink
chore(fix): Updated protos to suit v50 (#73)
Browse files Browse the repository at this point in the history
* initilize resetPoller to non-nil

* updated protos
  • Loading branch information
mtsitrin authored Mar 9, 2025
1 parent 4c3cf30 commit 8962789
Show file tree
Hide file tree
Showing 10 changed files with 1,296 additions and 233 deletions.
11 changes: 6 additions & 5 deletions eibc/lp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"
"time"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand All @@ -31,8 +32,8 @@ type rollappCriteria struct {
RollappID string
Denoms map[string]bool
MaxPrice sdk.Coins
MinFeePercentage sdk.Dec
OperatorFeeShare sdk.Dec
MinFeePercentage math.LegacyDec
OperatorFeeShare math.LegacyDec
SettlementValidated bool
spendLimit sdk.Coins // keep private to exclude from hash, as spendLimit decreases as orders are fulfilled
}
Expand Down Expand Up @@ -168,7 +169,7 @@ func (or *orderTracker) loadLPs(ctx context.Context) error {
continue
}
// check the operator fee is the minimum for what the operator wants
if rollapp.OperatorFeeShare.Dec.LT(or.minOperatorFeeShare) {
if rollapp.OperatorFeeShare.LT(or.minOperatorFeeShare) {
or.logger.Debug("operator fee share too low", zap.String("rollapp", rollapp.RollappId))
continue
}
Expand All @@ -182,8 +183,8 @@ func (or *orderTracker) loadLPs(ctx context.Context) error {
Denoms: denoms,
MaxPrice: rollapp.MaxPrice,
spendLimit: rollapp.SpendLimit,
MinFeePercentage: rollapp.MinFeePercentage.Dec,
OperatorFeeShare: rollapp.OperatorFeeShare.Dec,
MinFeePercentage: rollapp.MinFeePercentage,
OperatorFeeShare: rollapp.OperatorFeeShare,
SettlementValidated: rollapp.SettlementValidated,
}
if existLP {
Expand Down
6 changes: 4 additions & 2 deletions eibc/order_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"math/rand"
"time"

math "cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
"github.com/dymensionxyz/cosmosclient/cosmosclient"
Expand Down Expand Up @@ -44,7 +46,7 @@ func NewOrderClient(cfg config.Config, logger *zap.Logger) (*orderClient, error)
return nil, fmt.Errorf("failed to create full node clients: %w", err)
}

minOperatorFeeShare, err := sdk.NewDecFromStr(cfg.Operator.MinFeeShare)
minOperatorFeeShare, err := math.LegacyNewDecFromStr(cfg.Operator.MinFeeShare)
if err != nil {
return nil, fmt.Errorf("failed to parse min operator fee share: %w", err)
}
Expand All @@ -65,7 +67,7 @@ func NewOrderClient(cfg config.Config, logger *zap.Logger) (*orderClient, error)
processedCh,
cfg.OrderPolling.Interval, // we can use the same interval for order polling and LP balance checking
cfg.Validation.Interval,
nil, // set below
func() {},
logger,
),
logger: logger,
Expand Down
27 changes: 14 additions & 13 deletions eibc/order_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
"time"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/client"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -69,18 +70,18 @@ func TestOrderClient(t *testing.T) {
{
RollappId: "rollapp1",
Denoms: []string{"stake", "adym"},
MinFeePercentage: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.1")},
MinFeePercentage: math.LegacyMustNewDecFromStr("0.1"),
MaxPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(210)), sdk.NewCoin("adym", sdk.NewInt(150))),
OperatorFeeShare: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.1")},
OperatorFeeShare: math.LegacyMustNewDecFromStr("0.1"),
SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(210)), sdk.NewCoin("adym", sdk.NewInt(150))),
SettlementValidated: false,
}, {
RollappId: "rollapp2",
Denoms: []string{"stake", "adym"},
MinFeePercentage: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.1")},
MinFeePercentage: math.LegacyMustNewDecFromStr("0.1"),
MaxPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(210)), sdk.NewCoin("adym", sdk.NewInt(150))),
SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(210)), sdk.NewCoin("adym", sdk.NewInt(150))),
OperatorFeeShare: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.1")},
OperatorFeeShare: math.LegacyMustNewDecFromStr("0.1"),
}},
},
balance: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(201)), sdk.NewCoin("adym", sdk.NewInt(140))),
Expand All @@ -89,10 +90,10 @@ func TestOrderClient(t *testing.T) {
Rollapps: []*types.RollappCriteria{{
RollappId: "rollapp2",
Denoms: []string{"adym"},
MinFeePercentage: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.1")},
MinFeePercentage: math.LegacyMustNewDecFromStr("0.1"),
MaxPrice: sdk.NewCoins(sdk.NewCoin("adym", sdk.NewInt(450))),
SpendLimit: sdk.NewCoins(sdk.NewCoin("adym", sdk.NewInt(450))),
OperatorFeeShare: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.2")},
OperatorFeeShare: math.LegacyMustNewDecFromStr("0.2"),
SettlementValidated: true,
}},
},
Expand All @@ -102,10 +103,10 @@ func TestOrderClient(t *testing.T) {
Rollapps: []*types.RollappCriteria{{
RollappId: "rollapp1",
Denoms: []string{"stake"},
MinFeePercentage: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.1")},
MinFeePercentage: math.LegacyMustNewDecFromStr("0.1"),
MaxPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(450))),
SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(450))),
OperatorFeeShare: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.2")},
OperatorFeeShare: math.LegacyMustNewDecFromStr("0.2"),
SettlementValidated: false,
}},
},
Expand Down Expand Up @@ -258,7 +259,7 @@ func TestOrderClient(t *testing.T) {
getLPGrants,
fulfillOrdersFn,
lpBalances,
sdk.MustNewDecFromStr(tt.config.Operator.MinFeeShare),
math.LegacyMustNewDecFromStr(tt.config.Operator.MinFeeShare),
)
require.NoError(t, err)

Expand Down Expand Up @@ -369,9 +370,9 @@ func Test_OrderFulfillment(t *testing.T) {
{
RollappId: "rollapp1",
Denoms: []string{"stake", "adym"},
MinFeePercentage: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.1")},
MinFeePercentage: math.LegacyMustNewDecFromStr("0.1"),
MaxPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(210)), sdk.NewCoin("adym", sdk.NewInt(150))),
OperatorFeeShare: sdk.DecProto{Dec: sdk.MustNewDecFromStr("0.1")},
OperatorFeeShare: math.LegacyMustNewDecFromStr("0.1"),
SpendLimit: balance,
SettlementValidated: false,
},
Expand Down Expand Up @@ -418,7 +419,7 @@ func Test_OrderFulfillment(t *testing.T) {
getLPGrants,
fulfillOrdersFn,
lpBalances,
sdk.MustNewDecFromStr(cfg.Operator.MinFeeShare),
math.LegacyMustNewDecFromStr(cfg.Operator.MinFeeShare),
)
require.NoError(t, err)

Expand All @@ -438,7 +439,7 @@ func setupTestOrderClient(
grantsFn getLPGrantsFn,
fulfillOrdersFn func(demandOrder ...*demandOrder) error,
lpBalances map[string]sdk.Coins,
minOperatorFeeShare sdk.Dec,
minOperatorFeeShare math.LegacyDec,
) (*orderClient, error) {
logger, _ := zap.NewDevelopment()
orderCh := make(chan []*demandOrder, config.NewOrderBufferSize)
Expand Down
4 changes: 2 additions & 2 deletions eibc/order_fulfiller.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ func (ol *orderFulfiller) fulfillAuthorizedDemandOrders(demandOrder ...*demandOr
ol.operatorAddress,
order.fee.Amount.String(),
order.price,
sdk.IntProto{Int: order.amount},
sdk.DecProto{Dec: order.operatorFeePart},
order.amount,
order.operatorFeePart,
order.settlementValidated,
)

Expand Down
8 changes: 4 additions & 4 deletions eibc/order_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"sync"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"go.uber.org/zap"
Expand All @@ -35,7 +35,7 @@ type orderTracker struct {
outputOrdersCh chan<- []*demandOrder
processedOrdersCh chan []orderFulfillResult
lps map[string]*lp
minOperatorFeeShare sdk.Dec
minOperatorFeeShare math.LegacyDec

pool orderPool
failedOrderHashes map[string]string
Expand All @@ -57,7 +57,7 @@ type (
func newOrderTracker(
hubClient cosmosClient,
policyAddress string,
minOperatorFeeShare sdk.Dec,
minOperatorFeeShare math.LegacyDec,
fullNodeClient *nodeClient,
subscriberID string,
numFulfillers,
Expand Down Expand Up @@ -378,7 +378,7 @@ func (or *orderTracker) filterLPsForOrder(order *demandOrder) ([]*lp, []string)
}

// check the fee is at least the minimum of what the lp wants
minFee := sdk.NewDecFromInt(order.amount).Mul(rollapp.MinFeePercentage).TruncateInt()
minFee := math.LegacyNewDecFromInt(order.amount).Mul(rollapp.MinFeePercentage).TruncateInt()

if order.fee.Amount.LT(minFee) {
lpSkip = append(lpSkip, fmt.Sprintf("lp: %s; rollapp: %s: min_fee: %s", lp.address, order.rollappId, minFee.String()))
Expand Down
3 changes: 2 additions & 1 deletion eibc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package eibc
import (
"time"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -16,7 +17,7 @@ type demandOrder struct {
proofHeight int64
validDeadline time.Time
settlementValidated bool
operatorFeePart sdk.Dec
operatorFeePart math.LegacyDec
lpAddress string
from string
checking, valid bool
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.23.1

require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.46.16
github.com/cosmos/gogoproto v1.5.0
Expand All @@ -16,12 +17,12 @@ require (
github.com/stretchr/testify v1.8.4
github.com/tendermint/tendermint v0.34.29
go.uber.org/zap v1.24.0
google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe
google.golang.org/grpc v1.62.1
gopkg.in/yaml.v3 v3.0.1
)

require (
cosmossdk.io/math v1.3.0 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand Down Expand Up @@ -134,7 +135,6 @@ require (
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit 8962789

Please sign in to comment.