execution-spec-tests icon indicating copy to clipboard operation
execution-spec-tests copied to clipboard

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

Open danceratopz opened this issue 2 years ago • 1 comments

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.

danceratopz avatar Jan 19 '24 10:01 danceratopz

Another option could be to import the entire library:

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

marioevz avatar Apr 02 '24 00:04 marioevz