Skip to content

Commit fa06394

Browse files
author
Mikhail Kornilov
authored
[Release] Cosmos SDK version bump (#217)
* simulator: readme added, refactoring, new Cosmos SDK query results added to the report * Cosmos SDK version bump * genesis update: LPRation 1.0 -> 2.0
1 parent 19b6b84 commit fa06394

15 files changed

Lines changed: 406 additions & 136 deletions

cmd/config/genesis/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func OverrideGenesisStateDefaults(cdc *codec.Codec, genState map[string]json.Raw
101101
//
102102
moduleState.Params.BondDenom = defaults.StakingDenom
103103
moduleState.Params.LPDenom = defaults.LiquidityProviderDenom
104-
moduleState.Params.LPDistrRatio = sdk.NewDecWithPrec(1, 0) // 100%
104+
moduleState.Params.LPDistrRatio = sdk.NewDecWithPrec(2, 0) // 200%
105105
//
106106
moduleState.Params.MinSelfDelegationLvl = defaults.MinSelfDelegationCoin.Amount // 2500.0
107107
moduleState.Params.MaxDelegationsRatio = sdk.NewDecWithPrec(10, 0) // 10.0

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/dfinance/dnode
22

33
go 1.14
44

5-
replace github.com/cosmos/cosmos-sdk => github.com/dfinance/cosmos-sdk v0.38.4-0.20201006151646-1ac22b3a4a09
5+
replace github.com/cosmos/cosmos-sdk => github.com/dfinance/cosmos-sdk v0.38.4-0.20201009185146-b579213ebb05
66

77
// Local development option
88
//replace github.com/cosmos/cosmos-sdk => /Users/boris/go/src/github.com/dfinance/cosmos-sdk

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ github.com/dfinance/cosmos-sdk v0.38.4-0.20201002151830-6c83c28b89f4 h1:sUQDCT0d
154154
github.com/dfinance/cosmos-sdk v0.38.4-0.20201002151830-6c83c28b89f4/go.mod h1:6A7WcR5vEsVN5MSi5gkMJmJIMulHZftD7q63tBdt2r0=
155155
github.com/dfinance/cosmos-sdk v0.38.4-0.20201006151646-1ac22b3a4a09 h1:hNzQYh6QR6K097fL0HYDtgfyN2KgUXLu17/zRxSJezc=
156156
github.com/dfinance/cosmos-sdk v0.38.4-0.20201006151646-1ac22b3a4a09/go.mod h1:6A7WcR5vEsVN5MSi5gkMJmJIMulHZftD7q63tBdt2r0=
157+
github.com/dfinance/cosmos-sdk v0.38.4-0.20201008094428-b46810ed3864/go.mod h1:6A7WcR5vEsVN5MSi5gkMJmJIMulHZftD7q63tBdt2r0=
158+
github.com/dfinance/cosmos-sdk v0.38.4-0.20201009185146-b579213ebb05/go.mod h1:6A7WcR5vEsVN5MSi5gkMJmJIMulHZftD7q63tBdt2r0=
157159
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de h1:PZfrjeOs9epAU0n+FpX/JAr/e+5m5/GdfUsgtO8gCOY=
158160
github.com/dfinance/dvm-proto/go v0.0.0-20200819065410-6b70956c85de/go.mod h1:Vt1T0G56AYXbsduNKzSkq1RDTNa8PFraSqB9DaTCV0U=
159161
github.com/dfinance/glav v0.0.0-20200814081332-c4701f6c12a6 h1:fZIYncA5BRad0+YnP88cfBfo0ZPgxPSVeuh/jvoGrLc=

helpers/tests/simulator/README.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Simulation parameters
2+
3+
Simulation:
4+
* `ID` - simulation id;
5+
* `SimDuration` - simulation duration;
6+
* `BlockTimeMin` - minimum block duration;
7+
* `BlockTimeMax` - maximum block duration;
8+
9+
Account balances:
10+
* `MainTokens` - initial account balance for main tokens (`xfi`);
11+
* `StakingTokens` - initial account balance for staking tokens (`sxfi`);
12+
* `LPTokens` - initial account balance for LP tokens (`lpt`);
13+
14+
Validators:
15+
* `PoA validator` - number of PegZone validators, ATM has no influence on simulation;
16+
* `TM validators (total)` - total number of PoS validators (some of them might become `unbonded`);
17+
* `TM validators (active)` - number of active PoS validators (they would be `bonded`);
18+
19+
`DelegateBondingOp` / `DelegateLPOp` operation:
20+
* `Delegate bonding/LP tokens every` - period of operation in simulated time;
21+
* `Delegate amount ratio (of acc balance)` - % of account balance for delegation;
22+
* `Max limit ratio (staked ratio)` - operation limit: % of staked tokens to total tokens supply;
23+
24+
`RedelegateBondingOp` / `RedelegateLPOp` operation:
25+
* `Redelegate bonding/LP tokens every` - period of operation in simulated time;
26+
* `Redelegate amount ratio (of del shares)` - % of delegation shares for redelegation;
27+
28+
`UndelegateBondingOp` / `UndelegateLPOp` operation:
29+
* `Undelegate bonding/LP tokens every` - period of operation in simulated time;
30+
* `Undelegate amount ratio (of del shares)` - % of delegation shares for undelegation;
31+
32+
`ValidatorRewardOp` operation:
33+
* `Withdraw all validators comissions every` - period of operation in simulated time;
34+
35+
`DelegatorRewardOp` operation:
36+
* `Withdraw all delegators rewards every` - period of operation in simulated time;
37+
38+
`LockValidatorRewardsOp` operation:
39+
* `Lock rewards every` - period of operation in simulated time;
40+
* `Ratio of all validators` - operation limit: % of all validators to lock rewards;
41+
42+
# Operations
43+
44+
## `DelegateBondingOp` / `DelegateLPOp` operation
45+
46+
Picks a validator and searches for an account to delegate bonding tokens.
47+
* SelfStake increment is allowed;
48+
* Delegation amount = current account balance * {delegateRatio};
49+
* Delegation is allowed if ratio (current staking bonding pools supply / total bonding tokens supply) < {maxBondingRatio};
50+
51+
Op priorities:
52+
- validator:
53+
- bonded;
54+
- lowest bonding tokens amount;
55+
- account:
56+
- highest bonding tokens balance;
57+
- enough coins;
58+
59+
## `RedelegateBondingOp` / `RedelegateLPOp` operation
60+
61+
* Picks a validator and redelegate bonding tokens to an other validator;
62+
* Redelegation amount = current account delegation amount * {redelegateRatio};
63+
64+
Op priorities:
65+
- dstValidator:
66+
- bonded;
67+
- lowest bonding tokens amount;
68+
- srcValidator - highest account delegation bonding shares;
69+
- account:
70+
- random;
71+
- has no active redelegations with srcValidator and dstValidator;
72+
- has enough bonding coins;
73+
- not a dstValidator owner;
74+
75+
## `UndelegateBondingOp` / `UndelegateLPOp` operation
76+
77+
Picks a validator and undelegates bonding tokens.
78+
* Undelegation amount = current account delegation amount * {undelegateRatio}.
79+
80+
Op priorities:
81+
- validator - highest bonding tokens amount (all statuses);
82+
- account:
83+
- random;
84+
- has a validators bonding delegation;
85+
- not a validator owner;
86+
87+
## `ValidatorRewardOp` operation
88+
89+
Takes all validators commissions rewards.
90+
91+
## `DelegatorRewardOp` operation
92+
93+
Takes all delegators rewards (excluding locked ones).
94+
95+
## `LockValidatorRewardsOp` operation
96+
97+
Takes validator commissions rewards.
98+
99+
Op priority:
100+
- validator - random;
101+
102+
# CSV report
103+
104+
Report item is generated every simulated day.
105+
106+
* `BlockHeight` - block height;
107+
* `BlockTime` - block time;
108+
* `SimDuration` - simulation time (real world time);
109+
* `Validators: Bonded` - number of `bonded` PoS validator;
110+
* `Validators: Unbonding` - number of `unbonding` PoS validator;;
111+
* `Validators: Unbonded` - number of `unbonded` PoS validator;;
112+
* `Staking: Bonded` - amount of bonded staking tokens (`bonded` validators);
113+
* `Staking: NotBonded` - amount of not-bonded staking tokens (`unbonding`/`unbonded` validators);
114+
* `Staking: LPs` - amount of staked LP tokens;
115+
* `Staking: ActiveRedelegations` - number of current redelegations;
116+
* `Mint: MinInflation` - minimum inflation rate;
117+
* `Mint: MaxInflation` - maximum inflation rate;
118+
* `Mint: AnnualProvision` - annual minted tokens estimation (tokens per year);
119+
* `Mint: BlocksPerYear` - number of blocks per year estimation;
120+
* `Dist: FoundationPool` - FoundationPool supply (decimals);
121+
* `Dist: PTreasuryPool` - PublicTreasuryPool supply (decimals);
122+
* `Dist: LiquidityPPool` - LiquidityProvidersPool supply (decimals);
123+
* `Dist: HARP` - HARP supply (decimals);
124+
* `Dist: MAccBalance [main]` - rewards balance keeped by the distribution module (mail tokens);
125+
* `Dist: MAccBalance [staking]` - rewards balance keeped by the distribution module (staking tokens);
126+
* `Dist: BankBalance [main]` - rewards balance keeped by the distribution bank (mail tokens);
127+
* `Dist: BankBalance [staking]` - rewards balance keeped by the distribution bank (staking tokens);
128+
* `Dist: LockedRatio` - rate of bonded delegated tokens for locked validators to all bonded delegated tokens;
129+
* `Supply: Total [main]` - total tokens supply (main tokens);
130+
* `Supply: Total [staking]` - total tokens supply (staking tokens);
131+
* `Supply: Total [LP]` - total tokens supply (LP tokens);
132+
* `Stats: Staked/TotalSupply [staking]` - rate of (bonded + not-bonded tokens) to total supply of staking tokens;
133+
* `Stats: Staked/TotalSupply [LPs]` - rate of staked LP tokens to total supply;
134+
* `Accounts: TotalBalance [main]` - sum of all accounts balances (main tokens);
135+
* `Accounts: TotalBalance [staking]` - sum of all accounts balances (staking tokens);
136+
* `Counters: Bonding: Delegations` - number of bonding delegation operations;
137+
* `Counters: Bonding: Redelegations` - number of bonding redelegation operations;
138+
* `Counters: Bonding: Undelegations` - number of bonding undelegation operations;
139+
* `Counters: LP: Delegations` - number of LP delegation operations;
140+
* `Counters: LP: Redelegations` - number of LP redelegation operations;
141+
* `Counters: LP: Undelegations` - number of LP undelegation operations;
142+
* `Counters: RewardWithdraws` - number of delegators rewards withdraw operations;
143+
* `Counters: RewardsCollected [main]` - accumulated amount of delegators rewards collected (main tokens);
144+
* `Counters: RewardsCollected [staking]` - accumulated amount of delegators rewards collected (staking tokens);
145+
* `Counters: CommissionWithdraws` - number of validators commission rewards operations;
146+
* `Counters: CommissionsCollected [main]` - accumulated amount of validators commission rewards collected (main tokens);
147+
* `Counters: CommissionsCollected [staking]` - accumulated amount of validators commission rewards collected (staking tokens);
148+
* `Counters: LockedRewards` - number of validators rewards lock operations;

helpers/tests/simulator/inflation_test.go

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -70,38 +70,38 @@ func (p SimProfile) String() string {
7070
str := strings.Builder{}
7171
str.WriteString("Simulation:\n")
7272
str.WriteString(fmt.Sprintf(" - ID: %s\n", p.ID))
73-
str.WriteString(fmt.Sprintf(" - SimDuration: %s\n", FormatDuration(p.SimDuration)))
74-
str.WriteString(fmt.Sprintf(" - BlockTimeMin: %s\n", FormatDuration(p.BlockTimeMin)))
75-
str.WriteString(fmt.Sprintf(" - BlockTimeMax: %s\n", FormatDuration(p.BlockTimeMax)))
73+
str.WriteString(fmt.Sprintf(" - SimDuration: %v\n", p.SimDuration))
74+
str.WriteString(fmt.Sprintf(" - BlockTimeMin: %v\n", p.BlockTimeMin))
75+
str.WriteString(fmt.Sprintf(" - BlockTimeMax: %v\n", p.BlockTimeMax))
7676
str.WriteString("Initial balances:\n")
7777
str.WriteString(fmt.Sprintf(" - MainTokens: %d.0%s\n", p.MainTokensBalanceWODec, defaults.MainDenom))
7878
str.WriteString(fmt.Sprintf(" - StakingTokens: %d.0%s\n", p.BondingTokensBalanceWODec, defaults.StakingDenom))
7979
str.WriteString(fmt.Sprintf(" - LPTokens: %d.0%s\n", p.LPTokensBalanceWODec, defaults.LiquidityProviderDenom))
8080
str.WriteString("Total number of:\n")
81-
str.WriteString(fmt.Sprintf(" - Account: %d\n", p.Accounts))
81+
str.WriteString(fmt.Sprintf(" - Accounts: %d\n", p.Accounts))
8282
str.WriteString(fmt.Sprintf(" - PoA validators: %d\n", p.POAValidators))
8383
str.WriteString(fmt.Sprintf(" - TM validators (total): %d\n", p.TMValidatorsTotal))
8484
str.WriteString(fmt.Sprintf(" - TM validators (active): %d\n", p.TMValidatorsActive))
8585
str.WriteString("Operations:\n")
86-
str.WriteString(fmt.Sprintf(" - Create validators: %s\n", FormatDuration(p.OpCreateValidator)))
87-
str.WriteString(fmt.Sprintf(" - Delegate bonding tokens: %s\n", FormatDuration(p.OpDelegateBonding)))
88-
str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpDelegateBondingAmountRatio))
89-
str.WriteString(fmt.Sprintf(" Max limit ratio: %s\n", p.OpDelegateBondingMaxSupplyRatio))
90-
str.WriteString(fmt.Sprintf(" - Delegate LP tokens: %s\n", FormatDuration(p.OpDelegateLP)))
91-
str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpDelegateLPAmountRatio))
92-
str.WriteString(fmt.Sprintf(" Max limit ratio: %s\n", p.OpDelegateLPMaxSupplyRatio))
93-
str.WriteString(fmt.Sprintf(" - Redelegate bonding tokens: %s\n", FormatDuration(p.OpRedelegateBonding)))
94-
str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpRedelegateBondingAmountRatio))
95-
str.WriteString(fmt.Sprintf(" - Redelegate LP tokens: %s\n", FormatDuration(p.OpRedelegateLP)))
96-
str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpRedelegateLPAmountRatio))
97-
str.WriteString(fmt.Sprintf(" - Undelegate bonding tokens: %s\n", FormatDuration(p.OpUndelegateBonding)))
98-
str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpUndelegateBondingAmountRatio))
99-
str.WriteString(fmt.Sprintf(" - Undelegate LP tokens: %s\n", FormatDuration(p.OpUndelegateLP)))
100-
str.WriteString(fmt.Sprintf(" Amount ratio: %s\n", p.OpUndelegateLPAmountRatio))
101-
str.WriteString(fmt.Sprintf(" - Withdraw validator comission: %s\n", FormatDuration(p.OpGetValidatorRewards)))
102-
str.WriteString(fmt.Sprintf(" - Withdraw delegator reward: %s\n", FormatDuration(p.OpGetDelegatorRewards)))
103-
str.WriteString(fmt.Sprintf(" - Lock rewards: %s\n", FormatDuration(p.OpLockRewards)))
104-
str.WriteString(fmt.Sprintf(" Ratio: %s\n", p.OpLockRewardsRatio))
86+
str.WriteString(fmt.Sprintf(" - Create validator every: %s\n", FormatDuration(p.OpCreateValidator)))
87+
str.WriteString(fmt.Sprintf(" - Delegate bonding tokens every: %s\n", FormatDuration(p.OpDelegateBonding)))
88+
str.WriteString(fmt.Sprintf(" Delegate amount ratio (of acc balance): %s\n", p.OpDelegateBondingAmountRatio))
89+
str.WriteString(fmt.Sprintf(" Max limit ratio (staked ratio): %s\n", p.OpDelegateBondingMaxSupplyRatio))
90+
str.WriteString(fmt.Sprintf(" - Delegate LP tokens every: %s\n", FormatDuration(p.OpDelegateLP)))
91+
str.WriteString(fmt.Sprintf(" Delegate amount ratio (of acc balance): %s\n", p.OpDelegateLPAmountRatio))
92+
str.WriteString(fmt.Sprintf(" Max limit ratio (staked ratio): %s\n", p.OpDelegateLPMaxSupplyRatio))
93+
str.WriteString(fmt.Sprintf(" - Redelegate bonding tokens every: %s\n", FormatDuration(p.OpRedelegateBonding)))
94+
str.WriteString(fmt.Sprintf(" Redelegate amount ratio (of del shares): %s\n", p.OpRedelegateBondingAmountRatio))
95+
str.WriteString(fmt.Sprintf(" - Redelegate LP tokens every: %s\n", FormatDuration(p.OpRedelegateLP)))
96+
str.WriteString(fmt.Sprintf(" Redelegate amount ratio (of del shares): %s\n", p.OpRedelegateLPAmountRatio))
97+
str.WriteString(fmt.Sprintf(" - Undelegate bonding tokens every: %s\n", FormatDuration(p.OpUndelegateBonding)))
98+
str.WriteString(fmt.Sprintf(" Undelegate amount ratio (of del shares): %s\n", p.OpUndelegateBondingAmountRatio))
99+
str.WriteString(fmt.Sprintf(" - Undelegate LP tokens every: %s\n", FormatDuration(p.OpUndelegateLP)))
100+
str.WriteString(fmt.Sprintf(" Undelegate amount ratio (of del shares): %s\n", p.OpUndelegateLPAmountRatio))
101+
str.WriteString(fmt.Sprintf(" - Withdraw all validators comissions every: %s\n", FormatDuration(p.OpGetValidatorRewards)))
102+
str.WriteString(fmt.Sprintf(" - Withdraw all delegators rewards every: %s\n", FormatDuration(p.OpGetDelegatorRewards)))
103+
str.WriteString(fmt.Sprintf(" - Lock rewards every: %s\n", FormatDuration(p.OpLockRewards)))
104+
str.WriteString(fmt.Sprintf(" Ratio of all validators: %s\n", p.OpLockRewardsRatio))
105105

106106
return str.String()
107107
}
@@ -187,27 +187,27 @@ func simulate(t *testing.T, profile SimProfile) {
187187
func TestSimInflation(t *testing.T) {
188188
profile := SimProfile{
189189
ID: "low_staking",
190-
SimDuration: 1*Year + 6*Month,
191-
BlockTimeMin: 120 * time.Second,
192-
BlockTimeMax: 125 * time.Second,
190+
SimDuration: 3*Month,
191+
BlockTimeMin: 300 * time.Second,
192+
BlockTimeMax: 305 * time.Second,
193193
//
194194
MainTokensBalanceWODec: 50000,
195195
BondingTokensBalanceWODec: 500000,
196196
LPTokensBalanceWODec: 100000,
197197
//
198-
Accounts: 300,
198+
Accounts: 150,
199199
POAValidators: 3,
200-
TMValidatorsTotal: 150,
200+
TMValidatorsTotal: 110,
201201
TMValidatorsActive: 100,
202202
//
203203
OpCreateValidator: 3 * time.Hour,
204204
//
205-
OpDelegateBonding: 6 * time.Hour,
206-
OpDelegateBondingAmountRatio: sdk.NewDecWithPrec(40, 2),
205+
OpDelegateBonding: 2 * time.Hour,
206+
OpDelegateBondingAmountRatio: sdk.NewDecWithPrec(50, 2),
207207
OpDelegateBondingMaxSupplyRatio: sdk.NewDecWithPrec(30, 2),
208208
//
209-
OpDelegateLP: 1 * Day,
210-
OpDelegateLPAmountRatio: sdk.NewDecWithPrec(40, 2),
209+
OpDelegateLP: 4 * time.Hour,
210+
OpDelegateLPAmountRatio: sdk.NewDecWithPrec(50, 2),
211211
OpDelegateLPMaxSupplyRatio: sdk.NewDecWithPrec(30, 2),
212212
//
213213
OpRedelegateBonding: 4 * Day,
@@ -222,10 +222,10 @@ func TestSimInflation(t *testing.T) {
222222
OpUndelegateLP: 4 * Day,
223223
OpUndelegateLPAmountRatio: sdk.NewDecWithPrec(15, 2),
224224
//
225-
OpGetValidatorRewards: 1 * Week,
226-
OpGetDelegatorRewards: 1 * Day,
225+
OpGetValidatorRewards: 1 * Month,
226+
OpGetDelegatorRewards: 1 * Month,
227227
//
228-
OpLockRewards: 1 * Week,
228+
OpLockRewards: 4 * Day,
229229
OpLockRewardsRatio: sdk.NewDecWithPrec(30, 2),
230230
}
231231

helpers/tests/simulator/sim.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,19 @@ type Simulator struct {
7171
}
7272

7373
type Counter struct {
74-
BDelegations int64
75-
BUndelegations int64
76-
BRedelegations int64
77-
LPDelegations int64
78-
LPUndelegations int64
79-
LPRedelegations int64
80-
LockedRewards int64
81-
Rewards int64
82-
Commissions int64
83-
RewardsCollected sdk.Coins
84-
CommissionsCollected sdk.Coins
74+
BDelegations int64
75+
BUndelegations int64
76+
BRedelegations int64
77+
LPDelegations int64
78+
LPUndelegations int64
79+
LPRedelegations int64
80+
LockedRewards int64
81+
RewardsWithdraws int64
82+
CommissionWithdraws int64
83+
RewardsCollectedMain sdk.Int
84+
RewardsCollectedStaking sdk.Int
85+
CommissionsCollectedMain sdk.Int
86+
CommissionsCollectedStaking sdk.Int
8587
}
8688

8789
// BuildTmpFilePath builds file name inside of the Simulator working dir.
@@ -338,8 +340,10 @@ func NewSimulator(t *testing.T, workingDir string, defferQueue *DefferOps, optio
338340
cdc: app.MakeCodec(),
339341
defferQueue: defferQueue,
340342
}
341-
s.counter.RewardsCollected = sdk.NewCoins()
342-
s.counter.CommissionsCollected = sdk.NewCoins()
343+
s.counter.RewardsCollectedMain = sdk.ZeroInt()
344+
s.counter.RewardsCollectedStaking = sdk.ZeroInt()
345+
s.counter.CommissionsCollectedMain = sdk.ZeroInt()
346+
s.counter.CommissionsCollectedStaking = sdk.ZeroInt()
343347

344348
defaultGenesis, err := genesis.OverrideGenesisStateDefaults(s.cdc, app.ModuleBasics.DefaultGenesis())
345349
require.NoError(t, err)

helpers/tests/simulator/sim_ops_delegate.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ func delegateOpFindTarget(s *Simulator, bondingD bool, delegateRatio sdk.Dec) (t
118118

119119
// pick an account with max tokens
120120
var delAmt sdk.Int
121-
for _, acc := range s.GetAllAccounts().GetSortedByBalance(denom, true) {
121+
accs := s.GetAllAccounts().GetSortedByBalance(denom, true)
122+
for _, acc := range accs {
122123
// estimate delegation amount
123124
accCoinAmtDec := sdk.NewDecFromInt(acc.Coins.AmountOf(denom))
124125
delAmt = accCoinAmtDec.Mul(delegateRatio).TruncateInt()
@@ -128,6 +129,7 @@ func delegateOpFindTarget(s *Simulator, bondingD bool, delegateRatio sdk.Dec) (t
128129

129130
targetAcc = acc
130131
delCoin = sdk.NewCoin(denom, delAmt)
132+
return
131133
}
132134

133135
return

helpers/tests/simulator/sim_ops_redelegate.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ func redelegateOpFindTarget(s *Simulator, bondingRD bool, rdRatio sdk.Dec) (targ
9898
}
9999

100100
// pick a target account
101-
for _, acc := range s.GetAllAccounts().GetShuffled() {
101+
accs := s.GetAllAccounts().GetShuffled()
102+
for _, acc := range accs {
102103
accValAddr := sdk.ValAddress{}
103104
if acc.IsValOperator() {
104105
accValAddr = acc.OperatedValidator.GetAddress()
@@ -110,7 +111,8 @@ func redelegateOpFindTarget(s *Simulator, bondingRD bool, rdRatio sdk.Dec) (targ
110111
}
111112

112113
// pick a delegation with the highest share
113-
for _, delegation := range acc.GetSortedDelegations(bondingRD, true) {
114+
delegations := acc.GetSortedDelegations(bondingRD, true)
115+
for _, delegation := range delegations {
114116
srcValidatorApplicant := validators.GetByAddress(delegation.ValidatorAddress)
115117

116118
// check if applicant was found (that validator can be unbonded by now)

0 commit comments

Comments
 (0)