Skip to content

Comments

eip7805: add unit tests for InclusionListStore#4644

Merged
jtraglia merged 4 commits intoethereum:masterfrom
jihoonsong:inclusion-list-store-tests
Oct 14, 2025
Merged

eip7805: add unit tests for InclusionListStore#4644
jtraglia merged 4 commits intoethereum:masterfrom
jihoonsong:inclusion-list-store-tests

Conversation

@jihoonsong
Copy link
Member

This PR adds unit tests for InclusionListStore.

Comment on lines 21 to 35
def test_inclusion_list_store_transaction_uniqueness(spec, state):
def run_func():
forkchoice_store = get_genesis_forkchoice_store(spec, state)
inclusion_list_store = spec.get_inclusion_list_store()
inclusion_list_committee = spec.get_inclusion_list_committee(state, state.slot)

signed_inclusion_list_1 = get_sample_signed_inclusion_list(
spec, state, validator_index=inclusion_list_committee[0]
)
signed_inclusion_list_2 = get_sample_signed_inclusion_list(
spec, state, validator_index=inclusion_list_committee[1]
)
signed_inclusion_list_3 = get_sample_signed_inclusion_list(
spec, state, validator_index=inclusion_list_committee[2]
)
Copy link
Member

Choose a reason for hiding this comment

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

Will these ILs share one or more transactions? It doesn't appear that they do. Can we add an assert for that somewhere?

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've added two ILs with the same transactions. Let me know if we need an assertion as well!

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if you're planning on adding more, but it might be useful to add tests with:

  • Inclusion lists with no transactions.
  • Inclusion lists with the max number of transactions.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree

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've added them in test_inclusion_list_store_transaction_uniqueness test. Let me know if we want to add them in other tests as well!

@jtraglia jtraglia added the testing CI, actions, tests, testing infra label Oct 8, 2025
@jihoonsong
Copy link
Member Author

Thanks for feedback! Let me add more tests and the checklist in this PR.

"""

@lru_cache(maxsize=1)
def cached_or_new_inclusion_list_store():
Copy link
Member

Choose a reason for hiding this comment

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

Are we adding this for speed of the tests, or are we testing the effect of caching on the protocol?

Copy link
Member Author

@jihoonsong jihoonsong Oct 10, 2025

Choose a reason for hiding this comment

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

It's one of ways to return a cached IL store or an empty IL store, if it's not exist. Another way is using global keyword. No strong preferences, we can change it to something else if the intention is not straightforward.

Copy link
Member

Choose a reason for hiding this comment

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

My question is not about how you are caching it, but why are you replacing cached_or_new_inclusion_list_store, what are you trying to test with this?

Copy link
Member

Choose a reason for hiding this comment

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

Like this seems to be the same as the default spec but just adding the caching.

Copy link
Member Author

Choose a reason for hiding this comment

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

As the comment explains, it's monkeypatching it to make it viable. cached_or_new_inclusion_list_store itself is an implementation dependent function so you need to provide the impl somehow.

Copy link
Member

Choose a reason for hiding this comment

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

These tests only call, get_inclusion_list_store once per test, so the cached value is never used. So functional it is the same as the default implementation.

Is there a reason why this is necessary for these tests, or is it for future tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now I see what you mean. I think having this monkeypatching function would be useful in other tests such as test_process_execution_payload. It allows us to set IL transactions in the IL store directly, which will make testing concise and straightforward. Furthermore, get_inclusion_list_store is called multiple times per test. on_inclusion_list calls get_inclusion_list_store internally.

Having other tests that set the content of IL store would've made it clearer to see if this could be useful. My half-finished test_process_execution_payload is in my stash but I've been working on other stuff, sorry about that. Intuitively, I found this symmetrical to retrieve_blobs_and_proofs or retrieve_column_sidecars.

Copy link
Member

Choose a reason for hiding this comment

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

What do you think it we wait to include the test_process_execution_payload in this PR? That will make use of this, right?

I feel we should have a better way of setting the implementation of these. Perhaps it would be more pythonic doing it with wtih clause. But that would be a matter for another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

All IL related tests would use this. test_process_execution_payload is a big change so I don't want to hold this PR that longer tbh. It will add a new test case format for ILs as well as modify run_with_inclusion_list_store signature.

Making these kinds of test more pythonic sounds good but I agree that it deserves another PR.

Could you elaborate your concern? I'm happy to discuss how we can improve this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Hey @leolara the tests will fail without the caching decorator. I tried a few other things too and it seems that the current implementation is necessary. I'm going to merge this PR. Please submit another PR with the changes you want to see and we can discuss it more there. That way we have a concrete proposal to see.

@jihoonsong jihoonsong force-pushed the inclusion-list-store-tests branch from 74c2550 to ef6064b Compare October 10, 2025 12:44
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 @jihoonsong!

@jtraglia jtraglia merged commit aae5237 into ethereum:master Oct 14, 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