Skip to content

refactor: addressing internal audit - #216

Merged
kupermind merged 18 commits into
update_withheld_amountfrom
address_internal_audit
Jun 25, 2025
Merged

refactor: addressing internal audit#216
kupermind merged 18 commits into
update_withheld_amountfrom
address_internal_audit

Conversation

@kupermind

Copy link
Copy Markdown
Contributor
  • Addressing internal audit.

@kupermind
kupermind requested review from 77ph and mariapiamo June 23, 2025 17:26
/// @dev Processes the data received from L1.
/// @param data Bytes message data sent from L1.
function _processData(bytes memory data) internal {
function _processData(bytes memory data) internal returns (uint256 totalAmount) {

@kupermind kupermind Jun 23, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since proposed deposited amounts could be further cut off by the StakingFactory verification and result in more withheldAmount-s, let's compute the total amount that is deposited.

Comment on lines +201 to +202
// Update total to-be-deposited amount
totalAmount += amount;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add up to the total amount to-be-deposited

Comment on lines +342 to +358
// Process the data and calculate deposited amounts
uint256 totalAmount = _processData(data);

// Update withheld amount
if (updateWithheldAmount) {
uint256 localWithheldAmount = withheldAmount;

// Check for overflow
if (totalAmount > localWithheldAmount) {
revert Overflow(totalAmount, localWithheldAmount);
}

// Update withheld amount
localWithheldAmount -= totalAmount;
withheldAmount = localWithheldAmount;

emit WithheldAmountUpdated(localWithheldAmount);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calculate total amount being deposited from the balance of this contract. If the balance is used that is recorded in withheldAmount value, then it's the exact amount we need to subtract from withheldAmount.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why there should be an explicit calculation here, we had this implemented in such a way the DAO needs to take care to add correct numbers. Let's sync tomorrow on this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve this, since we discussed and converged on this approach

Comment on lines +373 to +376
// Check for the contract ownership
if (msg.sender != owner) {
revert OwnerOnly(msg.sender, owner);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding owner check as suggested by the audit.

Base automatically changed from v1.3.3-internal-audit to update_withheld_amount_tests June 24, 2025 16:54
Base automatically changed from update_withheld_amount_tests to update_withheld_amount June 24, 2025 16:55
@kupermind
kupermind merged commit 82b4e18 into update_withheld_amount Jun 25, 2025
2 checks passed
@kupermind
kupermind deleted the address_internal_audit branch June 25, 2025 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants