indexer-agent: Improve batch action preparation #817
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Multiple actions are executed in a single transaction using the multicall paradigm, so the call data for each action is prepared and then combined into a single transaction. The call data for each action in the batch are prepared concurrently for efficiency; however, there was some innefficiencies in the concurrent preparation of call data due to redundancy in data used between the functions and a naive approach being used to validate that a deployment is healthy.
Improvements
Share data
Instead of refetching the same data during the preparation step for each and every action in the batch let's just fetch the data once and share it across all of them. To do this I've created a new context interface:
I've updated the
prepareTransactions()
function to create an instance ofTransactionPreparationContext
and pass that into each call ofprepareTransaction()
(for each action).More robust and efficient validation of healthy deployment syncing
Another efficiency and robustness improvement made in this PR is specific to preparing an
allocate
action for execution. In the legacy codeGraphNode.ensure()
was called to deploy the subgraph to the graph-node. The idempotent nature ofensure()
was leaned on heavily here as it was used in this case to validate that the graph-node is already syncing that deployment. Instead of usingensure()
we now access the indexingStatuses data to check if the deployment is already syncing and ishealthy
. This change should also improve robustness when allocating because separating the deployment process from the allocation process should allow more time between deploy and allocate for syncing errors to be caught.