boba_legacy
boba_legacy copied to clipboard
[DTL] Excessive queries from this._getContractAddressAtBlock
Issue Type
[X] bug report
[ ] feature request
Current Behavior
The L1-ingestion service (src/services/l1-ingestion/service.ts) scans the SCC and CTC contracts in batches looking for rollup events. On a freshly-deployed DTL this scan starts at a configured block height corresponding to the initial deployment of the contracts. However there is functionality which also looks for AddressManager events indicating that a contract address has changed at some point:
private async _getContractAddressAtBlock(
contractName: string,
blockNumber: number
): Promise<string> {
const events = await this.state.contracts.Lib_AddressManager.queryFilter(
this.state.contracts.Lib_AddressManager.filters.AddressSet(contractName),
this.state.startingL1BlockNumber,
blockNumber
)
...continued
The problem is that this query always starts from this.state.startingL1BlockNumber regardless of how far removed that is from the current head of the chain. This is very inefficient and can eventually lead to request timeouts.
Expected Behavior
The AddressSet query should be restricted to the same range of blocks as the main CTC/SCC query, and the database should be used to persistently store the most recently discovered address for each contract. When no address-change event is found in the queried range of blocks, the previous DB value should be returned instead.
Steps to Reproduce
This can be reproduced by launching a Verifier node from boba_community/fraud-detector, and observing performance degradation as its DTL syncs L1 blocks which are increasingly removed from the CTC deployment event.
Suggested Fix
Since we do not intend to change contract addresses on deployed systems, we can bypass this query entirely and instead return addresses from the addresses.json data structure after it has been uploaded to the DTL.