ethereum / execution-spec-tests

A Python framework and collection of test cases to generate test vectors for Ethereum execution clients
https://ethereum.github.io/execution-spec-tests
MIT License
103 stars 72 forks source link

feat(forks): define an enum that contains all available forks #390

Open danceratopz opened 8 months ago

danceratopz commented 8 months ago

Define an enum that contains all available forks.

The initial aim was to use these forks in validity markers (whose arguments are currently string, not fork types). This would allow auto-complete and static type checking.

However, it might be possible to use this enum everywhere instead of importing each fork individually. Currently, we have (which can be a bit cumbersome if importing many forks):

from ethereum_test_forks import Paris, Shanghai

If we define our enum cleverly, we could simply:

from ethereum_test_forks import Forks

and use Forks.Paris and Forks.Shanghai. This is perhaps not quite as compact, but definitely more useful when writing code. We'd need to see if it's possible to modify the enum class to return the fork class object directly, otherwise we'd have to use Forks.Paris.value, which is not acceptable.

Also we'd have a unified way of defining forks in regular code and in validity markers.

marioevz commented 5 months ago

Another option could be to import the entire library:

import ethereum_test_forks as forks
...
forks.Frontier
forks.Homestead