code-423n4 / 2022-01-xdefi-findings

0 stars 0 forks source link

Avoid inline code for better readibility #136

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

StErMi

Vulnerability details

Impact

No direct impact on the risk factor but it could lead to possible developers mistake in the future and for sure make the code less readable for auditors / external developers.

Because this approach does not comes with Gas Optimization there's not real reason to adopt it.

Code like this

function proposeOwnership(address newOwner_) external onlyOwner {
    emit OwnershipProposed(owner, pendingOwner = newOwner_);
}

at first glance seems to not modify the state and you need to pay more attention to read all the changes.

Proof of Concept

Tools Used

Manual

Recommended Mitigation Steps

Avoid inline style code

deluca-mike commented 2 years ago

Acknowledged, but this forces a solidity optimization that usually (but not always) happens. Would rather keep it in-line. Instead, I'll span it over multiple lines.

emit OwnershipProposed(
    owner,
    pendingOwner = newOwner_
);
deluca-mike commented 2 years ago

Relevant line-spanning was done in the release candidate contracts.