From b643df70f49457c5c173731f718c3d0597a3d4a3 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Fri, 7 Aug 2020 01:59:08 +0300 Subject: [PATCH 1/3] fix: only shift gas costs for older ganache versions --- brownie/network/transaction.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/brownie/network/transaction.py b/brownie/network/transaction.py index 6c9697d42..cb4a94ce8 100644 --- a/brownie/network/transaction.py +++ b/brownie/network/transaction.py @@ -545,10 +545,15 @@ def _expand_trace(self) -> None: t["depth"] = t["depth"] - 1 else: self._trace_origin = "ganache" - self._call_cost = trace[0]["gasCost"] - for i in range(len(trace) - 1): - trace[i]["gasCost"] = trace[i + 1]["gasCost"] - trace[-1]["gasCost"] = 0 + if trace[0]["gasCost"] >= 21000: + # in ganache <6.10.0, gas costs are shifted by one step - we can + # identify this when the first step has a gas cost >= 21000 + self._call_cost = trace[0]["gasCost"] + for i in range(len(trace) - 1): + trace[i]["gasCost"] = trace[i + 1]["gasCost"] + trace[-1]["gasCost"] = 0 + else: + self._call_cost = self.gas_used - trace[0]["gas"] + trace[-1]["gas"] # last_map gives a quick reference of previous values at each depth last_map = {0: _get_last_map(self.receiver, self.input[:10])} # type: ignore From 9399d84e197c98a1a5fbf5cd8e70a0587582a138 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Fri, 7 Aug 2020 02:00:57 +0300 Subject: [PATCH 2/3] ci: update ganache version to 6.10.1 in CI --- .github/workflows/main.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e1143e4fe..64e63e252 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -58,7 +58,7 @@ jobs: uses: actions/setup-node@v1 - name: Install Ganache - run: npm install -g ganache-cli@6.8.2 + run: npm install -g ganache-cli@6.10.1 - name: Setup Python 3.8 uses: actions/setup-python@v1 @@ -98,7 +98,7 @@ jobs: uses: actions/setup-node@v1 - name: Install Ganache - run: npm install -g ganache-cli@6.8.2 + run: npm install -g ganache-cli@6.10.1 - name: Setup Python 3.8 uses: actions/setup-python@v1 @@ -138,7 +138,7 @@ jobs: uses: actions/setup-node@v1 - name: Install Ganache - run: npm install -g ganache-cli@6.8.2 + run: npm install -g ganache-cli@6.10.1 - name: Setup Python 3.8 uses: actions/setup-python@v1 @@ -172,7 +172,7 @@ jobs: uses: actions/setup-node@v1 - name: Install Ganache - run: npm install -g ganache-cli@6.8.2 + run: npm install -g ganache-cli@6.10.1 - name: Setup Python 3.7 uses: actions/setup-python@v1 @@ -206,7 +206,7 @@ jobs: uses: actions/setup-node@v1 - name: Install Ganache - run: npm install -g ganache-cli@6.8.2 + run: npm install -g ganache-cli@6.10.1 - name: Setup Python 3.6 uses: actions/setup-python@v1 From 350cecbc0fae20e91550791c0ce5fa0ca03a17d8 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Fri, 7 Aug 2020 02:01:15 +0300 Subject: [PATCH 3/3] docs: bump ganache version to 6.10.1 in dependency/install docs --- README.md | 2 +- docs/install.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60503e08d..a5827a580 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Brownie is a Python-based development and testing framework for smart contracts ## Dependencies * [python3](https://www.python.org/downloads/release/python-368/) version 3.6 or greater, python3-dev -* [ganache-cli](https://github.com/trufflesuite/ganache-cli) - tested with version [6.8.2](https://github.com/trufflesuite/ganache-cli/releases/tag/v6.8.2) +* [ganache-cli](https://github.com/trufflesuite/ganache-cli) - tested with version [6.10.1](https://github.com/trufflesuite/ganache-cli/releases/tag/v6.10.1) ## Installation diff --git a/docs/install.rst b/docs/install.rst index 89fec85a5..903ad0572 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -62,7 +62,7 @@ Dependencies Brownie has the following dependencies: * `python3 `_ version 3.6 or greater, python3-dev -* `ganache-cli `_ - tested with version `6.8.2 `_ +* `ganache-cli `_ - tested with version `6.10.1 `_ .. _install-tk: