bnb-chain / opbnb

MIT License
404 stars 162 forks source link

feature(op-node): pre-fetch receipts concurrently #100

Closed welkin22 closed 9 months ago

welkin22 commented 9 months ago

Description

I added pre-fetch receipt logic in the https://github.com/bnb-chain/opbnb/pull/57. However, if the L1 endpoint is not functioning well and the interface response time increases, the efficiency of pre-fetch will be significantly reduced. To address this issue, we parallelize the pre-fetch process for multiple future block heights. This allows us to achieve better performance even when the L1 endpoint is not in good condition.

Rationale

To solve the problem of low L1 endpoint performance, we have added concurrent logic to improve the efficiency of pre-fetching receipts.

Example

none

Changes

Notable changes:

welkin22 commented 9 months ago

I changed the value of MaxConcurrentRequests from 10 to 20 in https://github.com/bnb-chain/opbnb/pull/100/commits/ab8dcdf9fe85d5ecffa5b28954aef39a33274c34 and modified the limiter in GoOrUpdatePreFetchReceipts to be half of MaxConcurrentRequests. This is because if GoOrUpdatePreFetchReceipts takes up all of MaxConcurrentRequests, other places that need to request will be throttled. See the code here: https://github.com/bnb-chain/opbnb/blob/e62988aacf1c068650e1ae80001d1fb7da9f141a/op-node/sources/limit.go#L19

@krish-nr PTAL