Skip to content

Commit

Permalink
w3 is now attribute of project, license, added some req to the setup
Browse files Browse the repository at this point in the history
Signed-off-by: degrigis <degrigis@ucsb.edu>
  • Loading branch information
degrigis committed Dec 19, 2023
1 parent 9a4daf9 commit f22d194
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Shellphish

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 3 additions & 2 deletions greed/memory/partial_concrete_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def __init__(self, tag=None, value_sort=None, state=None, partial_init=False):
self.state = state

# Initialize the web3 connection
self.w3 = web3.Web3(web3.Web3.HTTPProvider(opt.WEB3_PROVIDER))
assert(self.w3.is_connected())
self.w3 = state.project.w3
assert(self.w3 is not None), "Web3 provider not initialized. Cannot use the partial concrete storage"
assert(self.w3.is_connected()), "Web3 connection not connected. Cannot use the partial concrete storage"

if "ADDRESS" not in self.state.ctx:
raise GreedException("Cannot initialize the PartialConcreteStorage with no contract address")
Expand Down
10 changes: 10 additions & 0 deletions greed/project.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import logging

import networkx as nx
import web3

from collections import defaultdict

from greed.TAC.TAC_parser import TAC_parser
from greed.TAC.gigahorse_ops import TAC_Callprivateargs
from greed.factory import Factory
from greed import options as opt

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -54,6 +56,14 @@ def __init__(self, target_dir: str):
target_function = self.factory.function(target_function_id)
self.callgraph.add_edge(source_function, target_function)

# trying to connect to the w3
try:
self.w3 = web3.Web3(web3.Web3.HTTPProvider(opt.WEB3_PROVIDER))
if not self.w3.is_connected():
self.w3 = None
except Exception as e:
self.w3 = None

def dump_callgraph(self, filename):
"""
Dump the callgraph in a dot file.
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
'solc-select>=0.2.1',
'sympy>=1.9',
'web3>=5.31.1',
'alive-progress',
'mkdocs',
'mkdocs-click',
'pymdown-extensions',
'lazydocs'
],
python_requires='>=3.8',
)

0 comments on commit f22d194

Please sign in to comment.