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

feat(hint): post state key hint [IDEA] #807

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat(hint): post state key hint [IDEA] #807

wants to merge 1 commit into from

Conversation

winsvega
Copy link
Collaborator

🗒️ Description

Add a hint dictionary for exceptions when generating the test.
Before:

E   ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001200 (runner_contract) for key 0x0000000000000000000000000000000000000000000000000000000000000001: want 0x3 (dec:3), got 0x2 (dec:2)

After

src/ethereum_test_base_types/composite_types.py:261: in must_be_equal
    raise Storage.KeyValueMismatch(
E   ethereum_test_base_types.composite_types.Storage.KeyValueMismatch: incorrect value in address 0x0000000000000000000000000000000000001200 (runner_contract) for key SIMPLE_CALL: want 0x3 (dec:3), got 0x2 (dec:2)

Possible improvements:
make storage keyvalue a class like Address so it can have hint label?
pass hint map for each address, each storage to convert sotrage keys into labels?

🔗 Related Issues

NONE

✅ Checklist

  • All: Set appropriate labels for the changes.
  • All: Considered squashing commits to improve commit history.
  • All: Added an entry to CHANGELOG.md.
  • All: Considered updating the online docs in the ./docs/ directory.
  • Tests: All converted JSON/YML tests from ethereum/tests have been added to converted-ethereum-tests.txt.
  • Tests: A PR with removal of converted JSON/YML tests from ethereum/tests have been opened.
  • Tests: Included the type and version of evm t8n tool used to locally execute test cases: e.g., ref with commit hash or geth 1.13.1-stable-3f40e65.
  • Tests: Ran mkdocs serve locally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.


key = Hash(self.key)
if self.hint is not None:
key = self.hint[self.key]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

need to revert to default value of Hash(self.key) if value is not found

@marioevz
Copy link
Member

This is a nice idea, we could even end up exporting the address tags and storage key hints to the fixtures in order for client consumers to also use this metadata.

One thing that might be a bit cumbersome is that the tester now has to create and maintain the post_hint dictionary, and my fear is that with time it could even get out of sync (e.g. you add a new key to your test for another verification and increment all keys but forget to update the post_hint).

I have an idea from the top of my head on how we could make it automatic:

Add the key hint dictionary to the Storage class, and allow users to pass the hint as a parameter to store_next. Caveat is that not all tests use this pattern, but it could be a way to encourage it.

We could also add some magic to the __setitem__ method like we do in the pre.deploy_contract function to get some information of the context where the key is being set and automatically obtain a hint in some of the cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants