Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
daejunpark committed Aug 26, 2024
1 parent 542eb2d commit 2234c9b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/halmos/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
Path,
SMTQuery,
State,
StorageData,
con_addr,
jumpid_str,
mnemonic,
Expand Down
6 changes: 3 additions & 3 deletions src/halmos/cheatcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ def symbolic_storage(ex, arg):
account = uint160(arg.get_word(4))

account_alias = account
# account_alias = sevm.resolve_address_alias(
# ex, account, stack, step_id, branching=False
# )
# account_alias = sevm.resolve_address_alias(
# ex, account, stack, step_id, branching=False
# )

ex.storage[account_alias].symbolic = True

Expand Down
28 changes: 22 additions & 6 deletions src/halmos/sevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def extend_path(self, path):
@dataclass
class StorageData:
symbolic: bool = False
mapping: Dict = field(default_factory=dict)
mapping: dict = field(default_factory=dict)


class Exec: # an execution path
Expand Down Expand Up @@ -956,7 +956,9 @@ def check(self, cond: Any) -> Any:

return self.path.check(cond)

def select(self, array: Any, key: Word, arrays: dict, symbolic: bool = False) -> Word:
def select(
self, array: Any, key: Word, arrays: dict, symbolic: bool = False
) -> Word:
if array in arrays:
store = arrays[array]
if store.decl().name() == "store" and store.num_args() == 3:
Expand Down Expand Up @@ -1180,7 +1182,10 @@ def load(cls, ex: Exec, addr: Any, loc: Word) -> Word:
Select(cls.empty(addr, slot, keys), concat(keys)) == ZERO
)
return ex.select(
ex.storage[addr].mapping[slot][num_keys][size_keys], concat(keys), ex.storages, ex.storage[addr].symbolic
ex.storage[addr].mapping[slot][num_keys][size_keys],
concat(keys),
ex.storages,
ex.storage[addr].symbolic,
)

@classmethod
Expand Down Expand Up @@ -1293,7 +1298,12 @@ def load(cls, ex: Exec, addr: Any, loc: Word) -> Word:
if not ex.storage[addr].symbolic:
# generate emptyness axiom for each array index, instead of using quantified formula; see init()
ex.path.append(Select(cls.empty(addr, loc), loc) == ZERO)
return ex.select(ex.storage[addr].mapping[loc.size()], loc, ex.storages, ex.storage[addr].symbolic)
return ex.select(
ex.storage[addr].mapping[loc.size()],
loc,
ex.storages,
ex.storage[addr].symbolic,
)

@classmethod
def store(cls, ex: Exec, addr: Any, loc: Any, val: Any) -> None:
Expand Down Expand Up @@ -2134,7 +2144,8 @@ def create(

# setup new account
ex.set_code(new_addr, Contract(b"")) # existing code must be empty
ex.storage[new_addr] = StorageData() # existing storage may not be empty and reset here
# existing storage may not be empty and reset here
ex.storage[new_addr] = StorageData()

# transfer value
self.transfer_value(ex, pranked_caller, new_addr, value)
Expand Down Expand Up @@ -2526,7 +2537,12 @@ def finalize(ex: Exec):
or eq(account, console.address)
):
# dummy arbitrary value, consistent with foundry
codesize = 1 if eq(account, hevm_cheat_code.address) or eq(account, halmos_cheat_code.address) else 0
codesize = (
1
if eq(account, hevm_cheat_code.address)
or eq(account, halmos_cheat_code.address)
else 0
)
else:
codesize = 0

Expand Down
4 changes: 1 addition & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@ def test_config_file_snake_case(config, toml_parser):

def test_config_e2e(config, parser, toml_parser):
# when we apply overrides to the default config
config_file_data = toml_parser.parse_str(
"[global]\nverbose = 42"
)
config_file_data = toml_parser.parse_str("[global]\nverbose = 42")
config = config.with_overrides(source="halmos.toml", **config_file_data)

args = parser.parse_args(["-vvv"])
Expand Down

0 comments on commit 2234c9b

Please sign in to comment.