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

[Merged by Bors] - Improve eth1 block sync #2008

Closed
wants to merge 10 commits into from
Closed

Conversation

paulhauner
Copy link
Member

@paulhauner paulhauner commented Nov 29, 2020

Issue Addressed

NA

Proposed Changes

  • Log about eth1 whilst waiting for genesis.
  • For the block and deposit caches, update them after each download instead of when all downloads are complete.
    • This prevents the case where a single timeout error can cause us to drop all previously download blocks/deposits.
  • Set max_log_requests_per_update to avoid timeouts due to very large log counts in a response.
  • Set max_blocks_per_update to prevent a single update of the block cache to download an unreasonable number of blocks.
    • This shouldn't have any affect in normal use, it's just a safe-guard against bugs.
  • Increase the timeout for eth1 calls from 15s to 60s, as per @pawanjay176's experience with Infura.

Additional Info

NA

@paulhauner paulhauner added the work-in-progress PR is a work-in-progress label Nov 29, 2020
@paulhauner paulhauner changed the base branch from stable to unstable November 30, 2020 01:02
@paulhauner paulhauner added ready-for-review The code is ready for review and removed work-in-progress PR is a work-in-progress labels Nov 30, 2020
@paulhauner paulhauner marked this pull request as ready for review November 30, 2020 04:36
Comment on lines 245 to 247
head_info
.genesis_time
.saturating_sub(voting_periods_past * voting_period_duration)
Copy link
Member

Choose a reason for hiding this comment

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

I think this should subtract the follow distance as well, otherwise we expect our cache to contain the block from the start of the (virtual) voting period rather than the latest block ETH1_FOLLOW_DISTANCE behind the start of the virtual voting period

@@ -27,7 +27,7 @@ pub const DEFAULT_NETWORK_ID: Eth1Id = Eth1Id::Goerli;
/// Indicates the default eth1 chain id we use for the deposit contract.
pub const DEFAULT_CHAIN_ID: Eth1Id = Eth1Id::Goerli;

const STANDARD_TIMEOUT_MILLIS: u64 = 15_000;
const STANDARD_TIMEOUT_MILLIS: u64 = 60_000;
Copy link
Member

Choose a reason for hiding this comment

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

I think the higher timeout could be applied to just the GET_DEPOSIT_LOG_TIMEOUT_MILLIS.
Other calls are lightweight and them taking > 15 secs could imply bad health of the eth1 nodes.

//
// This prevents the block downloading routine for running for a very long time and
// starving the deposit cache updater.
if Instant::now().duration_since(start_instant) > max_runtime {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand why we can't complete the blocks downloads before going back to deposits.

Even if we go back to updating deposits every 14secs, we usually won't get more than 1-2 new logs every update and this would slow down the block download.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I understand why we can't complete the blocks downloads before going back to deposits.

I suspect we could do this and I had a look at it, but it was sufficiently complicated that I wasn't confident to do it before mainnet :)

Copy link
Member

Choose a reason for hiding this comment

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

I meant we could just remove the
if Instant::now().duration_since(start_instant) > max_runtime
check and let all the block downloads complete. If we get an error somewhere in between, we start from that point in the next update.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had some reasoning behind this, but it was loosely held. I think I'll just follow your suggestion and leave it out :)

@paulhauner
Copy link
Member Author

All comments addressed!

Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

LGTM!

@paulhauner
Copy link
Member Author

Thanks reviewers!

bors r+

bors bot pushed a commit that referenced this pull request Nov 30, 2020
## Issue Addressed

NA

## Proposed Changes

- Log about eth1 whilst waiting for genesis.
- For the block and deposit caches, update them after each download instead of when *all* downloads are complete.
  - This prevents the case where a single timeout error can cause us to drop *all* previously download blocks/deposits.
- Set `max_log_requests_per_update` to avoid timeouts due to very large log counts in a response.
- Set `max_blocks_per_update` to prevent a single update of the block cache to download an unreasonable number of blocks.
  - This shouldn't have any affect in normal use, it's just a safe-guard against bugs.
- Increase the timeout for eth1 calls from 15s to 60s, as per @pawanjay176's experience with Infura.

## Additional Info

NA
@bors bors bot changed the title Improve eth1 block sync [Merged by Bors] - Improve eth1 block sync Nov 30, 2020
@bors bors bot closed this Nov 30, 2020
@michaelsproul michaelsproul deleted the eth1-sync branch November 30, 2020 22:35
bors bot pushed a commit that referenced this pull request Nov 30, 2020
## Issue Addressed

NA

## Proposed Changes

- Set version to `v1.0.3`
- Run cargo update

## Additional Info

- ~~Blocked on #2008~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review The code is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants