hedera-mirror-node icon indicating copy to clipboard operation
hedera-mirror-node copied to clipboard

Implement gas throttle mechanism in web3

Open IvanKavaldzhiev opened this issue 11 months ago • 0 comments

Problem

Currently in hedera-mirror-web3 we handle large traffic by using a fixed amount of transactions per second for all users combined, which are rate limited. Although this approach is working, we can further optimise the number of requests, which are processed by using a gas per second as a throttle.

Solution

We can implement a mechanism which counts how much gas the EVM has processed for a second and throttle the responses when we reach a certain amount of gas. In this way, if the users are sending very light-weight transactions we can handle a lot larger number compared to the fixed amount of rate limit, which treats all transactions the same. Analogically, if the majority of users are performing very gas heavy operations, the requests that could be handled per second would be lowered.

In this way the Archive Node would handle requests in a more flexible way and would be easier to scale.

In addition we can finish some copy mismatches between services mono code and hedera-mirror-web3.

### Tasks
- [ ] https://github.com/hashgraph/hedera-mirror-node/issues/8135
- [ ] https://github.com/hashgraph/hedera-mirror-node/issues/8136
- [ ] https://github.com/hashgraph/hedera-mirror-node/issues/8258
- [ ] Enable log and metrics for gasThrottle and call data size in Grafana to inform potential increase in maxGasLimit and maxDataSize per second
- [ ] https://github.com/hashgraph/hedera-mirror-node/issues/8056
- [ ] https://github.com/hashgraph/hedera-mirror-node/issues/8137

IvanKavaldzhiev avatar Apr 03 '24 15:04 IvanKavaldzhiev