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

Integrate ouroboros-network #1314

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft

Integrate ouroboros-network #1314

wants to merge 38 commits into from

Conversation

neilmayhew
Copy link
Contributor

@neilmayhew neilmayhew commented Nov 20, 2024

Description

Integrate ouroboros-network in preparation for cardano-node-10.2.0 release

See IntersectMBO/cardano-node#6040 for overall progress

@jasagredo
Copy link
Contributor

FYI, the cardano-ledger commit in the SRP is gone. I suspect the new one is IntersectMBO/cardano-ledger@3fe0221 or IntersectMBO/cardano-ledger@12f6aa6 (the merge commit of the PR).

@neilmayhew neilmayhew force-pushed the neilmayhew/release-srp branch 2 times, most recently from 7cbd3f8 to ef51726 Compare December 13, 2024 22:30
let (ys, zs) = splitAt i xs
in ys ++ dropElemsAt (drop 1 zs) is
dropElemsAt xs is' =
let is = Set.fromList is'
Copy link
Contributor

Choose a reason for hiding this comment

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

IntSet is more efficient at handling Set of Ints

Suggested change
let is = Set.fromList is'
let is = IntSet.fromList is'

Comment on lines +72 to +76
, gcfBlockFetchGracePeriod :: Maybe Integer
, gcfBucketCapacity :: Maybe Integer
, gcfBucketRate :: Maybe Integer
, gcfCSJJumpSize :: Maybe Integer
, gcfGDDRateLimit :: Maybe DiffTime
Copy link
Contributor

Choose a reason for hiding this comment

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

Configuration should always try and use the types that will be used in the end. This way we can protect against invalid values when parsing the config instead of allowing for dangerous values that can lead to overflows. For example, by using SlotNo, we here we can protect against a very large value being placed in the config that will end up overflowing

Suggested change
, gcfBlockFetchGracePeriod :: Maybe Integer
, gcfBucketCapacity :: Maybe Integer
, gcfBucketRate :: Maybe Integer
, gcfCSJJumpSize :: Maybe Integer
, gcfGDDRateLimit :: Maybe DiffTime
, gcfBlockFetchGracePeriod :: Maybe DiffTime
, gcfBucketCapacity :: Maybe Integer
, gcfBucketRate :: Maybe Integer
, gcfCSJJumpSize :: Maybe SlotNo
, gcfGDDRateLimit :: Maybe DiffTime

Comment on lines +156 to +159
gbfcGracePeriod = fromInteger $ fromMaybe defaultBlockFetchGracePeriod gcfBlockFetchGracePeriod
csbcCapacity = fromInteger $ fromMaybe defaultCapacity gcfBucketCapacity
csbcRate = fromInteger $ fromMaybe defaultRate gcfBucketRate
csjcJumpSize = fromInteger $ fromMaybe defaultCSJJumpSize gcfCSJJumpSize
Copy link
Contributor

Choose a reason for hiding this comment

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

@facundominguez I have a couple of suggestions and some minor concerns about this:

  • csbcCapacity is already an Integer, so fromInteger is redundant
  • using maybe instead of fromMaybe allows for default values to have the expected type.
  • All conversions with to/fromInteger and fromIntegral should have type annotations, because that way it is easier to spot dangers of overflow
  • SlotNo is backed by Word64, so there is danger of overflow here, so it would be better to use that type instead in gcfCSJJumpSize, as I suggested above.
Suggested change
gbfcGracePeriod = fromInteger $ fromMaybe defaultBlockFetchGracePeriod gcfBlockFetchGracePeriod
csbcCapacity = fromInteger $ fromMaybe defaultCapacity gcfBucketCapacity
csbcRate = fromInteger $ fromMaybe defaultRate gcfBucketRate
csjcJumpSize = fromInteger $ fromMaybe defaultCSJJumpSize gcfCSJJumpSize
gbfcGracePeriod = maybe defaultBlockFetchGracePeriod (fromInteger @DiffTime) gcfBlockFetchGracePeriod
csbcCapacity = fromMaybe defaultCapacity gcfBucketCapacity
csbcRate = maybe defaultRate (fromInteger @Rational) gcfBucketRate
csjcJumpSize = maybe defaultCSJJumpSize (fromInteger @SlotNo) gcfCSJJumpSize

