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

cmd/faucet: cache internal state, avoid sync-trashing les #17732

Merged
merged 1 commit into from
Sep 21, 2018

Conversation

karalabe
Copy link
Member

This PR is a much needed fix for the Rinkeby faucet.

The issue with the faucet lately was that the for every client connection, the faucet retrieved it's current stats (head, balance, nonce) from les. While syncing however, this meant that remote clients who have the page open hammer the light client with requests, which probably clog up the les queues and make everything time out (i.e. the sync requests time out, because we have data retrieval requests queued up in front).

A similar issue was that for every head request, the faucet retrieved its stats, but during a sync, each header is announced as a new head, again causing a ton of requests forced from the faucet towards les.

The "fix" introduced in this PR is to cache all internal states that the faucet streams to clients, so instead of requesting on demand, we have a loop that updates periodically and streams the cached value to new websocket connections. The second fix was that the faucet will from now on ignore chain head events that are older than 1 hour, to avoid putting extra strain on les during sync.


These fixes are not yet perfect, as les is still overloaded by the sync + data retrieval during normal operation if the faucet only has 1-2 connections, it however does manage to sync up fast and correctly queue and send transactions. The "ugly"-ness still present is that sometimes it takes a couple minutes until the old transactions are flushed out.

There are a few takeaways however related to les:

  • Client requests can essentially take the node offline due to exhausting/DoSing the queue. I think we need some internal prioritization so header retrievals always take precedence over anything else. This is needed for les to remain in sync even if a faulty client is hammering it.
  • Head headers should not be announced for every header imported (if I'm importing 1K for example), rather only for the last one. This ensures that we don't have a huge burden on the internal subscription feeds and also outer subscription over websocket/ipc.

@karalabe karalabe added this to the 1.8.16 milestone Sep 21, 2018
@karalabe karalabe merged commit 06d40d3 into ethereum:master Sep 21, 2018
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.

1 participant