Skip to content

Commit

Permalink
pr changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarom Swisa authored and Yarom Swisa committed Oct 10, 2024
1 parent 82424df commit d60f802
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
1 change: 1 addition & 0 deletions x/epochstorage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ The epochstorage module supports the following queries:
| `show-fixated-params` | chainid | a specific fixated param |
| `list-stake-storage` | chainid | list of all stake storages indices |
| `show-stake-storage` | chainid | show a specific stake storage |
| `provider-metadata` | provider-address | shows the metadata of a specific provider, if left empty returns metadata for all providers |

## Transactions

Expand Down
1 change: 1 addition & 0 deletions x/pairing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ The pairing module supports the following transactions:
| `stake-provider` | chain-id (string), amount (Coin), endpoints ([]Endpoint), geolocation (int32), validator (string, optional), --provider-moniker (string) --grant-provider-gas-fees-auth (bool)| stake a provider in a chain with multiple endpoints |
| `unfreeze` | chain-ids ([]string) | unfreeze a provider in multiple chains |
| `unstake-provider` | chain-ids ([]string), validator (string, optional) | unstake a provider from multiple chains |
| `move-provider-stake` | src-chain dst-chain amount (Coin)| move provider stake amount from one chain to another |

Note, the `Coin` type is from Cosmos-SDK (`cosmos.base.v1beta1.Coin`). From the CLI, use `100ulava` to assign a `Coin` argument. The `Endpoint` type defines a provider endpoint. From the CLI, use "my-provider-grpc-addr.com:9090,1" for one endpoint (includes the endpoint's URL+port and the endpoint's geolocation). When it comes to staking-related transactions, the geolocation argument should encompass the geolocations of all the endpoints combined.

Expand Down
2 changes: 1 addition & 1 deletion x/pairing/keeper/delegator_rewards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ func TestDelegatorRewardProviderAddingChain(t *testing.T) {
ts.AdvanceEpoch()
ts.AdvanceBlocks(ts.BlocksToSave() + 1)

// delegator should get half of the payment
// delegator should get third of the payment
res, err = ts.QueryDualstakingDelegatorRewards(delegator, provider, "")
require.Nil(ts.T, err)
require.Equal(ts.T, ts.plan.Price.Amount.QuoRaw(3).AddRaw(1), res.Rewards[0].Amount[0].Amount)
Expand Down
28 changes: 17 additions & 11 deletions x/pairing/keeper/single_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func TestUnstakeStake(t *testing.T) {

ts.AdvanceEpoch()

for i := 0; i < 5; i++ {
res, err := ts.QueryPairingProvider(provider0.Addr.String(), SpecName(i))
require.NoError(t, err)
require.Equal(t, int64(1000), res.StakeEntries[0].DelegateTotal.Amount.Int64())
stakeEntries := ts.Keepers.Epochstorage.GetAllStakeEntriesForEpoch(ts.Ctx, ts.EpochStart())
require.Len(t, stakeEntries, 5)
for _, entry := range stakeEntries {
require.Equal(t, int64(1000), entry.DelegateTotal.Amount.Int64())
}

// unstake spec0 provider
Expand Down Expand Up @@ -110,13 +110,11 @@ func TestUnstakeStake(t *testing.T) {

ts.AdvanceEpoch()

res1, err = ts.QueryPairingProvider(provider0.Addr.String(), SpecName(0))
require.NoError(t, err)
require.Equal(t, int64(2500), res1.StakeEntries[0].DelegateTotal.Amount.Int64())

res1, err = ts.QueryPairingProvider(provider0.Addr.String(), SpecName(1))
require.NoError(t, err)
require.Equal(t, int64(2500), res1.StakeEntries[0].DelegateTotal.Amount.Int64())
stakeEntries = ts.Keepers.Epochstorage.GetAllStakeEntriesForEpoch(ts.Ctx, ts.EpochStart())
require.Len(t, stakeEntries, 2)
for _, entry := range stakeEntries {
require.Equal(t, int64(2500), entry.DelegateTotal.Amount.Int64())
}
}

// * unstake to see the delegations distributions
Expand Down Expand Up @@ -152,6 +150,14 @@ func TestUnstakeStakeNewVault(t *testing.T) {
for i := 0; i < 5; i++ {
_, err = ts.TxPairingUnstakeProvider(provider0.GetVaultAddr(), SpecName(i))
require.NoError(t, err)

md, err := ts.Keepers.Epochstorage.GetMetadata(ts.Ctx, provider0.Addr.String())
if i == 4 {
require.Error(t, err)
} else {
require.NoError(t, err)
require.Len(t, md.Chains, 4-i)
}
}

res, err := ts.QueryDualstakingDelegatorProviders(delegator.Addr.String())
Expand Down
17 changes: 8 additions & 9 deletions x/pairing/keeper/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,14 @@ func (k Keeper) StakeNewEntry(ctx sdk.Context, validator, creator, chainID strin
}

stakeEntry := epochstoragetypes.StakeEntry{
Stake: stakeAmount,
Address: provider,
StakeAppliedBlock: stakeAppliedBlock,
Endpoints: endpointsVerified,
Geolocation: geolocation,
Chain: chainID,
DelegateTotal: sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), delegateTotal),
DelegateCommission: 0,
Vault: creator, // the stake-provider TX creator is always regarded as the vault address
Stake: stakeAmount,
Address: provider,
StakeAppliedBlock: stakeAppliedBlock,
Endpoints: endpointsVerified,
Geolocation: geolocation,
Chain: chainID,
DelegateTotal: sdk.NewCoin(k.stakingKeeper.BondDenom(ctx), delegateTotal),
Vault: creator, // the stake-provider TX creator is always regarded as the vault address
}

metadata.DelegateCommission = delegationCommission
Expand Down

0 comments on commit d60f802

Please sign in to comment.