forked from ethereum/py-evm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor tweaks to recent VMs for clarity
- Use the block header class for the appropriate VM by validating up to the previous VM, extracting the params, and plugging into the appropriate VM class. - Remove unnecessary fields in London state since they are already inheritted and do not need to be re-imported / overwritten
- Loading branch information
Showing
7 changed files
with
65 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
from typing import Any, Callable, Optional | ||
|
||
from toolz import curry | ||
|
||
from eth.abc import BlockHeaderAPI | ||
from .blocks import ( | ||
ArrowGlacierBlockHeader, | ||
) | ||
from eth.vm.forks.london.headers import ( | ||
create_header_from_parent, | ||
create_london_header_from_parent, | ||
) | ||
from eth.vm.forks.petersburg.headers import ( | ||
from eth.vm.forks.byzantium.headers import ( | ||
compute_difficulty, | ||
) | ||
from eth.vm.forks.istanbul.headers import ( | ||
from eth.vm.forks.byzantium.headers import ( | ||
configure_header, | ||
) | ||
|
||
|
||
compute_arrow_glacier_difficulty = compute_difficulty(10_700_000) | ||
configure_arrow_glacier_header = configure_header(compute_arrow_glacier_difficulty) | ||
|
||
create_arrow_glacier_header_from_parent = create_header_from_parent( | ||
compute_arrow_glacier_difficulty | ||
) | ||
|
||
configure_arrow_glacier_header = configure_header(compute_arrow_glacier_difficulty) | ||
@curry | ||
def create_arrow_glacier_header_from_parent( | ||
difficulty_fn: Callable[[BlockHeaderAPI, int], int], | ||
parent_header: Optional[BlockHeaderAPI], | ||
**header_params: Any | ||
) -> BlockHeaderAPI: | ||
london_validated_header = create_london_header_from_parent( | ||
difficulty_fn, parent_header, **header_params | ||
) | ||
|
||
# extract header params validated up to london (previous VM) and plug | ||
# into `ArrowGlacierBlockHeader` class | ||
all_fields = london_validated_header.as_dict() | ||
return ArrowGlacierBlockHeader(**all_fields) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,38 @@ | ||
from eth.vm.forks.london.headers import ( | ||
create_header_from_parent, | ||
from typing import Any, Callable, Optional | ||
|
||
from toolz import curry | ||
|
||
from .blocks import ( | ||
GrayGlacierBlockHeader, | ||
) | ||
from eth.abc import ( | ||
BlockHeaderAPI, | ||
) | ||
from eth.vm.forks.petersburg.headers import ( | ||
from eth.vm.forks.arrow_glacier.headers import ( | ||
create_arrow_glacier_header_from_parent, | ||
) | ||
from eth.vm.forks.byzantium.headers import ( | ||
compute_difficulty, | ||
) | ||
from eth.vm.forks.istanbul.headers import ( | ||
from eth.vm.forks.byzantium.headers import ( | ||
configure_header, | ||
) | ||
|
||
|
||
compute_gray_glacier_difficulty = compute_difficulty(11_400_000) | ||
configure_gray_glacier_header = configure_header(compute_gray_glacier_difficulty) | ||
|
||
create_gray_glacier_header_from_parent = create_header_from_parent( | ||
compute_gray_glacier_difficulty | ||
) | ||
|
||
configure_gray_glacier_header = configure_header(compute_gray_glacier_difficulty) | ||
@curry | ||
def create_gray_glacier_header_from_parent( | ||
difficulty_fn: Callable[[BlockHeaderAPI, int], int], | ||
parent_header: Optional[BlockHeaderAPI], | ||
**header_params: Any | ||
) -> BlockHeaderAPI: | ||
arrow_glacier_validated_header = create_arrow_glacier_header_from_parent( | ||
difficulty_fn, parent_header, **header_params | ||
) | ||
|
||
# extract header params validated up to arrow glacier (previous VM) and plug | ||
# into `GrayGlacierBlockHeader` class | ||
all_fields = arrow_glacier_validated_header.as_dict() | ||
return GrayGlacierBlockHeader(**all_fields) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters