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

Add WHISK fork only tests #3442

Merged
merged 25 commits into from
Dec 8, 2023
Merged

Add WHISK fork only tests #3442

merged 25 commits into from
Dec 8, 2023

Conversation

dapplion
Copy link
Member

@dapplion dapplion commented Jul 5, 2023

Description

Adds a baseline of tests covering the whisk feature introduced with #3342. In summary:

  • generate and validate tracker, opening and shuffle proofs
  • error cases for each assert condition in the spec

Scope / future work

Tests are only run for the whisk fork and minimal. The current crypto backend is significantly slower than BLS and KZG, so running more tests than that is prohibitively expensive at the moment.

Also to run tests from previous forks on Whisk, the vector generation has to be modified to accommodate the fact that the proposer is not known, and requires validator_size factorial G1 multiplications in an implementation without revealed shuffling data to figure out who is the proposer for a whisk round.

All those points can be addressed, but in a future PR if necessary

@dapplion
Copy link
Member Author

Note:

@dapplion
Copy link
Member Author

@hwwhww seems circle CI is experiencing a caching problem again https://app.circleci.com/pipelines/github/ethereum/consensus-specs/9434/workflows/86a7977e-ac75-42f6-8d2e-a81982c949e4/jobs/70233

ImportError while loading conftest '/home/circleci/specs-repo/tests/core/pyspec/eth2spec/test/conftest.py'.
eth2spec/test/conftest.py:1: in <module>
    from eth2spec.test import context
eth2spec/test/context.py:12: in <module>
    from eth2spec.whisk import mainnet as spec_whisk_mainnet, minimal as spec_whisk_minimal
eth2spec/whisk/__init__.py:1: in <module>
    from . import mainnet as spec  # noqa:F401
eth2spec/whisk/mainnet.py:222: in <module>
    CURDLEPROOFS_CRS = curdleproofs.CurdleproofsCrs.from_random_points(                 WHISK_VALIDATORS_PER_SHUFFLE,                 CURDLEPROOFS_N_BLINDERS,                 [G1Point.from_compressed_bytes_unchecked(p) for p in CURDLEPROOFS_CRS_G1]             )  # noqa: E501
E   AttributeError: type object 'CurdleproofsCrs' has no attribute 'from_random_points'

this method from_random_points exists in the referenced version and github CI and my local env pass tests

@hwwhww
Copy link
Contributor

hwwhww commented Jul 27, 2023

@dapplion

Oh my, it's so weird. I pushed a commit in my branch: ccd8026, and it seems to have installed with the correct commit but has some other errors.

But after I pushed that commit to this PR's branch, it showed the same error.

Is it possible because your repository has a different CircleCI setting?

@dapplion
Copy link
Member Author

dapplion commented Jul 28, 2023

Is it possible because your repository has a different CircleCI setting?

The reported errors were correct, there was a type issue with curdleproof's return values not caught in my local env due to caching.

With nalinbhardwaj/curdleproofs.pie#21 merged, now all tests should pass :)

EDIT: Circle CI version cache issue happening again. It's strange since the version bump is from a version that has from_random_points to a newer version that also has said method

ImportError while loading conftest '/home/circleci/specs-repo/tests/core/pyspec/eth2spec/test/conftest.py'.
eth2spec/test/conftest.py:1: in <module>
    from eth2spec.test import context
eth2spec/test/context.py:12: in <module>
    from eth2spec.whisk import mainnet as spec_whisk_mainnet, minimal as spec_whisk_minimal
eth2spec/whisk/__init__.py:1: in <module>
    from . import mainnet as spec  # noqa:F401
eth2spec/whisk/mainnet.py:222: in <module>
    CURDLEPROOFS_CRS = curdleproofs.CurdleproofsCrs.from_random_points(WHISK_VALIDATORS_PER_SHUFFLE, CURDLEPROOFS_N_BLINDERS, [G1Point.from_compressed_bytes_unchecked(p) for p in CURDLEPROOFS_CRS_G1])  # noqa: E501
E   AttributeError: type object 'CurdleproofsCrs' has no attribute 'from_random_points'

@dapplion
Copy link
Member Author

After debugging on a separate branch https://github.com/ethereum/consensus-specs/tree/whisk-tests-circleci results show that circle CI instances declare to install the correct commit of curdleproofs, but then a very old commit is actually used. I have not understood where this old version is coming from, but forcing an uninstall + reinstall seems to allow downstream steps to use the right version. I would suggest re-considering CircleCI as a platform to test the specs due to its non-determinism.

Note this hack forces mantainers to duplicate the version declaration in both a Makefile command (for CircleCI) and regular requirements (for Github Actions)

consensus-specs/Makefile

Lines 113 to 120 in db502dd

install_test: preinstallation
. venv/bin/activate; \
python3 -m pip install -e .; \
python3 -m pip install -e .[lint,test]; \
python3 -m pip freeze; \
python3 -m pip uninstall -y curdleproofs; \
python3 -m pip install "git+https://github.com/nalinbhardwaj/curdleproofs.pie@bc4bb34961a896af6bcf4a5ff4867bb2971742c8#egg=curdleproofs&subdirectory=curdleproofs"; \
python3 -m pip freeze;

@dapplion
Copy link
Member Author

dapplion commented Aug 18, 2023

@hwwhww Published curdleproofs 🎉 this PR is no longer using a Github ref

"curdleproofs==0.1.1",

@hwwhww hwwhww mentioned this pull request Sep 6, 2023
@dapplion
Copy link
Member Author

dapplion commented Oct 10, 2023

Updated the CRS with correct serialization. Tests should pass now.

@hwwhww There's this error on CI which I can't reproduce locally. The error points to a spec variable not being present, however it's defined in the preset file. Any ideas?

 eth2spec/test/whisk/block_processing/test_process_shuffled_trackers.py:132: in test_invalid_gap_non_zero_proof
    set_state_epoch_selection_gap(spec, state)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

spec = <module 'eth2spec.whisk.minimal' from '/home/devops/consensus-specs-02/consensus-specs-02/consensus-specs/consensus-specs/tests/core/pyspec/eth2spec/whisk/minimal.py'>
state = BeaconState(Container)
    genesis_time: uint64 = 0
    genesis_validators_root: Root = 0x0a08c27fe4ece2483f9e581f78c6...e002bbe9af91c6de91ab693f6477551e7ee0a1e675d0fc614814d8a8aa
                                                           )

    def set_state_epoch_selection_gap(spec, state):
>       set_state_epoch(spec, state, spec.WHISK_EPOCHS_PER_SHUFFLING_PHASE - 1)
E       AttributeError: module 'eth2spec.whisk.minimal' has no attribute 'WHISK_EPOCHS_PER_SHUFFLING_PHASE'

Ref: https://github.com/ethereum/consensus-specs/actions/runs/6468128943/job/17559568960#step:8:106

Copy link
Contributor

@mkalinin mkalinin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good to me!
@hwwhww what do you think about merging it after fixing the CI issue?

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dapplion

I believe it was because these parameters are defined in Configurations, so we use spec.config.* to access them.

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +19 to +21
# Must be unique among the set `whisk_ks_initial + whisk_ks_final`
def whisk_ks_final(i: int):
return i + 10000000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha

Comment on lines +15 to +16
def whisk_ks_initial(i: int):
return i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps add a TODO mark here

@hwwhww hwwhww merged commit bf09b9a into ethereum:dev Dec 8, 2023
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants