This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #641 from carver/beam-sync
Beam Sync v0.1
- Loading branch information
Showing
14 changed files
with
1,651 additions
and
3 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
Empty file.
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,59 @@ | ||
import asyncio | ||
|
||
from trinity.constants import ( | ||
SYNC_BEAM, | ||
) | ||
from trinity.db.eth1.manager import ( | ||
create_db_consumer_manager | ||
) | ||
from trinity.extensibility import ( | ||
AsyncioIsolatedPlugin, | ||
) | ||
from trinity.endpoint import ( | ||
TrinityEventBusEndpoint, | ||
) | ||
from trinity.sync.beam.importer import ( | ||
make_pausing_beam_chain, | ||
BlockImportServer, | ||
) | ||
from trinity._utils.shutdown import ( | ||
clean_up_endpoint, | ||
) | ||
|
||
|
||
class BeamChainExecutionPlugin(AsyncioIsolatedPlugin): | ||
""" | ||
Subscribe to events that request a block import: ``DoStatelessBlockImport``. | ||
Use the beam sync importer, which knows what to do when the state trie | ||
is missing data like: accounts, storage or bytecode. | ||
The beam sync importer blocks when data is missing, so it's important to run | ||
in an isolated process. | ||
""" | ||
_beam_chain = None | ||
|
||
@property | ||
def name(self) -> str: | ||
return "Beam Sync Chain Execution" | ||
|
||
def on_ready(self, manager_eventbus: TrinityEventBusEndpoint) -> None: | ||
if self.boot_info.args.sync_mode.upper() == SYNC_BEAM.upper(): | ||
self.start() | ||
|
||
def do_start(self) -> None: | ||
trinity_config = self.boot_info.trinity_config | ||
chain_config = trinity_config.get_chain_config() | ||
|
||
db_manager = create_db_consumer_manager(trinity_config.database_ipc_path) | ||
|
||
self._beam_chain = make_pausing_beam_chain( | ||
chain_config.vm_configuration, | ||
chain_config.chain_id, | ||
db_manager.get_db(), # type: ignore | ||
self.event_bus, | ||
) | ||
|
||
asyncio.ensure_future(clean_up_endpoint(self.event_bus)) | ||
|
||
import_server = BlockImportServer(self.event_bus, self._beam_chain) | ||
asyncio.ensure_future(import_server.run()) |
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
Empty file.
Oops, something went wrong.