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

Convert confirm and eth_filter to async #394

Merged
merged 3 commits into from Oct 27, 2020
Merged

Conversation

e00E
Copy link
Contributor

@e00E e00E commented Oct 23, 2020

It would be good if someone could double check that I did not accidentally introduce any logic changes when converting the state machine manual future implementations to async.

I've marked some problems that I noticed in the existing code while converting it. This PR doesn't fix them but I put a comment there to mark them.

Fixes #393

src/confirm.rs Outdated
Comment on lines 44 to 53
// TODO: The stream should have additional checks:
// * We should not continue calling next on a stream that has completed (has returned None). We expect this to never
// happen for the blocks filter but to be safe we should handle this case for example by `fuse`ing the stream or
// erroring when it does complete.
// * We do not handle the case where the stream returns an error which means we are wrongly counting it as a
// confirmation.
let filter_stream = filter.stream(poll_interval).skip(confirmations);
futures::pin_mut!(filter_stream);
loop {
let _ = filter_stream.next().await;
Copy link
Contributor Author

@e00E e00E Oct 23, 2020

Choose a reason for hiding this comment

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

problem 1

Copy link
Owner

Choose a reason for hiding this comment

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

I presume this behaviour was already broken before the refactor, right? Can we please log this as a separate issue and add an issue number to the TODO above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this PR doesn't change the behavior (bug was already there). I don't want to fix it in this PR. Added issue link.

src/confirm.rs Outdated
Comment on lines 81 to 87
// TODO: We should remove this `expect`. No matter what happens inside the node, this shouldn't be a panic.
// Should convert this into an some error. InternalError probably makes sense but then we cannot provide the error
// message. Maybe make new error for this? Or allow InternalError to carry a message.
let receipt = eth
.transaction_receipt(hash)
.await?
.expect("receipt can't be null after wait for confirmations; qed");
Copy link
Contributor Author

@e00E e00E Oct 23, 2020

Choose a reason for hiding this comment

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

problem 2

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe let's put the responsibility to unwrap on the user? I.e. returning Option<TransactionReceipt> here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like above the issue was already there and I don't want to fix it in this PR. Added issue link.

@e00E e00E force-pushed the confirm-async branch 2 times, most recently from ec29987 to cc3fd3b Compare October 23, 2020 13:05
Copy link
Owner

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Looks really nice! I didn't find anything suspicious, only couple of minor things to fix, thanks!

src/confirm.rs Outdated
Comment on lines 44 to 53
// TODO: The stream should have additional checks:
// * We should not continue calling next on a stream that has completed (has returned None). We expect this to never
// happen for the blocks filter but to be safe we should handle this case for example by `fuse`ing the stream or
// erroring when it does complete.
// * We do not handle the case where the stream returns an error which means we are wrongly counting it as a
// confirmation.
let filter_stream = filter.stream(poll_interval).skip(confirmations);
futures::pin_mut!(filter_stream);
loop {
let _ = filter_stream.next().await;
Copy link
Owner

Choose a reason for hiding this comment

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

I presume this behaviour was already broken before the refactor, right? Can we please log this as a separate issue and add an issue number to the TODO above?

src/confirm.rs Outdated
Comment on lines 81 to 87
// TODO: We should remove this `expect`. No matter what happens inside the node, this shouldn't be a panic.
// Should convert this into an some error. InternalError probably makes sense but then we cannot provide the error
// message. Maybe make new error for this? Or allow InternalError to carry a message.
let receipt = eth
.transaction_receipt(hash)
.await?
.expect("receipt can't be null after wait for confirmations; qed");
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe let's put the responsibility to unwrap on the user? I.e. returning Option<TransactionReceipt> here?

Copy link
Owner

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Great, thanks again!

@tomusdrw tomusdrw merged commit 96b7ac3 into tomusdrw:master Oct 27, 2020
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.

FilterStream violates Future contract by potentially polling a completed future
2 participants