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 and cardano-ledger #1314

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

Conversation

neilmayhew
Copy link

Description

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

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 from ef51726 to 9d27b2e Compare December 18, 2024 22:53
Niols and others added 23 commits December 18, 2024 16:15
* Addition of ChainSyncClientHandleCollection, grace period, and starvation event in BlockFetch
* Plug `rotateDynamo` into `BlockFetchConsensusInterface`
* Removal of `bfcMaxConcurrencyBulkSync`
* Changes in blockfetch decision tracing
Port of IntersectMBO/ouroboros-network#2721

Co-authored-by: Thomas Winant <thomas@well-typed.com>
Co-authored-by: Alexander Esgen <alexander.esgen@iohk.io>
* Move Genesis-specific BlockFetch config to GenesisConfig
* Introduce GenesisConfigFlags for interaction with config files/CLI
* Add missing instances for Genesis configuration
* 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 <nicolas.jeannerod@tweag.io>
* 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
Co-authored-by: Nicolas Bacquey <nicolas.bacquey@tweag.io>
@neilmayhew neilmayhew force-pushed the neilmayhew/release-srp branch from 9d27b2e to 038f9d6 Compare December 18, 2024 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants