Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mixup with chain_id and network_id #1343

Conversation

pipermerriam
Copy link
Member

@pipermerriam pipermerriam commented Oct 2, 2018

What was wrong?

The eth.chains.base.Chain class had a network_id property. This is wrong since network_id is above the EVM level. This should have been chain_id

How was it fixed?

  • migrated MAINNET_NEWORK_ID and ROPSTEN_... to live under trinity.constants
  • migrated DEFAULT_PREFERRED_NODES to also live under trinity to prevent some weird imports.
  • added MAINNET_CHAIN_ID and ROPSTEN_CHAIN_ID to eth module.
  • updated the net JSON-RPC module to return the chain_id (currently served over the event bus by the Node class)
    • In a subsequent PR I'd like to move this out of the Node class into something stand-alone which serves up the various config values like this. still mentally fleshing this out.

Cute Animal Picture

squirrel-in-a-pumpkin

@pipermerriam pipermerriam changed the title Piper/implement chain id builder function Fix mixup with chain_id and network_id Oct 2, 2018
@pipermerriam pipermerriam force-pushed the piper/implement-chain_id-builder-function branch 3 times, most recently from 4e7da20 to e25e388 Compare October 2, 2018 19:48
@pipermerriam pipermerriam force-pushed the piper/implement-chain_id-builder-function branch from e25e388 to f1b06d3 Compare October 2, 2018 20:00
self.run_task(self._periodically_report_stats())
if self.event_bus is not None:
self.run_daemon_task(self.handle_peer_count_requests())
self.run_daemon_task(self._periodically_report_stats())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is potentially not a good idea. It'll cause the node to crash if peer stats reporting crashes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but good enough for now. Fail hard during alpha/beta, then we can soften it in production.

@@ -856,7 +854,9 @@ def _add_peer(self,
async def _run(self) -> None:
# FIXME: PeerPool should probably no longer be a BaseService, but for now we're keeping it
# so in order to ensure we cancel all peers when we terminate.
self.run_task(self._periodically_report_stats())
if self.event_bus is not None:
self.run_daemon_task(self.handle_peer_count_requests())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cburgdorf can you 👍 / 👎 this change. It moves the task into the _run method so that it only starts when the peer pool has started as well as making it a deamon task which will crash the whole trinity process if it fails.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense. 👍 That said, I think this will move soon into its own child service or something similar.

Copy link
Contributor

@carver carver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, change makes sense to me 👍 We had a similar confusion in web3.py originally.

I don't know enough on the event bus to comment on any of that part.

self.run_task(self._periodically_report_stats())
if self.event_bus is not None:
self.run_daemon_task(self.handle_peer_count_requests())
self.run_daemon_task(self._periodically_report_stats())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but good enough for now. Fail hard during alpha/beta, then we can soften it in production.


async def handle_network_id_requests(self) -> None:
async def f() -> None:
# FIXME: There must be a way to cancel event_bus.stream() when our token is triggered,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: The comment could be redirected to mention that this hack will go away as soon as ethereum/lahja#14 is included in the next release

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will cleanup independently

@pipermerriam pipermerriam merged commit e237d89 into ethereum:master Oct 3, 2018
@pipermerriam pipermerriam deleted the piper/implement-chain_id-builder-function branch October 3, 2018 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants