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

change(state): Remove active_value field from ChainTipSender #4175

Merged
merged 6 commits into from
Apr 27, 2022

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Apr 22, 2022

Motivation

The ChainTipSender type had an extra field as a workaround to when Zebra was using an older version of Tokio that didn't have the watch::Sender::borrow() method. Zebra now depends on a newer version of Tokio, so that field can be removed.

This was a cleanup I did some time ago, and I was afraid I'd forget to push this.

Depends-On: #4198

Solution

Remove the field, replacing the usages with watcher::Sender::borrow().

As part of the changes, I also simplified the instrumentation attribute a bit.

Review

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

@jvff jvff added A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup P-Optional ✨ labels Apr 22, 2022
@jvff jvff self-assigned this Apr 22, 2022
@jvff jvff requested a review from a team as a code owner April 22, 2022 02:03
@jvff jvff requested review from dconnolly and removed request for a team April 22, 2022 02:03
@jvff jvff changed the title Remove active value field change(state): Remove active_value field from ChainTipSender Apr 22, 2022
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

This looks good, have you run a full sync test to check for locking bugs?

@jvff
Copy link
Contributor Author

jvff commented Apr 25, 2022

This looks good, have you run a full sync test to check for locking bugs?

I ran the unit tests and I started the full sync test but only ran for a few minutes to check if the chain tip was being updated. I can't run more than that locally because I'm having some internet issues :(

@teor2345
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Apr 25, 2022

update

✅ Branch has been successfully updated

jvff and others added 6 commits April 26, 2022 17:01
Record the fields using a helper method. This reduces duplicate code and
prepares for removing the `active_value` field from the type, because
the replacement for it has to be atomically read to avoid a deadlock
when reading from the `watch::Sender` endpoint.
Now that Tokio has been updated to a version in which `watch::Sender`
has a `borrow` method, we can remove the `active_value` field.

To prevent a deadlock like the one that happened with the synchronizer
some time ago, the method instrumentation was slightly refactored to
have the fields recorded in helper methods that avoid obtaining a
read-lock twice.
They are resolved with the current changes.
This is a minor optimization to remove an unnecessary second call to
`tracing::Span::current()`.
Explain why a binding can't be created for the old tip reference.
@teor2345 teor2345 force-pushed the remove-active-value-field branch from 9bf6c07 to 4e871e5 Compare April 26, 2022 07:01
@jvff jvff requested a review from a team as a code owner April 26, 2022 07:01
@conradoplg
Copy link
Collaborator

Does this close #2573?

@teor2345
Copy link
Contributor

Does this close #2573?

I think there might be more instances of this fix needed, @jvff might know?

@teor2345 teor2345 removed request for dconnolly and a team April 26, 2022 19:30
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

Thanks!

mergify bot added a commit that referenced this pull request Apr 27, 2022
mergify bot added a commit that referenced this pull request Apr 27, 2022
@mergify mergify bot merged commit b356a67 into main Apr 27, 2022
@mergify mergify bot deleted the remove-active-value-field branch April 27, 2022 04:13
@conradoplg conradoplg mentioned this pull request May 6, 2022
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust Area: Updates to Rust code C-cleanup Category: This is a cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants