Skip to content

refactor: pass references to objects instead of using global definitions - #4988

Merged
PastaPastaPasta merged 14 commits into
dashpay:developfrom
kwvg:prectx
Sep 22, 2022
Merged

refactor: pass references to objects instead of using global definitions#4988
PastaPastaPasta merged 14 commits into
dashpay:developfrom
kwvg:prectx

Conversation

@kwvg

@kwvg kwvg commented Aug 22, 2022

Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions

Copy link
Copy Markdown

This pull request has conflicts, please rebase.

@kwvg
kwvg force-pushed the prectx branch 10 times, most recently from 50d6627 to 59b1fe0 Compare September 3, 2022 19:12
@kwvg
kwvg requested a review from UdjinM6 September 3, 2022 19:20
UdjinM6
UdjinM6 previously requested changes Sep 6, 2022

@UdjinM6 UdjinM6 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

pls see 0baef90b86 + 0968c71533 (to avoid dereferencing it too early) OR maybe 5c48866762 instead (to avoid dereferencing completely)

Comment thread src/init.cpp Outdated
@kwvg
kwvg marked this pull request as ready for review September 18, 2022 17:29

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK for squash merge

@ogabrielides ogabrielides left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@PastaPastaPasta
PastaPastaPasta dismissed UdjinM6’s stale review September 22, 2022 11:12

changes were applied

@PastaPastaPasta
PastaPastaPasta merged commit a352456 into dashpay:develop Sep 22, 2022
michaelvkax pushed a commit to vkaxproject/vkax that referenced this pull request Oct 22, 2022
…ons (dashpay#4988)

* fix: move chain activation logic downward to succeed LLMQ initialization

* fix: change order of initialization to reflect dependency

* llmq: pass all global pointers invoked as CDSNotificationInterface arguments

* llmq: pass reference to quorumDKGDebugManager instead of invoking global

* llmq: pass reference to quorumBlockProcessor instead of invoking global

* llmq: pass reference to quorumDKGSessionManager instead of invoking global

* llmq: pass reference to quorumManager instead of invoking global

Co-authored-by: "UdjinM6 <UdjinM6@users.noreply.github.com>"

* llmq: pass reference to quorumSigSharesManager within CSigningManager and networking

* llmq: pass reference to quorumSigSharesManager instead of invoking global

* llmq: pass reference to chainLocksHandler instead of querying global

* llmq: pass reference to quorumInstantSendManager instead of querying global

* trivial: accept argument as const where possible

* style: remove an unneeded const_cast and instead pass by const reference

* style: use const where possible

Co-authored-by: pasta <pasta@dashboost.org>
@UdjinM6 UdjinM6 added this to the 18.1 milestone Sep 6, 2024
PastaPastaPasta added a commit that referenced this pull request Aug 4, 2026
…syncSignIfMember

7c05e56 refactor: drop redundant CSigningManager argument from AsyncSignIfMember (pasta)

Pull request description:

  ## Issue being fixed or feature implemented

  `CSigSharesManager::AsyncSignIfMember` takes a `CSigningManager&` argument it does not need. The class has held a `CSigningManager& sigman` member since a352456 (#4988), declared 34 lines above the method in the same header, and the parameter **shadows** it.

  There is exactly one `CSigningManager` in a node — `node.llmq_ctx->sigman`. `init.cpp` threads it into `ActiveContext`, which hands the same reference to `CSigSharesManager`'s member and to each caller's own member, so every call site already passes the object the member points at:

  | Call site | Passes |
  |---|---|
  | `chainlock/signing.cpp:177` | `m_sigman` |
  | `instantsend/signing.cpp:356`, `:415` | `m_sigman` |
  | `llmq/ehf_signals.cpp:82` | `sigman` |
  | `rpc/quorums.cpp:533` | `*llmq_ctx.sigman` |

  The parameter comes from 0052fca ("refactor: move `AsyncSignIfMember()` to `CSigSharesManager`"). Before that move the method lived on `CSigningManager` and took the *opposite* manager, `CSigSharesManager& shareman`. After the move that argument became `this`, and a `sigman` argument was added to reach back for the recovered-sigs db — a mirror-image swap that is correct in isolation, but that nobody reconciled with the member the destination class already had.

  Consequence today: the single `sigman.GetDb()` in the body resolves to the argument, while the surrounding code in the same function reaches for `qman` and `m_chainman` as members.

  ## What was done?

  Dropped the `CSigningManager& sigman` parameter from the declaration, the definition, and all five call sites.

  The body is untouched — `sigman` now resolves to the member, which is the same object it already received. Parameter-list continuation lines keep their alignment because the opening paren does not move.

  ## How Has This Been Tested?

  Not built or run locally — reviewed by inspection. Verified by grep that no declaration, definition, or call site still passes a `CSigningManager` to `AsyncSignIfMember`, and that removing the argument leaves no caller-side variable unused (`llmq_ctx` in `rpc/quorums.cpp` is still used a few lines below). Relying on CI for the compile and test run.

  Worth noting for reviewers: this class of shadowing is invisible to our warning set. Dash configures `-Wshadow-field`, which only fires when a field shadows a *base class* field; a parameter shadowing a member of the same class needs `-Wshadow-all` (or GCC's `-Wshadow`).

  ## Breaking Changes

  None.

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

Top commit has no ACKs.

Tree-SHA512: 64cb21e35730b4008804d719664810c851c4a8c84f7f2474d3c9104b75ccb00985fb8607a3cda83797e8b3d0bebfb94d278f54d2ae73faa3b2002bb790cfbcc6
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.

4 participants