ethereum / devp2p

Ethereum peer-to-peer networking specifications
979 stars 275 forks source link

Use utils.Limiter for discv5 #162

Open zsfelfoldi opened 3 years ago

zsfelfoldi commented 3 years ago

I have a WIP branch where I implemented a fairly simple DDoS protector for lespay UDP talk requests (400 LOC total + utils.WeightedRandomSelect, does not use the NodeStateMachine). The reason I spent time with it at this early stage is that I think the token market interface really needs to be designed with this aspect in mind. Polling rates and unhealthy competition (arms race) can be a problem with markets, especially in a decentralized and uncontrolled, somewhat chaotic environment. The reason I opened an issue for discussion about it is because I think something like this could be a recommendation (maybe even an EIP) for our entire DHT and I am interested in your opinons from both a security and DHT centric perspective. So basically what it does is

https://github.com/zsfelfoldi/go-ethereum/blob/les4udp/les/utils/limiter.go

The service throttling can also take actual serving resource costs (CPU and/or bandwidth usually) into account. An attack deliberately making the most expensive requests will be proportionally more heavily throttled while economical usage of the resources of the serving node is rewarded by quicker responses. Practice with LES servers has shown though that direct time-based cost metering sometimes gives extreme outliers that are unrelated to the given request. utils.CostFilter ensures that these outliers will not block service for some nodes by accident.

https://github.com/zsfelfoldi/go-ethereum/blob/les4udp/les/utils/costfilter.go

fjl commented 3 years ago

Related: https://github.com/ethereum/devp2p/issues/161