Skip to content

Comments

Port blob_to_kzg_commitment tests to pytest#4541

Merged
jtraglia merged 9 commits intoethereum:masterfrom
leolara:leolara/several-refactoring-testing
Sep 19, 2025
Merged

Port blob_to_kzg_commitment tests to pytest#4541
jtraglia merged 9 commits intoethereum:masterfrom
leolara:leolara/several-refactoring-testing

Conversation

@leolara
Copy link
Member

@leolara leolara commented Aug 28, 2025

In this PR:

  • I port one of the 7 formats introduced yesterday to the framework we are using reducing potentially the number of repeated code (considering the boilerplate in kzg_4844_legacy.py that is implemented elsewhere).
  • Enable these tests to run in pytest so allow to future use of the pytest plugins from STEEL.
  • Dramatically reduce the start time of generated tests, but refactoring a test that was being executed always at collection phase. This has been merged now in another PR

Note: this PR is based on the new caching system PR, to keep the non-multithread caching that was already implemented in kzg_4844_legacy in the refactored version. #4440

@leolara leolara requested a review from ralexstokes August 28, 2025 05:43
@jtraglia
Copy link
Member

jtraglia commented Aug 28, 2025

Hey Leo, yeah the proof of concept looks fine. Templates look nice. Just some random feedback:

  • These will be run with make test which isn't really what we wanted, but that's fine.
    • I expect they will make CI checks considerably slower.
    • You can disable these in the CI with the @generator_only decorator.
  • These are now under the kzg_4844 runner when they should be in kzg.
  • These are no longer in the general directory like before:
    • They are now in both the minimal & mainnet, which also means they're executed twice.
    • Eg consensus-spec-tests/tests/{minimal,mainnet}/deneb/kzg_4844/blob_to_kzg_commitment/.
    • Try running make reftests k=blob_to_kzg_commitment_case_valid_blob.
    • I think you'll want to use the @single_phase decorator.
    • But I'm not sure how to get it to be in the general directory.

PS: I merged a fix to the legacy tests which prevented other tests from working. See:

@leolara
Copy link
Member Author

leolara commented Aug 29, 2025

Hey Leo, yeah the proof of concept looks fine. Templates look nice. Just some random feedback:

  • These will be run with make test which isn't really what we wanted, but that's fine.

    • I expect they will make CI checks considerably slower.
    • You can disable these in the CI with the @generator_only decorator.

Will add a decorator that make the test run only in generation mode

  • These are now under the kzg_4844 runner when they should be in kzg.

ok

ok

  • They are now in both the minimal & mainnet, which also means they're executed twice.
  • Eg consensus-spec-tests/tests/{minimal,mainnet}/deneb/kzg_4844/blob_to_kzg_commitment/.
  • Try running make reftests k=blob_to_kzg_commitment_case_valid_blob.
  • I think you'll want to use the @single_phase decorator.
  • But I'm not sure how to get it to be in the general directory.

Ok, should run only in minimal or only in mainnet?

PS: I merged a fix to the legacy tests which prevented other tests from working. See:

Ok, will include this

@jtraglia
Copy link
Member

Ok, should run only in minimal or only in mainnet?

It will produce the same values for both, but technically it should exist in the general directory.

jtraglia pushed a commit that referenced this pull request Sep 10, 2025
By making the test run at test time instead of collection time in SSZ
generic container.

This was first introduced here:
#4541 but that PR
has more complications with other things
@leolara leolara marked this pull request as draft September 11, 2025 09:14
@leolara
Copy link
Member Author

leolara commented Sep 11, 2025

PS: I merged a fix to the legacy tests which prevented other tests from working. See:

#4546

I checked here that kzg_4844.py in master has the same content that here kzg_4844_legacy.py in this branch, so it should be included.

@leolara leolara marked this pull request as ready for review September 11, 2025 10:46
@leolara
Copy link
Member Author

leolara commented Sep 11, 2025

@jtraglia please check again

@leolara leolara changed the title Several refactorings to testing Port KZG 4844 blob_to_kzg_commitment tests to pytest Sep 11, 2025
blob = VALID_BLOBS[index]

@manifest(preset_name="general", suite_name="kzg-mainnet")
@only_generator("randomized test for broad coverage, not point-to-point CI")
Copy link
Member

Choose a reason for hiding this comment

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

Description isn't really accurate or helpful. It's not randomized and what is "point-to-point" CI exactly?

I'd prefer no rational sentence but if it's necessary maybe something like this instead? For both instances of this.

Suggested change
@only_generator("randomized test for broad coverage, not point-to-point CI")
@only_generator("too slow")

Copy link
Member

Choose a reason for hiding this comment

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

@leolara this suggestion applies to multiple lines:

For both instances of this.

@spec_cache(["blob_to_kzg_commitment"])
def the_test(spec):
commitment = spec.blob_to_kzg_commitment(blob)
# assert exception is not thrown with valid blob
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the useless comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok

except Exception:
pass

# exception is thrown
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the useless comment.

This comment was marked as spam.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not useless, it is a justtification to assert False

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean to assert commitment is None

Copy link
Member

Choose a reason for hiding this comment

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

Please remove the new spec caching stuff. This is irrelevant to this PR & I'm not ready to approve that stuff yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

But, you added non-multithreading caching to this?

Copy link
Member

Choose a reason for hiding this comment

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

You mean like the cached_blob_to_kzg_commitment wrapper function? Sure but that was way simpler. Not looking to start an argument, just stating that I'm not ready to review/merge that part yet. This PR should focus on converting the tests to pytest, not adding new features. Please remove it.

Copy link
Member

Choose a reason for hiding this comment

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

This PR doesn't need to include any caching. It doesn't matter to me if don't add back the cached_blob_to_kzg_commitment function. That's not really important.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I don't understand.

I am wrong stipulating that this is porting a test that in the orginal was caching spec.blob_to_kzg_commitment with cached_blob_to_kzg_commitment and now it is caching it with @spec_cache(["blob_to_kzg_commitment"])

Copy link
Member

Choose a reason for hiding this comment

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

Yes, so this PR is making a rather large additional change; it's doing more than just porting some test to pytest. @leolara I don't understand why you're pushing back so hard on this. I'm just asking for you to split the spec_cache part out of this PR. I will not approve this PR until then.

@leolara leolara force-pushed the leolara/several-refactoring-testing branch from 5363c1e to 53b3d50 Compare September 19, 2025 09:26
@leolara
Copy link
Member Author

leolara commented Sep 19, 2025

The command diff -rq consensus-spec-tests/tests consensus-spec-tests/tests-master/ returned nothing, which means that there are no differences.

@leolara
Copy link
Member Author

leolara commented Sep 19, 2025

@jtraglia please check again, I used diff -rq to compare, meld has many dependencies.

Copy link
Member

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @leolara

I can confirm these produce the same reference tests:

Image

@jtraglia jtraglia changed the title Port KZG 4844 blob_to_kzg_commitment tests to pytest Port blob_to_kzg_commitment tests to pytest Sep 19, 2025
@jtraglia jtraglia added the testing CI, actions, tests, testing infra label Sep 19, 2025
@jtraglia jtraglia merged commit 1a1cc25 into ethereum:master Sep 19, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing CI, actions, tests, testing infra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants