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

all: Trace types #474

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6834821
fix(setup): Add pydantic, bump mypy
marioevz Mar 13, 2024
5f6a6c4
all: Trace types
marioevz Mar 11, 2024
d2676eb
working
marioevz Mar 12, 2024
a603fbe
fix(evm_transition_tool): read correct file
marioevz Mar 13, 2024
d94d90b
feat(types): Add traceable exceptions
marioevz Mar 13, 2024
e4b07e0
feat(evm_transition_tool): more required methods
marioevz Mar 13, 2024
0bfe997
fix(types): refactor exception type
marioevz Mar 13, 2024
3fcd240
fix(tox): all tox fixes
marioevz Mar 13, 2024
6802950
changelog
marioevz Mar 13, 2024
a728549
refactor: Move TraceableException
marioevz Mar 14, 2024
9d370f4
Remove most aliases
marioevz Mar 15, 2024
78ab152
refactor(evm_transition_tool): Use geth PR #29353
marioevz Mar 26, 2024
a6eab95
fix(evm_transition_tool): use model_post_init
marioevz Mar 26, 2024
f9b3380
refactor(evm_transition_tool): Use a trace marker descriptor class
marioevz Mar 26, 2024
d37bff4
fix(fw): remove unnecessary init methods from exception classes
marioevz Mar 26, 2024
abfd9ff
refactor: exception printing
marioevz Mar 26, 2024
45db77a
setup: add rich
marioevz Mar 26, 2024
cf9ffb4
fix: rollback unnecessary docstring change
marioevz Mar 26, 2024
201b848
fix: Remove unnecessary import
marioevz Mar 26, 2024
ea68703
fix: Increase rich console size
marioevz Mar 26, 2024
2c712f2
feat: Add meaningful description to the relevant traces
marioevz Mar 26, 2024
0ce2780
docs: Add docs page on debug tracing
marioevz Mar 26, 2024
13f4971
fix(evm_transition_tool): trace.callframes only for geth
marioevz Mar 26, 2024
2a90466
Merge branch 'main' into evm-trace-types
danceratopz Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Test fixtures for use by clients are available for each release on the [Github r

### 🔧 EVM Tools

- ✨ Better trace printing by selecting relevant trace lines depending on error type ([#474](https://github.com/ethereum/execution-spec-tests/pull/474)).

### 📋 Misc

- 🐞 Fix CI by using Golang 1.21 in Github Actions to build geth ([#484](https://github.com/ethereum/execution-spec-tests/pull/484)).
Expand Down
1 change: 1 addition & 0 deletions docs/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [Types of Test](writing_tests/types_of_tests.md)
* [Adding a New Test](writing_tests/adding_a_new_test.md)
* [Writing a New Test](writing_tests/writing_a_new_test.md)
* [Debugging Tests](writing_tests/debugging_tests.md)
* [Referencing an EIP Spec Version](writing_tests/reference_specification.md)
* [Verifying Changes Locally](writing_tests/verifying_changes.md)
* [Exception Tests](writing_tests/exception_tests.md)
Expand Down
95 changes: 95 additions & 0 deletions docs/writing_tests/debugging_tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Debugging Tests

The easiest way to debug tests while writing them is to run the test with the `--traces` flag. This will output the traces of the test, which can be used to understand the behavior of the test and the client.

```bash
fill 'tests/frontier/opcodes/test_dup.py::test_dup[fork_Byzantium-state_test-DUP1]' --traces
```

Depending on the test failure type, a list of relevant traces will be printed.

For example, if the test fails because an expected storage key was not set (`Storage.KeyValueMismatch`), the output will show EVM traces where the storage key was set, or the executing contract returned with error.

```python
{
1: RelevantTraceContext(
execution_index=0,
transaction_index=0,
transaction_hash='0xf8616cc40f214a4729758189c77720a6b672f29dcb62cd206a49ebacaf00e96f',
traces=[
EVMTraceLine(
pc=34,
op=128,
op_name='DUP1',
gas=78949,
gas_cost=3,
mem_size=0,
stack=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
depth=1,
refund=0,
context_address='0x0000000000000000000000000000000000000100'
),
EVMTraceLine(
pc=35,
op=96,
op_name='PUSH1',
gas=78946,
gas_cost=3,
mem_size=0,
stack=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16],
depth=1,
refund=0,
context_address='0x0000000000000000000000000000000000000100'
),
EVMTraceLine(
pc=37,
op=85,
op_name='SSTORE',
gas=78943,
gas_cost=20000,
mem_size=0,
stack=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 0],
depth=1,
refund=0,
context_address='0x0000000000000000000000000000000000000100'
)
],
description='SSTORE event on address 0x0000000000000000000000000000000000000100 and key 0x0'
),
2: RelevantTraceContext(
execution_index=0,
transaction_index=0,
transaction_hash='0xf8616cc40f214a4729758189c77720a6b672f29dcb62cd206a49ebacaf00e96f',
traces=[
EVMTraceLine(
pc=44,
op=96,
op_name='PUSH1',
gas=18937,
gas_cost=3,
mem_size=0,
stack=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
depth=1,
refund=0,
context_address='0x0000000000000000000000000000000000000100'
),
EVMTraceLine(
pc=46,
op=85,
op_name='SSTORE',
gas=18934,
gas_cost=20000,
mem_size=0,
stack=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 3],
depth=1,
refund=0,
context_address='0x0000000000000000000000000000000000000100'
),
EVMCallFrameExit(from_address='0x0000000000000000000000000000000000000100', output=b'', gas_used=79000, error='out of gas')
],
description='Exit frame from address 0x0000000000000000000000000000000000000100 with error'
)
}
```

In this example, the test failed because the storage key `0x0` was not set. The traces show that the storage key was indeed set to `0x10`, but later the contract ran out of gas.
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ install_requires =
coincurve>=18.0.0,<19
trie==2.1.1
semver==3.0.1
pydantic>=2.6.3
rich>=13.7.0,<14
click>=8.0.0,<9

[options.package_data]
Expand Down Expand Up @@ -61,7 +63,7 @@ test =

lint =
isort>=5.8,<6
mypy==0.982; implementation_name == "cpython"
mypy==0.991; implementation_name == "cpython"
types-requests
black==22.3.0; implementation_name == "cpython"
flake8-spellcheck>=0.24,<0.25
Expand Down
3 changes: 3 additions & 0 deletions src/ethereum_test_tools/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Common definitions and types.
"""

from .base_types import (
Address,
Bloom,
Expand Down Expand Up @@ -41,6 +42,7 @@
JSONEncoder,
Removable,
Storage,
TraceableException,
Transaction,
Withdrawal,
alloc_to_accounts,
Expand Down Expand Up @@ -75,6 +77,7 @@
"TestParameterGroup",
"TestPrivateKey",
"TestPrivateKey2",
"TraceableException",
"Transaction",
"Withdrawal",
"ZeroPaddedHexNumber",
Expand Down