-
Notifications
You must be signed in to change notification settings - Fork 174
refactor(exceptions,specs): Support general block exceptions - Pydantic context to parse using mapper #1396
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
Conversation
Hey @gurukamath, I have a branch for the Wanted to ask your opinion on this and whether you think it's a good idea to have this. |
Is there any particular scenario you have in mind? Because the system transactions are supposed to fail silently iirc, so I am not sure you would expect to catch anything here. |
Yes that was the way they worked but with ethereum/EIPs#9508 and ethereum/EIPs#9582 they are no longer supposed to fail silently, so instead the block should be invalid, even when the call does not fail but instead the address contains no code. The problem as I could debug it is that T8N throws at some point when the block is invalid, and a zero length response is returned instead of the usual JSON response, so we cannot parse anything. The branch I pointed out uses a try-except block to catch the exception, and when caught it populates a new field in the t8n response to signal a block-wide issue, which is what we parse in this PR. Please feel free to suggest anything else since I'm not super familiar with T8N in EELS so there's potentially a better solution 👍 |
Ah. I see. In that case this sounds reasonable to me. |
looks like a good approach.
as well as the error strings in case. just check that this hint logic is not affected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice refactor! This is a much nicer approach. Just a couple of comments below, respectively in #1404.
…ock exceptions - Pydantic context to parse using mapper (#1404) * refactor(fw): use enum helper; rename `ty` to `execution_context` * refactor(fw): use more specific names for exception classes
Thanks! This unit test actually already existed here but it contained an execution-spec-tests/src/ethereum_test_specs/tests/test_expect.py Lines 261 to 354 in 58a2ec1
And actually the test was in correct but I fixed in this PR. Also it was extremely slow, and it turns out that every time we do So I implemented the @danceratopz I added the comment you requested in the blobs test 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one small question and a possible improvement to src/ethereum/test_spec/helpers.py::verify()
.
…erty` to `ClassVar`
…ock exceptions - Pydantic context to parse using mapper (#1404) * refactor(fw): use enum helper; rename `ty` to `execution_context` * refactor(fw): use more specific names for exception classes
…rom most unit tests
Co-authored-by: danceratopz <[email protected]>
0578e71
to
ed500cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…ic context to parse using mapper (ethereum#1396) * feat(clis,exceptions,specs): Pydantic validation using exception mapper * fix(specs): Skip block exception check on requests modifications * fix(docs): Links * fix(tests): EIP-4844: mark block as skip block exception verification * refactor(exceptions): Mapper mappings allow regex, convert from `property` to `ClassVar` * fix(docs): tox * chore(deps): remove now unused bdict dependency * Suggestions for ethereum#1396, refactor(exceptions,specs): Support general block exceptions - Pydantic context to parse using mapper (ethereum#1404) * refactor(fw): use enum helper; rename `ty` to `execution_context` * refactor(fw): use more specific names for exception classes * fix(tests): Add comment explaining `skip_exception_verification` * feat(clis): Add `reliable` flag to exception mapper class * fix: tests * fix(specs,clis,tools): Use `default_t8n` and remove `run_in_serial` from most unit tests * fix(specs): Bug and variable names * fix: bug * feat(clis/evmone): Add insufficient-blob-fee error * fix(tests): Allow similar blob exceptions * Apply suggestions from code review Co-authored-by: danceratopz <[email protected]> --------- Co-authored-by: danceratopz <[email protected]>
…ic context to parse using mapper (ethereum#1396) * feat(clis,exceptions,specs): Pydantic validation using exception mapper * fix(specs): Skip block exception check on requests modifications * fix(docs): Links * fix(tests): EIP-4844: mark block as skip block exception verification * refactor(exceptions): Mapper mappings allow regex, convert from `property` to `ClassVar` * fix(docs): tox * chore(deps): remove now unused bdict dependency * Suggestions for ethereum#1396, refactor(exceptions,specs): Support general block exceptions - Pydantic context to parse using mapper (ethereum#1404) * refactor(fw): use enum helper; rename `ty` to `execution_context` * refactor(fw): use more specific names for exception classes * fix(tests): Add comment explaining `skip_exception_verification` * feat(clis): Add `reliable` flag to exception mapper class * fix: tests * fix(specs,clis,tools): Use `default_t8n` and remove `run_in_serial` from most unit tests * fix(specs): Bug and variable names * fix: bug * feat(clis/evmone): Add insufficient-blob-fee error * fix(tests): Allow similar blob exceptions * Apply suggestions from code review Co-authored-by: danceratopz <[email protected]> --------- Co-authored-by: danceratopz <[email protected]>
🗒️ Description
Pydantic Mapper Parsing
This changes introduces the exception types right in the model when reading external tool responses.
Instead of parsing all exceptions to a
str
, and then using the mapper to manually parse the exception when it's time to use it, the mapper is passed as a context parameter tomodel_validate
and picked up by aBeforeValidator
defined in a field so it is automatically converted toBlockException
,EOFException
,TransactionException
orUndefinedException
.If the field is parsed as
UndefinedException
it means that the mapper does not know about the exception and it could not be parsed.Mapper Optimizations/Improvements
Instead of defining a
_mapping_data
property, which must be re-computed each time the property is accessed, two newClassVar
have been defined and are used to parse exceptions in the mapper.mapping_substring
Similar behavior to
_mapping_data
but in the form of a dictionary: the substring is searched within the message returned by the external tool and if found the exception is returned.mapping_regex
Dictionary containing regex strings mapped to exceptions:
re.search
is used on the message returned by the external tool and if found the exception is returned.Block.exception
Matched Against Transition Tool ResponseBlock.exception
is now matched against a new optional field returned by the transition tool in theResult
object:blockException
.Previously we could produced an invalid block test by one of several methods:
Result.rejected_transactions
field of the returned object by the transition tool.None of these methods required the transition tool to inform us that a block was invalid, but with new EIP changes like:
ethereum/EIPs#9508
ethereum/EIPs#9582
There's a block failure type that we cannot mock in the tests: system contract failures.
This new field is used the tests for both of these EIP changes: #1394
reliable
Class Variable in the Exception MapperAdded a new property to the exception mappers that when set to
False
means that the exception mapper cannot reliably discriminate between types of exceptions.This needs to be set back to
True
once the EELS's t8n returns different exceptions for each type.Global
default_t8n
Fixture for Unit TestsNew global fixture that contains an already-running instance of the default t8n tool, which significantly speeds up unit test runs.
🔗 Related Issues
✅ Checklist
mkdocs serve
locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.