@@ -994,6 +994,44 @@ export default function() {
994994 await nodeDeposit ( node , '8' . ether ) ;
995995 } ) ;
996996
997+ it ( printTitle ( 'node' , 'can create a new validator if bond requirement increases and node is underbonded by > 32 ETH' ) , async ( ) => {
998+ const dissolvePeriod = ( 60 * 60 * 24 * 10 ) ; // 10 Days
999+ await setDAOProtocolBootstrapSetting ( RocketDAOProtocolSettingsMegapool , 'megapool.time.before.dissolve' , dissolvePeriod , { from : owner } ) ;
1000+ // Reduce reduced.bond to 2 ETH
1001+ await setDAOProtocolBootstrapSetting ( RocketDAOProtocolSettingsNode , 'reduced.bond' , '2' . ether , { from : owner } ) ;
1002+ // Increase deposit pool capacity
1003+ await setDAOProtocolBootstrapSetting ( RocketDAOProtocolSettingsDeposit , 'deposit.pool.maximum' , '10000' . ether , { from : owner } ) ;
1004+ // Set penalty to 0.1 ETH
1005+ const dissolvePenalty = '0.1' . ether ;
1006+ await setDAOProtocolBootstrapSetting ( RocketDAOProtocolSettingsMegapool , 'megapool.dissolve.penalty' , dissolvePenalty , { from : owner } ) ;
1007+ // Deposit ETH
1008+ await userDeposit ( { from : random , value : '30' . ether * 35n } ) ;
1009+ // Make 32 validators with 2 ETH bond
1010+ await nodeDeposit ( node , '4' . ether ) ;
1011+ await nodeDeposit ( node , '4' . ether ) ;
1012+ for ( let i = 0n ; i < 30n ; i ++ ) {
1013+ await nodeDeposit ( node , '2' . ether ) ;
1014+ }
1015+ // Node should now have 32 active validators with a bond of 4+4+(2*30) = 68ETH
1016+ assertBN . equal ( await megapool . getNodeBond ( ) , '68' . ether ) ;
1017+ assertBN . equal ( await megapool . getUserCapital ( ) , '32' . ether * 32n - '68' . ether ) ;
1018+ assertBN . equal ( await megapool . getNodeQueuedBond ( ) , '0' . ether ) ;
1019+ assertBN . equal ( await megapool . getUserQueuedCapital ( ) , '0' . ether ) ;
1020+ // Increase reduced.bond back to 4 ETH
1021+ await setDAOProtocolBootstrapSetting ( RocketDAOProtocolSettingsNode , 'reduced.bond' , '4' . ether , { from : owner } ) ;
1022+ // Node is now underbonded by 4+4+(4*30)-68 = 60 ETH so next validator must have 32 ETH bond
1023+ assertBN . equal ( await megapool . getNewValidatorBondRequirement ( ) , '32' . ether ) ;
1024+ await nodeDeposit ( node , '32' . ether ) ;
1025+ // Node now has bond of 68+32 = 100, bond requirement with new validator is is 4+4+(4*32) = 136 ETH, so next validator requires 32 ETH
1026+ assertBN . equal ( await megapool . getNodeBond ( ) , '100' . ether ) ;
1027+ assertBN . equal ( await megapool . getNewValidatorBondRequirement ( ) , '32' . ether ) ;
1028+ await nodeDeposit ( node , '32' . ether ) ;
1029+ // Node now has bond of 100 + 32 = 132, bond requirement with new validator is 4+4+(4*33) = 140 ETH, so next validator requires 8 ETH
1030+ assertBN . equal ( await megapool . getNodeBond ( ) , '132' . ether ) ;
1031+ assertBN . equal ( await megapool . getNewValidatorBondRequirement ( ) , '8' . ether ) ;
1032+ await nodeDeposit ( node , '8' . ether ) ;
1033+ } ) ;
1034+
9971035 it ( printTitle ( 'node' , 'can dissolve and exit validators when underbonded' ) , async ( ) => {
9981036 const dissolvePeriod = ( 60 * 60 * 24 * 10 ) ; // 10 Days
9991037 await setDAOProtocolBootstrapSetting ( RocketDAOProtocolSettingsMegapool , 'megapool.time.before.dissolve' , dissolvePeriod , { from : owner } ) ;
@@ -1074,7 +1112,8 @@ export default function() {
10741112 }
10751113 assertBN . equal ( await megapool . getNodeBond ( ) , '0' . ether ) ;
10761114 assertBN . equal ( await megapool . getUserCapital ( ) , '0' . ether ) ;
1077- } ) ;
1115+ } )
1116+
10781117
10791118 it ( printTitle ( 'node' , 'cannot exit queue to underbonded state due to dissolves' ) , async ( ) => {
10801119 const dissolvePeriod = ( 60 * 60 * 24 * 10 ) ; // 10 Days
0 commit comments