Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Issue 4393: Correcting Unnecessary Use of Arc #6882

Merged
merged 19 commits into from
Mar 16, 2023
Merged

Issue 4393: Correcting Unnecessary Use of Arc #6882

merged 19 commits into from
Mar 16, 2023

Conversation

BradleyOlson64
Copy link
Contributor

@BradleyOlson64 BradleyOlson64 commented Mar 14, 2023

Follow up PR to #6838

Modified ParticipationRequest so that its field request_timer doesn't need to use Arc.

Also may change histogram metric bucket sizes with this fix.

@BradleyOlson64 BradleyOlson64 self-assigned this Mar 14, 2023
@BradleyOlson64 BradleyOlson64 added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. labels Mar 14, 2023
@BradleyOlson64 BradleyOlson64 linked an issue Mar 14, 2023 that may be closed by this pull request
@@ -160,6 +160,21 @@ impl PartialEq for ParticipationRequest {
}
#[cfg(test)]
impl Eq for ParticipationRequest {}
#[cfg(test)]
impl Clone for ParticipationRequest {
Copy link
Member

Choose a reason for hiding this comment

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

I would just not have implemented Clone at all. This is a bit hacky. Instead of cloning, we should be able to create new instances in tests where necessary. E.g. just a new let ... = create_test_partitipation_request ... instead of cloning the previous one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and tried your suggestion. It turns out there's some non-determinism in the helper make_participation_request() such that the candidate hashes end up different. Particularly the signature field in the CandidateDescriptor within the CandidateReceipt is different each time it is generated.

This means that calling make_participation_request() multiple times results in requests that don't compare as equal, ruining our asserts.

Know of other ways we can do this without clone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or here's another idea which might be considered better form.

I could at least move the clone functionality into tests.rs as a helper function rather than implementing it on the ParticipationRequest type.

Copy link
Member

Choose a reason for hiding this comment

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

yes, making it a standalone function like test_clone core something would also be way better. The non-determinism is interesting, I don't see where it would be coming from?

Comment on lines 174 to 176
fn clone_from(&mut self, source: &Self) {
*self = source.clone();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. My understanding is that I need to provide this function as a part of the Clone implementation. Is there a better way to handle these unused but required parts of a type?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see it's a part of the Clone trait! I've never seen it before. But it doesn't seem to be a required method, so you can remove it. The doc for it is interesting:

a.clone_from(&b) is equivalent to a = b.clone() in functionality, but can be overridden to reuse the resources of a to avoid unnecessary allocations.

@eskimor eskimor merged commit 79b0d6e into master Mar 16, 2023
@eskimor eskimor deleted the brad-issue-4393 branch March 16, 2023 09:00
ordian added a commit that referenced this pull request Mar 16, 2023
* master: (50 commits)
  Issue 4393: Correcting Unnecessary Use of Arc (#6882)
  Companion for #13287  (#6655)
  timestamp ci job logs (#6890)
  Release parachain host API v4 (#6885)
  polkadot companion: #13128 (Pools commission) (#6264)
  companion for #13555 (#6842)
  Bump libgit2-sys from 0.14.1+1.5.0 to 0.14.2+1.5.1 (#6600)
  Bump bumpalo from 3.8.0 to 3.12.0 (#6599)
  Bump git2 from 0.16.0 to 0.16.1 (#6601)
  Council as SpendOrigin (#6877)
  PVF: Document that preparation cannot lead to disputes (#6873)
  Sync versions with current release (0.9.39) (#6875)
  Companion for paritytech/substrate#13592 (#6869)
  Update orchestra to the recent version (#6854)
  Delete unused Cargo.lock (#6870)
  Remove use of Store trait (#6835)
  Companion for Substrate #13564 (#6845)
  Adding Dispute Participation Metrics (#6838)
  Update `substrate` to 48e7cb1 (#6851)
  Move PVF timeouts to executor environment parameters (#6823)
  ...
ordian added a commit that referenced this pull request Mar 21, 2023
…slashing-client

* ao-past-session-slashing-runtime: (23 commits)
  Issue 4393: Correcting Unnecessary Use of Arc (#6882)
  Companion for #13287  (#6655)
  timestamp ci job logs (#6890)
  Release parachain host API v4 (#6885)
  polkadot companion: #13128 (Pools commission) (#6264)
  companion for #13555 (#6842)
  Bump libgit2-sys from 0.14.1+1.5.0 to 0.14.2+1.5.1 (#6600)
  Bump bumpalo from 3.8.0 to 3.12.0 (#6599)
  Bump git2 from 0.16.0 to 0.16.1 (#6601)
  Council as SpendOrigin (#6877)
  PVF: Document that preparation cannot lead to disputes (#6873)
  Sync versions with current release (0.9.39) (#6875)
  Companion for paritytech/substrate#13592 (#6869)
  Update orchestra to the recent version (#6854)
  Delete unused Cargo.lock (#6870)
  Remove use of Store trait (#6835)
  Companion for Substrate #13564 (#6845)
  Adding Dispute Participation Metrics (#6838)
  Update `substrate` to 48e7cb1 (#6851)
  Move PVF timeouts to executor environment parameters (#6823)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

dispute-coordinator: Add metrics on participation performance
3 participants