Skip to content

Commit

Permalink
Merge branch 'main' into adarsh/fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amityadav0 authored Dec 3, 2024
2 parents b30abff + 6df9463 commit 37b71f6
Show file tree
Hide file tree
Showing 24 changed files with 727 additions and 1,422 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/delete-branch-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- name: Retrieve post upgrade snapshot generator binary
run: |
POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION=v0.6.1
POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION=v0.6.2
DOWNLOAD_URL=https://github.com/elys-network/post-upgrade-snapshot-generator/releases/download/${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}/post-upgrade-snapshot-generator-${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}-linux-amd64
POST_UPGRADE_SNAPSHOT_GENERATOR_PATH=/tmp/post-upgrade-snapshot-generator-${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}
curl -L $DOWNLOAD_URL -o $POST_UPGRADE_SNAPSHOT_GENERATOR_PATH && chmod +x $POST_UPGRADE_SNAPSHOT_GENERATOR_PATH
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/software-upgrade-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
create-new-snapshot:
runs-on: elys-runner-x2
runs-on: elys-runner-x2-2

steps:
- name: Check if secrets are set
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Retrieve post upgrade snapshot generator binary
run: |
POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION=v0.6.1
POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION=v0.6.2
DOWNLOAD_URL=https://github.com/elys-network/post-upgrade-snapshot-generator/releases/download/${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}/post-upgrade-snapshot-generator-${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}-linux-amd64
POST_UPGRADE_SNAPSHOT_GENERATOR_PATH=/tmp/post-upgrade-snapshot-generator-${POST_UPGRADE_SNAPSHOT_GENERATOR_VERSION}
curl -L $DOWNLOAD_URL -o $POST_UPGRADE_SNAPSHOT_GENERATOR_PATH && chmod +x $POST_UPGRADE_SNAPSHOT_GENERATOR_PATH
Expand Down
16 changes: 0 additions & 16 deletions proto/elys/estaking/dex_rewards_tracker.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,3 @@ message DexRewardsTracker {
(gogoproto.nullable) = false
];
}

message LegacyDexRewardsTracker {
// Number of blocks since start of epoch (distribution epoch)
string num_blocks = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
// Accumulated amount at distribution epoch - recalculated at every
// distribution epoch
string amount = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
28 changes: 0 additions & 28 deletions proto/elys/estaking/incentive.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,6 @@ import "cosmos_proto/cosmos.proto";

option go_package = "github.com/elys-network/elys/x/estaking/types";

// Incentive Info
message LegacyIncentiveInfo {
// reward amount in eden for 1 year
string eden_amount_per_year = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
// starting block height of the distribution
string distribution_start_block = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
// distribution duration - block number per year
string total_blocks_per_year = 3 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
// blocks distributed
string blocks_distributed = 4 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];
}

message IncentiveInfo {
// reward amount in eden for 1 year
string eden_amount_per_year = 1 [
Expand Down
22 changes: 0 additions & 22 deletions proto/elys/estaking/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@ import "cosmos_proto/cosmos.proto";

option go_package = "github.com/elys-network/elys/x/estaking/types";

message LegacyParams {
option (gogoproto.goproto_stringer) = false;

LegacyIncentiveInfo stake_incentives = 1;
string eden_commit_val = 2;
string edenb_commit_val = 3;
// Maximum eden reward apr for stakers - [0 - 0.3]
string max_eden_reward_apr_stakers = 5 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
string eden_boost_apr = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// Tracking dex rewards given to stakers
LegacyDexRewardsTracker dex_rewards_stakers = 7
[ (gogoproto.nullable) = false ];
}

// Params defines the parameters for the module.
message Params {
IncentiveInfo stake_incentives = 1;
Expand Down
16 changes: 16 additions & 0 deletions proto/elys/tier/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ service Query {
"/elys-network/elys/tier/liquid_total/{user}";
}

// Queries a list of LockedOrder items.
rpc LockedOrder(QueryLockedOrderRequest) returns (QueryLockedOrderResponse) {
option (google.api.http).get =
"/elys-network/elys/tier/locked_order/{user}";
}

// Queries a list of GetAmmPrice items.
rpc GetAmmPrice(QueryGetAmmPriceRequest) returns (QueryGetAmmPriceResponse) {
option (google.api.http).get =
Expand Down Expand Up @@ -183,6 +189,16 @@ message QueryLiquidTotalResponse {
];
}

message QueryLockedOrderRequest { string user = 1; }

message QueryLockedOrderResponse {
string total = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}

message QueryGetAmmPriceRequest {
string denom = 1;
int32 decimal = 2;
Expand Down
24 changes: 0 additions & 24 deletions x/estaking/keeper/elys_stake_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ func (k Keeper) RemoveElysStakeChange(ctx sdk.Context, address sdk.AccAddress) {
store.Delete(key)
}

func (k Keeper) SetLegacyElysStakeChange(ctx sdk.Context, addr sdk.AccAddress) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyElysStakeChangeKeyPrefix))
key := types.GetElysStakeChangeKey(addr)
store.Set(key, addr)
}

func (k Keeper) DeleteLegacyElysStakeChange(ctx sdk.Context, address sdk.AccAddress) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyElysStakeChangeKeyPrefix))
store.Delete([]byte(address))
}

