-
Notifications
You must be signed in to change notification settings - Fork 665
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor consensus handling to be more flexible and sound
- Loading branch information
Showing
24 changed files
with
626 additions
and
290 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from .applier import ConsensusApplier # noqa: F401 | ||
from .clique.clique import ( # noqa: F401 | ||
CliqueApplier, | ||
CliqueConsensus, | ||
CliqueConsensusContext, | ||
) | ||
from .context import ConsensusContext # noqa: F401 | ||
from .noproof import NoProofConsensus # noqa: F401 | ||
from .pow import PowConsensus # noqa: F401 |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from typing import ( | ||
Iterable, | ||
Type, | ||
) | ||
|
||
from eth_utils import ( | ||
to_tuple, | ||
) | ||
|
||
from eth.abc import ( | ||
ConsensusAPI, | ||
VirtualMachineModifierAPI, | ||
VMConfiguration, | ||
) | ||
from eth.typing import ( | ||
VMFork, | ||
) | ||
|
||
|
||
class ConsensusApplier(VirtualMachineModifierAPI): | ||
""" | ||
This class is used to apply simple types of consensus engines to a series of virtual machines. | ||
Note that this *must not* be used for Clique, which has its own modifier | ||
""" | ||
|
||
def __init__(self, consensus_class: Type[ConsensusAPI]) -> None: | ||
self._consensus_class = consensus_class | ||
|
||
@to_tuple | ||
def amend_vm_configuration(self, config: VMConfiguration) -> Iterable[VMFork]: | ||
""" | ||
Amend the given ``VMConfiguration`` to operate under the rules of the pre-defined consensus | ||
""" | ||
for pair in config: | ||
block_number, vm = pair | ||
yield block_number, vm.configure(consensus_class=self._consensus_class) |
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
Oops, something went wrong.