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

fallback to multiple eth_getTransactionReceipt calls if eth_getBlockReceipts is not present #94

Merged

Conversation

cool-mestorf
Copy link
Contributor

Motivation

resolves #93

Solution

To add a robust fallback mechanism for eth_getBlockReceipts, which had become outdated after recent updates, I created an extension trait FetcherExt. This trait is implemented for Arc<Fetcher<P>> and allows us to use reference of rate-limited providers over multiple tasks. I welcome any feedback on how to test this implementation effectively.

command tested:

$ cryo txs -b 145968168:145968169 --rpc https://arb1.arbitrum.io/rpc

before:

...
collecting data
───────────────
started at 2023-11-01 15:54:01.276
   done at 2023-11-01 15:54:01.639


error summary
─────────────
(errors in 1 chunks)
- Failed to get block: (code: -32601, message: the method eth_getBlockReceipts does not exist/is not available, data: None) (1x)


collection summary
──────────────────
- total duration: 0.362 seconds
- total chunks: 1
    - chunks errored:   1 / 1 (100.0%)
    - chunks skipped:   0 / 1 (0.0%)
    - chunks collected: 0 / 1 (0.0%)
- blocks collected: 0
    - blocks per second: 0.0
    - blocks per minute: 0.0
    - blocks per hour:   0.0
    - blocks per day:    0.0

after:

...
collecting data
───────────────
started at 2023-11-01 15:43:00.476
   done at 2023-11-01 15:43:01.056


collection summary
──────────────────
- total duration: 0.579 seconds
- total chunks: 1
    - chunks errored:   0 / 1 (0.0%)
    - chunks skipped:   0 / 1 (0.0%)
    - chunks collected: 1 / 1 (100.0%)
- blocks collected: 1
    - blocks per second:    1.7
    - blocks per minute:  103.5
    - blocks per hour:  6,207.1
    - blocks per day: 148,991.2

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@sslivkoff
Copy link
Member

thanks for digging into this. solution is looking nice. lets put the get_tx_receipts_in_block method directly in Fetcher instead of defining a new trait. then lgtm

@cool-mestorf
Copy link
Contributor Author

Well actually I tried it first but it was impossible because - for concurrent eth_getTransactionReceipt calls I needed to clone reference of fetcher (self) to send through async tasks, but it wouldn't be possible as long as Fetcher is wrapped inside Arc. The original implementation also held Arc<Fetcher> so I approached to define an extension trait and implement it for Arc<Fetcher>.

@sslivkoff
Copy link
Member

ah ok I see. I think that's why the former get_txs_gas_used was implemented directly on Source instead of Fetcher

not 100% sure but I think putting it directly on Source would be cleaner than using a new trait. because when we want more concurrent-task-spawn functions like this in the future, we only need to write out the function signature one time, in Source's impl. otherwise each signature will appear two times in the file and that's less maintainable if you have 10 such functions

@cool-mestorf
Copy link
Contributor Author

I moved the implementation into Source. This would be the first implementation to use a wrapper implementation around Source rather than using source.fetcher directly, which was why I didn't implement it on Source at first time... :)

@sslivkoff sslivkoff merged commit be8078b into paradigmxyz:main Nov 3, 2023
3 checks passed
@sslivkoff
Copy link
Member

excellent stuff. thanks

feel free to submit more issues but also come check out the TG group where there's lots of cryo discussion https://t.me/paradigm_data

@cool-mestorf cool-mestorf deleted the feat/get_block_receipts_fallback branch November 3, 2023 05:15
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.

About use of eth_getBlockReceipts JSON RPC for cryo txs
2 participants