code.vegaprotocol.io/vega@v0.79.0/core/integration/features/verified/0061-REWP-delegation_rewards.feature (about) 1 Feature: Staking & Delegation 2 3 Background: 4 Given the following network parameters are set: 5 | name | value | 6 | reward.asset | VEGA | 7 | validators.epoch.length | 10s | 8 | validators.delegation.minAmount | 10 | 9 | reward.staking.delegation.delegatorShare | 0.883 | 10 | reward.staking.delegation.minimumValidatorStake | 100 | 11 | reward.staking.delegation.maxPayoutPerParticipant | 100000 | 12 | reward.staking.delegation.competitionLevel | 1.1 | 13 | reward.staking.delegation.minValidators | 5 | 14 | reward.staking.delegation.optimalStakeMultiplier | 5.0 | 15 16 17 Given time is updated to "2021-08-26T00:00:00Z" 18 Given the average block duration is "2" 19 20 And the validators: 21 | id | staking account balance | 22 | node1 | 1000000 | 23 | node2 | 1000000 | 24 | node3 | 1000000 | 25 | node4 | 1000000 | 26 | node5 | 1000000 | 27 | node6 | 1000000 | 28 | node7 | 1000000 | 29 | node8 | 1000000 | 30 | node9 | 1000000 | 31 | node10 | 1000000 | 32 | node11 | 1000000 | 33 | node12 | 1000000 | 34 | node13 | 1000000 | 35 36 #set up the self delegation of the validators 37 Then the parties submit the following delegations: 38 | party | node id | amount | 39 | node1 | node1 | 10000 | 40 | node2 | node2 | 10000 | 41 | node3 | node3 | 10000 | 42 | node4 | node4 | 10000 | 43 | node5 | node5 | 10000 | 44 | node6 | node6 | 10000 | 45 | node7 | node7 | 10000 | 46 | node8 | node8 | 10000 | 47 | node9 | node9 | 10000 | 48 | node10 | node10 | 10000 | 49 | node11 | node11 | 10000 | 50 | node12 | node12 | 10000 | 51 | node13 | node13 | 10000 | 52 53 And the parties deposit on staking account the following amount: 54 | party | asset | amount | 55 | party1 | VEGA | 10000 | 56 57 Then the parties submit the following delegations: 58 | party | node id | amount | 59 | party1 | node1 | 100 | 60 | party1 | node2 | 200 | 61 | party1 | node3 | 300 | 62 63 #complete the first epoch for the self delegation to take effect 64 Then the network moves ahead "7" blocks 65 66 Scenario: Parties get rewarded for a full epoch of having delegated stake (0061-REWP-006) 67 Desciption: Parties have had their tokens delegated to nodes for a full epoch and get rewarded for the full epoch. 68 69 #advance to the end of the epoch / start next epoch 70 Then the network moves ahead "7" blocks 71 72 #verify validator score 73 Then the validators should have the following val scores for epoch 1: 74 | node id | validator score | normalised score | 75 | node1 | 0.07734 | 0.07734 | 76 | node2 | 0.07810 | 0.07810 | 77 | node3 | 0.07887 | 0.07887 | 78 | node4 | 0.07657 | 0.07657 | 79 80 @CurrentEpoch 81 Scenario: No funds in reward account however validator scores get published (0061-REWP-additional-tests) 82 Desciption: Parties have had their tokens delegated to nodes for a full epoch but the reward account balance is 0 83 84 #advance to the end of the epoch / start next epoch 85 When the network moves ahead "7" blocks 86 87 #verify validator score 88 Then the validators should have the following val scores for epoch 1: 89 | node id | validator score | normalised score | 90 | node1 | 0.07734 | 0.07734 | 91 | node2 | 0.07810 | 0.07810 | 92 | node3 | 0.07887 | 0.07887 | 93 | node4 | 0.07657 | 0.07657 | 94 And the current epoch is "2" 95 Then the network moves ahead "1" epochs 96 97 Scenario: Parties get rewarded for a full epoch of having delegated stake - the reward amount is capped (0061-REWP-additional-tests) 98 Desciption: Parties have had their tokens delegated to nodes for a full epoch and get rewarded for the full epoch. 99 100 #the available amount for the epoch is 50k 101 And the parties deposit on asset's general account the following amount: 102 | party | asset | amount | 103 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 104 And the parties submit the following one off transfers: 105 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 106 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 50000 | 2021-08-26T00:00:01Z | 107 108 #advance to the end of the epoch 109 Then the network moves ahead "7" blocks 110 111 #verify validator score 112 Then the validators should have the following val scores for epoch 1: 113 | node id | validator score | normalised score | 114 | node1 | 0.07734 | 0.07734 | 115 | node2 | 0.07810 | 0.07810 | 116 | node3 | 0.07887 | 0.07887 | 117 | node4 | 0.07657 | 0.07657 | 118 119 #node1 has 10k self delegation + 100 from party1 120 #node2 has 10k self delegation + 200 from party2 121 #node3 has 10k self delegation + 300 from party3 122 #all other nodes have 10k self delegation 123 #party1 gets 0.07734 * 50000 * 0.883 * 100/10100 + 0.07810 * 50000 * 0.883 * 200/10200 + 0.07887 * 50000 * 0.883 * 300/10300 124 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 50000 125 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 50000 126 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 50000 127 #node4 - node13 gets: 0.07657 * 50000 128 And the parties receive the following reward for epoch 1: 129 | party | asset | amount | 130 | party1 | VEGA | 201 | 131 | node1 | VEGA | 3832 | 132 | node2 | VEGA | 3837 | 133 | node3 | VEGA | 3841 | 134 | node4 | VEGA | 3828 | 135 | node5 | VEGA | 3828 | 136 | node6 | VEGA | 3828 | 137 | node8 | VEGA | 3828 | 138 | node10 | VEGA | 3828 | 139 | node11 | VEGA | 3828 | 140 | node12 | VEGA | 3828 | 141 | node13 | VEGA | 3828 | 142 143 Scenario: Parties request to undelegate at the end of the epoch. They get fully rewarded for the current epoch and not get rewarded in the following epoch for the undelegated stake (0061-REWP-additional-tests) 144 Desciption: Parties have had their tokens delegated to nodes for a full epoch and get rewarded for the full epoch. During the epoch however they request to undelegate at the end of the epoch part of their stake. On the following epoch they are not rewarded for the undelegated stake. 145 146 Then the parties submit the following undelegations: 147 | party | node id | amount | when | 148 | party1 | node2 | 150 | end of epoch | 149 | party1 | node3 | 300 | end of epoch | 150 151 And the parties deposit on asset's general account the following amount: 152 | party | asset | amount | 153 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 154 And the parties submit the following one off transfers: 155 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 156 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 50000 | 2021-08-26T00:00:01Z | 157 #advance to the end of the epoch 158 When the network moves ahead "7" blocks 159 160 #node1 has 10k self delegation + 100 from party1 161 #node2 has 10k self delegation + 200 from party2 162 #node3 has 10k self delegation + 300 from party3 163 #all other nodes have 10k self delegation 164 #party1 gets 0.07734 * 50000 * 0.883 * 100/10100 + 0.07810 * 50000 * 0.883 * 200/10200 + 0.07887 * 50000 * 0.883 * 300/10300 165 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 50000 166 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 50000 167 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 50000 168 #node4 - node13 gets: 0.07657 * 50000 169 And the parties receive the following reward for epoch 1: 170 | party | asset | amount | 171 | party1 | VEGA | 201 | 172 | node1 | VEGA | 3832 | 173 | node2 | VEGA | 3837 | 174 | node3 | VEGA | 3841 | 175 | node4 | VEGA | 3828 | 176 | node5 | VEGA | 3828 | 177 | node6 | VEGA | 3828 | 178 | node7 | VEGA | 3828 | 179 | node8 | VEGA | 3828 | 180 | node9 | VEGA | 3828 | 181 | node10 | VEGA | 3828 | 182 | node11 | VEGA | 3828 | 183 | node12 | VEGA | 3828 | 184 | node13 | VEGA | 3828 | 185 186 And the parties deposit on asset's general account the following amount: 187 | party | asset | amount | 188 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 189 And the parties submit the following one off transfers: 190 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 191 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 25000 | 2021-08-26T00:00:01Z | 192 193 #advance to the beginning and end of the following epoch 194 When the network moves ahead "7" blocks 195 196 #verify validator score 197 Then the validators should have the following val scores for epoch 2: 198 | node id | validator score | normalised score | 199 | node1 | 0.07760 | 0.07760 | 200 | node2 | 0.07722 | 0.07722 | 201 | node3 | 0.07683 | 0.07683 | 202 203 #node1 has 10k self delegation + 100 from party1 204 #node2 has 10k self delegation + 50 from party2 205 #all other nodes have 10k self delegation 206 #party1 gets 0.0776 * 25004 * 0.883 * 100/10100 + 0.07722 * 25004 * 0.883 * 50/10050 207 #node1 gets: (1 - 0.883 * 100/10100) * 0.0776 * 25004 208 #node2 gets: (1 - 0.883 * 50/10050) * 0.07722 * 25004 209 #node4 - node13 gets: 0.07683 * 25004 210 And the parties receive the following reward for epoch 2: 211 | party | asset | amount | 212 | party1 | VEGA | 24 | 213 | node1 | VEGA | 1923 | 214 | node2 | VEGA | 1922 | 215 | node3 | VEGA | 1921 | 216 | node4 | VEGA | 1921 | 217 | node5 | VEGA | 1921 | 218 | node6 | VEGA | 1921 | 219 | node7 | VEGA | 1921 | 220 | node8 | VEGA | 1921 | 221 | node9 | VEGA | 1921 | 222 | node10 | VEGA | 1921 | 223 | node11 | VEGA | 1921 | 224 | node12 | VEGA | 1921 | 225 | node13 | VEGA | 1921 | 226 227 Scenario: Parties request to undelegate now during the epoch. They only get rewarded for the current epoch for the fraction that remained for the whole duration (0061-REWP-additional-tests) 228 Desciption: Parties have had their tokens delegated to nodes for a full epoch and get rewarded for the full epoch. During the epoch however they request to undelegate at the end of the epoch part of their stake. On the following epoch they are not rewarded for the undelegated stake. 229 230 Then the parties submit the following undelegations: 231 | party | node id | amount | when | 232 | party1 | node2 | 150 | now | 233 | party1 | node3 | 300 | now | 234 235 And the parties deposit on asset's general account the following amount: 236 | party | asset | amount | 237 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 238 And the parties submit the following one off transfers: 239 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 240 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 50000 | 2021-08-26T00:00:01Z | 241 242 #advance to the end of the epoch 243 When the network moves ahead "7" blocks 244 245 #verify validator score 246 Then the validators should have the following val scores for epoch 1: 247 | node id | validator score | normalised score | 248 | node1 | 0.07760 | 0.07760 | 249 | node2 | 0.07722 | 0.07722 | 250 | node3 | 0.07683 | 0.07683 | 251 252 #node1 has 10k self delegation + 100 from party1 253 #node2 has 10k self delegation + 50 from party2 254 #all other nodes have 10k self delegation 255 256 #party1 gets 0.07760 * 50000 * 0.883 * 100/10100 + 0.07722 * 50000 * 0.883 * 50/10050 257 #node1 gets: (1 - 0.883 * 100/10100) * 0.07760 * 50000 258 #node2 gets: (1 - 0.883 * 50/10050) * 0.07722 * 50000 259 #node3 - node13 gets: 0.07683 * 50000 260 And the parties receive the following reward for epoch 1: 261 | party | asset | amount | 262 | party1 | VEGA | 49 | 263 | node1 | VEGA | 3846 | 264 | node2 | VEGA | 3843 | 265 | node3 | VEGA | 3841 | 266 | node4 | VEGA | 3841 | 267 | node5 | VEGA | 3841 | 268 | node6 | VEGA | 3841 | 269 | node7 | VEGA | 3841 | 270 | node8 | VEGA | 3841 | 271 | node9 | VEGA | 3841 | 272 | node10 | VEGA | 3841 | 273 | node11 | VEGA | 3841 | 274 | node12 | VEGA | 3841 | 275 | node13 | VEGA | 3841 | 276 277 Scenario: Parties withdraw from their staking account during an epoch once having active delegations - they should not get rewarded for those uncovered delegations (0061-REWP-additional-tests) 278 Desciption: Parties have active delegations on epoch 1 and withdraw stake from the staking account. They should only get rewarded for any delegation that still has cover 279 280 #party1 has a balance of 10k tokens in their staking account and an active delegation in this epoch of 600. By withdrawing 9850, 450 of their delegation needs to be revoked and they should only get rewarded for the 150 tokens 281 #NB: the undelegation is done proportionally to the stake they have in each node, so for example party1 has 100, 200, 300 in nodes 1-3 respectively so 282 #after undelegation they will have 25, 50, 75 in nodes 1-3 respectively 283 Given the parties withdraw from staking account the following amount: 284 | party | asset | amount | 285 | party1 | VEGA | 9850 | 286 287 And the parties deposit on asset's general account the following amount: 288 | party | asset | amount | 289 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 290 And the parties submit the following one off transfers: 291 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 292 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 50000 | 2021-08-26T00:00:01Z | 293 294 #advance to the end of the epoch 295 When the network moves ahead "7" blocks 296 297 #verify validator score 298 Then the validators should have the following val scores for epoch 1: 299 | node id | validator score | normalised score | 300 | node1 | 0.07703 | 0.07703 | 301 | node2 | 0.07722 | 0.07722 | 302 | node3 | 0.07741 | 0.07741 | 303 | node4 | 0.07683 | 0.07683 | 304 305 #node1 has 10k self delegation + 25 from party1 306 #node2 has 10k self delegation + 50 from party1 307 #node3 has 10k self delegation + 75 from party1 308 #all other nodes have 10k self delegation 309 310 #party1 gets 0.07703 * 50000 * 0.883 * 25/10025 + 0.07722 * 50000 * 0.883 * 50/10050 + 0.07741 * 50000 * 0.883 * 75/10075 311 #node1 gets: (1 - 0.883 * 25/10025) * 0.07703 * 50000 312 #node2 gets: (1 - 0.883 * 50/10050) * 0.07722 * 50000 313 #node3 gets: (1 - 0.883 * 75/10075) * 0.07741 * 50000 314 #node4 - node13 get: 0.07683 * 50000 315 316 And the parties receive the following reward for epoch 1: 317 | party | asset | amount | 318 | party1 | VEGA | 49 | 319 | node1 | VEGA | 3842 | 320 | node2 | VEGA | 3843 | 321 | node3 | VEGA | 3845 | 322 | node4 | VEGA | 3841 | 323 | node5 | VEGA | 3841 | 324 | node6 | VEGA | 3841 | 325 | node7 | VEGA | 3841 | 326 | node8 | VEGA | 3841 | 327 | node9 | VEGA | 3841 | 328 | node10 | VEGA | 3841 | 329 | node11 | VEGA | 3841 | 330 | node12 | VEGA | 3841 | 331 | node13 | VEGA | 3841 | 332 333 Then "party1" should have vesting account balance of "49" for asset "VEGA" 334 Then "node1" should have vesting account balance of "3842" for asset "VEGA" 335 336 Scenario: Party has delegation unfunded for majority of the epoch (except for begining and end) - should get no rewards (0061-REWP-additional-tests) 337 Given the parties withdraw from staking account the following amount: 338 | party | asset | amount | 339 | party1 | VEGA | 9999 | 340 341 When the network moves ahead "6" blocks 342 343 And the parties deposit on staking account the following amount: 344 | party | asset | amount | 345 | party1 | VEGA | 9999 | 346 347 #advance to the end of the epoch 348 When the network moves ahead "1" blocks 349 350 And the parties receive the following reward for epoch 1: 351 | party | asset | amount | 352 | party1 | VEGA | 0 | 353 354 Scenario: A party changes delegation from one validator to another in the same epoch 355 Description: A party can change delegation from one validator to another 356 When the network moves ahead "7" blocks 357 358 #now request to undelegate from node2 and node3 359 And the parties submit the following undelegations: 360 | party | node id | amount | when | 361 | party1 | node2 | 180 | end of epoch | 362 | party1 | node3 | 300 | end of epoch | 363 Then the parties submit the following delegations: 364 | party | node id | amount | 365 | party1 | node1 | 180 | 366 | party1 | node1 | 190 | 367 368 #advance to the end of the epoch for the delegation to become effective 369 And the parties deposit on asset's general account the following amount: 370 | party | asset | amount | 371 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 372 And the parties submit the following one off transfers: 373 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 374 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 25004 | 2021-08-26T00:00:01Z | 375 Then the network moves ahead "7" blocks 376 377 #verify validator score 378 Then the validators should have the following val scores for epoch 2: 379 | node id | validator score | normalised score | 380 | node1 | 0.07734 | 0.07734 | 381 | node2 | 0.07810 | 0.07810 | 382 | node3 | 0.07887 | 0.07887 | 383 | node4 | 0.07657 | 0.07657 | 384 385 #node1 has 10k self delegation + 100 from party1 386 #node2 has 10k self delegation + 200 from party1 387 #node3 has 10k self delegation + 300 from party1 388 #all other nodes have 10k self delegation 389 #party1 gets 0.07734 * 25004 * 0.883 * 100/10100 + 0.07810 * 25004 * 0.883 * 200/10200 + 0.07887 * 25004 * 0.883 * 300/10300 390 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 25004 391 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 25004 392 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 25004 393 #node4 - node13 gets: 0.07657 * 25004 394 395 And the parties receive the following reward for epoch 2: 396 | party | asset | amount | 397 | party1 | VEGA | 99 | 398 | node1 | VEGA | 1916 | 399 | node2 | VEGA | 1919 | 400 | node3 | VEGA | 1921 | 401 | node4 | VEGA | 1914 | 402 | node5 | VEGA | 1914 | 403 | node6 | VEGA | 1914 | 404 | node7 | VEGA | 1914 | 405 | node8 | VEGA | 1914 | 406 | node9 | VEGA | 1914 | 407 | node10 | VEGA | 1914 | 408 | node11 | VEGA | 1914 | 409 | node12 | VEGA | 1914 | 410 | node13 | VEGA | 1914 | 411 Then the parties should have the following delegation balances for epoch 3: 412 | party | node id | amount | 413 | party1 | node1 | 470 | 414 | party1 | node2 | 20 | 415 | party1 | node3 | 0 | 416 417 #advance to the beginning and end of the following epoch 418 And the parties deposit on asset's general account the following amount: 419 | party | asset | amount | 420 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 421 And the parties submit the following one off transfers: 422 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 423 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 12497 | 2021-08-26T00:00:01Z | 424 Then the network moves ahead "7" blocks 425 426 #verify validator score 427 Then the validators should have the following val scores for epoch 3: 428 | node id | validator score | normalised score | 429 | node1 | 0.08024 | 0.08024 | 430 | node2 | 0.07679 | 0.07679 | 431 | node3 | 0.07663 | 0.07663 | 432 433 #node1 has 10k self delegation + 470 from party1 434 #node2 has 10k self delegation + 20 from party1 435 #node3 has 10k self delegation + 0 from party1 436 #all other nodes have 10k self delegation 437 #party1 gets 0.08024 * 12506 * 0.883 * 470/10470 + 0.07679 * 12506 * 0.883 * 20/10020 438 #node1 gets: (1 - 0.883 * 470/10470) * 0.08024 * 12506 439 #node2 gets: (1 - 0.883 * 20/10020) * 0.07679 * 12506 440 #node3 gets: (1 - 0.883 * 0/1000) * 0.07663 * 12506 441 #node4 - node13 gets: 0.07663 * 12506 442 443 And the parties receive the following reward for epoch 3: 444 | party | asset | amount | 445 | party1 | VEGA | 40 | 446 | node1 | VEGA | 963 | 447 | node2 | VEGA | 958 | 448 | node3 | VEGA | 958 | 449 | node4 | VEGA | 958 | 450 | node5 | VEGA | 958 | 451 | node6 | VEGA | 958 | 452 | node7 | VEGA | 958 | 453 | node8 | VEGA | 958 | 454 | node9 | VEGA | 958 | 455 | node10 | VEGA | 958 | 456 | node11 | VEGA | 958 | 457 | node12 | VEGA | 958 | 458 | node13 | VEGA | 958 | 459 460 Scenario: A party can request delegate and undelegate from the same node at the same epoch such that the request can balance each other without affecting the actual delegate balance (0061-REWP-additional-tests) 461 Description: party requests to delegate to node1 at the end of the epoch and regrets it and undelegate the whole amount to delegate it to another node 462 And the parties submit the following undelegations: 463 | party | node id | amount | when | 464 | party1 | node1 | 100 | end of epoch | 465 And the parties submit the following delegations: 466 | party | node id | amount | 467 | party1 | node4 | 100 | 468 #advance to the end of the epoch 469 And the parties deposit on asset's general account the following amount: 470 | party | asset | amount | 471 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 472 And the parties submit the following one off transfers: 473 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 474 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 50000 | 2021-08-26T00:00:01Z | 475 Then the network moves ahead "7" blocks 476 #node1 has 10k self delegation + 100 from party1 477 #node2 has 10k self delegation + 200 from party1 478 #node3 has 10k self delegation + 300 from party1 479 #all other nodes have 10k self delegation 480 #party1 gets 0.07734 * 50000 * 0.883 * 100/10100 + 0.07810 * 50000 * 0.883 * 200/10200 + 0.07887 * 50000 * 0.883 * 300/10300 481 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 50000 482 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 50000 483 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 50000 484 #node4 - node13 gets: 0.07657 * 50000 485 And the parties receive the following reward for epoch 1: 486 | party | asset | amount | 487 | party1 | VEGA | 201 | 488 | node1 | VEGA | 3832 | 489 | node2 | VEGA | 3837 | 490 | node3 | VEGA | 3841 | 491 | node4 | VEGA | 3828 | 492 | node5 | VEGA | 3828 | 493 | node6 | VEGA | 3828 | 494 | node7 | VEGA | 3828 | 495 | node8 | VEGA | 3828 | 496 | node9 | VEGA | 3828 | 497 | node10 | VEGA | 3828 | 498 | node11 | VEGA | 3828 | 499 | node12 | VEGA | 3828 | 500 | node13 | VEGA | 3828 | 501 Then the parties should have the following delegation balances for epoch 2: 502 | party | node id | amount | 503 | party1 | node1 | 0 | 504 | party1 | node4 | 100 | 505 #advance to the beginning and end of the following epoch 506 507 And the parties deposit on asset's general account the following amount: 508 | party | asset | amount | 509 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 510 And the parties submit the following one off transfers: 511 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 512 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 24995 | 2021-08-26T00:00:01Z | 513 514 Then the network moves ahead "7" blocks 515 #verify validator score 516 Then the validators should have the following val scores for epoch 2: 517 | node id | validator score | normalised score | 518 | node1 | 0.07657 | 0.07657 | 519 | node2 | 0.07810 | 0.07810 | 520 | node3 | 0.07887 | 0.07887 | 521 | node4 | 0.07734 | 0.07734 | 522 | node5 | 0.07657 | 0.07657 | 523 #node1 has 10k self delegation 524 #node2 has 10k self delegation + 200 from party1 525 #node3 has 10k self delegation + 300 from party1 526 #node4 has 10k self delegation + 100 from party1 527 #all other nodes have 10k self delegation 528 #party1 gets 0.07657 * 25004 * 0.883 * 0/10100 + 0.07810 * 25004 * 0.883 * 200/10200 + 0.07887 * 25004 * 0.883 * 300/10300 + 0.07734 * 25004 * 0.883 * 100/10100 529 #node1 gets: (1 - 0.883 * 0/10100) * 0.07657 * 25004 530 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 25004 531 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 25004 532 #node4 gets: (1 - 0.883 * 100/10100) * 0.07734 * 25004 533 #node5 - node13 gets: 0.07657 * 25004 534 And the parties receive the following reward for epoch 2: 535 | party | asset | amount | 536 | party1 | VEGA | 99 | 537 | node1 | VEGA | 1914 | 538 | node2 | VEGA | 1919 | 539 | node3 | VEGA | 1921 | 540 | node4 | VEGA | 1916 | 541 | node5 | VEGA | 1914 | 542 | node6 | VEGA | 1914 | 543 | node7 | VEGA | 1914 | 544 | node8 | VEGA | 1914 | 545 | node9 | VEGA | 1914 | 546 | node10 | VEGA | 1914 | 547 | node11 | VEGA | 1914 | 548 | node12 | VEGA | 1914 | 549 | node13 | VEGA | 1914 | 550 551 Scenario: A party has active delegations and submits an undelegate request followed by a delegation request that covers only part of the undelegation such that the undelegation still takes place (0061-REWP-additional-tests) 552 Description: A party delegated tokens to node1 at previous epoch such that the delegations is now active and is requesting to undelegate some of the tokens at the end of the current epoch. Then regret some of it and submit a delegation request that undoes some of the undelegation but still some of it remains. 553 554 #advance to the end of the epoch 555 Then the network moves ahead "7" blocks 556 Then the parties submit the following undelegations: 557 | party | node id | amount | when | 558 | party1 | node1 | 100 | end of epoch | 559 And the parties submit the following delegations: 560 | party | node id | amount | 561 | party1 | node1 | 50 | 562 563 And the parties deposit on asset's general account the following amount: 564 | party | asset | amount | 565 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 566 And the parties submit the following one off transfers: 567 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 568 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 25004 | 2021-08-26T00:00:01Z | 569 570 When the network moves ahead "7" blocks 571 #verify validator score 572 Then the validators should have the following val scores for epoch 2: 573 | node id | validator score | normalised score | 574 | node1 | 0.07734 | 0.07734 | 575 | node2 | 0.07810 | 0.07810 | 576 | node3 | 0.07887 | 0.07887 | 577 | node4 | 0.07657 | 0.07657 | 578 #node1 has 10k self delegation + 100 from party1 579 #node2 has 10k self delegation + 200 from party1 580 #node3 has 10k self delegation + 300 from party1 581 #all other nodes have 10k self delegation 582 #party1 gets 0.07734 * 25004 * 0.883 * 100/10100 + 0.07810 * 25004 * 0.883 * 200/10200 + 0.07887 * 25004 * 0.883 * 300/10300 583 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 25004 584 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 25004 585 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 25004 586 #node4 - node13 gets: 0.07657 * 25004 587 And the parties receive the following reward for epoch 2: 588 | party | asset | amount | 589 | party1 | VEGA | 99 | 590 | node1 | VEGA | 1916 | 591 | node2 | VEGA | 1919 | 592 | node3 | VEGA | 1921 | 593 | node4 | VEGA | 1914 | 594 | node5 | VEGA | 1914 | 595 | node6 | VEGA | 1914 | 596 | node7 | VEGA | 1914 | 597 | node8 | VEGA | 1914 | 598 | node9 | VEGA | 1914 | 599 | node10 | VEGA | 1914 | 600 | node11 | VEGA | 1914 | 601 | node12 | VEGA | 1914 | 602 | node13 | VEGA | 1914 | 603 And the parties should have the following delegation balances for epoch 3: 604 | party | node id | amount | 605 | party1 | node1 | 50 | 606 #advance to the beginning and end of the following epoch 607 608 And the parties deposit on asset's general account the following amount: 609 | party | asset | amount | 610 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 611 And the parties submit the following one off transfers: 612 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 613 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 12501 | 2021-08-26T00:00:01Z | 614 615 When the network moves ahead "7" blocks 616 #verify validator score 617 Then the validators should have the following val scores for epoch 3: 618 | node id | validator score | normalised score | 619 | node1 | 0.07698 | 0.07698 | 620 | node2 | 0.07813 | 0.07813 | 621 | node3 | 0.07890 | 0.07890 | 622 | node4 | 0.07660 | 0.07660 | 623 #node1 has 10k self delegation + 50 from party1 624 #node2 has 10k self delegation + 200 from party1 625 #node3 has 10k self delegation + 300 from party1 626 #all other nodes have 10k self delegation 627 #party1 gets 0.07698 * 12506 * 0.883 * 50/10050 + 0.07813 * 12506 * 0.883 * 200/10200 + 0.07890 * 12506 * 0.883 * 300/10300 628 #node1 gets: (1 - 0.883 * 50/10050) * 0.07698 * 12506 629 #node2 gets: (1 - 0.883 * 200/10200) * 0.07813 * 12506 630 #node3 gets: (1 - 0.883 * 300/10300) * 0.07890 * 12506 631 #node4 - node13 gets: 0.07660 * 12506 632 And the parties receive the following reward for epoch 3: 633 | party | asset | amount | 634 | party1 | VEGA | 45 | 635 | node1 | VEGA | 958 | 636 | node2 | VEGA | 960 | 637 | node3 | VEGA | 961 | 638 | node4 | VEGA | 958 | 639 | node5 | VEGA | 958 | 640 | node6 | VEGA | 958 | 641 | node7 | VEGA | 958 | 642 | node8 | VEGA | 958 | 643 | node9 | VEGA | 958 | 644 | node10 | VEGA | 958 | 645 | node11 | VEGA | 958 | 646 | node12 | VEGA | 958 | 647 | node13 | VEGA | 958 | 648 649 Scenario: Parties get rewarded for a full epoch of having delegated stake - the reward amount is capped per participant (0061-REWP-additional-tests) 650 Description: Parties have had their tokens delegated to nodes for a full epoch and get rewarded for the full epoch and the reward amount per participant is capped 651 652 Given the following network parameters are set: 653 | name | value | 654 | reward.staking.delegation.maxPayoutPerParticipant | 3000 | 655 #the reward amount for each participant per epoch is capped to 3k by maxPayoutPerParticipant 656 #advance to the end of the epoch 657 And the parties deposit on asset's general account the following amount: 658 | party | asset | amount | 659 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 660 And the parties submit the following one off transfers: 661 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 662 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 50000 | 2021-08-26T00:00:01Z | 663 When the network moves ahead "7" blocks 664 #verify validator score 665 Then the validators should have the following val scores for epoch 1: 666 | node id | validator score | normalised score | 667 | node1 | 0.07734 | 0.07734 | 668 | node2 | 0.07810 | 0.07810 | 669 | node3 | 0.07887 | 0.07887 | 670 | node4 | 0.07657 | 0.07657 | 671 #node1 has 10k self delegation + 100 from party1 672 #node2 has 10k self delegation + 200 from party2 673 #node3 has 10k self delegation + 300 from party3 674 #all other nodes have 10k self delegation 675 #party1 gets 0.07734 * 50000 * 0.883 * 100/10100 + 0.07810 * 50000 * 0.883 * 200/10200 + 0.07887 * 50000 * 0.883 * 300/10300 676 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 50000 677 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 50000 678 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 50000 679 #node4 - node13 gets: 0.07657 * 50000 680 And the parties receive the following reward for epoch 1: 681 | party | asset | amount | 682 | party1 | VEGA | 201 | 683 | node1 | VEGA | 3000 | 684 | node2 | VEGA | 3000 | 685 | node3 | VEGA | 3000 | 686 | node4 | VEGA | 3000 | 687 | node5 | VEGA | 3000 | 688 | node6 | VEGA | 3000 | 689 | node7 | VEGA | 3000 | 690 | node8 | VEGA | 3000 | 691 | node9 | VEGA | 3000 | 692 | node10 | VEGA | 3000 | 693 | node11 | VEGA | 3000 | 694 | node12 | VEGA | 3000 | 695 | node13 | VEGA | 3000 | 696 697 Scenario: Topping up the reward account and confirming reward transfers are correctly refelected in parties account balances (0061-REWP-additional-tests) 698 Description: Topping up the reward account and confirming reward transfers are correctly refelected in parties account balances when they get rewarded for a full epoch of having delegated stake 699 #advance to the end of the epoch 700 And the parties deposit on asset's general account the following amount: 701 | party | asset | amount | 702 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 703 And the parties submit the following one off transfers: 704 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 705 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 25000 | 2021-08-26T00:00:01Z | 706 When the network moves ahead "7" blocks 707 708 #verify validator score 709 Then the validators should have the following val scores for epoch 1: 710 | node id | validator score | normalised score | 711 | node1 | 0.07734 | 0.07734 | 712 | node2 | 0.07810 | 0.07810 | 713 | node3 | 0.07887 | 0.07887 | 714 | node4 | 0.07657 | 0.07657 | 715 716 #node1 has 10k self delegation + 100 from party1 717 #node2 has 10k self delegation + 200 from party2 718 #node3 has 10k self delegation + 300 from party3 719 #all other nodes have 10k self delegation 720 #party1 gets 0.07734 * 25000 * 0.883 * 100/10100 + 0.07810 * 25000 * 0.883 * 200/10200 + 0.07887 * 25000 * 0.883 * 300/10300 721 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 25000 722 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 25000 723 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 25000 724 #node4 - node13 gets: 0.07657 * 25000 725 726 And the parties receive the following reward for epoch 1: 727 | party | asset | amount | 728 | party1 | VEGA | 99 | 729 | node1 | VEGA | 1916 | 730 | node2 | VEGA | 1918 | 731 | node3 | VEGA | 1920 | 732 | node4 | VEGA | 1914 | 733 | node5 | VEGA | 1914 | 734 | node6 | VEGA | 1914 | 735 | node7 | VEGA | 1914 | 736 | node8 | VEGA | 1914 | 737 | node9 | VEGA | 1914 | 738 | node10 | VEGA | 1914 | 739 | node11 | VEGA | 1914 | 740 | node12 | VEGA | 1914 | 741 | node13 | VEGA | 1914 | 742 743 Then "party1" should have vesting account balance of "99" for asset "VEGA" 744 Then "node1" should have vesting account balance of "1916" for asset "VEGA" 745 746 And the parties deposit on asset's general account the following amount: 747 | party | asset | amount | 748 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 749 And the parties submit the following one off transfers: 750 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 751 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 49992 | 2021-08-26T00:00:01Z | 752 753 When the network moves ahead "7" blocks 754 755 #verify validator score 756 Then the validators should have the following val scores for epoch 2: 757 | node id | validator score | normalised score | 758 | node1 | 0.07734 | 0.07734 | 759 | node2 | 0.07810 | 0.07810 | 760 | node3 | 0.07887 | 0.07887 | 761 | node4 | 0.07657 | 0.07657 | 762 763 #node1 has 10k self delegation + 100 from party1 764 #node2 has 10k self delegation + 200 from party2 765 #node3 has 10k self delegation + 300 from party3 766 #all other nodes have 10k self delegation 767 #party1 gets 0.07734 * 50000 * 0.883 * 100/10100 + 0.07810 * 50000 * 0.883 * 200/10200 + 0.07887 * 50000 * 0.883 * 300/10300 768 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 50000 769 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 50000 770 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 50000 771 #node4 - node13 gets: 0.07657 * 50000 772 773 And the parties receive the following reward for epoch 2: 774 | party | asset | amount | 775 | party1 | VEGA | 201 | 776 | node1 | VEGA | 3832 | 777 | node2 | VEGA | 3837 | 778 | node3 | VEGA | 3841 | 779 | node4 | VEGA | 3828 | 780 | node5 | VEGA | 3828 | 781 | node6 | VEGA | 3828 | 782 | node8 | VEGA | 3828 | 783 | node10 | VEGA | 3828 | 784 | node11 | VEGA | 3828 | 785 | node12 | VEGA | 3828 | 786 | node13 | VEGA | 3828 | 787 788 Then "party1" should have vesting account balance of "300" for asset "VEGA" 789 Then "node1" should have vesting account balance of "5748" for asset "VEGA" 790 791 Scenario: Parties get the smallest reward amount of 1 when the reward pot is smallest (0061-REWP-additional-tests) 792 Description: Validators get the smallest reward amount of 1 and delegator earns nothing 793 # Explanation - 1 vega is actually 1000000000000000000 so when reward account = 27 then that’s a very very very small fraction of a vega. Hence noone gets anything because the calculation is made in integers so anything that ends up being less than one is 0 794 795 Given the parties deposit on asset's general account the following amount: 796 | party | asset | amount | 797 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | VEGA | 100000 | 798 And the parties submit the following one off transfers: 799 | id | from | from_account_type | to | to_account_type | asset | amount | delivery_time | 800 | 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | 0000000000000000000000000000000000000000000000000000000000000000 | ACCOUNT_TYPE_GLOBAL_REWARD | VEGA | 14 | 2021-08-26T00:00:01Z | 801 802 #advance to the end of the epoch 803 When the network moves ahead "7" blocks 804 805 #verify validator score 806 Then the validators should have the following val scores for epoch 1: 807 | node id | validator score | normalised score | 808 | node1 | 0.07734 | 0.07734 | 809 | node2 | 0.07810 | 0.07810 | 810 | node3 | 0.07887 | 0.07887 | 811 | node4 | 0.07657 | 0.07657 | 812 813 #node1 has 10k self delegation + 100 from party1 814 #node2 has 10k self delegation + 200 from party2 815 #node3 has 10k self delegation + 300 from party3 816 #all other nodes have 10k self delegation 817 #party1 gets 0.07734 * 28 * 0.883 * 100/10100 + 0.07810 * 28 * 0.883 * 200/10200 + 0.07887 * 28 * 0.883 * 300/10300 818 #node1 gets: (1 - 0.883 * 100/10100) * 0.07734 * 28 819 #node2 gets: (1 - 0.883 * 200/10200) * 0.07810 * 28 820 #node3 gets: (1 - 0.883 * 300/10300) * 0.07887 * 28 821 #node4 - node13 gets: 0.07657 * 28 822 823 And the parties receive the following reward for epoch 1: 824 | party | asset | amount | 825 | party1 | VEGA | 0 | 826 | node1 | VEGA | 1 | 827 | node2 | VEGA | 1 | 828 | node3 | VEGA | 1 | 829 | node4 | VEGA | 1 | 830 | node5 | VEGA | 1 | 831 | node6 | VEGA | 1 | 832 | node7 | VEGA | 1 | 833 | node8 | VEGA | 1 | 834 | node9 | VEGA | 1 | 835 | node10 | VEGA | 1 | 836 | node11 | VEGA | 1 | 837 | node12 | VEGA | 1 | 838 | node13 | VEGA | 1 | 839 840 Then "node1" should have vesting account balance of "1" for asset "VEGA"