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: feature to read contract storage data #968

Merged
merged 13 commits into from
Apr 21, 2022

Conversation

0xalpharush
Copy link
Contributor

@0xalpharush 0xalpharush commented Oct 28, 2021

Closes #793 and #932

  • state variables
  • read from array at index/ key
  • support mapping
  • support deep mapping
  • support mapping with structs
  • add tests Create thorough tests for storage_size #932
  • add ci tests for tool
  • test multidimensional arrays
  • Refactor imports so web3 isn't a dependency
  • Fix dynamic and fixed-size arrays
  • Parse enums?
  • Handle string/ bytes values greater than a single word
  • Add support for ContractStructure types
  • add documentation of CLI and API

@0xalpharush 0xalpharush added the enhancement New feature or request label Oct 28, 2021
@lgtm-com
Copy link

lgtm-com bot commented Oct 28, 2021

This pull request introduces 1 alert when merging 6188045 into 3bc22a9 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Nov 3, 2021

This pull request introduces 1 alert when merging bfc27fd into 3bc22a9 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Dec 1, 2021

This pull request introduces 1 alert when merging ff4c625 into 1548c82 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Dec 1, 2021

This pull request introduces 1 alert when merging 4d683c2 into 1548c82 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Dec 2, 2021

This pull request introduces 1 alert when merging 1ca2a2c into 5de54f7 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

@lgtm-com
Copy link

lgtm-com bot commented Dec 3, 2021

This pull request introduces 1 alert when merging 23ab9ce into 5de54f7 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

@lgtm-com
Copy link

lgtm-com bot commented Dec 3, 2021

This pull request introduces 1 alert when merging 665c3fe into 5de54f7 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

@lgtm-com
Copy link

lgtm-com bot commented Dec 8, 2021

This pull request introduces 1 alert when merging a8c1d13 into 5de54f7 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

setup.py Outdated Show resolved Hide resolved
slither/tools/read_storage/read_storage.py Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Dec 23, 2021

This pull request introduces 2 alerts when merging a578882 into a4d7f98 - view on LGTM.com

new alerts:

  • 1 for Syntax error
  • 1 for Variable defined multiple times

@lgtm-com
Copy link

lgtm-com bot commented Dec 24, 2021

This pull request introduces 1 alert when merging 76a9712 into a4d7f98 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

@lgtm-com
Copy link

lgtm-com bot commented Dec 26, 2021

This pull request introduces 1 alert when merging 5ddc6e8 into a4d7f98 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

@lgtm-com
Copy link

lgtm-com bot commented Dec 28, 2021

This pull request introduces 1 alert when merging 279d0de into a4d7f98 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

@lgtm-com
Copy link

lgtm-com bot commented Dec 31, 2021

This pull request introduces 3 alerts when merging e22b102 into a4d7f98 - view on LGTM.com

new alerts:

  • 2 for Variable defined multiple times
  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Dec 31, 2021

This pull request introduces 3 alerts when merging 25576c2 into a4d7f98 - view on LGTM.com

new alerts:

  • 2 for Variable defined multiple times
  • 1 for Unused import

@lgtm-com
Copy link

lgtm-com bot commented Jan 13, 2022

This pull request introduces 3 alerts when merging 4a2f8ba into 1771e48 - view on LGTM.com

new alerts:

  • 2 for Variable defined multiple times
  • 1 for 'import *' may pollute namespace

@lgtm-com
Copy link

lgtm-com bot commented Jan 23, 2022

This pull request introduces 3 alerts when merging 3c96660 into 1771e48 - view on LGTM.com

new alerts:

  • 2 for Variable defined multiple times
  • 1 for 'import *' may pollute namespace

@0xalpharush 0xalpharush marked this pull request as ready for review February 11, 2022 15:13
@lgtm-com
Copy link

lgtm-com bot commented Feb 11, 2022

This pull request introduces 3 alerts when merging 0b62138 into 0342506 - view on LGTM.com

new alerts:

  • 2 for Variable defined multiple times
  • 1 for 'import *' may pollute namespace

@0xalpharush 0xalpharush force-pushed the feat/read_storage branch 6 times, most recently from c1684f6 to 17e942b Compare February 11, 2022 19:26
lint and fix workflow
from slither.tools.read_storage.read_storage import get_storage_layout, get_storage_slot_and_val


def parse_args():
Copy link
Member

Choose a reason for hiding this comment

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

Add return type

return parser.parse_args()


def main():
Copy link
Member

Choose a reason for hiding this comment

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

Add return type



# pylint: disable=too-many-arguments
def _all_struct_variables(var, contracts, address, rpc_url, storage_address=None, key=None):
Copy link
Member

Choose a reason for hiding this comment

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

Add parameters and return types



# pylint: disable=too-many-branches,too-many-locals,too-many-nested-blocks
def get_storage_layout(
Copy link
Member

Choose a reason for hiding this comment

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

Add return type

return data


# pylint: disable=too-many-branches,too-many-locals,too-many-nested-blocks
Copy link
Member

Choose a reason for hiding this comment

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

I think we can split this function into sub-functions to not remove all these warnings

json.dump(data, f, indent=4)


# pylint: disable=too-many-statements,too-many-branches,inconsistent-return-statements
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, I think we can split this function into sub-functions to not remove all these warnings


return int_slot, value, type_to

if not found:
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we can remove found and raise a exception if we reached this part of the code, is that correct?

Copy link
Member

Choose a reason for hiding this comment

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

that would also avoid having an undefined return

@lgtm-com
Copy link

lgtm-com bot commented Mar 18, 2022

This pull request introduces 1 alert when merging 931a151 into 61bcec4 - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

@0xalpharush 0xalpharush force-pushed the feat/read_storage branch 2 times, most recently from 4165055 to 3d6ef9d Compare March 18, 2022 14:11
@0xalpharush 0xalpharush requested a review from montyly March 18, 2022 14:14
@montyly montyly mentioned this pull request Apr 15, 2022
9 tasks
@montyly montyly merged commit e324c90 into crytic:dev Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants