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

refactor(katana): replace cursor-based api with by block basis for simplicity #1986

Merged
merged 3 commits into from
May 23, 2024

Conversation

kariy
Copy link
Member

@kariy kariy commented May 20, 2024

Description

currently, the saya_getTransactionsExecutions API is based on a cursor to determine how the traces are being fetched.

trace!(target: LOG_TARGET, block_number = %block_number, "Fetching transactions executions.");
let cursor = TransactionsPageCursor { block_number, chunk_size: 50, ..Default::default() };
let client = HttpClientBuilder::default().build(&self.rpc_url).unwrap();
let mut executions = vec![];
loop {
let rsp: TransactionsExecutionsPage =
client.get_transactions_executions(cursor).await.unwrap();
executions.extend(rsp.transactions_executions);
if rsp.cursor.block_number > block_number {
break;
}
}

one issue it currently has it that the api params does not put any constraint on whether the returned traces are guarantee to only be from a specific block. however, the implementation seems to indicate otherwise.

anyway, this pr basically want to remove the complexity of the pagination logic (which we dont even need!) and to replace it with a basic get Xs from block Y api instead.

so we can simplify the endpoint itself to just return the traces per block instead of based on a cursor. the cursor is only adding more complexity to the api itself.

Related issue

Tests

  • Yes
  • No, because they aren't needed
  • No, because I need help

Added to documentation?

  • README.md
  • Dojo Book
  • No documentation needed

Checklist

  • I've formatted my code (scripts/prettier.sh, scripts/rust_fmt.sh, scripts/cairo_fmt.sh)
  • I've linted my code (scripts/clippy.sh, scripts/docs.sh)
  • I've commented my code
  • I've requested a review after addressing the comments

@kariy
Copy link
Member Author

kariy commented May 20, 2024

@kariy kariy changed the title replace cursor with by block basis refactor(katana): replace cursor-based api with May 20, 2024
@kariy kariy changed the title refactor(katana): replace cursor-based api with refactor(katana): replace cursor-based api with by block basis for simplicity May 20, 2024
@kariy kariy marked this pull request as ready for review May 20, 2024 18:31
Copy link

codecov bot commented May 21, 2024

Codecov Report

Attention: Patch coverage is 94.17476% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 69.84%. Comparing base (bec687b) to head (e693598).
Report is 1 commits behind head on main.

Files Patch % Lines
crates/katana/storage/provider/src/lib.rs 37.50% 5 Missing ⚠️
crates/katana/rpc/rpc/src/saya.rs 97.82% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1986      +/-   ##
==========================================
+ Coverage   69.73%   69.84%   +0.10%     
==========================================
  Files         314      314              
  Lines       35654    35726      +72     
==========================================
+ Hits        24864    24953      +89     
+ Misses      10790    10773      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glihm glihm added the katana This issue is related to Katana label May 23, 2024
@kariy
Copy link
Member Author

kariy commented May 23, 2024

Merge activity

  • May 23, 9:16 AM EDT: @kariy started a stack merge that includes this pull request via Graphite.
  • May 23, 9:16 AM EDT: @kariy merged this pull request with Graphite.

@kariy kariy merged commit ad94ba6 into main May 23, 2024
13 checks passed
@kariy kariy deleted the refactor/saya-api branch May 23, 2024 13:16
kariy added a commit that referenced this pull request May 23, 2024
# Description

basically refactor the tx traces fetching logic to using the new API introduced in #1986.

ref: #1986 (comment) 

to simplify the process of extracting the l1 -> l2 messages bcs currently we have to compute the message hash in order to find the corresponding tx as seen here:

https://github.com/dojoengine/dojo/blob/855da3112c87faea87646db5a406ac77b4daf149/crates/saya/core/src/prover/program_input.rs#L54-L74

these changes (including #1986) make the process more straightforward as we can just filter based on the tx hash which is more straightforward.

## Related issue

<!--
Please link related issues: Fixes #<issue_number>
More info: https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

## Tests

<!--
Please refer to the CONTRIBUTING.md file to know more about the testing process. Ensure you've tested at least the package you're modifying if running all the tests consumes too much memory on your system.
-->

- [ ] Yes
- [x] No, because they aren't needed
- [ ] No, because I need help

## Added to documentation?

<!--
If the changes are small, code comments are enough, otherwise, the documentation is needed. It
may be a README.md file added to your module/package, a DojoBook PR or both.
-->

- [ ] README.md
- [ ] [Dojo Book](https://github.com/dojoengine/book)
- [x] No documentation needed

## Checklist

- [x] I've formatted my code (`scripts/prettier.sh`, `scripts/rust_fmt.sh`, `scripts/cairo_fmt.sh`)
- [x] I've linted my code (`scripts/clippy.sh`, `scripts/docs.sh`)
- [x] I've commented my code
- [ ] I've requested a review after addressing the comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
katana This issue is related to Katana
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants