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

[WIP] Remove share of functions and modifiers instances #213

Merged
merged 15 commits into from
May 15, 2019

Conversation

montyly
Copy link
Member

@montyly montyly commented Apr 26, 2019

This PR aims to change the way functions and modifiers are internally stored.

Currently, the instances of functions and modifiers are shared across all the contracts, this creates several issues, such as incorrect internal functions calls resolutions.

This a considerable change, and will require thorough tests (including for both detectors and printers)

The PR fixes #155

Current changelog:

  • function/modifier inherits from ChildInheritance, which contains contract_declarer, pointing to the base contract
  • function.contract will point to the contract where the instance is stored
  • function.is_shadowed indicates if a function is shadowed
  • function.canonical_name returns original_contract+ '.'+ name
  • contract._functions/_modifiers are indexed by their canonical_name
  • contract.functions_as_dict is renamed available_functions_as_dict and return non-shadowed functions (same for modifiers_as_dict)
  • For better clarity, all the detectors use now canoncal_name, for variable/function/structure/... rather than contract.name + '.' + name
  • abstract_detector.add_event_to_json/ abstract_detector.add_events_to_json (the json type is still function to simplify the 3-party parsing)
  • contract.*not_inherited renamed contract.*_declared. Add events/enums/state_variables/structures _declared

montyly added 12 commits April 24, 2019 19:55
…acts, each contract has an own copy of all the functions/modifiers

Changed:
- function/modifier inherits from ChildInheritance, which contains original_contract, pointing to the base contract
- function.contract will point to the contract where the instance is stored
- function.is_shadowed indicates if a function is shadowed
- function.canonical_name returns original_contract+ '.'+ name
- contract._functions/_modifiers are indexes by their canonical_name
- contract.functions_as_dict is rename available_functions_as_dict and return non-shadowed functions (same for modifiers_as_dict)
- For better clarity, all the detectors use now canoncal_name, for variable/function/structure/... rather than contract.name + name
- abstract_detector.add_event_to_json/ abstract_detector.add_events_to_json (the json type is still 'function' to simplify the 3-party parsing)
- slithir convert: fix incorrect internal call conversion (use canonical name)
- slithir internalcall: use tuple(func_nale, contract_name) to init unknown internal call
- Update upgradability-check with new API
        contracts.*not_inherited -> contracts.*_declared
        Add *_inherited *_declared for events/enums/state_variables/structures
Use *_declared in core and detectors (remove *.contract == contract type of check)
@CLAassistant
Copy link

CLAassistant commented Apr 29, 2019

CLA assistant check
All committers have signed the CLA.

montyly added 2 commits May 15, 2019 10:07
 Conflicts:
	slither/core/declarations/structure.py
	slither/core/variables/state_variable.py
	slither/detectors/abstract_detector.py
	slither/detectors/attributes/const_functions.py
	slither/detectors/erc/incorrect_erc20_interface.py
	slither/detectors/erc/unindexed_event_parameters.py
	slither/detectors/naming_convention/naming_convention.py
	slither/detectors/operations/unused_return_values.py
	slither/detectors/statements/calls_in_loop.py
	slither/detectors/statements/incorrect_strict_equality.py
	slither/detectors/statements/tx_origin.py
	slither/detectors/variables/possible_const_state_variables.py
	slither/detectors/variables/unused_state_variables.py
	slither/slithir/convert.py
@montyly montyly merged commit c81c32d into dev May 15, 2019
@montyly montyly deleted the dev-fix-c3-linearalization branch May 15, 2019 09:54
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