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

Why not having an async Database trait? #1575

Open
wtdcode opened this issue Jun 28, 2024 · 1 comment
Open

Why not having an async Database trait? #1575

wtdcode opened this issue Jun 28, 2024 · 1 comment

Comments

@wtdcode
Copy link
Contributor

wtdcode commented Jun 28, 2024

Reading through #554 and #1534 , I notice that the root cause is that current revm doesn't have async traits.

Given the fact that we already split the original single Database trait into both Database and DatabaseRef traits, can we have another trait like DatabaseAsync (and maybe DatabaseRefAsync) by using https://github.com/dtolnay/async-trait ? In this case:

  1. All databases implemented Database immediately get DatabaseAsync implemented by simply forwarding function calls. However, implementing DatabaseAsync doesn't imply Database trait.
  2. Current ethersdb/alloydb can have a more clean and reasonable implementation because the functions like basic is async now. And they will no longer implement Database.
  3. This avoids confusion like: Does this Database implementation play with async world?

Generally, the modification is a bit huge because we need to add new async API since transact() and many places to support the async trait. Thus, I'm opening the issue for discussion before starting to work on it.

@wtdcode
Copy link
Contributor Author

wtdcode commented Jun 28, 2024

The new API style may be similar to reqwest, btw.

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

No branches or pull requests

1 participant