-
Notifications
You must be signed in to change notification settings - Fork 0
PeerSelectionPolicy for dmq-node #27
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
Changes from all commits
94d44b2
8c52be9
fcaa6c5
ed653a6
0bcae9d
edf4667
7b3b7b8
e4660c8
aea70e8
363cb28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||
| ### Breaking | ||||||
|
|
||||||
| - `validateSig`: removed the hashing function for cold key from arguments, added required constraints ledger's `hashKey . VKey` usage instead | ||||||
|
||||||
| - `validateSig`: removed the hashing function for cold key from arguments, added required constraints ledger's `hashKey . VKey` usage instead | |
| - `validateSig`: removed the hashing function for cold key from arguments, added required constraints for using `Ledger.hashKey (Ledger.VKey coldKey)` instead |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changelog entry mentions "Added a lock to avoid race conditions between trace events" but this appears to be unrelated to the PR title "PeerSelectionPolicy for dmq-node". Consider either updating the PR title to reflect all changes, or split this into a separate PR if it's an independent change.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,40 +1,116 @@ | ||||||||||
| module DMQ.Diffusion.PeerSelection where | ||||||||||
|
|
||||||||||
| import Data.Set (Set) | ||||||||||
| import Control.Concurrent.Class.MonadSTM.Strict | ||||||||||
| import Data.List (sortOn, unfoldr) | ||||||||||
| import Data.Map.Strict qualified as Map | ||||||||||
| import Data.Set qualified as Set | ||||||||||
| import Network.Socket (SockAddr) | ||||||||||
| import Ouroboros.Network.PeerSelection.Governor.Types | ||||||||||
| import System.Random (Random (..), StdGen) | ||||||||||
| import Data.Word (Word32) | ||||||||||
| import Ouroboros.Network.PeerSelection | ||||||||||
| import System.Random (Random (..), StdGen, split) | ||||||||||
|
|
||||||||||
| -- | Trivial peer selection policy used as dummy value | ||||||||||
| -- | ||||||||||
|
Comment on lines
11
to
12
|
||||||||||
| -- | Trivial peer selection policy used as dummy value | |
| -- | |
| -- | Weighted peer selection policy that prioritizes peers based on | |
| -- their state and failure history. |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failWeight function uses integer division which could result in a weight of 0 when failCnt peer is large. When multiple peers have a weight of 0, their ordering becomes non-deterministic (dependent only on the random number). Consider using a minimum weight (e.g., max 1 (r \div` ...)`) to ensure some randomness is preserved, or document that this behavior is intentional.
| (peer, r `div` fromIntegral (failCnt peer + 1)) | |
| (peer, max 1 (r `div` fromIntegral (failCnt peer + 1))) |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment has incorrect indentation. It should start at column 1 like the function definition below it, not with a leading space.
| -- Add scaled random number in order to prevent ordering based on SockAddr | |
| -- Add scaled random number in order to prevent ordering based on SockAddr |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two spaces between random) and rng on this line. Consider removing the extra space for consistency.
| rns = take (Set.size available) $ unfoldr (Just . random) rng :: [Word32] | |
| rns = take (Set.size available) $ unfoldr (Just . random) rng :: [Word32] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR depends on an unreleased branch (
coot/dmq-related-changes) of ouroboros-network. Consider documenting what changes in that branch are required for this PR to work, or ensure that branch is merged and released before merging this PR. Using unreleased dependencies can make builds unstable and difficult to reproduce.