diff --git a/src/test/StakingContract.t.sol b/src/test/StakingContract.t.sol index 479f107..d33f332 100644 --- a/src/test/StakingContract.t.sol +++ b/src/test/StakingContract.t.sol @@ -50,6 +50,20 @@ contract DepositContractMock is IDepositContract { } } +// 10 PUBLIC KEYS +bytes constant PUBLIC_KEYS = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e06014451b3fb9288549aff6dea9843b43e0c47a3b856f307732175230e254c0004e48b02414987088ac7003e148930017b49a1a8d4600f33d463c4afc07bbfc82703c9fcf81a5891f90a71c86a02faff443c6c3b2592bd44d5d3d7a93cb4aaaa105612496d61e68140a5418b468f872bf2f3e79f9cb0d9c3e889663fca02939b31e8ee3092203ee1417128e965c6406a07f68abf2ebe2689cf6c853ef126ffa8574c2a7d913e28de9147fa6b96706ea5bf9eacd1aba06edeaee155009fb912c00070774cc64136fcffde12ed731260bc5529df64da298f493561198e9d6acf42cf21e853ae7b2df85f27d2183149969d623b9237254c2cfe1d0082742eb042ac096d686dbe03c79ee31cbd03bb4682f8797043eed9f6e622814831ac5dfe1176552fb7f9b6ff38a149ae1d8414097a32fd96da6453c52fda13e3402a09e2fa6886daa4300f09c73e4bc2901b99c44744c5cfdca2994adc49ddccb195bda2510e50a4ae10de26cf96dee5e577689f51650a610a33da0a826ae47247d8d1189cb3386"; +bytes constant PUBLIC_KEYS_2 = hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b07f03dbc79d85fa9d41f9eefa8e598353b652aadf497673744527c73127f872b91cf31ec8041dae1b3a4238683cf442ea23a95fe68b400ab42b14e8c99280a057d1d840e80723c3622b38e6acd1f471bf247cf62312c9b863a75ac0d270cefa4f84fd8586dbda15c67c1a46e85cf56c60550f54cb082770baf3d2bbf4c33f5254bd0b93e017f3ed036b13baec41bb69085f9eff48651be38c8f9e1f67b643f84ec356864aaa057f0042b121b9d040ed9be3f5cc9cc659d8f8fc02575ed3c25708adac2c8d0c50ab7e4599ce9edf300d98e1cfcfc8e0022a24c712f0769de99a3389bac1cdca92ae20fba323142fe2e8d09ef2cb59c3f822779b3fe6410cddce7255d35db01093cc435c0a35bbb4cd8d4eb3bd2cc597c49a7a909c16f67fe8b6702d5d0c22ad189b1c45325190015b0017606f768c7aa2006cc19dfeb5f367eae9dd17a5c307705db1f5cec552fc038e5fa3a76352d9621a4d74b1fd7e1707c7bfb5e912e2b5a33a2f34a419055d0c4065aa787f743aff953d73441e96ffc9b0f5a3248c23398518a758aec8451b626bff7eed063a3b11bf661d10ad6dac5ee62f47be125e3c668e14b3c704d736b4fbff"; + +bytes constant PUBKEY_1 = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; +bytes constant PUBKEY_2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; + +// 10 SIGNATURES +bytes constant SIGNATURES = hex"ccb81f4485957f440bc17dbe760f374cbb112c6f12fa10e8709fac4522b30440d918c7bb867fa04f6b3cfbd977455f8f2fde586fdf3d7baa429e98e497ff871f3b8db1528b2b964fa24d26e377c74746496cc719c50dbf391fb3f74f5ca4b93a02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966f393d619cbf13ff427df11dcb17026df25f35268de5b168e359c16f2a3d5fbc6376db44638d773c851c875f21222448433d285920e8bdc4f5cbff130d7387c0a9589324286aea398e5aacad3bbfe3992dfce62571f0e282ed9c29e3fa5b07aa5c81749589b1170d3b85a84331e2f6b8e26eadebfd569b225759f40bbd12d6c3d253ed3f379b014b2ea44cce54d362072e2d020ff139a903b7d87fc3fddc2e6657c83e0b79851c22c6e0e477463463c97d6cc0e2e2de5e35b227bddb285521be3766358abaf3159d89f68c9770e28278f177088cfc4089b817effaaecabdffa4e66427868b105cb9348ea2d84eeea059a5d1ff3277d6f9cf656fc973d07cabed70fb8f8eb2798a65d207a8e1f8a26910949db9fa62d62bc15ecc097a93a27a1873405b8589a4ddf0ecf0303c6031484562b32eb7881975026524d6d4a9de6cd73fe2c324501586b9b6fa6bce950bbd21472278302f83dbfd6be036f2fc36d299d66578e844be3d6aa8314fab468f038fd6e130ada0a886fccfb2fd843f7dd07e8968401bbe2af7345fce52ba4b310b30af2d54b15669d06c206682c1730ab6b17787e361f04401f78dc5cbd5fac955df4e83c24cdabfabdb3f4ea40961d04a5ca166c17694fca144025b47131a68ddb230d36fe6e831e82624c9a925d706bff86982852b26ebf019a3f6ee36aedbbc6bec2d50531a233e09225493d3c5fd48379aec373baf622fb9feed6261e5296e5ae6601e7523c7f386801ed63a344b07106a0d03e5848209db5e114c0e67884916a43a1bfb77d9b8ea113c3ba8cad4b006aafeadcc31e70e85c5efecaf807154d011c1413340d4b592d2f270fb48b2050e08493c1427ddfac8dcc27fe434d32a35dcbddbcb1c4e22ead6734a4ac910f6768bc9ff6b355c1151695e41121cdcc9d9d3b18cf4d66ca3c1db0527c471a0dcf256590602a7269dcb26175e7eb370bd9794ac8ab558bea69e6a92d8e818b675a80e2df0516b8307291d93cb85d959ac60d47b46455a7ab0a38687c747c6d2d9e8c20ccf74dc6cdf145ec06805d4ac24a39aec2f5cd6e26e63e3d043a31c42411e4"; +bytes constant SIGNATURES_2 = hex"fe41ffbe702fb08d01063c9cd99fac11a16e921c784e681e365db00c4bd6760df67cfc0d0555a8ee8bf534a2c0987b7949b18dba726ced579240fa063274bc7ab25e44b758c452c433debfebbc075cbe105f07502402a9591dc891640a9f2b34fe0863bf987ff4b5a601b0ffcecc185f04847e0b97d3fb9457c32efb9c3ce35520308cfcc8ca78d5d4da164f6d1575d32fe466b8076bc4056ad97fa3e3607a60e5e420bdec413e5ffcc3119b1b89a957b14a437e009a858c4c40c0f1fc7f3d1ad83bc96ada6c2c772260637774e5fbdc60791db6de3a31e136c28106b35c21932a8ed610306f0723675730e31d3deceff4f912e6070c9efcd6e3f0c9ad4a0e203f437f21679b87d46351714b5a1b6226f8ffadd19e18f85c918461ab67291e1c8cdfdc05280adf2b923f1269cf7de8bd351a7ede13524e836cbfc7ba22db91aaa5c9a0729a469985f5bd844347ba9a9b4019f4ad42c2025457cf48557494ac3ce6e311a1ded3e903cd3009d18133015d445d02a3ce3858781b582d28701a311ddb271f8a0c91c65b32cc13c512c35e5be9bb9dc556dfd3249a3733f58426718974820f17b3242a089e29b129fcea37c8b84996e2c725b59efccee24068625584e583700346f823ce92e11ac9db5964ca6300905c5e9f294330037ec1cb7d9b8fc28829b98fcc0fc405afcd54f43cb4a14e8cab3f5aa979fe2c3492fe295e1a50170e8857bd94e5b009bcec9626e6eb137b272882037202da7329dadcb5b99bbd7835b8875d696dab41774dcb559bfb4c79a5337efc5f1606bc7c2752389a49b6a578f0c7c58e2bf9efc55eef19beaf3de94da90c712ca3891ac71a6ff6d778a1c0c31f77fdde2c4b7f29adf8ccf000050e9e4829d2de36fda8d6b26020e6f0ece339e9ad96c01b166301238e1aaa30ddfb978968361a5f9d3fcaa381973c967c0dd88c6d54d00fa375ab4df3be57c4360b69d7634e95e4d4201da8f2348d0ce53be690146f0049d5d173a635d21406b10ed23ec9996bd0a43b812df363986fb8dedf5be1cdb3f85a5090460511af617507d24657e3733310b42e1406070a0316620037da35c5227bb85d3aacf3aebf750265838994e03a8770cdc1c31723ca1037232c32d21f31eee561575b18b1b4c0f027f270898aed60ab4bfe41160cd989cd5bdfeb795097ff01cd0ff41fea96311e92798c0a619aa957772cfd408747fc30dcb39210839a4c70b87d3ad881207fa5eee926bc2c6936ce10b382c7a37606d40bb1cf2637768255aae4a4cd18ed7004e3046520bea92c66a7074e4b46d3d566703e44d0c3f9ef49a2ff30632fe3f6a409178db66423809514cd7473f83d21"; + +bytes constant SIGNATURE_1 = hex"ccb81f4485957f440bc17dbe760f374cbb112c6f12fa10e8709fac4522b30440d918c7bb867fa04f6b3cfbd977455f8f2fde586fdf3d7baa429e98e497ff871f3b8db1528b2b964fa24d26e377c74746496cc719c50dbf391fb3f74f5ca4b93a"; +bytes constant SIGNATURE_2 = hex"02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966"; + contract StakingContractTest is DSTestPlus { Vm internal vm = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); @@ -144,14 +158,8 @@ contract StakingContractTest is DSTestPlus { vm.stopPrank(); { - bytes - memory publicKeys = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e06014451b3fb9288549aff6dea9843b43e0c47a3b856f307732175230e254c0004e48b02414987088ac7003e148930017b49a1a8d4600f33d463c4afc07bbfc82703c9fcf81a5891f90a71c86a02faff443c6c3b2592bd44d5d3d7a93cb4aaaa105612496d61e68140a5418b468f872bf2f3e79f9cb0d9c3e889663fca02939b31e8ee3092203ee1417128e965c6406a07f68abf2ebe2689cf6c853ef126ffa8574c2a7d913e28de9147fa6b96706ea5bf9eacd1aba06edeaee155009fb912c00070774cc64136fcffde12ed731260bc5529df64da298f493561198e9d6acf42cf21e853ae7b2df85f27d2183149969d623b9237254c2cfe1d0082742eb042ac096d686dbe03c79ee31cbd03bb4682f8797043eed9f6e622814831ac5dfe1176552fb7f9b6ff38a149ae1d8414097a32fd96da6453c52fda13e3402a09e2fa6886daa4300f09c73e4bc2901b99c44744c5cfdca2994adc49ddccb195bda2510e50a4ae10de26cf96dee5e577689f51650a610a33da0a826ae47247d8d1189cb3386"; - - bytes - memory signatures = hex"ccb81f4485957f440bc17dbe760f374cbb112c6f12fa10e8709fac4522b30440d918c7bb867fa04f6b3cfbd977455f8f2fde586fdf3d7baa429e98e497ff871f3b8db1528b2b964fa24d26e377c74746496cc719c50dbf391fb3f74f5ca4b93a02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966f393d619cbf13ff427df11dcb17026df25f35268de5b168e359c16f2a3d5fbc6376db44638d773c851c875f21222448433d285920e8bdc4f5cbff130d7387c0a9589324286aea398e5aacad3bbfe3992dfce62571f0e282ed9c29e3fa5b07aa5c81749589b1170d3b85a84331e2f6b8e26eadebfd569b225759f40bbd12d6c3d253ed3f379b014b2ea44cce54d362072e2d020ff139a903b7d87fc3fddc2e6657c83e0b79851c22c6e0e477463463c97d6cc0e2e2de5e35b227bddb285521be3766358abaf3159d89f68c9770e28278f177088cfc4089b817effaaecabdffa4e66427868b105cb9348ea2d84eeea059a5d1ff3277d6f9cf656fc973d07cabed70fb8f8eb2798a65d207a8e1f8a26910949db9fa62d62bc15ecc097a93a27a1873405b8589a4ddf0ecf0303c6031484562b32eb7881975026524d6d4a9de6cd73fe2c324501586b9b6fa6bce950bbd21472278302f83dbfd6be036f2fc36d299d66578e844be3d6aa8314fab468f038fd6e130ada0a886fccfb2fd843f7dd07e8968401bbe2af7345fce52ba4b310b30af2d54b15669d06c206682c1730ab6b17787e361f04401f78dc5cbd5fac955df4e83c24cdabfabdb3f4ea40961d04a5ca166c17694fca144025b47131a68ddb230d36fe6e831e82624c9a925d706bff86982852b26ebf019a3f6ee36aedbbc6bec2d50531a233e09225493d3c5fd48379aec373baf622fb9feed6261e5296e5ae6601e7523c7f386801ed63a344b07106a0d03e5848209db5e114c0e67884916a43a1bfb77d9b8ea113c3ba8cad4b006aafeadcc31e70e85c5efecaf807154d011c1413340d4b592d2f270fb48b2050e08493c1427ddfac8dcc27fe434d32a35dcbddbcb1c4e22ead6734a4ac910f6768bc9ff6b355c1151695e41121cdcc9d9d3b18cf4d66ca3c1db0527c471a0dcf256590602a7269dcb26175e7eb370bd9794ac8ab558bea69e6a92d8e818b675a80e2df0516b8307291d93cb85d959ac60d47b46455a7ab0a38687c747c6d2d9e8c20ccf74dc6cdf145ec06805d4ac24a39aec2f5cd6e26e63e3d043a31c42411e4"; - vm.startPrank(operatorOne); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS, SIGNATURES); vm.stopPrank(); } @@ -382,11 +390,6 @@ contract StakingContractTest is DSTestPlus { } function testAddValidatorsOperatorOne() public { - bytes - memory publicKeys = hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b07f03dbc79d85fa9d41f9eefa8e598353b652aadf497673744527c73127f872b91cf31ec8041dae1b3a4238683cf442ea23a95fe68b400ab42b14e8c99280a057d1d840e80723c3622b38e6acd1f471bf247cf62312c9b863a75ac0d270cefa4f84fd8586dbda15c67c1a46e85cf56c60550f54cb082770baf3d2bbf4c33f5254bd0b93e017f3ed036b13baec41bb69085f9eff48651be38c8f9e1f67b643f84ec356864aaa057f0042b121b9d040ed9be3f5cc9cc659d8f8fc02575ed3c25708adac2c8d0c50ab7e4599ce9edf300d98e1cfcfc8e0022a24c712f0769de99a3389bac1cdca92ae20fba323142fe2e8d09ef2cb59c3f822779b3fe6410cddce7255d35db01093cc435c0a35bbb4cd8d4eb3bd2cc597c49a7a909c16f67fe8b6702d5d0c22ad189b1c45325190015b0017606f768c7aa2006cc19dfeb5f367eae9dd17a5c307705db1f5cec552fc038e5fa3a76352d9621a4d74b1fd7e1707c7bfb5e912e2b5a33a2f34a419055d0c4065aa787f743aff953d73441e96ffc9b0f5a3248c23398518a758aec8451b626bff7eed063a3b11bf661d10ad6dac5ee62f47be125e3c668e14b3c704d736b4fb1e"; - bytes - memory signatures = hex"fe41ffbe702fb08d01063c9cd99fac11a16e921c784e681e365db00c4bd6760df67cfc0d0555a8ee8bf534a2c0987b7949b18dba726ced579240fa063274bc7ab25e44b758c452c433debfebbc075cbe105f07502402a9591dc891640a9f2b34fe0863bf987ff4b5a601b0ffcecc185f04847e0b97d3fb9457c32efb9c3ce35520308cfcc8ca78d5d4da164f6d1575d32fe466b8076bc4056ad97fa3e3607a60e5e420bdec413e5ffcc3119b1b89a957b14a437e009a858c4c40c0f1fc7f3d1ad83bc96ada6c2c772260637774e5fbdc60791db6de3a31e136c28106b35c21932a8ed610306f0723675730e31d3deceff4f912e6070c9efcd6e3f0c9ad4a0e203f437f21679b87d46351714b5a1b6226f8ffadd19e18f85c918461ab67291e1c8cdfdc05280adf2b923f1269cf7de8bd351a7ede13524e836cbfc7ba22db91aaa5c9a0729a469985f5bd844347ba9a9b4019f4ad42c2025457cf48557494ac3ce6e311a1ded3e903cd3009d18133015d445d02a3ce3858781b582d28701a311ddb271f8a0c91c65b32cc13c512c35e5be9bb9dc556dfd3249a3733f58426718974820f17b3242a089e29b129fcea37c8b84996e2c725b59efccee24068625584e583700346f823ce92e11ac9db5964ca6300905c5e9f294330037ec1cb7d9b8fc28829b98fcc0fc405afcd54f43cb4a14e8cab3f5aa979fe2c3492fe295e1a50170e8857bd94e5b009bcec9626e6eb137b272882037202da7329dadcb5b99bbd7835b8875d696dab41774dcb559bfb4c79a5337efc5f1606bc7c2752389a49b6a578f0c7c58e2bf9efc55eef19beaf3de94da90c712ca3891ac71a6ff6d778a1c0c31f77fdde2c4b7f29adf8ccf000050e9e4829d2de36fda8d6b26020e6f0ece339e9ad96c01b166301238e1aaa30ddfb978968361a5f9d3fcaa381973c967c0dd88c6d54d00fa375ab4df3be57c4360b69d7634e95e4d4201da8f2348d0ce53be690146f0049d5d173a635d21406b10ed23ec9996bd0a43b812df363986fb8dedf5be1cdb3f85a5090460511af617507d24657e3733310b42e1406070a0316620037da35c5227bb85d3aacf3aebf750265838994e03a8770cdc1c31723ca1037232c32d21f31eee561575b18b1b4c0f027f270898aed60ab4bfe41160cd989cd5bdfeb795097ff01cd0ff41fea96311e92798c0a619aa957772cfd408747fc30dcb39210839a4c70b87d3ad881207fa5eee926bc2c6936ce10b382c7a37606d40bb1cf2637768255aae4a4cd18ed7004e3046520bea92c66a7074e4b46d3d566703e44d0c3f9ef49a2ff30632fe3f6a409178db66423809514cd7473f83d0c"; - ( address operatorAddress, address feeRecipientAddress, @@ -404,17 +407,15 @@ contract StakingContractTest is DSTestPlus { assertEq(available, 10); assert(deactivated == false); - bytes - memory pubKey1 = hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b0"; - assertFalse(stakingContract.getEnabledFromPublicKeyRoot(sha256(abi.encodePacked(pubKey1, bytes16(0))))); + assertFalse(stakingContract.getEnabledFromPublicKeyRoot(sha256(abi.encodePacked(PUBKEY_1, bytes16(0))))); vm.startPrank(operatorOne); vm.expectEmit(true, true, true, true); - emit ValidatorKeysAdded(0, publicKeys, signatures); - stakingContract.addValidators(0, 10, publicKeys, signatures); + emit ValidatorKeysAdded(0, PUBLIC_KEYS_2, SIGNATURES_2); + stakingContract.addValidators(0, 10, PUBLIC_KEYS_2, SIGNATURES_2); vm.stopPrank(); - assertTrue(stakingContract.getEnabledFromPublicKeyRoot(sha256(abi.encodePacked(pubKey1, bytes16(0))))); + assertTrue(stakingContract.getEnabledFromPublicKeyRoot(sha256(abi.encodePacked(PUBKEY_1, bytes16(0))))); (operatorAddress, feeRecipientAddress, limit, keys, funded, available, deactivated) = stakingContract .getOperator(0); @@ -446,11 +447,6 @@ contract StakingContractTest is DSTestPlus { event ActivatedOperator(uint256 _operatorIndex); function testAddValidatorsDeactivatedOperatorOne() public { - bytes - memory publicKeys = hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b07f03dbc79d85fa9d41f9eefa8e598353b652aadf497673744527c73127f872b91cf31ec8041dae1b3a4238683cf442ea23a95fe68b400ab42b14e8c99280a057d1d840e80723c3622b38e6acd1f471bf247cf62312c9b863a75ac0d270cefa4f84fd8586dbda15c67c1a46e85cf56c60550f54cb082770baf3d2bbf4c33f5254bd0b93e017f3ed036b13baec41bb69085f9eff48651be38c8f9e1f67b643f84ec356864aaa057f0042b121b9d040ed9be3f5cc9cc659d8f8fc02575ed3c25708adac2c8d0c50ab7e4599ce9edf300d98e1cfcfc8e0022a24c712f0769de99a3389bac1cdca92ae20fba323142fe2e8d09ef2cb59c3f822779b3fe6410cddce7255d35db01093cc435c0a35bbb4cd8d4eb3bd2cc597c49a7a909c16f67fe8b6702d5d0c22ad189b1c45325190015b0017606f768c7aa2006cc19dfeb5f367eae9dd17a5c307705db1f5cec552fc038e5fa3a76352d9621a4d74b1fd7e1707c7bfb5e912e2b5a33a2f34a419055d0c4065aa787f743aff953d73441e96ffc9b0f5a3248c23398518a758aec8451b626bff7eed063a3b11bf661d10ad6dac5ee62f47be125e3c668e14b3c704d736b4fb1e"; - bytes - memory signatures = hex"fe41ffbe702fb08d01063c9cd99fac11a16e921c784e681e365db00c4bd6760df67cfc0d0555a8ee8bf534a2c0987b7949b18dba726ced579240fa063274bc7ab25e44b758c452c433debfebbc075cbe105f07502402a9591dc891640a9f2b34fe0863bf987ff4b5a601b0ffcecc185f04847e0b97d3fb9457c32efb9c3ce35520308cfcc8ca78d5d4da164f6d1575d32fe466b8076bc4056ad97fa3e3607a60e5e420bdec413e5ffcc3119b1b89a957b14a437e009a858c4c40c0f1fc7f3d1ad83bc96ada6c2c772260637774e5fbdc60791db6de3a31e136c28106b35c21932a8ed610306f0723675730e31d3deceff4f912e6070c9efcd6e3f0c9ad4a0e203f437f21679b87d46351714b5a1b6226f8ffadd19e18f85c918461ab67291e1c8cdfdc05280adf2b923f1269cf7de8bd351a7ede13524e836cbfc7ba22db91aaa5c9a0729a469985f5bd844347ba9a9b4019f4ad42c2025457cf48557494ac3ce6e311a1ded3e903cd3009d18133015d445d02a3ce3858781b582d28701a311ddb271f8a0c91c65b32cc13c512c35e5be9bb9dc556dfd3249a3733f58426718974820f17b3242a089e29b129fcea37c8b84996e2c725b59efccee24068625584e583700346f823ce92e11ac9db5964ca6300905c5e9f294330037ec1cb7d9b8fc28829b98fcc0fc405afcd54f43cb4a14e8cab3f5aa979fe2c3492fe295e1a50170e8857bd94e5b009bcec9626e6eb137b272882037202da7329dadcb5b99bbd7835b8875d696dab41774dcb559bfb4c79a5337efc5f1606bc7c2752389a49b6a578f0c7c58e2bf9efc55eef19beaf3de94da90c712ca3891ac71a6ff6d778a1c0c31f77fdde2c4b7f29adf8ccf000050e9e4829d2de36fda8d6b26020e6f0ece339e9ad96c01b166301238e1aaa30ddfb978968361a5f9d3fcaa381973c967c0dd88c6d54d00fa375ab4df3be57c4360b69d7634e95e4d4201da8f2348d0ce53be690146f0049d5d173a635d21406b10ed23ec9996bd0a43b812df363986fb8dedf5be1cdb3f85a5090460511af617507d24657e3733310b42e1406070a0316620037da35c5227bb85d3aacf3aebf750265838994e03a8770cdc1c31723ca1037232c32d21f31eee561575b18b1b4c0f027f270898aed60ab4bfe41160cd989cd5bdfeb795097ff01cd0ff41fea96311e92798c0a619aa957772cfd408747fc30dcb39210839a4c70b87d3ad881207fa5eee926bc2c6936ce10b382c7a37606d40bb1cf2637768255aae4a4cd18ed7004e3046520bea92c66a7074e4b46d3d566703e44d0c3f9ef49a2ff30632fe3f6a409178db66423809514cd7473f83d0c"; - ( address operatorAddress, address feeRecipient, @@ -485,7 +481,7 @@ contract StakingContractTest is DSTestPlus { vm.startPrank(operatorOne); vm.expectRevert(abi.encodeWithSignature("Deactivated()")); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS_2, SIGNATURES_2); vm.stopPrank(); vm.startPrank(operatorOne); @@ -507,7 +503,7 @@ contract StakingContractTest is DSTestPlus { vm.stopPrank(); vm.startPrank(operatorOne); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS_2, SIGNATURES_2); vm.stopPrank(); (operatorAddress, feeRecipient, limit, keys, funded, available, deactivated) = stakingContract.getOperator(0); @@ -522,11 +518,6 @@ contract StakingContractTest is DSTestPlus { } function testAddValidatorsOperatorOneDuplicateKeys() public { - bytes - memory publicKeys = hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b07f03dbc79d85fa9d41f9eefa8e598353b652aadf497673744527c73127f872b91cf31ec8041dae1b3a4238683cf442ea23a95fe68b400ab42b14e8c99280a057d1d840e80723c3622b38e6acd1f471bf247cf62312c9b863a75ac0d270cefa4f84fd8586dbda15c67c1a46e85cf56c60550f54cb082770baf3d2bbf4c33f5254bd0b93e017f3ed036b13baec41bb69085f9eff48651be38c8f9e1f67b643f84ec356864aaa057f0042b121b9d040ed9be3f5cc9cc659d8f8fc02575ed3c25708adac2c8d0c50ab7e4599ce9edf300d98e1cfcfc8e0022a24c712f0769de99a3389bac1cdca92ae20fba323142fe2e8d09ef2cb59c3f822779b3fe6410cddce7255d35db01093cc435c0a35bbb4cd8d4eb3bd2cc597c49a7a909c16f67fe8b6702d5d0c22ad189b1c45325190015b0017606f768c7aa2006cc19dfeb5f367eae9dd17a5c307705db1f5cec552fc038e5fa3a76352d9621a4d74b1fd7e1707c7bfb5e912e2b5a33a2f34a419055d0c4065aa787f743aff953d73441e96ffc9b0f5a3248c23398518a758aec8451b626bff7eed063a3b11bf661d10ad6dac5ee62f47be125e3c668e14b3c704d736b4fb1e"; - bytes - memory signatures = hex"fe41ffbe702fb08d01063c9cd99fac11a16e921c784e681e365db00c4bd6760df67cfc0d0555a8ee8bf534a2c0987b7949b18dba726ced579240fa063274bc7ab25e44b758c452c433debfebbc075cbe105f07502402a9591dc891640a9f2b34fe0863bf987ff4b5a601b0ffcecc185f04847e0b97d3fb9457c32efb9c3ce35520308cfcc8ca78d5d4da164f6d1575d32fe466b8076bc4056ad97fa3e3607a60e5e420bdec413e5ffcc3119b1b89a957b14a437e009a858c4c40c0f1fc7f3d1ad83bc96ada6c2c772260637774e5fbdc60791db6de3a31e136c28106b35c21932a8ed610306f0723675730e31d3deceff4f912e6070c9efcd6e3f0c9ad4a0e203f437f21679b87d46351714b5a1b6226f8ffadd19e18f85c918461ab67291e1c8cdfdc05280adf2b923f1269cf7de8bd351a7ede13524e836cbfc7ba22db91aaa5c9a0729a469985f5bd844347ba9a9b4019f4ad42c2025457cf48557494ac3ce6e311a1ded3e903cd3009d18133015d445d02a3ce3858781b582d28701a311ddb271f8a0c91c65b32cc13c512c35e5be9bb9dc556dfd3249a3733f58426718974820f17b3242a089e29b129fcea37c8b84996e2c725b59efccee24068625584e583700346f823ce92e11ac9db5964ca6300905c5e9f294330037ec1cb7d9b8fc28829b98fcc0fc405afcd54f43cb4a14e8cab3f5aa979fe2c3492fe295e1a50170e8857bd94e5b009bcec9626e6eb137b272882037202da7329dadcb5b99bbd7835b8875d696dab41774dcb559bfb4c79a5337efc5f1606bc7c2752389a49b6a578f0c7c58e2bf9efc55eef19beaf3de94da90c712ca3891ac71a6ff6d778a1c0c31f77fdde2c4b7f29adf8ccf000050e9e4829d2de36fda8d6b26020e6f0ece339e9ad96c01b166301238e1aaa30ddfb978968361a5f9d3fcaa381973c967c0dd88c6d54d00fa375ab4df3be57c4360b69d7634e95e4d4201da8f2348d0ce53be690146f0049d5d173a635d21406b10ed23ec9996bd0a43b812df363986fb8dedf5be1cdb3f85a5090460511af617507d24657e3733310b42e1406070a0316620037da35c5227bb85d3aacf3aebf750265838994e03a8770cdc1c31723ca1037232c32d21f31eee561575b18b1b4c0f027f270898aed60ab4bfe41160cd989cd5bdfeb795097ff01cd0ff41fea96311e92798c0a619aa957772cfd408747fc30dcb39210839a4c70b87d3ad881207fa5eee926bc2c6936ce10b382c7a37606d40bb1cf2637768255aae4a4cd18ed7004e3046520bea92c66a7074e4b46d3d566703e44d0c3f9ef49a2ff30632fe3f6a409178db66423809514cd7473f83d0c"; - ( address operatorAddress, address feeRecipientAddress, @@ -545,7 +536,7 @@ contract StakingContractTest is DSTestPlus { assert(deactivated == false); vm.startPrank(operatorOne); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS_2, SIGNATURES_2); vm.stopPrank(); vm.startPrank(operatorOne); @@ -555,42 +546,33 @@ contract StakingContractTest is DSTestPlus { hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b0" ) ); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS_2, SIGNATURES_2); vm.stopPrank(); } function testAddValidatorsInvalidPubKey() public { bytes memory publicKeys = hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b07f03dbc79d85fa9d41f9eefa8e598353b652aadf497673744527c73127f872b91cf31ec8041dae1b3a4238683cf442ea23a95fe68b400ab42b14e8c99280a057d1d840e80723c3622b38e6acd1f471bf247cf62312c9b863a75ac0d270cefa4f84fd8586dbda15c67c1a46e85cf56c60550f54cb082770baf3d2bbf4c33f5254bd0b93e017f3ed036b13baec41bb69085f9eff48651be38c8f9e1f67b643f84ec356864aaa057f0042b121b9d040ed9be3f5cc9cc659d8f8fc02575ed3c25708adac2c8d0c50ab7e4599ce9edf300d98e1cfcfc8e0022a24c712f0769de99a3389bac1cdca92ae20fba323142fe2e8d09ef2cb59c3f822779b3fe6410cddce7255d35db01093cc435c0a35bbb4cd8d4eb3bd2cc597c49a7a909c16f67fe8b6702d5d0c22ad189b1c45325190015b0017606f768c7aa2006cc19dfeb5f367eae9dd17a5c307705db1f5cec552fc038e5fa3a76352d9621a4d74b1fd7e1707c7bfb5e912e2b5a33a2f34a419055d0c4065aa787f743aff953d73441e96ffc9b0f5a3248c23398518a758aec8451b626bff7eed063a3b11bf661d10ad6dac5ee62f47be125e3c668e14b3c704d736b4fb"; - bytes - memory signatures = hex"fe41ffbe702fb08d01063c9cd99fac11a16e921c784e681e365db00c4bd6760df67cfc0d0555a8ee8bf534a2c0987b7949b18dba726ced579240fa063274bc7ab25e44b758c452c433debfebbc075cbe105f07502402a9591dc891640a9f2b34fe0863bf987ff4b5a601b0ffcecc185f04847e0b97d3fb9457c32efb9c3ce35520308cfcc8ca78d5d4da164f6d1575d32fe466b8076bc4056ad97fa3e3607a60e5e420bdec413e5ffcc3119b1b89a957b14a437e009a858c4c40c0f1fc7f3d1ad83bc96ada6c2c772260637774e5fbdc60791db6de3a31e136c28106b35c21932a8ed610306f0723675730e31d3deceff4f912e6070c9efcd6e3f0c9ad4a0e203f437f21679b87d46351714b5a1b6226f8ffadd19e18f85c918461ab67291e1c8cdfdc05280adf2b923f1269cf7de8bd351a7ede13524e836cbfc7ba22db91aaa5c9a0729a469985f5bd844347ba9a9b4019f4ad42c2025457cf48557494ac3ce6e311a1ded3e903cd3009d18133015d445d02a3ce3858781b582d28701a311ddb271f8a0c91c65b32cc13c512c35e5be9bb9dc556dfd3249a3733f58426718974820f17b3242a089e29b129fcea37c8b84996e2c725b59efccee24068625584e583700346f823ce92e11ac9db5964ca6300905c5e9f294330037ec1cb7d9b8fc28829b98fcc0fc405afcd54f43cb4a14e8cab3f5aa979fe2c3492fe295e1a50170e8857bd94e5b009bcec9626e6eb137b272882037202da7329dadcb5b99bbd7835b8875d696dab41774dcb559bfb4c79a5337efc5f1606bc7c2752389a49b6a578f0c7c58e2bf9efc55eef19beaf3de94da90c712ca3891ac71a6ff6d778a1c0c31f77fdde2c4b7f29adf8ccf000050e9e4829d2de36fda8d6b26020e6f0ece339e9ad96c01b166301238e1aaa30ddfb978968361a5f9d3fcaa381973c967c0dd88c6d54d00fa375ab4df3be57c4360b69d7634e95e4d4201da8f2348d0ce53be690146f0049d5d173a635d21406b10ed23ec9996bd0a43b812df363986fb8dedf5be1cdb3f85a5090460511af617507d24657e3733310b42e1406070a0316620037da35c5227bb85d3aacf3aebf750265838994e03a8770cdc1c31723ca1037232c32d21f31eee561575b18b1b4c0f027f270898aed60ab4bfe41160cd989cd5bdfeb795097ff01cd0ff41fea96311e92798c0a619aa957772cfd408747fc30dcb39210839a4c70b87d3ad881207fa5eee926bc2c6936ce10b382c7a37606d40bb1cf2637768255aae4a4cd18ed7004e3046520bea92c66a7074e4b46d3d566703e44d0c3f9ef49a2ff30632fe3f6a409178db66423809514cd7473f83d0c"; vm.startPrank(operatorOne); vm.expectRevert(abi.encodeWithSignature("InvalidPublicKeys()")); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, publicKeys, SIGNATURES); vm.stopPrank(); } function testAddValidatorsInvalidSignature() public { - bytes - memory publicKeys = hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b07f03dbc79d85fa9d41f9eefa8e598353b652aadf497673744527c73127f872b91cf31ec8041dae1b3a4238683cf442ea23a95fe68b400ab42b14e8c99280a057d1d840e80723c3622b38e6acd1f471bf247cf62312c9b863a75ac0d270cefa4f84fd8586dbda15c67c1a46e85cf56c60550f54cb082770baf3d2bbf4c33f5254bd0b93e017f3ed036b13baec41bb69085f9eff48651be38c8f9e1f67b643f84ec356864aaa057f0042b121b9d040ed9be3f5cc9cc659d8f8fc02575ed3c25708adac2c8d0c50ab7e4599ce9edf300d98e1cfcfc8e0022a24c712f0769de99a3389bac1cdca92ae20fba323142fe2e8d09ef2cb59c3f822779b3fe6410cddce7255d35db01093cc435c0a35bbb4cd8d4eb3bd2cc597c49a7a909c16f67fe8b6702d5d0c22ad189b1c45325190015b0017606f768c7aa2006cc19dfeb5f367eae9dd17a5c307705db1f5cec552fc038e5fa3a76352d9621a4d74b1fd7e1707c7bfb5e912e2b5a33a2f34a419055d0c4065aa787f743aff953d73441e96ffc9b0f5a3248c23398518a758aec8451b626bff7eed063a3b11bf661d10ad6dac5ee62f47be125e3c668e14b3c704d736b4fbff"; bytes memory signatures = hex"fe41ffbe702fb08d01063c9cd99fac11a16e921c784e681e365db00c4bd6760df67cfc0d0555a8ee8bf534a2c0987b7949b18dba726ced579240fa063274bc7ab25e44b758c452c433debfebbc075cbe105f07502402a9591dc891640a9f2b34fe0863bf987ff4b5a601b0ffcecc185f04847e0b97d3fb9457c32efb9c3ce35520308cfcc8ca78d5d4da164f6d1575d32fe466b8076bc4056ad97fa3e3607a60e5e420bdec413e5ffcc3119b1b89a957b14a437e009a858c4c40c0f1fc7f3d1ad83bc96ada6c2c772260637774e5fbdc60791db6de3a31e136c28106b35c21932a8ed610306f0723675730e31d3deceff4f912e6070c9efcd6e3f0c9ad4a0e203f437f21679b87d46351714b5a1b6226f8ffadd19e18f85c918461ab67291e1c8cdfdc05280adf2b923f1269cf7de8bd351a7ede13524e836cbfc7ba22db91aaa5c9a0729a469985f5bd844347ba9a9b4019f4ad42c2025457cf48557494ac3ce6e311a1ded3e903cd3009d18133015d445d02a3ce3858781b582d28701a311ddb271f8a0c91c65b32cc13c512c35e5be9bb9dc556dfd3249a3733f58426718974820f17b3242a089e29b129fcea37c8b84996e2c725b59efccee24068625584e583700346f823ce92e11ac9db5964ca6300905c5e9f294330037ec1cb7d9b8fc28829b98fcc0fc405afcd54f43cb4a14e8cab3f5aa979fe2c3492fe295e1a50170e8857bd94e5b009bcec9626e6eb137b272882037202da7329dadcb5b99bbd7835b8875d696dab41774dcb559bfb4c79a5337efc5f1606bc7c2752389a49b6a578f0c7c58e2bf9efc55eef19beaf3de94da90c712ca3891ac71a6ff6d778a1c0c31f77fdde2c4b7f29adf8ccf000050e9e4829d2de36fda8d6b26020e6f0ece339e9ad96c01b166301238e1aaa30ddfb978968361a5f9d3fcaa381973c967c0dd88c6d54d00fa375ab4df3be57c4360b69d7634e95e4d4201da8f2348d0ce53be690146f0049d5d173a635d21406b10ed23ec9996bd0a43b812df363986fb8dedf5be1cdb3f85a5090460511af617507d24657e3733310b42e1406070a0316620037da35c5227bb85d3aacf3aebf750265838994e03a8770cdc1c31723ca1037232c32d21f31eee561575b18b1b4c0f027f270898aed60ab4bfe41160cd989cd5bdfeb795097ff01cd0ff41fea96311e92798c0a619aa957772cfd408747fc30dcb39210839a4c70b87d3ad881207fa5eee926bc2c6936ce10b382c7a37606d40bb1cf2637768255aae4a4cd18ed7004e3046520bea92c66a7074e4b46d3d566703e44d0c3f9ef49a2ff30632fe3f6a409178db66423809514cd7473f83d"; vm.startPrank(operatorOne); vm.expectRevert(abi.encodeWithSignature("InvalidSignatures()")); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS, signatures); vm.stopPrank(); } function testAddValidatorsUnauthorized() public { - bytes - memory publicKeys = hex"0c74b6d3d877bbb2083f1bcc83b302f3ed533eaf3cd39cff97daf2c7b9b776168481aa7b51778df673a37049886f25b07f03dbc79d85fa9d41f9eefa8e598353b652aadf497673744527c73127f872b91cf31ec8041dae1b3a4238683cf442ea23a95fe68b400ab42b14e8c99280a057d1d840e80723c3622b38e6acd1f471bf247cf62312c9b863a75ac0d270cefa4f84fd8586dbda15c67c1a46e85cf56c60550f54cb082770baf3d2bbf4c33f5254bd0b93e017f3ed036b13baec41bb69085f9eff48651be38c8f9e1f67b643f84ec356864aaa057f0042b121b9d040ed9be3f5cc9cc659d8f8fc02575ed3c25708adac2c8d0c50ab7e4599ce9edf300d98e1cfcfc8e0022a24c712f0769de99a3389bac1cdca92ae20fba323142fe2e8d09ef2cb59c3f822779b3fe6410cddce7255d35db01093cc435c0a35bbb4cd8d4eb3bd2cc597c49a7a909c16f67fe8b6702d5d0c22ad189b1c45325190015b0017606f768c7aa2006cc19dfeb5f367eae9dd17a5c307705db1f5cec552fc038e5fa3a76352d9621a4d74b1fd7e1707c7bfb5e912e2b5a33a2f34a419055d0c4065aa787f743aff953d73441e96ffc9b0f5a3248c23398518a758aec8451b626bff7eed063a3b11bf661d10ad6dac5ee62f47be125e3c668e14b3c704d736b4fbff"; - bytes - memory signatures = hex"fe41ffbe702fb08d01063c9cd99fac11a16e921c784e681e365db00c4bd6760df67cfc0d0555a8ee8bf534a2c0987b7949b18dba726ced579240fa063274bc7ab25e44b758c452c433debfebbc075cbe105f07502402a9591dc891640a9f2b34fe0863bf987ff4b5a601b0ffcecc185f04847e0b97d3fb9457c32efb9c3ce35520308cfcc8ca78d5d4da164f6d1575d32fe466b8076bc4056ad97fa3e3607a60e5e420bdec413e5ffcc3119b1b89a957b14a437e009a858c4c40c0f1fc7f3d1ad83bc96ada6c2c772260637774e5fbdc60791db6de3a31e136c28106b35c21932a8ed610306f0723675730e31d3deceff4f912e6070c9efcd6e3f0c9ad4a0e203f437f21679b87d46351714b5a1b6226f8ffadd19e18f85c918461ab67291e1c8cdfdc05280adf2b923f1269cf7de8bd351a7ede13524e836cbfc7ba22db91aaa5c9a0729a469985f5bd844347ba9a9b4019f4ad42c2025457cf48557494ac3ce6e311a1ded3e903cd3009d18133015d445d02a3ce3858781b582d28701a311ddb271f8a0c91c65b32cc13c512c35e5be9bb9dc556dfd3249a3733f58426718974820f17b3242a089e29b129fcea37c8b84996e2c725b59efccee24068625584e583700346f823ce92e11ac9db5964ca6300905c5e9f294330037ec1cb7d9b8fc28829b98fcc0fc405afcd54f43cb4a14e8cab3f5aa979fe2c3492fe295e1a50170e8857bd94e5b009bcec9626e6eb137b272882037202da7329dadcb5b99bbd7835b8875d696dab41774dcb559bfb4c79a5337efc5f1606bc7c2752389a49b6a578f0c7c58e2bf9efc55eef19beaf3de94da90c712ca3891ac71a6ff6d778a1c0c31f77fdde2c4b7f29adf8ccf000050e9e4829d2de36fda8d6b26020e6f0ece339e9ad96c01b166301238e1aaa30ddfb978968361a5f9d3fcaa381973c967c0dd88c6d54d00fa375ab4df3be57c4360b69d7634e95e4d4201da8f2348d0ce53be690146f0049d5d173a635d21406b10ed23ec9996bd0a43b812df363986fb8dedf5be1cdb3f85a5090460511af617507d24657e3733310b42e1406070a0316620037da35c5227bb85d3aacf3aebf750265838994e03a8770cdc1c31723ca1037232c32d21f31eee561575b18b1b4c0f027f270898aed60ab4bfe41160cd989cd5bdfeb795097ff01cd0ff41fea96311e92798c0a619aa957772cfd408747fc30dcb39210839a4c70b87d3ad881207fa5eee926bc2c6936ce10b382c7a37606d40bb1cf2637768255aae4a4cd18ed7004e3046520bea92c66a7074e4b46d3d566703e44d0c3f9ef49a2ff30632fe3f6a409178db66423809514cd7473f83d0c"; - vm.expectRevert(abi.encodeWithSignature("Unauthorized()")); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS, SIGNATURES); } function testRemoveValidatorsOperatorOne() public { @@ -836,8 +818,7 @@ contract StakingContractTest is DSTestPlus { assertEq(user.balance, 0); - bytes - memory pk = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory pk = PUBKEY_1; assertEq(stakingContract.getWithdrawer(pk), user); @@ -864,14 +845,11 @@ contract StakingContractTest is DSTestPlus { assertEq(user.balance, 0); - bytes - memory pk = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - - assertEq(stakingContract.getWithdrawer(pk), user); + assertEq(stakingContract.getWithdrawer(PUBKEY_1), user); vm.startPrank(user); vm.expectRevert(abi.encodeWithSignature("Forbidden()")); - stakingContract.setWithdrawer(pk, anotherUser); + stakingContract.setWithdrawer(PUBKEY_1, anotherUser); vm.stopPrank(); } @@ -891,14 +869,11 @@ contract StakingContractTest is DSTestPlus { stakingContract.setWithdrawerCustomizationEnabled(true); vm.stopPrank(); - bytes - memory pk = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - - assertEq(stakingContract.getWithdrawer(pk), user); + assertEq(stakingContract.getWithdrawer(PUBKEY_1), user); vm.startPrank(anotherUser); vm.expectRevert(abi.encodeWithSignature("Unauthorized()")); - stakingContract.setWithdrawer(pk, anotherUser); + stakingContract.setWithdrawer(PUBKEY_1, anotherUser); vm.stopPrank(); } @@ -1105,14 +1080,9 @@ contract StakingContractOperatorTest is DSTestPlus { assertEq(i, operatorIndex); } - bytes - memory publicKeys = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e06014451b3fb9288549aff6dea9843b43e0c47a3b856f307732175230e254c0004e48b02414987088ac7003e148930017b49a1a8d4600f33d463c4afc07bbfc82703c9fcf81a5891f90a71c86a02faff443c6c3b2592bd44d5d3d7a93cb4aaaa105612496d61e68140a5418b468f872bf2f3e79f9cb0d9c3e889663fca02939b31e8ee3092203ee1417128e965c6406a07f68abf2ebe2689cf6c853ef126ffa8574c2a7d913e28de9147fa6b96706ea5bf9eacd1aba06edeaee155009fb912c00070774cc64136fcffde12ed731260bc5529df64da298f493561198e9d6acf42cf21e853ae7b2df85f27d2183149969d623b9237254c2cfe1d0082742eb042ac096d686dbe03c79ee31cbd03bb4682f8797043eed9f6e622814831ac5dfe1176552fb7f9b6ff38a149ae1d8414097a32fd96da6453c52fda13e3402a09e2fa6886daa4300f09c73e4bc2901b99c44744c5cfdca2994adc49ddccb195bda2510e50a4ae10de26cf96dee5e577689f51650a610a33da0a826ae47247d8d1189cb3386"; - - bytes - memory signatures = hex"ccb81f4485957f440bc17dbe760f374cbb112c6f12fa10e8709fac4522b30440d918c7bb867fa04f6b3cfbd977455f8f2fde586fdf3d7baa429e98e497ff871f3b8db1528b2b964fa24d26e377c74746496cc719c50dbf391fb3f74f5ca4b93a02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966f393d619cbf13ff427df11dcb17026df25f35268de5b168e359c16f2a3d5fbc6376db44638d773c851c875f21222448433d285920e8bdc4f5cbff130d7387c0a9589324286aea398e5aacad3bbfe3992dfce62571f0e282ed9c29e3fa5b07aa5c81749589b1170d3b85a84331e2f6b8e26eadebfd569b225759f40bbd12d6c3d253ed3f379b014b2ea44cce54d362072e2d020ff139a903b7d87fc3fddc2e6657c83e0b79851c22c6e0e477463463c97d6cc0e2e2de5e35b227bddb285521be3766358abaf3159d89f68c9770e28278f177088cfc4089b817effaaecabdffa4e66427868b105cb9348ea2d84eeea059a5d1ff3277d6f9cf656fc973d07cabed70fb8f8eb2798a65d207a8e1f8a26910949db9fa62d62bc15ecc097a93a27a1873405b8589a4ddf0ecf0303c6031484562b32eb7881975026524d6d4a9de6cd73fe2c324501586b9b6fa6bce950bbd21472278302f83dbfd6be036f2fc36d299d66578e844be3d6aa8314fab468f038fd6e130ada0a886fccfb2fd843f7dd07e8968401bbe2af7345fce52ba4b310b30af2d54b15669d06c206682c1730ab6b17787e361f04401f78dc5cbd5fac955df4e83c24cdabfabdb3f4ea40961d04a5ca166c17694fca144025b47131a68ddb230d36fe6e831e82624c9a925d706bff86982852b26ebf019a3f6ee36aedbbc6bec2d50531a233e09225493d3c5fd48379aec373baf622fb9feed6261e5296e5ae6601e7523c7f386801ed63a344b07106a0d03e5848209db5e114c0e67884916a43a1bfb77d9b8ea113c3ba8cad4b006aafeadcc31e70e85c5efecaf807154d011c1413340d4b592d2f270fb48b2050e08493c1427ddfac8dcc27fe434d32a35dcbddbcb1c4e22ead6734a4ac910f6768bc9ff6b355c1151695e41121cdcc9d9d3b18cf4d66ca3c1db0527c471a0dcf256590602a7269dcb26175e7eb370bd9794ac8ab558bea69e6a92d8e818b675a80e2df0516b8307291d93cb85d959ac60d47b46455a7ab0a38687c747c6d2d9e8c20ccf74dc6cdf145ec06805d4ac24a39aec2f5cd6e26e63e3d043a31c42411e4"; vm.stopPrank(); vm.startPrank(operatorZero); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS, SIGNATURES); vm.stopPrank(); vm.startPrank(admin); stakingContract.setOperatorLimit(0, 10, block.number); @@ -1299,14 +1269,8 @@ contract StakingContractOneValidatorTest is Test { vm.stopPrank(); { - bytes - memory publicKeys = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e06014451b3fb9288549aff6dea9843b43e0c47a3b856f307732175230e254c0004e48b02414987088ac7003e148930017b49a1a8d4600f33d463c4afc07bbfc82703c9fcf81a5891f90a71c86a02faff443c6c3b2592bd44d5d3d7a93cb4aaaa105612496d61e68140a5418b468f872bf2f3e79f9cb0d9c3e889663fca02939b31e8ee3092203ee1417128e965c6406a07f68abf2ebe2689cf6c853ef126ffa8574c2a7d913e28de9147fa6b96706ea5bf9eacd1aba06edeaee155009fb912c00070774cc64136fcffde12ed731260bc5529df64da298f493561198e9d6acf42cf21e853ae7b2df85f27d2183149969d623b9237254c2cfe1d0082742eb042ac096d686dbe03c79ee31cbd03bb4682f8797043eed9f6e622814831ac5dfe1176552fb7f9b6ff38a149ae1d8414097a32fd96da6453c52fda13e3402a09e2fa6886daa4300f09c73e4bc2901b99c44744c5cfdca2994adc49ddccb195bda2510e50a4ae10de26cf96dee5e577689f51650a610a33da0a826ae47247d8d1189cb3386"; - - bytes - memory signatures = hex"ccb81f4485957f440bc17dbe760f374cbb112c6f12fa10e8709fac4522b30440d918c7bb867fa04f6b3cfbd977455f8f2fde586fdf3d7baa429e98e497ff871f3b8db1528b2b964fa24d26e377c74746496cc719c50dbf391fb3f74f5ca4b93a02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966f393d619cbf13ff427df11dcb17026df25f35268de5b168e359c16f2a3d5fbc6376db44638d773c851c875f21222448433d285920e8bdc4f5cbff130d7387c0a9589324286aea398e5aacad3bbfe3992dfce62571f0e282ed9c29e3fa5b07aa5c81749589b1170d3b85a84331e2f6b8e26eadebfd569b225759f40bbd12d6c3d253ed3f379b014b2ea44cce54d362072e2d020ff139a903b7d87fc3fddc2e6657c83e0b79851c22c6e0e477463463c97d6cc0e2e2de5e35b227bddb285521be3766358abaf3159d89f68c9770e28278f177088cfc4089b817effaaecabdffa4e66427868b105cb9348ea2d84eeea059a5d1ff3277d6f9cf656fc973d07cabed70fb8f8eb2798a65d207a8e1f8a26910949db9fa62d62bc15ecc097a93a27a1873405b8589a4ddf0ecf0303c6031484562b32eb7881975026524d6d4a9de6cd73fe2c324501586b9b6fa6bce950bbd21472278302f83dbfd6be036f2fc36d299d66578e844be3d6aa8314fab468f038fd6e130ada0a886fccfb2fd843f7dd07e8968401bbe2af7345fce52ba4b310b30af2d54b15669d06c206682c1730ab6b17787e361f04401f78dc5cbd5fac955df4e83c24cdabfabdb3f4ea40961d04a5ca166c17694fca144025b47131a68ddb230d36fe6e831e82624c9a925d706bff86982852b26ebf019a3f6ee36aedbbc6bec2d50531a233e09225493d3c5fd48379aec373baf622fb9feed6261e5296e5ae6601e7523c7f386801ed63a344b07106a0d03e5848209db5e114c0e67884916a43a1bfb77d9b8ea113c3ba8cad4b006aafeadcc31e70e85c5efecaf807154d011c1413340d4b592d2f270fb48b2050e08493c1427ddfac8dcc27fe434d32a35dcbddbcb1c4e22ead6734a4ac910f6768bc9ff6b355c1151695e41121cdcc9d9d3b18cf4d66ca3c1db0527c471a0dcf256590602a7269dcb26175e7eb370bd9794ac8ab558bea69e6a92d8e818b675a80e2df0516b8307291d93cb85d959ac60d47b46455a7ab0a38687c747c6d2d9e8c20ccf74dc6cdf145ec06805d4ac24a39aec2f5cd6e26e63e3d043a31c42411e4"; - vm.startPrank(operatorOne); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS, SIGNATURES); vm.stopPrank(); } @@ -1327,21 +1291,16 @@ contract StakingContractOneValidatorTest is Test { vm.startPrank(user); bytes memory expectedWithdrawalCredentials = abi.encodePacked( bytes32( - uint256( - uint160( - stakingContract.getCLFeeRecipient( - hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759" - ) - ) - ) + 0x0100000000000000000000000000000000000000000000000000000000000000 + uint256(uint160(stakingContract.getCLFeeRecipient(PUBKEY_1))) + + 0x0100000000000000000000000000000000000000000000000000000000000000 ) ); vm.expectEmit(true, true, true, true); emit DepositEvent( - hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759", + PUBKEY_1, expectedWithdrawalCredentials, hex"0040597307000000", - hex"ccb81f4485957f440bc17dbe760f374cbb112c6f12fa10e8709fac4522b30440d918c7bb867fa04f6b3cfbd977455f8f2fde586fdf3d7baa429e98e497ff871f3b8db1528b2b964fa24d26e377c74746496cc719c50dbf391fb3f74f5ca4b93a", + SIGNATURE_1, hex"0000000000000000" ); stakingContract.deposit{value: 32 ether}(); @@ -1383,12 +1342,7 @@ contract StakingContractOneValidatorTest is Test { vm.startPrank(user); vm.expectEmit(true, true, true, true); - emit Deposit( - user, - user, - hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060", - hex"02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966" - ); + emit Deposit(user, user, PUBKEY_2, SIGNATURE_2); stakingContract.deposit{value: 32 * 2 ether}(); vm.stopPrank(); @@ -1503,7 +1457,7 @@ contract StakingContractOneValidatorTest is Test { user, user, hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060", - hex"02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966" + SIGNATURE_2 ); (bool _success, ) = address(stakingContract).call{value: 32 * 2 ether}(""); assert(_success == true); @@ -1666,8 +1620,7 @@ contract StakingContractOneValidatorTest is Test { } function testFeeRecipients() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); address _elfr = stakingContract.getELFeeRecipient(publicKey); @@ -1676,8 +1629,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawELFees() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1699,8 +1651,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawELFees_asAdmin() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1722,8 +1673,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawELFees_asRandom() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1744,8 +1694,7 @@ contract StakingContractOneValidatorTest is Test { vm.startPrank(admin); stakingContract.setOperatorFee(5000); vm.stopPrank(); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1768,8 +1717,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawELFeesAlreadyDeployed() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1798,8 +1746,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawELFeesEmptyWithdrawal() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1809,8 +1756,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawCLFeesExitedValidator() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1839,8 +1785,7 @@ contract StakingContractOneValidatorTest is Test { vm.startPrank(admin); stakingContract.setOperatorFee(5000); vm.stopPrank(); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1866,8 +1811,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawCLFeesSkimmedValidator() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1890,8 +1834,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawCLFeesSkimmedLuckyValidator() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1914,8 +1857,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawCLFeesSlashedValidator() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1937,8 +1879,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawCLFeesAlreadyDeployed() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1975,8 +1916,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawCLFeesEmptyWithdrawal() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -1987,8 +1927,7 @@ contract StakingContractOneValidatorTest is Test { } function testWithdrawAllFees() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; + bytes memory publicKey = PUBKEY_1; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -2098,14 +2037,8 @@ contract StakingContractBehindProxyTest is Test { vm.stopPrank(); { - bytes - memory publicKeys = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e06014451b3fb9288549aff6dea9843b43e0c47a3b856f307732175230e254c0004e48b02414987088ac7003e148930017b49a1a8d4600f33d463c4afc07bbfc82703c9fcf81a5891f90a71c86a02faff443c6c3b2592bd44d5d3d7a93cb4aaaa105612496d61e68140a5418b468f872bf2f3e79f9cb0d9c3e889663fca02939b31e8ee3092203ee1417128e965c6406a07f68abf2ebe2689cf6c853ef126ffa8574c2a7d913e28de9147fa6b96706ea5bf9eacd1aba06edeaee155009fb912c00070774cc64136fcffde12ed731260bc5529df64da298f493561198e9d6acf42cf21e853ae7b2df85f27d2183149969d623b9237254c2cfe1d0082742eb042ac096d686dbe03c79ee31cbd03bb4682f8797043eed9f6e622814831ac5dfe1176552fb7f9b6ff38a149ae1d8414097a32fd96da6453c52fda13e3402a09e2fa6886daa4300f09c73e4bc2901b99c44744c5cfdca2994adc49ddccb195bda2510e50a4ae10de26cf96dee5e577689f51650a610a33da0a826ae47247d8d1189cb3386"; - - bytes - memory signatures = hex"ccb81f4485957f440bc17dbe760f374cbb112c6f12fa10e8709fac4522b30440d918c7bb867fa04f6b3cfbd977455f8f2fde586fdf3d7baa429e98e497ff871f3b8db1528b2b964fa24d26e377c74746496cc719c50dbf391fb3f74f5ca4b93a02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966f393d619cbf13ff427df11dcb17026df25f35268de5b168e359c16f2a3d5fbc6376db44638d773c851c875f21222448433d285920e8bdc4f5cbff130d7387c0a9589324286aea398e5aacad3bbfe3992dfce62571f0e282ed9c29e3fa5b07aa5c81749589b1170d3b85a84331e2f6b8e26eadebfd569b225759f40bbd12d6c3d253ed3f379b014b2ea44cce54d362072e2d020ff139a903b7d87fc3fddc2e6657c83e0b79851c22c6e0e477463463c97d6cc0e2e2de5e35b227bddb285521be3766358abaf3159d89f68c9770e28278f177088cfc4089b817effaaecabdffa4e66427868b105cb9348ea2d84eeea059a5d1ff3277d6f9cf656fc973d07cabed70fb8f8eb2798a65d207a8e1f8a26910949db9fa62d62bc15ecc097a93a27a1873405b8589a4ddf0ecf0303c6031484562b32eb7881975026524d6d4a9de6cd73fe2c324501586b9b6fa6bce950bbd21472278302f83dbfd6be036f2fc36d299d66578e844be3d6aa8314fab468f038fd6e130ada0a886fccfb2fd843f7dd07e8968401bbe2af7345fce52ba4b310b30af2d54b15669d06c206682c1730ab6b17787e361f04401f78dc5cbd5fac955df4e83c24cdabfabdb3f4ea40961d04a5ca166c17694fca144025b47131a68ddb230d36fe6e831e82624c9a925d706bff86982852b26ebf019a3f6ee36aedbbc6bec2d50531a233e09225493d3c5fd48379aec373baf622fb9feed6261e5296e5ae6601e7523c7f386801ed63a344b07106a0d03e5848209db5e114c0e67884916a43a1bfb77d9b8ea113c3ba8cad4b006aafeadcc31e70e85c5efecaf807154d011c1413340d4b592d2f270fb48b2050e08493c1427ddfac8dcc27fe434d32a35dcbddbcb1c4e22ead6734a4ac910f6768bc9ff6b355c1151695e41121cdcc9d9d3b18cf4d66ca3c1db0527c471a0dcf256590602a7269dcb26175e7eb370bd9794ac8ab558bea69e6a92d8e818b675a80e2df0516b8307291d93cb85d959ac60d47b46455a7ab0a38687c747c6d2d9e8c20ccf74dc6cdf145ec06805d4ac24a39aec2f5cd6e26e63e3d043a31c42411e4"; - vm.startPrank(operatorOne); - stakingContract.addValidators(0, 10, publicKeys, signatures); + stakingContract.addValidators(0, 10, PUBLIC_KEYS, SIGNATURES); vm.stopPrank(); } @@ -2128,21 +2061,16 @@ contract StakingContractBehindProxyTest is Test { vm.startPrank(user); bytes memory expectedWithdrawalCredentials = abi.encodePacked( bytes32( - uint256( - uint160( - stakingContract.getCLFeeRecipient( - hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759" - ) - ) - ) + 0x0100000000000000000000000000000000000000000000000000000000000000 + uint256(uint160(stakingContract.getCLFeeRecipient(PUBKEY_1))) + + 0x0100000000000000000000000000000000000000000000000000000000000000 ) ); vm.expectEmit(true, true, true, true); emit DepositEvent( - hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759", + PUBKEY_1, expectedWithdrawalCredentials, hex"0040597307000000", - hex"ccb81f4485957f440bc17dbe760f374cbb112c6f12fa10e8709fac4522b30440d918c7bb867fa04f6b3cfbd977455f8f2fde586fdf3d7baa429e98e497ff871f3b8db1528b2b964fa24d26e377c74746496cc719c50dbf391fb3f74f5ca4b93a", + SIGNATURE_1, hex"0000000000000000" ); stakingContract.deposit{value: 32 ether}(); @@ -2204,6 +2132,7 @@ contract StakingContractBehindProxyTest is Test { vm.startPrank(user); stakingContract.deposit{value: 32 ether}(); vm.stopPrank(); + assertEq(user, stakingContract.getWithdrawer(PUBKEY_1)); } function test_deposit_BlockedUser(address user) public { @@ -2230,7 +2159,7 @@ contract StakingContractBehindProxyTest is Test { user, user, hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060", - hex"02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966" + SIGNATURE_2 ); stakingContract.deposit{value: 32 * 2 ether}(); vm.stopPrank(); @@ -2346,7 +2275,7 @@ contract StakingContractBehindProxyTest is Test { user, user, hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060", - hex"02a9f0007cd7b7d2af2d1b07c8600ab86a5d27dc51a29c2e3007c7a69cb73bcaecc764641e02370955dba100428d259d6475ee3566872bd43b0e73e55b9669e50f2b1666e57b326a5dfad655c7921e0dfb421b1ec59c8fdb48eb77421fd06966" + SIGNATURE_2 ); (bool _success, ) = address(stakingContract).call{value: 32 * 2 ether}(""); assert(_success == true); @@ -2455,31 +2384,27 @@ contract StakingContractBehindProxyTest is Test { } function testFeeRecipients() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); - address _elfr = stakingContract.getELFeeRecipient(publicKey); - address _clfr = stakingContract.getCLFeeRecipient(publicKey); + address _elfr = stakingContract.getELFeeRecipient(PUBKEY_1); + address _clfr = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(_elfr != _clfr); } function testWithdrawELFees() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); assert(elfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); assert(feeRecipientOne.balance == 0); vm.deal(address(elfrBob), 1 ether); vm.prank(bob); - stakingContract.withdrawELFee(publicKey); + stakingContract.withdrawELFee(PUBKEY_1); assert(elfrBob.code.length != 0); assert(bob.balance == 0.9 ether); assert(operatorOne.balance == 0); @@ -2488,20 +2413,16 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawELFees() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); - address elfrBob2 = stakingContract.getELFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); + address elfrBob2 = stakingContract.getELFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.deal(address(elfrBob), 1 ether); vm.deal(address(elfrBob2), 1 ether); vm.prank(bob); @@ -2513,20 +2434,16 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawELFees_asAdmin() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); - address elfrBob2 = stakingContract.getELFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); + address elfrBob2 = stakingContract.getELFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.deal(address(elfrBob), 1 ether); vm.deal(address(elfrBob2), 1 ether); vm.prank(admin); @@ -2538,23 +2455,19 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawELFees_WrongWithdrawerSecondKey() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 32 ether); address bob2 = makeAddr("bob2"); vm.deal(bob2, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); vm.prank(bob2); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob2); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); - address elfrBob2 = stakingContract.getELFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob2); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); + address elfrBob2 = stakingContract.getELFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.deal(address(elfrBob), 1 ether); vm.deal(address(elfrBob2), 1 ether); vm.expectRevert(abi.encodeWithSignature("InvalidWithdrawer()")); @@ -2563,20 +2476,16 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawELFees_WrongPublicKeys() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); - address elfrBob2 = stakingContract.getELFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); + address elfrBob2 = stakingContract.getELFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); publicKeys = BytesLib.concat(publicKeys, hex"66"); vm.deal(address(elfrBob), 1 ether); vm.deal(address(elfrBob2), 1 ether); @@ -2589,14 +2498,12 @@ contract StakingContractBehindProxyTest is Test { vm.startPrank(admin); stakingContract.setOperatorFee(5000); vm.stopPrank(); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); assert(elfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); @@ -2604,7 +2511,7 @@ contract StakingContractBehindProxyTest is Test { assert(address(treasury).balance == 0); vm.deal(address(elfrBob), 1 ether); vm.prank(bob); - stakingContract.withdrawELFee(publicKey); + stakingContract.withdrawELFee(PUBKEY_1); assert(elfrBob.code.length != 0); assert(bob.balance == 0.9 ether); assert(operatorOne.balance == 0); @@ -2613,21 +2520,19 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawELFeesAlreadyDeployed() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); assert(elfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); assert(feeRecipientOne.balance == 0); vm.deal(address(elfrBob), 1 ether); vm.prank(bob); - stakingContract.withdrawELFee(publicKey); + stakingContract.withdrawELFee(PUBKEY_1); assert(elfrBob.code.length != 0); assert(bob.balance == 0.9 ether); assert(operatorOne.balance == 0); @@ -2635,7 +2540,7 @@ contract StakingContractBehindProxyTest is Test { assert(address(treasury).balance == 0.08 ether); vm.deal(address(elfrBob), 1 ether); vm.prank(bob); - stakingContract.withdrawELFee(publicKey); + stakingContract.withdrawELFee(PUBKEY_1); assert(bob.balance == 1.8 ether); assert(operatorOne.balance == 0); assert(feeRecipientOne.balance == 0.04 ether); @@ -2643,27 +2548,23 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawELFeesEmptyWithdrawal() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); vm.expectRevert(abi.encodeWithSignature("ZeroBalanceWithdrawal()")); vm.prank(bob); - stakingContract.withdrawELFee(publicKey); + stakingContract.withdrawELFee(PUBKEY_1); } function testWithdrawCLFeesExitedValidator() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); @@ -2671,10 +2572,10 @@ contract StakingContractBehindProxyTest is Test { assert(feeRecipientOne.balance == 0); vm.deal(address(clfrBob), 1 ether); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); vm.deal(address(clfrBob), 33 ether); vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); assert(clfrBob.code.length != 0); assertApproxEqAbs(bob.balance, 32.90 ether, 10**5); assert(operatorOne.balance == 0); @@ -2683,14 +2584,12 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesExitedValidator_RewardsAfterRequest() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); @@ -2698,10 +2597,10 @@ contract StakingContractBehindProxyTest is Test { assert(feeRecipientOne.balance == 0); vm.deal(address(clfrBob), 1 ether); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); vm.deal(address(clfrBob), 34 ether); // skimming + exit + rewards earned since last skimming vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); assert(clfrBob.code.length != 0); assertApproxEqAbs(bob.balance, 33.80 ether, 10**5); assert(operatorOne.balance == 0); @@ -2710,29 +2609,27 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesExitedValidator_UserTriesToStealFee() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); assert(address(treasury).balance == 0 ether); assert(feeRecipientOne.balance == 0); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); vm.deal(address(clfrBob), 2 ether); // skimming happens between request & actual exit vm.deal(address(clfrBob), 32 ether); // withdrawer send 30 ETH to the fee recipient, using a self destructing contract vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); assertEq(bob.balance, 32 ether); // no fee was paid on the last withdraw, it was treated as an exiting validator vm.deal(address(clfrBob), 32 ether); vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); // The user tried to scam the commission, as a consequence the fee is applied to their principal + stakingContract.withdrawCLFee(PUBKEY_1); // The user tried to scam the commission, as a consequence the fee is applied to their principal assert(clfrBob.code.length != 0); assertEq(bob.balance, 60.8 ether); assert(operatorOne.balance == 0); @@ -2744,14 +2641,12 @@ contract StakingContractBehindProxyTest is Test { vm.startPrank(admin); stakingContract.setOperatorFee(5000); vm.stopPrank(); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); @@ -2759,10 +2654,10 @@ contract StakingContractBehindProxyTest is Test { assert(address(treasury).balance == 0); vm.deal(address(clfrBob), 1 ether); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); vm.deal(address(clfrBob), 33 ether); vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); assert(clfrBob.code.length != 0); assertApproxEqAbs(bob.balance, 32.90 ether, 10**5); @@ -2772,14 +2667,12 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesSkimmedValidator() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); @@ -2787,7 +2680,7 @@ contract StakingContractBehindProxyTest is Test { assert(address(treasury).balance == 0); vm.deal(address(clfrBob), 1 ether); vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); assert(clfrBob.code.length != 0); assertApproxEqAbs(bob.balance, 0.90 ether, 10**5); assert(operatorOne.balance == 0); @@ -2796,14 +2689,12 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesSkimmedValidator_asAdmin() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); @@ -2811,7 +2702,7 @@ contract StakingContractBehindProxyTest is Test { assert(address(treasury).balance == 0); vm.deal(address(clfrBob), 1 ether); vm.prank(admin); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); assert(clfrBob.code.length != 0); assertApproxEqAbs(bob.balance, 0.90 ether, 10**5); assert(operatorOne.balance == 0); @@ -2820,14 +2711,12 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesSkimmedValidator_asRandom() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); @@ -2836,24 +2725,20 @@ contract StakingContractBehindProxyTest is Test { vm.deal(address(clfrBob), 1 ether); vm.expectRevert(abi.encodeWithSignature("InvalidWithdrawer()")); vm.prank(address(0xdede)); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); } function testBatchWithdrawCLFees_asAdmin() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); - address clfrBob2 = stakingContract.getCLFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); + address clfrBob2 = stakingContract.getCLFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.deal(address(clfrBob), 1 ether); vm.deal(address(clfrBob2), 1 ether); vm.prank(admin); @@ -2865,23 +2750,19 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawCLFees_WrongSecondWithdrawer() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 32 ether); address bob2 = makeAddr("bob2"); vm.deal(bob2, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); vm.prank(bob2); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob2); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); - address clfrBob2 = stakingContract.getCLFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob2); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); + address clfrBob2 = stakingContract.getCLFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.deal(address(clfrBob), 1 ether); vm.deal(address(clfrBob2), 1 ether); vm.expectRevert(abi.encodeWithSignature("InvalidWithdrawer()")); @@ -2890,20 +2771,16 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawCLFees() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); - address clfrBob2 = stakingContract.getCLFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); + address clfrBob2 = stakingContract.getCLFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.deal(address(clfrBob), 1 ether); vm.deal(address(clfrBob2), 1 ether); vm.prank(bob); @@ -2915,20 +2792,16 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawCLFees_WrongPublicKeys() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); - address clfrBob2 = stakingContract.getCLFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); + address clfrBob2 = stakingContract.getCLFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); publicKeys = BytesLib.concat(publicKeys, hex"66"); vm.deal(address(clfrBob), 1 ether); vm.deal(address(clfrBob2), 1 ether); @@ -2938,14 +2811,12 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesSlashedValidator() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); @@ -2953,7 +2824,7 @@ contract StakingContractBehindProxyTest is Test { // Less than 32 ETH land on the fee recipient vm.deal(address(clfrBob), 31.95 ether); vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); // In this case the user will the be manually rebated and covered by insurance assert(clfrBob.code.length != 0); @@ -2962,23 +2833,21 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesSlashedValidatorWithRewards() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); vm.deal(address(clfrBob), 1 ether); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); vm.deal(address(clfrBob), 28.755 ether); vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); // In this case the user will the be manually rebated and covered by insurance assert(clfrBob.code.length != 0); @@ -2987,21 +2856,19 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesAlreadyDeployed() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); assert(operatorOne.balance == 0); assert(feeRecipientOne.balance == 0); vm.deal(address(clfrBob), 1 ether); vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); assert(clfrBob.code.length != 0); assertApproxEqAbs(bob.balance, 0.90 ether, 10**5); assert(operatorOne.balance == 0); @@ -3010,10 +2877,10 @@ contract StakingContractBehindProxyTest is Test { vm.deal(address(clfrBob), 1 ether); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); vm.deal(address(clfrBob), 33 ether); vm.prank(bob); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); assertApproxEqAbs(bob.balance, 33.80 ether, 10**6); assert(operatorOne.balance == 0); @@ -3022,14 +2889,12 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawCLFeesEmptyWithdrawal() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.expectRevert(abi.encodeWithSignature("ZeroBalanceWithdrawal()")); - stakingContract.withdrawCLFee(publicKey); + stakingContract.withdrawCLFee(PUBKEY_1); vm.stopPrank(); assertEq(bob.balance, 0); assertEq(address(treasury).balance, 0); @@ -3037,15 +2902,13 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawAllFees() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); assert(bob.balance == 0); @@ -3055,14 +2918,14 @@ contract StakingContractBehindProxyTest is Test { vm.deal(address(clfrBob), 1 ether); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); vm.deal(address(clfrBob), 33 ether); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); assert(elfrBob.code.length == 0); vm.deal(address(elfrBob), 1 ether); vm.prank(bob); - stakingContract.withdraw(publicKey); + stakingContract.withdraw(PUBKEY_1); assertApproxEqAbs(bob.balance, 33.80 ether, 10**5); assert(operatorOne.balance == 0); @@ -3075,8 +2938,6 @@ contract StakingContractBehindProxyTest is Test { vm.prank(admin); stakingContract.setSanctionsOracle(address(oracle)); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); vm.expectRevert(abi.encodeWithSignature("AddressSanctioned(address)", bob)); @@ -3085,19 +2946,17 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawAllFees_asAdmin() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); vm.deal(address(clfrBob), 1 ether); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); assert(elfrBob.code.length == 0); vm.deal(address(elfrBob), 1 ether); @@ -3107,7 +2966,7 @@ contract StakingContractBehindProxyTest is Test { assert(address(treasury).balance == 0); vm.prank(admin); - stakingContract.withdraw(publicKey); + stakingContract.withdraw(PUBKEY_1); assertApproxEqAbs(bob.balance, 1.80 ether, 10**5); assert(operatorOne.balance == 0); @@ -3116,19 +2975,17 @@ contract StakingContractBehindProxyTest is Test { } function testWithdrawAllFees_asRandom() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); assert(clfrBob.code.length == 0); vm.deal(address(clfrBob), 33 ether); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); assert(elfrBob.code.length == 0); vm.deal(address(elfrBob), 1 ether); @@ -3139,28 +2996,24 @@ contract StakingContractBehindProxyTest is Test { vm.expectRevert(abi.encodeWithSignature("InvalidWithdrawer()")); vm.prank(address(0xdede)); - stakingContract.withdraw(publicKey); + stakingContract.withdraw(PUBKEY_1); } function testBatchWithdrawAllFees() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); - address elfrBob2 = stakingContract.getELFeeRecipient(publicKey2); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); + address elfrBob2 = stakingContract.getELFeeRecipient(PUBKEY_2); vm.deal(address(elfrBob), 1 ether); vm.deal(address(elfrBob2), 1 ether); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); - address clfrBob2 = stakingContract.getCLFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); + address clfrBob2 = stakingContract.getCLFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.prank(bob); vm.deal(address(clfrBob), 1 ether); vm.deal(address(clfrBob2), 1 ether); @@ -3172,24 +3025,20 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawAllFees_asAdmin() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); - address elfrBob2 = stakingContract.getELFeeRecipient(publicKey2); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); + address elfrBob2 = stakingContract.getELFeeRecipient(PUBKEY_2); vm.deal(address(elfrBob), 1 ether); vm.deal(address(elfrBob2), 1 ether); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); - address clfrBob2 = stakingContract.getCLFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); + address clfrBob2 = stakingContract.getCLFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.prank(admin); vm.deal(address(clfrBob), 1 ether); vm.deal(address(clfrBob2), 1 ether); @@ -3201,27 +3050,23 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawAllFees_WrongWithdrawer() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 32 ether); address bob2 = makeAddr("bob2"); vm.deal(bob2, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); vm.prank(bob2); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob2); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); - address elfrBob2 = stakingContract.getELFeeRecipient(publicKey2); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob2); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); + address elfrBob2 = stakingContract.getELFeeRecipient(PUBKEY_2); vm.deal(address(elfrBob), 1 ether); vm.deal(address(elfrBob2), 1 ether); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); - address clfrBob2 = stakingContract.getCLFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); + address clfrBob2 = stakingContract.getCLFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.prank(bob); vm.deal(address(clfrBob), 1 ether); vm.deal(address(clfrBob2), 1 ether); @@ -3230,24 +3075,20 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawAllFees_WrongPublicKeys() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 64 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - address elfrBob = stakingContract.getELFeeRecipient(publicKey); - address elfrBob2 = stakingContract.getELFeeRecipient(publicKey2); + address elfrBob = stakingContract.getELFeeRecipient(PUBKEY_1); + address elfrBob2 = stakingContract.getELFeeRecipient(PUBKEY_2); vm.deal(address(elfrBob), 1 ether); vm.deal(address(elfrBob2), 1 ether); - address clfrBob = stakingContract.getCLFeeRecipient(publicKey); - address clfrBob2 = stakingContract.getCLFeeRecipient(publicKey2); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + address clfrBob = stakingContract.getCLFeeRecipient(PUBKEY_1); + address clfrBob2 = stakingContract.getCLFeeRecipient(PUBKEY_2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); publicKeys = BytesLib.concat(publicKeys, hex"66"); vm.prank(bob); vm.deal(address(clfrBob), 1 ether); @@ -3257,22 +3098,20 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawELFees_10() public { - bytes - memory publicKeys_10 = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e06014451b3fb9288549aff6dea9843b43e0c47a3b856f307732175230e254c0004e48b02414987088ac7003e148930017b49a1a8d4600f33d463c4afc07bbfc82703c9fcf81a5891f90a71c86a02faff443c6c3b2592bd44d5d3d7a93cb4aaaa105612496d61e68140a5418b468f872bf2f3e79f9cb0d9c3e889663fca02939b31e8ee3092203ee1417128e965c6406a07f68abf2ebe2689cf6c853ef126ffa8574c2a7d913e28de9147fa6b96706ea5bf9eacd1aba06edeaee155009fb912c00070774cc64136fcffde12ed731260bc5529df64da298f493561198e9d6acf42cf21e853ae7b2df85f27d2183149969d623b9237254c2cfe1d0082742eb042ac096d686dbe03c79ee31cbd03bb4682f8797043eed9f6e622814831ac5dfe1176552fb7f9b6ff38a149ae1d8414097a32fd96da6453c52fda13e3402a09e2fa6886daa4300f09c73e4bc2901b99c44744c5cfdca2994adc49ddccb195bda2510e50a4ae10de26cf96dee5e577689f51650a610a33da0a826ae47247d8d1189cb3386"; - assertEq(publicKeys_10.length, 480); + assertEq(PUBLIC_KEYS.length, 480); vm.deal(bob, 320 ether); vm.startPrank(bob); - for (uint256 i = 0; i < publicKeys_10.length; i += 48) { + for (uint256 i = 0; i < PUBLIC_KEYS.length; i += 48) { stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(BytesLib.slice(publicKeys_10, i, 48)) == bob); + assert(stakingContract.getWithdrawer(BytesLib.slice(PUBLIC_KEYS, i, 48)) == bob); } vm.stopPrank(); - for (uint256 i = 0; i < publicKeys_10.length; i += 48) { - address elfrBob = stakingContract.getELFeeRecipient(BytesLib.slice(publicKeys_10, i, 48)); + for (uint256 i = 0; i < PUBLIC_KEYS.length; i += 48) { + address elfrBob = stakingContract.getELFeeRecipient(BytesLib.slice(PUBLIC_KEYS, i, 48)); vm.deal(address(elfrBob), 1 ether); } vm.prank(bob); - stakingContract.batchWithdrawELFee(publicKeys_10); + stakingContract.batchWithdrawELFee(PUBLIC_KEYS); assertEq(bob.balance, 9 ether); assertEq(operatorOne.balance, 0); assertEq(feeRecipientOne.balance, 0.2 ether); @@ -3280,22 +3119,20 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawCLFees_10() public { - bytes - memory publicKeys_10 = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e06014451b3fb9288549aff6dea9843b43e0c47a3b856f307732175230e254c0004e48b02414987088ac7003e148930017b49a1a8d4600f33d463c4afc07bbfc82703c9fcf81a5891f90a71c86a02faff443c6c3b2592bd44d5d3d7a93cb4aaaa105612496d61e68140a5418b468f872bf2f3e79f9cb0d9c3e889663fca02939b31e8ee3092203ee1417128e965c6406a07f68abf2ebe2689cf6c853ef126ffa8574c2a7d913e28de9147fa6b96706ea5bf9eacd1aba06edeaee155009fb912c00070774cc64136fcffde12ed731260bc5529df64da298f493561198e9d6acf42cf21e853ae7b2df85f27d2183149969d623b9237254c2cfe1d0082742eb042ac096d686dbe03c79ee31cbd03bb4682f8797043eed9f6e622814831ac5dfe1176552fb7f9b6ff38a149ae1d8414097a32fd96da6453c52fda13e3402a09e2fa6886daa4300f09c73e4bc2901b99c44744c5cfdca2994adc49ddccb195bda2510e50a4ae10de26cf96dee5e577689f51650a610a33da0a826ae47247d8d1189cb3386"; - assertEq(publicKeys_10.length, 480); + assertEq(PUBLIC_KEYS.length, 480); vm.deal(bob, 320 ether); vm.startPrank(bob); - for (uint256 i = 0; i < publicKeys_10.length; i += 48) { + for (uint256 i = 0; i < PUBLIC_KEYS.length; i += 48) { stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(BytesLib.slice(publicKeys_10, i, 48)) == bob); + assert(stakingContract.getWithdrawer(BytesLib.slice(PUBLIC_KEYS, i, 48)) == bob); } vm.stopPrank(); - for (uint256 i = 0; i < publicKeys_10.length; i += 48) { - address clfrBob = stakingContract.getCLFeeRecipient(BytesLib.slice(publicKeys_10, i, 48)); + for (uint256 i = 0; i < PUBLIC_KEYS.length; i += 48) { + address clfrBob = stakingContract.getCLFeeRecipient(BytesLib.slice(PUBLIC_KEYS, i, 48)); vm.deal(address(clfrBob), 1 ether); } vm.prank(bob); - stakingContract.batchWithdrawCLFee(publicKeys_10); + stakingContract.batchWithdrawCLFee(PUBLIC_KEYS); assertApproxEqAbs(bob.balance, 9 ether, 10**7); assertEq(operatorOne.balance, 0); assertApproxEqAbs(address(treasury).balance, 0.8 ether, 10**6); @@ -3303,24 +3140,22 @@ contract StakingContractBehindProxyTest is Test { } function testBatchWithdrawAllFees_10() public { - bytes - memory publicKeys_10 = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e06014451b3fb9288549aff6dea9843b43e0c47a3b856f307732175230e254c0004e48b02414987088ac7003e148930017b49a1a8d4600f33d463c4afc07bbfc82703c9fcf81a5891f90a71c86a02faff443c6c3b2592bd44d5d3d7a93cb4aaaa105612496d61e68140a5418b468f872bf2f3e79f9cb0d9c3e889663fca02939b31e8ee3092203ee1417128e965c6406a07f68abf2ebe2689cf6c853ef126ffa8574c2a7d913e28de9147fa6b96706ea5bf9eacd1aba06edeaee155009fb912c00070774cc64136fcffde12ed731260bc5529df64da298f493561198e9d6acf42cf21e853ae7b2df85f27d2183149969d623b9237254c2cfe1d0082742eb042ac096d686dbe03c79ee31cbd03bb4682f8797043eed9f6e622814831ac5dfe1176552fb7f9b6ff38a149ae1d8414097a32fd96da6453c52fda13e3402a09e2fa6886daa4300f09c73e4bc2901b99c44744c5cfdca2994adc49ddccb195bda2510e50a4ae10de26cf96dee5e577689f51650a610a33da0a826ae47247d8d1189cb3386"; - assertEq(publicKeys_10.length, 480); + assertEq(PUBLIC_KEYS.length, 480); vm.deal(bob, 320 ether); vm.startPrank(bob); - for (uint256 i = 0; i < publicKeys_10.length; i += 48) { + for (uint256 i = 0; i < PUBLIC_KEYS.length; i += 48) { stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(BytesLib.slice(publicKeys_10, i, 48)) == bob); + assert(stakingContract.getWithdrawer(BytesLib.slice(PUBLIC_KEYS, i, 48)) == bob); } vm.stopPrank(); - for (uint256 i = 0; i < publicKeys_10.length; i += 48) { - address elfrBob = stakingContract.getELFeeRecipient(BytesLib.slice(publicKeys_10, i, 48)); + for (uint256 i = 0; i < PUBLIC_KEYS.length; i += 48) { + address elfrBob = stakingContract.getELFeeRecipient(BytesLib.slice(PUBLIC_KEYS, i, 48)); vm.deal(address(elfrBob), 1 ether); - address clfrBob = stakingContract.getCLFeeRecipient(BytesLib.slice(publicKeys_10, i, 48)); + address clfrBob = stakingContract.getCLFeeRecipient(BytesLib.slice(PUBLIC_KEYS, i, 48)); vm.deal(address(clfrBob), 1 ether); } vm.prank(bob); - stakingContract.batchWithdraw(publicKeys_10); + stakingContract.batchWithdraw(PUBLIC_KEYS); assertApproxEqAbs(bob.balance, 18 ether, 10**7); assertEq(operatorOne.balance, 0); assertApproxEqAbs(address(treasury).balance, 1.6 ether, 10**6); @@ -3328,24 +3163,20 @@ contract StakingContractBehindProxyTest is Test { } function testRequestValidatorsExits_OneValidator() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); vm.expectEmit(true, true, true, true); - emit ExitRequest(bob, publicKey); + emit ExitRequest(bob, PUBKEY_1); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); } function test_requestValidatorExits_OracleActive_OwnerSanctioned() public { vm.prank(admin); stakingContract.setSanctionsOracle(address(oracle)); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); @@ -3355,55 +3186,48 @@ contract StakingContractBehindProxyTest is Test { vm.expectRevert(abi.encodeWithSignature("AddressSanctioned(address)", bob)); vm.prank(bob); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); } function testRequestValidatorsExits_TwoValidators() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; + vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_2) == bob); vm.stopPrank(); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.expectEmit(true, true, true, true); - emit ExitRequest(bob, publicKey); + emit ExitRequest(bob, PUBKEY_1); vm.expectEmit(true, true, true, true); - emit ExitRequest(bob, publicKey2); + emit ExitRequest(bob, PUBKEY_2); vm.prank(bob); stakingContract.requestValidatorsExit(publicKeys); } function testRequestValidatorsExits_WrongWithdrawer() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); vm.expectRevert(abi.encodeWithSignature("Unauthorized()")); vm.prank(address(1337)); - stakingContract.requestValidatorsExit(publicKey); + stakingContract.requestValidatorsExit(PUBKEY_1); } function testRequestValidatorsExits_WrongPublicKeys() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; vm.deal(bob, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); vm.expectRevert(abi.encodeWithSignature("InvalidPublicKeys()")); vm.prank(bob); @@ -3413,22 +3237,18 @@ contract StakingContractBehindProxyTest is Test { } function testRequestValidatorsExits_WrongSecondWithdrawer() public { - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - bytes - memory publicKey2 = hex"b0ce3fa164aae897adca509ed44429e7b1f91b7c46ddbe199cee848e09b1ccbb9736b78b68aacff1011b7266fe11e060"; vm.deal(bob, 32 ether); vm.deal(alice, 32 ether); vm.startPrank(bob); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey) == bob); + assert(stakingContract.getWithdrawer(PUBKEY_1) == bob); vm.stopPrank(); vm.startPrank(alice); stakingContract.deposit{value: 32 ether}(); - assert(stakingContract.getWithdrawer(publicKey2) == alice); + assert(stakingContract.getWithdrawer(PUBKEY_2) == alice); vm.stopPrank(); - bytes memory publicKeys = BytesLib.concat(publicKey, publicKey2); + bytes memory publicKeys = BytesLib.concat(PUBKEY_1, PUBKEY_2); vm.expectRevert(abi.encodeWithSignature("Unauthorized()")); vm.prank(bob); @@ -3476,19 +3296,16 @@ contract StakingContractBehindProxyTest is Test { vm.prank(bob); stakingContract.deposit{value: 32 ether}(); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; - vm.expectEmit(true, true, true, true); - emit ExitRequest(bob, publicKey); + emit ExitRequest(bob, PUBKEY_1); vm.prank(admin); - stakingContract.blockAccount(bob, publicKey); + stakingContract.blockAccount(bob, PUBKEY_1); (bool isBlocked, bool isSanctioned) = stakingContract.isBlockedOrSanctioned(bob); assertTrue(isBlocked); - assertTrue(stakingContract.getExitRequestedFromRoot(getPubkeyRoot(publicKey))); + assertTrue(stakingContract.getExitRequestedFromRoot(getPubkeyRoot(PUBKEY_1))); } function test_block_UserDepositOneValidator_Sanctioned() public { @@ -3500,18 +3317,16 @@ contract StakingContractBehindProxyTest is Test { vm.prank(bob); stakingContract.deposit{value: 32 ether}(); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; oracle.setSanction(bob, true); vm.prank(admin); - stakingContract.blockAccount(bob, publicKey); + stakingContract.blockAccount(bob, PUBKEY_1); (bool isBlocked, bool isSanctioned) = stakingContract.isBlockedOrSanctioned(bob); assertTrue(isBlocked); - assertFalse(stakingContract.getExitRequestedFromRoot(getPubkeyRoot(publicKey))); + assertFalse(stakingContract.getExitRequestedFromRoot(getPubkeyRoot(PUBKEY_1))); } function test_block_UserDepositOneValidator_NotSanctioned_WrongPublicKey() public { @@ -3523,8 +3338,6 @@ contract StakingContractBehindProxyTest is Test { vm.prank(bob); stakingContract.deposit{value: 32 ether}(); - bytes - memory publicKey = hex"21d2e725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759"; bytes memory wrongPublicKey = hex"ffffe725aef3a8f9e09d8f4034948bb7f79505fc7c40e7a7ca15734bad4220a594bf0c6257cef7db88d9fc3fd4360759";