Skip to content

Commit

Permalink
Merge branch 'main' into neitdung/test-tokenize-shares
Browse files Browse the repository at this point in the history
  • Loading branch information
ThanhNhann authored Oct 30, 2023
2 parents 23cd9e0 + df252ef commit c74675d
Show file tree
Hide file tree
Showing 21 changed files with 1,040 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CODEOWNERS: https://help.github.com/articles/about-codeowners/

# Primary repo maintainers
* @joe-bowman @ajansari95 @muku314115 @ThanhNhann @faddat @sontrinh16 @anhductn2001
* @joe-bowman @ThanhNhann @faddat @sontrinh16 @anhductn2001
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/armon/go-metrics v0.4.1
github.com/client9/misspell v0.3.4
github.com/cometbft/cometbft-db v0.8.0
github.com/confio/ics23/go v0.9.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.46.15
github.com/cosmos/gogoproto v1.4.3
Expand Down Expand Up @@ -96,7 +97,6 @@ require (
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/coinbase/rosetta-sdk-go v0.8.3 // indirect
github.com/coinbase/rosetta-sdk-go/types v1.0.0 // indirect
github.com/confio/ics23/go v0.9.0 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/iavl v0.19.6 // indirect
Expand Down
35 changes: 0 additions & 35 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/simulation/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty
simAccs = accounts

case config.ParamsFile != "":
appParams := make(simtypes.AppParams)
bz, err := os.ReadFile(config.ParamsFile)
if err != nil {
panic(err)
}

appParams := make(simtypes.AppParams)
err = json.Unmarshal(bz, &appParams)
if err != nil {
panic(err)
Expand Down
19 changes: 11 additions & 8 deletions x/interchainstaking/keeper/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ func RewardsCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes.Que

k.Logger(ctx).Debug("rewards callback", "zone", query.ChainId)

// unmarshal request payload
rewardsQuery := distrtypes.QueryDelegationTotalRewardsRequest{}
if len(query.Request) == 0 {
return errors.New("attempted to unmarshal zero length byte slice (2)")
}

// unmarshal request payload
rewardsQuery := distrtypes.QueryDelegationTotalRewardsRequest{}
err := k.cdc.Unmarshal(query.Request, &rewardsQuery)
if err != nil {
return err
Expand All @@ -130,10 +131,11 @@ func DelegationsCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes
return fmt.Errorf("no registered zone for chain id: %s", query.GetChainId())
}

delegationQuery := stakingtypes.QueryDelegatorDelegationsRequest{}
if len(query.Request) == 0 {
return errors.New("attempted to unmarshal zero length byte slice (3)")
}

delegationQuery := stakingtypes.QueryDelegatorDelegationsRequest{}
err := k.cdc.Unmarshal(query.Request, &delegationQuery)
if err != nil {
return err
Expand Down Expand Up @@ -228,11 +230,11 @@ func DepositIntervalCallback(k *Keeper, ctx sdk.Context, args []byte, query icqt

k.Logger(ctx).Debug("Deposit interval callback", "zone", zone.ChainId)

txs := tx.GetTxsEventResponse{}

if len(args) == 0 {
return errors.New("attempted to unmarshal zero length byte slice (4)")
}

txs := tx.GetTxsEventResponse{}
err := k.cdc.Unmarshal(args, &txs)
if err != nil {
k.Logger(ctx).Error("unable to unmarshal txs for deposit account", "deposit_address", zone.DepositAddress.GetAddress(), "err", err)
Expand All @@ -242,7 +244,7 @@ func DepositIntervalCallback(k *Keeper, ctx sdk.Context, args []byte, query icqt
for _, txn := range txs.TxResponses {
req := tx.GetTxRequest{Hash: txn.TxHash}
hashBytes := k.cdc.MustMarshal(&req)
_, found = k.GetReceipt(ctx, types.GetReceiptKey(zone.ChainId, txn.TxHash))
_, found = k.GetReceipt(ctx, zone.ChainId, txn.TxHash)
if found {
k.Logger(ctx).Debug("Found previously handled tx. Ignoring.", "txhash", txn.TxHash)
continue
Expand Down Expand Up @@ -443,7 +445,7 @@ func DepositTxCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes.Q
return fmt.Errorf("invalid tx for query - expected %s, got %s", queryRequest.Hash, hashStr)
}

_, found = k.GetReceipt(ctx, types.GetReceiptKey(zone.ChainId, hashStr))
_, found = k.GetReceipt(ctx, zone.ChainId, hashStr)
if found {
k.Logger(ctx).Info("Found previously handled tx. Ignoring.", "txhash", hashStr)
return nil
Expand Down Expand Up @@ -561,11 +563,12 @@ func DelegationAccountBalanceCallback(k *Keeper, ctx sdk.Context, args []byte, q
}

func AllBalancesCallback(k *Keeper, ctx sdk.Context, args []byte, query icqtypes.Query) error {
balanceQuery := banktypes.QueryAllBalancesRequest{}
// this shouldn't happen because query.Request comes from Quicksilver
if len(query.Request) == 0 {
return errors.New("attempted to unmarshal zero length byte slice (7)")
}

balanceQuery := banktypes.QueryAllBalancesRequest{}
err := k.cdc.Unmarshal(query.Request, &balanceQuery)
if err != nil {
return err
Expand Down
258 changes: 258 additions & 0 deletions x/interchainstaking/keeper/callbacks_test.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (k *Keeper) TxStatus(c context.Context, req *types.QueryTxStatusRequest) (*

ctx := sdk.UnwrapSDKContext(c)

txReceipt, found := k.GetReceipt(ctx, types.GetReceiptKey(req.GetChainId(), req.GetTxHash()))
txReceipt, found := k.GetReceipt(ctx, req.GetChainId(), req.GetTxHash())
if !found {
return nil, status.Error(codes.NotFound, fmt.Sprintf("no receipt found matching %s", req.TxHash))
}
Expand Down
12 changes: 6 additions & 6 deletions x/interchainstaking/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ func (suite *KeeperTestSuite) TestKeeper_ZoneWithdrawalRecords() {
zone, found := icsKeeper.GetZone(ctx, suite.chainB.ChainID)
suite.True(found)

distribution := []*types.Distribution{
distributions := []*types.Distribution{
{
Valoper: icsKeeper.GetValidators(ctx, suite.chainB.ChainID)[0].ValoperAddress,
Amount: 10000000,
Expand All @@ -788,7 +788,7 @@ func (suite *KeeperTestSuite) TestKeeper_ZoneWithdrawalRecords() {
ctx,
zone.ChainId,
delegatorAddress,
distribution,
distributions,
testAddress,
sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(15000000))),
sdk.NewCoin(zone.LocalDenom, math.NewInt(15000000)),
Expand Down Expand Up @@ -877,7 +877,7 @@ func (suite *KeeperTestSuite) TestKeeper_UserWithdrawalRecords() {
zone, found := icsKeeper.GetZone(ctx, suite.chainB.ChainID)
suite.True(found)

distribution := []*types.Distribution{
distributions := []*types.Distribution{
{
Valoper: icsKeeper.GetValidators(ctx, suite.chainB.ChainID)[0].ValoperAddress,
Amount: 10000000,
Expand All @@ -893,7 +893,7 @@ func (suite *KeeperTestSuite) TestKeeper_UserWithdrawalRecords() {
ctx,
zone.ChainId,
delegatorAddress,
distribution,
distributions,
testAddress,
sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(15000000))),
sdk.NewCoin(zone.LocalDenom, math.NewInt(15000000)),
Expand Down Expand Up @@ -970,7 +970,7 @@ func (suite *KeeperTestSuite) TestKeeper_WithdrawalRecords() {
zone, found := icsKeeper.GetZone(ctx, suite.chainB.ChainID)
suite.True(found)

distribution := []*types.Distribution{
distributions := []*types.Distribution{
{
Valoper: icsKeeper.GetValidators(ctx, suite.chainB.ChainID)[0].ValoperAddress,
Amount: 10000000,
Expand All @@ -986,7 +986,7 @@ func (suite *KeeperTestSuite) TestKeeper_WithdrawalRecords() {
ctx,
zone.ChainId,
delegatorAddress,
distribution,
distributions,
testAddress,
sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, math.NewInt(15000000))),
sdk.NewCoin(zone.LocalDenom, math.NewInt(15000000)),
Expand Down
2 changes: 1 addition & 1 deletion x/interchainstaking/keeper/ibc_packet_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ func (k *Keeper) HandleDelegate(ctx sdk.Context, msg sdk.Msg, memo string) error
}
}
default:
receipt, found := k.GetReceipt(ctx, types.GetReceiptKey(zone.ChainId, memo))
receipt, found := k.GetReceipt(ctx, zone.ChainId, memo)
if !found {
return fmt.Errorf("unable to find receipt for hash %s", memo)
}
Expand Down
Loading

0 comments on commit c74675d

Please sign in to comment.