func (k Keeper) GetAllElysStakeChange(ctx sdk.Context) (list []sdk.AccAddress) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.ElysStakeChangeKeyPrefix)
iterator := storetypes.KVStorePrefixIterator(store, []byte{})
Expand All @@ -49,16 +38,3 @@ func (k Keeper) GetAllElysStakeChange(ctx sdk.Context) (list []sdk.AccAddress) {

return
}

func (k Keeper) GetAllLegacyElysStakeChange(ctx sdk.Context) (list []sdk.AccAddress) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyElysStakeChangeKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte{})

defer iterator.Close()

for ; iterator.Valid(); iterator.Next() {
list = append(list, sdk.AccAddress(iterator.Value()))
}

return
}
42 changes: 0 additions & 42 deletions x/estaking/keeper/elys_stake_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,6 @@ func (suite *EstakingKeeperTestSuite) TestElysStakeChange() {
suite.Require().True(found)
},
},
{
"delete legacy elys stake change",
func() (addr sdk.AccAddress) {
suite.ResetSuite()

addr = suite.AddAccounts(1, nil)[0]

return addr
},
func(addr sdk.AccAddress) {
suite.app.EstakingKeeper.DeleteLegacyElysStakeChange(suite.ctx, addr)
},
},
{
"get all legacy elys stake change with no data",
func() (addr sdk.AccAddress) {
suite.ResetSuite()

return sdk.AccAddress{}
},
func(addr sdk.AccAddress) {
list := suite.app.EstakingKeeper.GetAllLegacyElysStakeChange(suite.ctx)
suite.Require().Equal(0, len(list))
},
},
{
"get all legacy elys stake change with data",
func() (addr sdk.AccAddress) {
suite.ResetSuite()

addr = suite.AddAccounts(1, nil)[0]

// set legacy elys stake change
suite.app.EstakingKeeper.SetLegacyElysStakeChange(suite.ctx, addr)

return sdk.AccAddress{}
},
func(addr sdk.AccAddress) {
list := suite.app.EstakingKeeper.GetAllLegacyElysStakeChange(suite.ctx)
suite.Require().Equal(1, len(list))
},
},
}

for _, tc := range testCases {
Expand Down
30 changes: 0 additions & 30 deletions x/estaking/keeper/elys_staked.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,3 @@ func (k Keeper) GetAllElysStaked(ctx sdk.Context) (list []types.ElysStaked) {

return
}

// SetLegacyElysStaked set a specific elysStaked in the store from its index
func (k Keeper) SetLegacyElysStaked(ctx sdk.Context, elysStaked types.ElysStaked) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyElysStakedKeyPrefix))
b := k.cdc.MustMarshal(&elysStaked)
key := types.GetElysStakedKey(elysStaked.GetAccountAddress())
store.Set(key, b)
}

// remove after migration
func (k Keeper) GetAllLegacyElysStaked(ctx sdk.Context) (list []types.ElysStaked) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyElysStakedKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte{})

defer iterator.Close()

for ; iterator.Valid(); iterator.Next() {
var val types.ElysStaked
k.cdc.MustUnmarshal(iterator.Value(), &val)
list = append(list, val)
}

return
}

// TODO: remove all legacy prefixes and functions after migration
func (k Keeper) DeleteLegacyElysStaked(ctx sdk.Context, address string) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.LegacyKeyPrefix(types.LegacyElysStakedKeyPrefix))
store.Delete(types.LegacyElysStakedKey(address))
}
34 changes: 0 additions & 34 deletions x/estaking/keeper/elys_staked_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,6 @@ func (suite *EstakingKeeperTestSuite) TestElysStaked() {
suite.Require().Equal(2, len(list))
},
},
{
"get all legacy elys staked",
func() (addr sdk.AccAddress) {
suite.ResetSuite()

addr = suite.AddAccounts(1, nil)[0]

// set elys staked
suite.app.EstakingKeeper.SetLegacyElysStaked(suite.ctx, types.ElysStaked{
Address: addr.String(),
Amount: math.NewInt(1000),
})

return addr
},
func(addr sdk.AccAddress) {
list := suite.app.EstakingKeeper.GetAllLegacyElysStaked(suite.ctx)
suite.Require().Equal(1, len(list))
suite.Require().Equal(math.NewInt(1000), list[0].Amount)
},
},
{
"delete legacy elys staked",
func() (addr sdk.AccAddress) {
suite.ResetSuite()

addr = suite.AddAccounts(1, nil)[0]

return addr
},
func(addr sdk.AccAddress) {
suite.app.EstakingKeeper.DeleteLegacyElysStaked(suite.ctx, addr.String())
},
},
}

