@@ -60,13 +60,19 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
6060 // a public contributor fulfills the node).
6161 bool public manualFinalize;
6262
63- // Modifers
63+ // Modifiers
6464 modifier onlyOperator () {
6565 if (msg .sender != operator)
6666 revert OnlyOperatorIsAuthorised (msg .sender , operator);
6767 _;
6868 }
6969
70+ modifier requireWaitForOperatorContribStatus () {
71+ if (status != Status.WaitForOperatorContrib)
72+ revert RequireWaitForOperatorContribStatus (status);
73+ _;
74+ }
75+
7076 /// @notice Constructs a multi-contribution node contract for the
7177 /// specified `_stakingRewardsContract`.
7278 ///
@@ -115,16 +121,17 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
115121
116122 function _updateManualFinalize (bool value ) private {
117123 manualFinalize = value;
124+ emit UpdateManualFinalize (value);
118125 }
119126
120127 function updateFee (uint16 fee ) external onlyOperator { _updateFee (fee); }
121128
122- function _updateFee (uint16 fee ) private {
123- if (status != Status.WaitForOperatorContrib)
124- revert FeeUpdateNotPossible (status);
129+ function _updateFee (uint16 fee ) private requireWaitForOperatorContribStatus {
125130 if (fee > MAX_FEE)
126131 revert FeeExceedsPossibleValue (fee, MAX_FEE);
127132 _serviceNodeParams.fee = fee;
133+
134+ emit UpdateFee (fee);
128135 }
129136
130137 function updatePubkeys (BN256G1.G1Point memory newBLSPubkey ,
@@ -139,10 +146,7 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
139146 IServiceNodeRewards.BLSSignatureParams memory newBLSSig ,
140147 uint256 ed25519Pubkey ,
141148 uint256 ed25519Sig0 ,
142- uint256 ed25519Sig1 ) private {
143- if (status != Status.WaitForOperatorContrib)
144- revert PubkeyUpdateNotPossible (status);
145-
149+ uint256 ed25519Sig1 ) private requireWaitForOperatorContribStatus {
146150 stakingRewardsContract.validateProofOfPossession (newBLSPubkey, newBLSSig, operator, ed25519Pubkey);
147151
148152 // NOTE: Update BLS keys
@@ -153,16 +157,15 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
153157 _serviceNodeParams.serviceNodePubkey = ed25519Pubkey;
154158 _serviceNodeParams.serviceNodeSignature1 = ed25519Sig0;
155159 _serviceNodeParams.serviceNodeSignature2 = ed25519Sig1;
160+
161+ emit UpdatePubkeys (newBLSPubkey, ed25519Pubkey);
156162 }
157163
158164 function updateReservedContributors (IServiceNodeRewards.ReservedContributor[] memory reserved ) external onlyOperator {
159165 _updateReservedContributors (reserved);
160166 }
161167
162- function _updateReservedContributors (IServiceNodeRewards.ReservedContributor[] memory reserved ) private {
163- if (status != Status.WaitForOperatorContrib)
164- revert ReservedContributorUpdateNotPossible (status);
165-
168+ function _updateReservedContributors (IServiceNodeRewards.ReservedContributor[] memory reserved ) private requireWaitForOperatorContribStatus {
166169 // NOTE: Remove old reserved contributions
167170 {
168171 uint256 length = reservedContributionsAddresses.length ;
@@ -213,6 +216,8 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
213216
214217 unchecked { i += 1 ; }
215218 }
219+
220+ emit UpdateReservedContributors (reserved);
216221 }
217222
218223 // @notice Select the beneficiary as the `beneficiary` is not the
@@ -249,7 +254,7 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
249254 if (! updated)
250255 revert NonContributorUpdatedBeneficiary (stakerAddr);
251256
252- emit UpdateStakerBeneficiary (stakerAddr, oldBeneficiary, desiredBeneficiary);
257+ emit UpdateStakerBeneficiary (stakerAddr, desiredBeneficiary);
253258 }
254259
255260 function contributeFunds (uint256 amount , address beneficiary ) external { _contributeFunds (msg .sender , beneficiary, amount); }
@@ -271,7 +276,7 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
271276 if (caller != operator)
272277 revert FirstContributionMustBeOperator (caller, operator);
273278 status = Status.OpenForPublicContrib;
274- emit OpenForPublicContribution (_serviceNodeParams.serviceNodePubkey, operator, _serviceNodeParams.fee );
279+ emit OpenForPublicContribution ();
275280 }
276281
277282 // NOTE: Verify the contribution
@@ -318,8 +323,8 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
318323 // State transition before calling out to external code to mitigate
319324 // re-entrancy.
320325 if (currTotalContribution == stakingRequirement) {
321- emit Filled (_serviceNodeParams.serviceNodePubkey, operator);
322326 status = Status.WaitForFinalized;
327+ emit Filled ();
323328 }
324329
325330 // NOTE: Transfer funds from sender to contract
@@ -340,7 +345,7 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
340345
341346 // NOTE: Finalize the contract
342347 status = Status.Finalized;
343- emit Finalized (_serviceNodeParams.serviceNodePubkey );
348+ emit Finalized ();
344349
345350 uint256 length = _contributorAddresses.length ;
346351 IServiceNodeRewards.Contributor[] memory contributors = new IServiceNodeRewards.Contributor [](length);
@@ -382,6 +387,8 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
382387 IServiceNodeRewards.ReservedContributor[] memory zero = new IServiceNodeRewards.ReservedContributor [](0 );
383388 _updateReservedContributors (zero);
384389 }
390+
391+ emit Reset ();
385392 }
386393
387394 function resetUpdateAndContribute (BN256G1.G1Point memory key ,
@@ -410,19 +417,6 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
410417 _contributeFunds (operator, beneficiary, amount);
411418 }
412419
413- function resetUpdateFeeReservedAndContribute (uint16 fee ,
414- IServiceNodeRewards.ReservedContributor[] memory reserved ,
415- bool _manualFinalize ,
416- address beneficiary ,
417- uint256 amount ) external onlyOperator {
418- _reset ();
419- _updateFee (fee);
420- _updateReservedContributors (reserved);
421- _updateManualFinalize (_manualFinalize);
422- if (amount > 0 )
423- _contributeFunds (operator, beneficiary, amount);
424- }
425-
426420 function rescueERC20 (address tokenAddress ) external onlyOperator {
427421 // NOTE: ERC20 tokens sent to the contract can only be rescued after the
428422 // contract is finalized or the contract has been reset
@@ -437,15 +431,16 @@ contract ServiceNodeContribution is Shared, IServiceNodeContribution {
437431 // This allows them to refund any other tokens that might have
438432 // mistakenly been sent throughout the lifetime of the contract without
439433 // giving them access to contributor tokens.
440- if (status != Status.Finalized && status == Status.WaitForOperatorContrib)
434+ if (status == Status.Finalized || status == Status.WaitForOperatorContrib) {
435+ IERC20 token = IERC20 (tokenAddress);
436+ uint256 balance = token.balanceOf (address (this ));
437+ if (balance <= 0 )
438+ revert RescueBalanceIsEmpty (tokenAddress);
439+ token.safeTransfer (operator, balance);
440+ } else {
441441 revert RescueNotPossible (status);
442+ }
442443
443- IERC20 token = IERC20 (tokenAddress);
444- uint256 balance = token.balanceOf (address (this ));
445- if (balance <= 0 )
446- revert RescueBalanceIsEmpty (tokenAddress);
447-
448- token.safeTransfer (operator, balance);
449444 }
450445
451446 function withdrawContribution () external {
0 commit comments