-
Notifications
You must be signed in to change notification settings - Fork 981
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
Exclude empty requests in requests list #3998
Merged
+234
−29
Merged
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0c5a136
Exclude empty requests in requests list
jtraglia 369b7e5
Fix table of contents
jtraglia 2bd570c
Use assert instead of raise
jtraglia 8a8a321
Fix indentation
jtraglia 3ce2929
Simplify get_execution_requests
jtraglia 4438166
Check for ascending order
jtraglia e90c792
Fix typo
jtraglia b3e77d2
Apply other stokes suggestion
jtraglia 276c562
Use less python sugar
jtraglia ebbce03
Replace assert messages with comments
jtraglia e472afd
Include requests_root in block_hash computation
jtraglia b1c9d27
Add comment to compute_requests_hash
jtraglia de52c76
Fix block hash computation for deposit transition tests
etan-status 36b4979
Merge pull request #1 from etan-status/exclude-empty-requests
jtraglia 15e3f15
Fix block hash computation for withdrawal sanity tests
etan-status bfe166c
Merge pull request #2 from etan-status/exclude-empty-requests
jtraglia 4aad8eb
Rename requests_root to requests_hash
jtraglia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
tests/core/pyspec/eth2spec/test/electra/unittests/test_execution_requests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
from eth2spec.test.context import ( | ||
single_phase, | ||
spec_test, | ||
with_electra_and_later, | ||
) | ||
|
||
|
||
@with_electra_and_later | ||
@spec_test | ||
@single_phase | ||
def test_requests_serialization_round_trip__empty(spec): | ||
execution_requests = spec.ExecutionRequests() | ||
serialized_execution_requests = spec.get_execution_requests_list(execution_requests) | ||
deserialized_execution_requests = spec.get_execution_requests(serialized_execution_requests) | ||
assert deserialized_execution_requests == execution_requests | ||
|
||
|
||
@with_electra_and_later | ||
@spec_test | ||
@single_phase | ||
def test_requests_serialization_round_trip__one_request(spec): | ||
execution_requests = spec.ExecutionRequests( | ||
deposits=[spec.DepositRequest()], | ||
) | ||
serialized_execution_requests = spec.get_execution_requests_list(execution_requests) | ||
deserialized_execution_requests = spec.get_execution_requests(serialized_execution_requests) | ||
assert deserialized_execution_requests == execution_requests | ||
|
||
|
||
@with_electra_and_later | ||
@spec_test | ||
@single_phase | ||
def test_requests_serialization_round_trip__multiple_requests(spec): | ||
execution_requests = spec.ExecutionRequests( | ||
deposits=[spec.DepositRequest()], | ||
withdrawals=[spec.WithdrawalRequest()], | ||
consolidations=[spec.ConsolidationRequest()], | ||
) | ||
serialized_execution_requests = spec.get_execution_requests_list(execution_requests) | ||
deserialized_execution_requests = spec.get_execution_requests(serialized_execution_requests) | ||
assert deserialized_execution_requests == execution_requests | ||
|
||
|
||
@with_electra_and_later | ||
@spec_test | ||
@single_phase | ||
def test_requests_serialization_round_trip__one_request_with_real_data(spec): | ||
execution_requests = spec.ExecutionRequests( | ||
deposits=[ | ||
spec.DepositRequest( | ||
pubkey=spec.BLSPubkey(48 * "aa"), | ||
withdrawal_credentials=spec.Bytes32(32 * "bb"), | ||
amount=spec.Gwei(11111111), | ||
signature=spec.BLSSignature(96 * "cc"), | ||
index=spec.uint64(22222222), | ||
), | ||
] | ||
) | ||
serialized_execution_requests = spec.get_execution_requests_list(execution_requests) | ||
deserialized_execution_requests = spec.get_execution_requests(serialized_execution_requests) | ||
assert deserialized_execution_requests == execution_requests | ||
|
||
|
||
@with_electra_and_later | ||
@spec_test | ||
@single_phase | ||
def test_requests_deserialize__allow_out_of_order_requests(spec): | ||
serialized_execution_requests = [ | ||
spec.WITHDRAWAL_REQUEST_TYPE + 76 * b"\x0a", | ||
spec.DEPOSIT_REQUEST_TYPE + 192 * b"\x0b", | ||
] | ||
assert int(serialized_execution_requests[0][0]) > int(serialized_execution_requests[1][0]) | ||
spec.get_execution_requests(serialized_execution_requests) | ||
|
||
|
||
@with_electra_and_later | ||
@spec_test | ||
@single_phase | ||
def test_requests_deserialize__reject_empty_request(spec): | ||
serialized_execution_requests = [b"\x01"] | ||
try: | ||
spec.get_execution_requests(serialized_execution_requests) | ||
assert False, "expected exception" | ||
except Exception as e: | ||
assert "empty request data" in str(e) | ||
|
||
|
||
@with_electra_and_later | ||
@spec_test | ||
@single_phase | ||
def test_requests_deserialize__reject_duplicate_request(spec): | ||
serialized_withdrawal = 76 * b"\x0a" | ||
serialized_execution_requests = [ | ||
spec.WITHDRAWAL_REQUEST_TYPE + serialized_withdrawal, | ||
spec.WITHDRAWAL_REQUEST_TYPE + serialized_withdrawal, | ||
] | ||
try: | ||
spec.get_execution_requests(serialized_execution_requests) | ||
assert False, "expected exception" | ||
except Exception as e: | ||
assert "duplicate request" in str(e) | ||
|
||
|
||
@with_electra_and_later | ||
@spec_test | ||
@single_phase | ||
def test_requests_deserialize__reject_unexpected_request_type(spec): | ||
serialized_execution_requests = [ | ||
b"\x03\xff\xff\xff", | ||
] | ||
try: | ||
spec.get_execution_requests(serialized_execution_requests) | ||
assert False, "expected exception" | ||
except Exception as e: | ||
assert "unexpected request type" in str(e) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For CL specs, they should be named with
REQUEST_TYPE_*
, but I figured out they are EIP constants... 😭@lightclient is it too late to change?