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

feat(relayer): ListOperations api endpoint #4089

Merged
merged 5 commits into from
Jul 4, 2024

Conversation

daniel-savu
Copy link
Contributor

@daniel-savu daniel-savu commented Jul 2, 2024

Description

Adds a list_operations API endpoint to the relayer, which returns all operations in its prepare queue.

Example output from GET http://0.0.0.0:9092/list_operations?destination_domain=13371

[
  {
    "app_context": null,
    "message": {
      "body": [
        18,
        52
      ],
      "destination": 13371,
      "nonce": 1,
      "origin": 13373,
      "recipient": "0x000000000000000000000000927b167526babb9be047421db732c663a0b77b11",
      "sender": "0x000000000000000000000000927b167526babb9be047421db732c663a0b77b11",
      "version": 3
    },
    "num_retries": 13,
    "status": {
      "Retry": "CouldNotFetchMetadata"
    },
    "submitted": false,
    "type": "PendingMessage"
  },
  {
    "app_context": null,
    "message": {
      "body": [
        18,
        52
      ],
      "destination": 13371,
      "nonce": 2,
      "origin": 13372,
      "recipient": "0x000000000000000000000000927b167526babb9be047421db732c663a0b77b11",
      "sender": "0x000000000000000000000000927b167526babb9be047421db732c663a0b77b11",
      "version": 3
    },
    "num_retries": 13,
    "status": {
      "Retry": "CouldNotFetchMetadata"
    },
    "submitted": false,
    "type": "PendingMessage"
  }
]

Drive-by changes

Makes PendingOperation serializable, which means switching from JSON format to e.g. CSV (for easily filtering / aggregating in excel) should be very easy.

Related issues

Backward compatibility

Yes

Testing

Manual and Unit Tests

@daniel-savu daniel-savu requested a review from tkporter as a code owner July 2, 2024 13:32
Copy link

changeset-bot bot commented Jul 2, 2024

⚠️ No Changeset found

Latest commit: f62d687

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codecov bot commented Jul 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (befc38d) to head (f62d687).
Report is 18 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (befc38d) and HEAD (f62d687). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (befc38d) HEAD (f62d687)
2 1
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #4089       +/-   ##
==========================================
- Coverage   60.56%   0.00%   -60.57%     
==========================================
  Files         129       1      -128     
  Lines        1656      14     -1642     
  Branches      176       0      -176     
==========================================
- Hits         1003       0     -1003     
+ Misses        626      14      -612     
+ Partials       27       0       -27     
Components Coverage Δ
core ∅ <ø> (∅)
hooks ∅ <ø> (∅)
isms ∅ <ø> (∅)
token ∅ <ø> (∅)
middlewares ∅ <ø> (∅)

@daniel-savu
Copy link
Contributor Author

Slightly annoying how the operation status is serialized:

    "status": {
      "Retry": "CouldNotFetchMetadata"
    },

whereas I would've wanted the value to have no nesting: status: "Retry(CouldNotFetchMetadata)", because in csv you get a new column for each nested field within status, e.g. status/Retry and status/FirstPrepareAttempt. Not that big of a deal though

@tkporter
Copy link
Collaborator

tkporter commented Jul 3, 2024

@daniel-savu are there any alternative enum representations https://serde.rs/enum-representations.html that would help? maybe the internal one where we can have "type": "Retry" instead?

Copy link
Collaborator

@tkporter tkporter left a comment

Choose a reason for hiding this comment

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

nice 🔥

might be nice in the future to include gas payments but for now I think this is sufficient

rust/Cargo.toml Show resolved Hide resolved
rust/agents/relayer/src/msg/op_submitter.rs Outdated Show resolved Hide resolved
rust/agents/relayer/src/msg/op_submitter.rs Outdated Show resolved Hide resolved
@daniel-savu daniel-savu enabled auto-merge July 4, 2024 11:23
@daniel-savu
Copy link
Contributor Author

@daniel-savu are there any alternative enum representations https://serde.rs/enum-representations.html that would help? maybe the internal one where we can have "type": "Retry" instead?

turns out there is a way, since individual enum member can be untagged (serde-rs/serde#2403), and for Retry(ReprepareReason) it wouldn't matter if retry isn't part of the serialization. But this actually breaks DB storage so we may want to think about this twice - probably still ok to do now, while we don't have that many GBs of messages

@daniel-savu daniel-savu added this pull request to the merge queue Jul 4, 2024
Merged via the queue into main with commit 8c8f39a Jul 4, 2024
37 of 38 checks passed
@daniel-savu daniel-savu deleted the dan/list-ops-relayer-api branch July 4, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants