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

Actions queue #419

Merged
merged 8 commits into from
Jun 21, 2022
Merged

Actions queue #419

merged 8 commits into from
Jun 21, 2022

Conversation

fordN
Copy link
Contributor

@fordN fordN commented May 9, 2022

Background

The action queue aims to decouple action execution from decision making, provide oversight of decisions to indexers, and provide a more clear delineation of concerns in the software. The indexer management server will handle external interactions (data fetching and executing actions) while the indexer agent will be focused on managing the reconciliation loop decision making process and ongoing management of allocations. By moving transaction execution and data fetching to the indexer management server, providing the option to turn off the agents allocation management, and providing an allocation management interface hosted by the the indexer management server we open up the design space for 3rd party decision making software to replace or supplement the indexer-agent.

Changes Summary

  • Add action queue models and resolvers to indexer-common
  • Add actions module to indexer-cli
  • Add actions worker that polls and executes approved action queue
    items
  • Add new oversight allocation management mode to the indexer-agent (description below)
  • Update indexer-agent to add items to queue instead of executing them immediately
  • Add action-queue usage guide to /docs
  • Update README with up to date usage --help instructions for each component

Usage

The action execution worker will only grab items from the action queue to execute if they have ActionStatus = approved. In the recommended path actions are added to the queue with ActionStatus = queued, so they must then be approved in order to be executed on-chain. The indexer-agent now has 3 management modes (set using --allocation-management or INDEXER_AGENT_ALLOCATION_MANAGEMENT): auto, manual, and oversight.

Allocation management modes:

  • auto: The indexer-agent will act similarly to the current paradigm. When it identifies allocation actions it will add them to the queue with ActionStatus = approved and the execution worker process will pick it up within 30 seconds and execute it.
  • manual: The indexer-agent will not add any items to the action queue in this mode. It will host the indexer-management server which can be interacted with manually or integrated with 3rd party tools to add actions to the action queue and execute them.
  • oversight: The indexer-agent will add run its reconciliation loop to make allocation decisions and will add proposed actions to the action queue with ActionStatus = queued. These actions will then require approval before they will be executed.

Actions CLI

An actions module has been added to the indexer-cli for interacting with the actions queue.

# Fetch all
./bin/graph-indexer indexer actions get all

# Fetch by status
./bin/graph-indexer indexer actions get --status queued

# Queue allocate action (allocateFrom())
./bin/graph-indexer indexer actions queue allocate QmeqJ6hsdyk9dVbo1tvRgAxWrVS3rkERiEMsxzPShKLco6 5000

# Queue reallocate action (closeAndAllocate())
./bin/graph-indexer indexer actions queue reallocate QmeqJ6hsdyk9dVbo1tvRgAxWrVS3rkERiEMsxzPShKLco6 0x4a58d33e27d3acbaecc92c15101fbc82f47c2ae5 55000

# Queue unallocate action (closeAllocation())
./bin/graph-indexer indexer actions queue unallocate QmeqJ6hsdyk9dVbo1tvRgAxWrVS3rkERiEMsxzPShKLco6 0x4a58d33e27d3acbaecc92c15101fbc82f47c2ae

# Approve multiple actions for execution
./bin/graph-indexer indexer actions approve 1 3 5 

@fordN fordN marked this pull request as draft May 9, 2022 19:09
@fordN fordN force-pushed the ford/action-queue branch from 7632d83 to 7086518 Compare May 9, 2022 19:11
@fordN fordN force-pushed the ford/action-queue branch 4 times, most recently from 2239dcd to 490c381 Compare May 26, 2022 23:41
@fordN fordN marked this pull request as ready for review May 26, 2022 23:42
@fordN fordN force-pushed the ford/action-queue branch from 490c381 to c924c1e Compare May 26, 2022 23:44
@fordN fordN force-pushed the ford/action-queue branch 5 times, most recently from 6c908a7 to 259d0c2 Compare June 7, 2022 20:48
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.

Hey Ford! This PR is amazing! 😻 A ton of refactoring and design. Thank you so much! I have a few comments for you, other than that, the manual mode of action queue works amazingly with the optimizer

packages/indexer-common/src/actions.ts Outdated Show resolved Hide resolved
packages/indexer-agent/src/agent.ts Show resolved Hide resolved
packages/indexer-common/src/actions.ts Outdated Show resolved Hide resolved
packages/indexer-cli/src/actions.ts Show resolved Hide resolved
fordN added 2 commits June 15, 2022 12:43
- Add action queue models and resolvers to indexer-common
- Add actions module to indexer-cli
- Add actions worker that polls and executes approved action queue
items
- Include validation of action queue inputs
- Provide control of allocation management via AlloctionManagementMode
enum (AUTO | MANUAL | OVERSIGHT)
- Auto created indexing rules were setting a nonexistent property amount
where it should be allocationAmount
- Several typos were fixed in the logs
- Additional information is now included in the multicall tx logs so
indexers don't have to search the logs for type and deployment target
for the various actions being executed
@fordN fordN force-pushed the ford/action-queue branch from 259d0c2 to 6b18bb7 Compare June 15, 2022 19:43
@fordN fordN force-pushed the ford/action-queue branch from f757356 to 2195d51 Compare June 16, 2022 20:27
@fordN fordN requested a review from hopeyen June 18, 2022 03:23
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:)
Just a small question about ActionType.collect that was previously considered, I guess we don't need it since the worker will handle it along with unallocate and reallocate?

docs/action-queue.md Show resolved Hide resolved
@fordN
Copy link
Contributor Author

fordN commented Jun 21, 2022

LGTM:) Just a small question about ActionType.collect that was previously considered, I guess we don't need it since the worker will handle it along with unallocate and reallocate?

Yeah, collect is just always performed after a successful unnallocate or reallocate action.

fordN added 3 commits June 21, 2022 09:15
- Simply truncate the models after each test instead of recreating
the server
- Provide control of log level via LOG_LEVEL env var
@fordN fordN force-pushed the ford/action-queue branch from 817f92a to ad7e3db Compare June 21, 2022 16:17
@fordN fordN merged commit 8a3086e into main Jun 21, 2022
@fordN fordN deleted the ford/action-queue branch June 21, 2022 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants