Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug-Candidate]: Fails to generate IR for solidity file that reads an Event Selector #2566

Open
hamdiallam opened this issue Sep 25, 2024 · 0 comments
Labels
bug-candidate Bugs reports that are not yet confirmed

Comments

@hamdiallam
Copy link

Describe the issue:

slither checks fails due to an error in this PR: ethereum-optimism/optimism#11592

With some debugging on when it fails, the faulty line is the SentMessage member here

if (selector != SentMessage.selector) revert EventPayloadNotSentMessage();

Looking at when the assertion fails, it seems like adding Event as a a valid instance of variable_left for Member fixes this bug

Code example to reproduce the issue:

if (selector != SentMessage.selector) revert EventPayloadNotSentMessage();

Version:

0.10.4

Relevant log output:

Failed to generate IR for L2ToL2CrossDomainMessenger.relayMessage. Please open an issue https://github.com/crytic/slither/issues.
L2ToL2CrossDomainMessenger.relayMessage (src/L2/L2ToL2CrossDomainMessenger.sol#132-182):
 	_id.origin != Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER
	revert IdentifierOriginNotL2ToL2CrossDomainMessenger()()
	CrossL2Inbox(Predeploys.CROSS_L2_INBOX).validateMessage(_id,keccak256(bytes)(_sentMessage))
	(selector,_destination,_target,_nonce) = abi.decode(_sentMessage,(bytes32,uint256,address,uint256))
	selector != SentMessage.selector
	revert EventPayloadNotSentMessage()()
	_destination != block.chainid
	revert MessageDestinationNotRelayChain()()
	_target == Predeploys.CROSS_L2_INBOX
	revert MessageTargetCrossL2Inbox()()
	_target == Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER
	revert MessageTargetL2ToL2CrossDomainMessenger()()
	(_sender,_message) = abi.decode(_sentMessage,(address,bytes))
	_source = _id.chainId
	messageHash = keccak256(bytes)(abi.encode(_destination,_source,_nonce,_sender,_target,_message))
	successfulMessages[messageHash]
	revert MessageAlreadyRelayed()()
	_storeMessageMetadata(_source,_sender)
	success = SafeCall.call(_target,msg.value,_message)
	success
	successfulMessages[messageHash] = true
	RelayedMessage(_source,_nonce,messageHash)
	FailedRelayedMessage(_source,_nonce,messageHash)
	_storeMessageMetadata(0,address(0))
	nonReentrant()
Traceback (most recent call last):
  File "/opt/slither/bin/slither", line 8, in <module>
    sys.exit(main())
  File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 776, in main
    main_impl(all_detector_classes=detectors, all_printer_classes=printers)
  File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 882, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 107, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 80, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/opt/slither/lib/python3.9/site-packages/slither/slither.py", line 202, in __init__
    self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
  File "/opt/slither/lib/python3.9/site-packages/slither/slither.py", line 221, in _init_parsing_and_analyses
    raise e
  File "/opt/slither/lib/python3.9/site-packages/slither/slither.py", line 217, in _init_parsing_and_analyses
    parser.analyze_contracts()
  File "/opt/slither/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 593, in analyze_contracts
    self._convert_to_slithir()
  File "/opt/slither/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 827, in _convert_to_slithir
    raise e
  File "/opt/slither/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 812, in _convert_to_slithir
    func.generate_slithir_and_analyze()
  File "/opt/slither/lib/python3.9/site-packages/slither/core/declarations/function.py", line 1827, in generate_slithir_and_analyze
    node.slithir_generation()
  File "/opt/slither/lib/python3.9/site-packages/slither/core/cfg/node.py", line 717, in slithir_generation
    self._irs = convert_expression(expression, self)  # type:ignore
  File "/opt/slither/lib/python3.9/site-packages/slither/slithir/convert.py", line 115, in convert_expression
    visitor = ExpressionToSlithIR(expression, node)
  File "/opt/slither/lib/python3.9/site-packages/slither/visitors/slithir/expression_to_slithir.py", line 174, in __init__
    self._visit_expression(self.expression)
  File "/opt/slither/lib/python3.9/site-packages/slither/visitors/expression/expression.py", line 76, in _visit_expression
    visitor(expression)
  File "/opt/slither/lib/python3.9/site-packages/slither/visitors/expression/expression.py", line 88, in _visit_binary_operation
    self._visit_expression(expression.expression_right)
  File "/opt/slither/lib/python3.9/site-packages/slither/visitors/expression/expression.py", line 78, in _visit_expression
    self._post_visit(expression)
  File "/opt/slither/lib/python3.9/site-packages/slither/visitors/expression/expression.py", line 276, in _post_visit
    self._post_member_access(expression)
  File "/opt/slither/lib/python3.9/site-packages/slither/visitors/slithir/expression_to_slithir.py", line 612, in _post_member_access
    member = Member(expr, Constant(expression.member_name), val_ref)
  File "/opt/slither/lib/python3.9/site-packages/slither/slithir/operations/member.py", line 34, in __init__
    assert is_valid_rvalue(variable_left) or isinstance(
AssertionError
@hamdiallam hamdiallam added the bug-candidate Bugs reports that are not yet confirmed label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-candidate Bugs reports that are not yet confirmed
Projects
None yet
Development

No branches or pull requests

1 participant