code.vegaprotocol.io/vega@v0.79.0/core/integration/features/delegation/reconciliation.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                           | 120s   |
     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        | network.markPriceUpdateMaximumFrequency           | 0s     |
    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   | 700    |
    56        | party2 | VEGA   | 20000  |
    57        | party3 | VEGA   | 500    |
    58  
    59      When the parties submit the following delegations:
    60      | party  | node id  | amount |
    61      | party1 |  node1   |  100   | 
    62      | party1 |  node2   |  200   |       
    63      | party1 |  node3   |  300   |     
    64      | party2 |  node2   |  400   |     
    65      | party2 |  node3   |  500   |     
    66      | party2 |  node4   |  600   |     
    67  
    68      #complete the first epoch for the self delegation to take effect
    69      Then the network moves ahead "63" blocks
    70  
    71  
    72    Scenario: Party submits delegations which by the time they are processed are uncovered
    73      Description: when the party submits the delegation request they have cover for all but by the time the epoch ends they only leave enough to cover some of the delegations
    74      
    75      When the parties submit the following delegations:
    76      | party  | node id  | amount |
    77      | party3 |  node1   |  100   | 
    78      | party3 |  node2   |  100   |       
    79      | party3 |  node3   |  100   |    
    80      | party3 |  node4   |  100   |    
    81      | party3 |  node5   |  100   |    
    82  
    83      Then the parties should have the following delegation balances for epoch 2:
    84      | party  | node id  | amount |
    85      | party3 |  node1   | 100    | 
    86      | party3 |  node2   | 100    |       
    87      | party3 |  node3   | 100    |   
    88      | party3 |  node4   | 100    |   
    89      | party3 |  node5   | 100    |   
    90      
    91      Given the parties withdraw from staking account the following amount:  
    92      | party  | asset  | amount |
    93      | party3 | VEGA   |  350   | 
    94  
    95      When the network moves ahead "63" blocks    
    96      Then the parties should have the following delegation balances for epoch 2:
    97      | party  | node id  | amount |
    98      | party3 |  node1   | 30     | 
    99      | party3 |  node2   | 30     |       
   100      | party3 |  node3   | 30     |   
   101      | party3 |  node4   | 30     |   
   102      | party3 |  node5   | 30     |   
   103  
   104    Scenario: Party dissociation gets reconciled during the epoch
   105      Description: A party with delegation dissociates all of their tokens which causes their whole delegation to be undone within 30 seconds and reflected before the epoch ends
   106      
   107      Given the parties withdraw from staking account the following amount:  
   108      | party  | asset  | amount |
   109      | party1 | VEGA   |  700   | 
   110  
   111      Then the parties should have the following delegation balances for epoch 1:
   112      | party  | node id  | amount |
   113      | party1 |  node1   | 100    | 
   114      | party1 |  node2   | 200    |       
   115      | party1 |  node3   | 300    |   
   116      | party2 |  node2   | 400    |   
   117      | party2 |  node3   | 500    |   
   118      | party2 |  node4   | 600    |  
   119  
   120      When the network moves ahead "16" blocks
   121      Then the parties should have the following delegation balances for epoch 1:
   122      | party  | node id  | amount |
   123      | party1 |  node1   | 0      | 
   124      | party1 |  node2   | 0      |       
   125      | party1 |  node3   | 0      |   
   126      | party2 |  node2   | 400    |   
   127      | party2 |  node3   | 500    |   
   128      | party2 |  node4   | 600    |  
   129  
   130      Then the parties should have the following delegation balances for epoch 2:
   131      | party  | node id  | amount |
   132      | party1 |  node1   | 0      | 
   133      | party1 |  node2   | 0      |       
   134      | party1 |  node3   | 0      |  
   135      | party2 |  node2   | 400    |   
   136      | party2 |  node3   | 500    |   
   137      | party2 |  node4   | 600    |   
   138  
   139      When the network moves ahead "47" blocks
   140      Then the parties should have the following delegation balances for epoch 1:
   141      | party  | node id  | amount |
   142      | party1 |  node1   | 0      | 
   143      | party1 |  node2   | 0      |       
   144      | party1 |  node3   | 0      |   
   145      | party2 |  node2   | 400    |   
   146      | party2 |  node3   | 500    |   
   147      | party2 |  node4   | 600    |  
   148  
   149      Then the parties should have the following delegation balances for epoch 2:
   150      | party  | node id  | amount |
   151      | party1 |  node1   | 0      | 
   152      | party1 |  node2   | 0      |       
   153      | party1 |  node3   | 0      |   
   154      | party2 |  node2   | 400    |   
   155      | party2 |  node3   | 500    |   
   156      | party2 |  node4   | 600    |  
   157  
   158    Scenario: Party dissociation gets reconciled during the epoch incrementally
   159      Description: A party with delegation dissociates some tokens in multiple withdrawals which causes their whole delegation to be undone within 30 seconds and reflected before the epoch ends
   160     
   161      Given the parties submit the following undelegations:
   162      | party  | node id  | amount |  when         |
   163      | party1 |  node1   |  100   |  end of epoch |      
   164  
   165      #epoch 1 withdraw 100 
   166      Given the parties withdraw from staking account the following amount:  
   167      | party  | asset  | amount |
   168      | party1 | VEGA   |  100   | 
   169  
   170      When the network moves ahead "2" blocks
   171  
   172      #epoch 1 withdraw another 300 - in total 400 meaning only 300 remain associated
   173      Given the parties withdraw from staking account the following amount:  
   174      | party  | asset  | amount |
   175      | party1 | VEGA   |  300   | 
   176  
   177      When the network moves ahead "14" blocks
   178  
   179      # within 30 seconds we expect to have seen events of the nomination corrected accordingly
   180      Then the parties should have the following delegation balances for epoch 1:
   181      | party  | node id  | amount |
   182      | party1 |  node1   | 50     | 
   183      | party1 |  node2   | 100    |       
   184      | party1 |  node3   | 150    |   
   185      | party2 |  node2   | 400    |   
   186      | party2 |  node3   | 500    |   
   187      | party2 |  node4   | 600    | 
   188  
   189      #no changes in these 30 seconds so expect balances to not change 
   190      When the network moves ahead "15" blocks
   191      Then the parties should have the following delegation balances for epoch 1:
   192      | party  | node id  | amount |
   193      | party1 |  node1   | 50     | 
   194      | party1 |  node2   | 100    |       
   195      | party1 |  node3   | 150    |   
   196      | party2 |  node2   | 400    |   
   197      | party2 |  node3   | 500    |   
   198      | party2 |  node4   | 600    |  
   199  
   200      #still in epoch 1 withdraw the remaining 300 tokens
   201      Given the parties withdraw from staking account the following amount:  
   202      | party  | asset  | amount |
   203      | party1 | VEGA   |  300   | 
   204  
   205      When the network moves ahead "16" blocks
   206      Then the parties should have the following delegation balances for epoch 1:
   207      | party  | node id  | amount |
   208      | party1 |  node1   | 0      | 
   209      | party1 |  node2   | 0      |       
   210      | party1 |  node3   | 0      |   
   211      | party2 |  node2   | 400    |   
   212      | party2 |  node3   | 500    |   
   213      | party2 |  node4   | 600    |  
   214  
   215      # the adjustment should be published for the next epoch as well 
   216      Then the parties should have the following delegation balances for epoch 2:
   217      | party  | node id  | amount |
   218      | party1 |  node1   | 0      | 
   219      | party1 |  node2   | 0      |       
   220      | party1 |  node3   | 0      |   
   221      
   222      #epoch 1 is ending
   223      When the network moves ahead "15" blocks
   224      Then the parties should have the following delegation balances for epoch 1:
   225      | party  | node id  | amount |
   226      | party1 |  node1   | 0      | 
   227      | party1 |  node2   | 0      |       
   228      | party1 |  node3   | 0      |   
   229      | party2 |  node2   | 400    |   
   230      | party2 |  node3   | 500    |   
   231      | party2 |  node4   | 600    |  
   232  
   233      Then the parties should have the following delegation balances for epoch 2:
   234      | party  | node id  | amount |
   235      | party1 |  node1   | 0      | 
   236      | party1 |  node2   | 0      |       
   237      | party1 |  node3   | 0      |   
   238      | party2 |  node2   | 400    |   
   239      | party2 |  node3   | 500    |   
   240      | party2 |  node4   | 600    |  
   241  
   242   Scenario: A party withdraws during the epoch and has pending delegations for next epoch
   243      Description: A party with a balance in the staking account can delegate to a validator
   244  
   245      #we are in epoch one delegating for epoch 2
   246      When the parties submit the following delegations:
   247      | party  | node id  | amount |
   248      | party3 |  node1   |  100   | 
   249      | party3 |  node2   |  100   |       
   250      | party3 |  node3   |  100   |   
   251      | party3 |  node4   |  100   | 
   252      | party3 |  node5   |  100   | 
   253  
   254      # the expected balance for epoch 2
   255      Then the parties should have the following delegation balances for epoch 2:
   256      | party  | node id  | amount |
   257      | party3 |  node1   | 100    | 
   258      | party3 |  node2   | 100    |       
   259      | party3 |  node3   | 100    |  
   260      | party3 |  node4   | 100    |  
   261      | party3 |  node5   | 100    |  
   262  
   263      #advance to epoch 2
   264      When the network moves ahead "63" blocks
   265  
   266      #parties change the delegation for epoch 3 to undelegate 100 from each node and delegate the 400 to the last node 
   267      #to set a delegation of 500 to a single validator
   268      Then the parties submit the following undelegations:
   269      | party  | node id  | amount |      when     |
   270      | party3 |  node1   |  100   |  end of epoch |
   271      | party3 |  node2   |  100   |  end of epoch |              
   272      | party3 |  node3   |  100   |  end of epoch |         
   273      | party3 |  node4   |  100   |  end of epoch |         
   274  
   275      Then the parties submit the following delegations:
   276      | party  | node id  | amount |
   277      | party3 |  node5   |  400   | 
   278  
   279      #so the expected balance for epoch 3 is 500 in node 5 ano nothing in the other nodes
   280      Then the parties should have the following delegation balances for epoch 3:
   281      | party  | node id  | amount |
   282      | party3 |  node1   | 0      | 
   283      | party3 |  node2   | 0      |       
   284      | party3 |  node3   | 0      |  
   285      | party3 |  node4   | 0      |  
   286      | party3 |  node5   | 500    |  
   287  
   288      #then during epoch 2 the party withdraws their stake 
   289      Given the parties withdraw from staking account the following amount:  
   290      | party  | asset  | amount  |
   291      | party3 | VEGA   |  500  |
   292  
   293      #within 30 seconds the *active delegations* are removed so the balances for epoch 2 are reset to 0
   294      When the network moves ahead "20" blocks
   295      Then the parties should have the following delegation balances for epoch 2:
   296      | party  | node id  | amount |
   297      | party3 |  node1   | 0      | 
   298      | party3 |  node2   | 0      |       
   299      | party3 |  node3   | 0      |  
   300      | party3 |  node4   | 0      |  
   301      | party3 |  node5   | 0      |  
   302  
   303      Then the parties should have the following delegation balances for epoch 3:
   304      | party  | node id  | amount |
   305      | party3 |  node1   | 0      | 
   306      | party3 |  node2   | 0      |       
   307      | party3 |  node3   | 0      |  
   308      | party3 |  node4   | 0      |  
   309      | party3 |  node5   | 0      |  
   310  
   311      # the party deposits 500 again
   312      When the network moves ahead "5" blocks
   313      And the parties deposit on staking account the following amount:  
   314      | party  | asset  | amount |
   315      | party3 | VEGA   | 500    |
   316  
   317      # and delegates again 500 to node5 for epoch 3
   318      Then the parties submit the following delegations:
   319      | party  | node id  | amount |
   320      | party3 |  node5   |  500   |    
   321  
   322      # which gives a total of 900 
   323      Then the parties should have the following delegation balances for epoch 3:
   324      | party  | node id  | amount |
   325      | party3 |  node1   | 0      | 
   326      | party3 |  node2   | 0      |       
   327      | party3 |  node3   | 0      |  
   328      | party3 |  node4   | 0      |  
   329      | party3 |  node5   | 500    |  
   330    
   331      # when the epoch ends we enforce the stronger rules and allow only 500 to go through .
   332      When the network moves ahead "50" blocks
   333      Then the parties should have the following delegation balances for epoch 3:
   334      | party  | node id  | amount |
   335      | party3 |  node1   | 0      | 
   336      | party3 |  node2   | 0      |       
   337      | party3 |  node3   | 0      |  
   338      | party3 |  node4   | 0      |  
   339      | party3 |  node5   | 500    |