for _, tc := range testCases {
Expand Down
9 changes: 5 additions & 4 deletions x/estaking/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
stypes "github.com/cosmos/cosmos-sdk/x/staking/types"
simapp "github.com/elys-network/elys/app"
aptypes "github.com/elys-network/elys/x/assetprofile/types"
ckeeper "github.com/elys-network/elys/x/commitment/keeper"
Expand Down Expand Up @@ -169,6 +168,7 @@ func (suite *EstakingKeeperTestSuite) TestEstakingExtendedFunctions() {
suite.Require().Nil(err)

delegations, err := suite.app.StakingKeeper.GetValidatorDelegations(suite.ctx, operatorAddr)
suite.Require().Nil(err)

suite.Require().True(len(delegations) > 0)
addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress)
Expand Down Expand Up @@ -212,6 +212,7 @@ func (suite *EstakingKeeperTestSuite) TestEstakingExtendedFunctions() {
suite.Require().Nil(err)
suite.Require().Equal(validator, edenVal)
validator, err = suite.app.EstakingKeeper.Validator(suite.ctx, operatorBValAddr)
suite.Require().Nil(err)
suite.Require().Equal(validator, edenBVal)

edenDel, err := suite.app.EstakingKeeper.Delegation(suite.ctx, addr, operatorValAddr)
Expand All @@ -223,22 +224,22 @@ func (suite *EstakingKeeperTestSuite) TestEstakingExtendedFunctions() {
suite.Require().Nil(edenBDel)

numDelegations := int64(0)
suite.app.EstakingKeeper.IterateDelegations(suite.ctx, addr, func(index int64, delegation stypes.DelegationI) (stop bool) {
suite.app.EstakingKeeper.IterateDelegations(suite.ctx, addr, func(index int64, delegation stakingtypes.DelegationI) (stop bool) {
numDelegations++
return false
})
suite.Require().Equal(numDelegations, int64(2))

numBondedValidators := int64(0)
suite.app.EstakingKeeper.IterateBondedValidatorsByPower(suite.ctx, func(index int64, delegation stypes.ValidatorI) (stop bool) {
suite.app.EstakingKeeper.IterateBondedValidatorsByPower(suite.ctx, func(index int64, delegation stakingtypes.ValidatorI) (stop bool) {
numBondedValidators++
return false
})
suite.Require().Equal(numBondedValidators, int64(2))

// test IterateValidators
numValidators := int64(0)
suite.app.EstakingKeeper.IterateValidators(suite.ctx, func(index int64, validator stypes.ValidatorI) (stop bool) {
suite.app.EstakingKeeper.IterateValidators(suite.ctx, func(index int64, validator stakingtypes.ValidatorI) (stop bool) {
numValidators++
return false
})
Expand Down
1 change: 1 addition & 0 deletions x/estaking/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (suite *EstakingKeeperTestSuite) TestMsgServer() {
suite.Require().Nil(err)

delegations, err := suite.app.StakingKeeper.GetValidatorDelegations(suite.ctx, valAddr)
suite.Require().Nil(err)
suite.Require().True(len(delegations) > 0)
addr := sdk.MustAccAddressFromBech32(delegations[0].DelegatorAddress)

Expand Down
19 changes: 0 additions & 19 deletions x/estaking/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,9 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
return
}

func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))

b := store.Get(types.ParamsKeyPrefix)
if b == nil {
return
}

k.cdc.MustUnmarshal(b, &params)
return
}

// SetParams set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
b := k.cdc.MustMarshal(&params)
store.Set(types.ParamsKeyPrefix, b)
}

// SetLegacyParams set the params
func (k Keeper) SetLegacyParams(ctx sdk.Context, params types.LegacyParams) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
b := k.cdc.MustMarshal(&params)
store.Set(types.ParamsKeyPrefix, b)
}
Loading

0 comments on commit 37b71f6

Please sign in to comment.