-
Notifications
You must be signed in to change notification settings - Fork 996
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
✅ Add optimistic sync tests #3489
base: dev
Are you sure you want to change the base?
✅ Add optimistic sync tests #3489
Conversation
I tried to implement the first case from this issue; which is in my case the below:
Does it match what you asked ? I am not sure the way I am manipulating weights is the best way to do it (I used the parameter |
The test looks good in general but I am not sure that |
I did manage attestation instead of participation indices; but it can't run with mainnet config because of the function |
Now it run whatever the preset + added a test with equal weight (1 validator attestation per branch) |
@wenceslas-sanchez is this PR ready for review or are you expecting to do more changes to it? |
Nothing more than code refactoring, so you can review it. |
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.
Test scenarios look good to me! 👍
I haven't looked deep into implementation design though, I hope @hwwhww will do that 😜
@@ -112,3 +114,209 @@ def test_from_syncing_to_invalid(spec, state): | |||
assert mega_store.opt_store.head_block_root == signed_blocks_a[-1].message.hash_tree_root() | |||
|
|||
yield 'steps', test_steps | |||
|
|||
|
|||
def add_attestation_and_sign_block_with_aggregation_bit_list(spec, state, store, block, index, aggregation_bit_list): |
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.
This function should be moved to one of the helper packages I believe
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.
Isn't this method too specific to what I am testing ? For instance I complete the aggregation_bits
full of zeros to match the expected list size.
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.
I think this method can potentially be reused in other tests, cc @hwwhww
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.
Slightly inclined to move to fork_choice.py
.
tests/core/pyspec/eth2spec/test/bellatrix/sync/test_optimistic.py
Outdated
Show resolved
Hide resolved
Sorry for the late reply! Great work @wenceslas-sanchez! I'm now picking up the reviews after the long conference weeks. 🙏 There was an unrelated issue (#3495) that broke our CI. I fixed it and the linter errors. But now we can see that the |
It seems that you are right, and that's because each preset/fork generates a different
(It's seems to have a lot of red cross, but sometimes it happens at the first assertion, and sometimes to the second.) What we can do to manage this:
I will try to revert very soon with the second solution. |
Ok I think I found a solution but it's not super elegant.. what do you think ? |
@@ -112,3 +114,209 @@ def test_from_syncing_to_invalid(spec, state): | |||
assert mega_store.opt_store.head_block_root == signed_blocks_a[-1].message.hash_tree_root() | |||
|
|||
yield 'steps', test_steps | |||
|
|||
|
|||
def add_attestation_and_sign_block_with_aggregation_bit_list(spec, state, store, block, index, aggregation_bit_list): |
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.
Slightly inclined to move to fork_choice.py
.
data=attestation_data, | ||
) | ||
sign_attestation(spec, state, attestation) | ||
spec.on_attestation(store, attestation, is_from_block=True) |
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.
It's implicit (sorry!), but I made all add_*
helpers that yield something from the fork choice spec on_*
helpers. If we yield here, it will output the attestation SSZ file to the test vectors.
In the given test cases, I think we don't need the spec.on_attestation
call because the block will include the attestations?
If so, we should:
- remove this line
- rename
add_attestation_and_sign_block_with_aggregation_bit_list
tosign_block_with_aggregation_bit_list
If not, we should:
- replace this line with
fork_choice::add_attestation
helper
yield from add_attestation(spec, store, attestation, test_steps)
- replace
signed_block = add_attestation_and_sign_block_with_aggregation_bit_list
withsigned_block = yield from add_attestation_and_sign_block_with_aggregation_bit_list
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.
Oh okay understoood, I did rename the method + remove the on_attestation
call. I also moved it to fork_choice.py
The goal of this PR is to add more cases for optimistic sync feature.
Test TODO:
Global TODO: