-
Notifications
You must be signed in to change notification settings - Fork 394
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
Enrichment Improvements #3538
Enrichment Improvements #3538
Conversation
Implemented a new batch processing system for address enrichment. This aggregates enrichment lookup requests, and switches the source of data to on-chain read only calls through multicall and a custom smart contract. This significantly minimizes resource usage by reducing the number of dispatched requests, improving speed and resource usage of the enrichment process.
A few changes to better accommodate the new batch processing system: - Restructured data flow to optimize for batch processing of address enrichment. - Cleanup of unnecessary/duplicate enrichment requests, further enhancing performance. - Removal of balance checks for non-pending transactions, reducing processing overhead. - Refactored transaction log parsing to prevent additional redundant requests.
Just a quick glance here, but is this... Removing the name service from the flow entirely, but only doing that for Ethereum? |
Yes, this is switching the source of enrichment name resolution for remote resolvers (ens/uns) to read-only calls, in this initial implementation I did not factor in local name resolution but it can be added without a lot of effort. This contract is only deployed on Ethereum since I wanted to gather the team input's on this, and I think it would have been difficult to test this without it. Considering enrichment is mostly a concern for chains were we're able to retrieve asset transfers, and these limited by alchemy, we could deploy some variant of it on those other networks if this is the direction we want to take. While enrichment requires data for multiple sources (or most likely will), I think it's worth considering the retrieval of certain information for enrichment as it's own separate thing. This solves an issue we currently have because we're not storing enrichment data, and we're constantly retrieving new transactions to enrich. Another thing to keep in mind is that we can still benefit from batching if we decide not to use a contract for enrichment. |
Short version here:
The next step here IMO is to try to get the bulk of this gain across the whole wallet by implementing bundling in the relevant services for their specific calls, leveraging that helper contract. Fleshing out thoughts in no particular about this path:
I suggest we close this PR for now, but continue to push on this direction. |
Thank you for the insightful analysis. I agree, the helper contract does seem promising, but the complexity and code duplication it adds make it less appealing. We can still make use of the bundling mechanism and the other fixes included in this PR to improve our existing implementation. I'd suggest we revisit this when we're able to decide if we want to include and/or prioritize it appropriately within our roadmap. |
At the moment, during enrichment, we have to dispatch 2 RPC calls for name resolution with ENS alone. The first to get the resolver and another to perform the actual lookup. Additionally, we also need to run a query for balances and retrieve the address's code to determine if we're dealing with a contract address.
For a simple ETH transfer this is fine, but for something involving a contract, like an erc20 transfer or a swap, this can involve a lot of addresses which in turn result in a significant amount of requests being made. This is further worsened by the fact that during initial activity load we're also querying block, transaction, and receipts data.
This PR implements batch processing for address enrichment and, on-chain data resolution for enrichment requests, reducing RPC calls by as much as 87.5% during account onboarding, account switching and extension startup. This could be improved further by caching certain results by block height, since we're not performing special enrichment lookups for transactions already mined.
The deployed contract's source is here: https://gist.github.com/hyphenized/decfe5f079fc9c07d1f87939311bc16f
To Test
main
, open the network inspector on the background page, then load an account wait a couple of mins.Latest build: extension-builds-3538 (as of Mon, 10 Jul 2023 02:34:37 GMT).