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

ENG-190: Partial Monza #34

Merged
merged 95 commits into from
Apr 25, 2024
Merged

ENG-190: Partial Monza #34

merged 95 commits into from
Apr 25, 2024

Conversation

l-monninger
Copy link
Collaborator

@l-monninger l-monninger commented Apr 19, 2024


impl MempoolTransactionOperations for RocksdbMempool {

async fn has_mempool_transaction(&self, transaction_id: Id) -> Result<bool, Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a warning about async methods in this trait:

warning: use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified
  --> protocol-units/mempool/util/src/lib.rs:11:5
   |
11 |     async fn has_mempool_transaction(&self, transaction_id :Id) -> Result<bool, anyhow::Error>;
   |     ^^^^^
   |
   = note: you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future`
   = note: `#[warn(async_fn_in_trait)]` on by default
help: you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change
   |
11 -     async fn has_mempool_transaction(&self, transaction_id :Id) -> Result<bool, anyhow::Error>;
11 +     fn has_mempool_transaction(&self, transaction_id :Id) -> impl std::future::Future<Output = Result<bool, anyhow::Error>> + Send;

Think twice about whether we want it to be async or desugar as per the warning? There is also a proc macro to auto-generate a Send version of the trait. See the details in Rust blog

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I noticed these .. I thought maybe its a good idea for a maintenance ticket. The #[trait_variant::make()] looks good, or we can desugar manually if we prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IDC whichever way you guys want to go. I don't care about desugared or not. I've only been using #[tonic::async_trait] when I want to Box<dyn >> because 1.75.0's async traits don't allow this.

And, @0xmovses, I don't thing this needs to be a ticket.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I don’t mind the warnings for now. Thought it could be a nice starter issue for a new team member.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But at least it's clear we want async here at all, isn't it?

The async_trait proc macro puts you up for boxing, while the new in-language async traits (or desugared impl Future in return types of trait methods) leave the room for static future types.

@mzabaluev
Copy link
Collaborator

This should help unbreak the build: movementlabsxyz/aptos-core#8

@mzabaluev
Copy link
Collaborator

One more time, with testing: movementlabsxyz/aptos-core#9

async fn get_api(
&self,
mode : &FinalityMode,
) -> Result<Apis, anyhow::Error>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like aptos-api is going to be needed and movementlabsxyz/aptos-core#5 cuts out too much. Correct me if this is not so; I will look into restoring a subset of it.

@l-monninger l-monninger mentioned this pull request Apr 25, 2024
@l-monninger l-monninger merged commit fd5f250 into monza Apr 25, 2024
0 of 4 checks passed
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.

3 participants