Skip to content

Commit

Permalink
Merge pull request #2329 from crytic/dev-constant-yul
Browse files Browse the repository at this point in the history
Track storage variables read/written in assembly
  • Loading branch information
0xalpharush authored Feb 29, 2024
2 parents 1854c14 + 801a13e commit 754d64d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions slither/core/cfg/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
SolidityFunction,
)
from slither.core.expressions.expression import Expression
from slither.core.expressions import CallExpression, Identifier, AssignmentOperation
from slither.core.solidity_types import ElementaryType
from slither.core.source_mapping.source_mapping import SourceMapping
from slither.core.variables.local_variable import LocalVariable
Expand Down Expand Up @@ -898,6 +899,21 @@ def _find_read_write_call(self) -> None: # pylint: disable=too-many-statements
# TODO: consider removing dependancy of solidity_call to internal_call
self._solidity_calls.append(ir.function)
self._internal_calls.append(ir.function)
if (
isinstance(ir, SolidityCall)
and ir.function == SolidityFunction("sstore(uint256,uint256)")
and isinstance(ir.node.expression, CallExpression)
and isinstance(ir.node.expression.arguments[0], Identifier)
):
self._vars_written.append(ir.arguments[0])
if (
isinstance(ir, SolidityCall)
and ir.function == SolidityFunction("sload(uint256)")
and isinstance(ir.node.expression, AssignmentOperation)
and isinstance(ir.node.expression.expression_right, CallExpression)
and isinstance(ir.node.expression.expression_right.arguments[0], Identifier)
):
self._vars_read.append(ir.arguments[0])
if isinstance(ir, LowLevelCall):
assert isinstance(ir.destination, (Variable, SolidityVariable))
self._low_level_calls.append((ir.destination, str(ir.function_name.value)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,18 @@ contract Good {
uint immutable should_be_immutable_3 = 10 + block.number;
B immutable should_be_immutable_4 = new B();
uint immutable should_be_immutable_5;

uint blobBaseFee;
constructor(uint b) {
should_be_immutable_5 = b;
}

function getNumber() public returns(uint){
return block.number;
}


function updateBlobBaseFee(uint _blobBaseFee) public {
assembly {
sstore(blobBaseFee.slot, _blobBaseFee)
}
}
}
Binary file not shown.

0 comments on commit 754d64d

Please sign in to comment.