Comment on lines +251 to +252
let is = Set.fromList is'
in map fst $ filter (\(_, i) -> not $ i `Set.member` is) (zip xs [0..])
Copy link
Contributor

Choose a reason for hiding this comment

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

@nbacquey List comprehensions seem to be more readable, more compact and won't rely on list fusion to be efficient.

Also switching to IntSet will be more efficient and there are special functions in containers notMember x s, that can be used instead of not $ member x s

Suggested change
let is = Set.fromList is'
in map fst $ filter (\(_, i) -> not $ i `Set.member` is) (zip xs [0..])
let is = IntSet.fromList is'
in [x | (x, i) <- zip xs [0..], i `IntSet.notMember` is]

@neilmayhew neilmayhew force-pushed the neilmayhew/release-srp branch 2 times, most recently from 9d27b2e to 038f9d6 Compare December 18, 2024 23:16
neilmayhew and others added 13 commits December 23, 2024 11:33
* Addition of ChainSyncClientHandleCollection, grace period, and starvation event in BlockFetch
* Plug `rotateDynamo` into `BlockFetchConsensusInterface`
* Removal of `bfcMaxConcurrencyBulkSync`
* Changes in blockfetch decision tracing
* Move Genesis-specific BlockFetch config to GenesisConfig
* Introduce GenesisConfigFlags for interaction with config files/CLI
* Add missing instances for Genesis configuration
facundominguez and others added 16 commits December 23, 2024 11:33
* Mention that the objector also gets demoted
* Edit note on Interactions with the BlockFetch logic
* Expand the comments motivating DynamoInitState and ObjectorInitState

Co-authored-by: Nicolas “Niols” Jeannerod <[email protected]>
* Run more repetitions of LoE, LoP, CSJ, and gdd tests
* Print timestamps for node restarts
* Disable boring timeouts in the node restart test
* Wait sufficiently long at the end of tests
* Expect CandidateTooSparse in gdd tests
* Add a notice about untracked delays in the node restart test
* Set the GDD rate limit to 0 in the peer simulator
* Have the peer simulator use the default grace period for chainsel starvations
* Relax expectations of test blockFetch in the BulkSync case
* Allow to run the decision logic once after the last tick in the blockfetch leashing attack
* Shift point schedule times before giving the schedules to tests
* Accomodate for separate decision loop intervals for fetch modes
* Accomodate for timer added in blockFetchLogic
* Switch peer simulator to `FetchModeBulkSync`
* Allow parameterizing whether chainsel starvation is handled
* Add some wiggle room for duplicate headers in CSJ tests
* Disable chainsel starvation in CSJ test
@lehins lehins force-pushed the neilmayhew/release-srp branch from 038f9d6 to a50e092 Compare December 23, 2024 18:33
@lehins lehins changed the title Integrate ouroboros-network and cardano-ledger Integrate ouroboros-network Dec 23, 2024
@jasagredo
Copy link
Contributor

jasagredo commented Dec 26, 2024

@lehins This branch should incorporate the latest commits in blockfetch/milestone-1. In particular it is missing:

9e001f766 * origin/blockfetch/milestone-1 Make `ChainSelStarvation` carry an `Enclosed`
a36fd875d * Enrich comment about disabled `mustReplyTimeout`
513f34756 * Fix tests that relied on default timeouts
4e561806d * Rework default ChainSyncTimeouts in peer simulator
bee2c8445 * Log ChainSync mini-protocol events if need be
7b04c2822 * Make the `DynamoStarting` trace more explicit
ef092ca75 * Add a `TraceDrainingThePipe` event
3f8da3b60 * Improve and clarify CSJ documentation

I created #1351 which you can merge right away.

@jasagredo
Copy link
Contributor

jasagredo commented Dec 26, 2024

I removed the no changelog label. Please only apply it at the very end when merging this iff there are changes in non-testing libraries (those whose name is not prefixed by unstable-) that do not require a changelog entry. For tests/benchmarks/unstable-*/executables, the CI check should already ignore changes in those.

If we apply this label too early in the process, we risk introducing changes in the meantime which don't end up in the Changelog.

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.

7 participants