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

Ganache 7.7.x support and fixes for anvil #1652

Merged
merged 4 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ This changelog format is based on [Keep a Changelog](https://keepachangelog.com/
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/eth-brownie/brownie)
### Added
- Ganache 7.7.x support.

### Fixed
- Anvil support, you can now access trace, events and return_value for anvil transactions.
- Removes `eth-abi` depreciation warnings
- Bump web3.py dep to support async provider in threaded applications

Expand Down
12 changes: 9 additions & 3 deletions brownie/network/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,9 @@ def _get_trace(self) -> None:
raise RPCRequestError("Node client does not support `debug_traceTransaction`")
try:
trace = web3.provider.make_request( # type: ignore
"debug_traceTransaction", (self.txid, {"disableStorage": CONFIG.mode != "console"})
# Set enableMemory to all RPC as anvil return the memory key
"debug_traceTransaction", (self.txid, {
"disableStorage": CONFIG.mode != "console", "enableMemory": True})
)
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as e:
msg = f"Encountered a {type(e).__name__} while requesting "
Expand Down Expand Up @@ -674,8 +676,12 @@ def _get_trace(self) -> None:
if fix_gas:
# handle traces where numeric values are returned as hex (Nethermind)
step["gas"] = int(step["gas"], 16)
step["gasCost"] = int.from_bytes(HexBytes(step["gasCost"]), "big", signed=True)
step["pc"] = int(step["pc"], 16)
# Check if gasCost is hex before converting.
if isinstance(step["gasCost"], str):
step["gasCost"] = int.from_bytes(
HexBytes(step["gasCost"]), "big", signed=True)
if isinstance(step["pc"], str): # Check if pc is hex before converting.
step["pc"] = int(step["pc"], 16)

if self.status:
self._confirmed_trace(trace)
Expand Down
2 changes: 1 addition & 1 deletion brownie/project/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _generate_revert_map(self, pcMap: Dict, source_map: Dict, language: str) ->
for k, v in pcMap.items()
if v["op"] in ("REVERT", "INVALID") or "jump_revert" in v
):
if "path" not in data:
if "path" not in data or data["path"] == None:
continue
path_str = source_map[data["path"]]

Expand Down