Skip to content
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

indexer-agent: Improve batch action preparation #817

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

fordN
Copy link
Contributor

@fordN fordN commented Nov 13, 2023

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:

export interface TransactionPreparationContext {
  activeAllocations: Allocation[]
  currentEpoch: BigNumber
  indexingStatuses: IndexingStatus[]
}

I've updated the prepareTransactions() function to create an instance of TransactionPreparationContext and pass that into each call of prepareTransaction() (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 code GraphNode.ensure() was called to deploy the subgraph to the graph-node. The idempotent nature of ensure() 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 using ensure() we now access the indexingStatuses data to check if the deployment is already syncing and is healthy. 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.

@fordN fordN requested a review from hopeyen November 13, 2023 21:14
- Fetch 'currentEpoch' and 'activeAllocations' ony once; instead of
for each action being prepared
- Check indexing status before allocating; instead of calling ensure()
@fordN fordN force-pushed the ford/improve-deployment-management branch from 4157709 to 203cfd8 Compare November 13, 2023 21:26
@fordN fordN self-assigned this Nov 14, 2023
@fordN fordN added optimization enhancement New feature or request labels Nov 14, 2023
Copy link
Contributor

@hopeyen hopeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@fordN fordN merged commit edf0012 into main Nov 22, 2023
9 checks passed
@fordN fordN deleted the ford/improve-deployment-management branch November 22, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request optimization
Projects
Status: 🚗 Merged
Development

Successfully merging this pull request may close these issues.

None yet

2 participants