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

Bolt12/coot/tx submission #4928

Closed
wants to merge 19 commits into from
Closed

Conversation

bolt12
Copy link
Contributor

@bolt12 bolt12 commented Aug 12, 2024

No description provided.

@bolt12 bolt12 force-pushed the bolt12/coot/tx-submission branch 4 times, most recently from f434785 to 91304d1 Compare August 14, 2024 10:30
@bolt12 bolt12 force-pushed the bolt12/coot/tx-submission branch 2 times, most recently from 8504d49 to 9e6e0f4 Compare September 16, 2024 10:40
@bolt12 bolt12 marked this pull request as ready for review September 16, 2024 10:41
@bolt12 bolt12 requested a review from a team as a code owner September 16, 2024 10:41
@bolt12 bolt12 self-assigned this Sep 16, 2024
@bolt12 bolt12 requested a review from coot September 16, 2024 10:46
Allow monadic action when trying to pipeline more messages, while
collecting responses.
* `prop_makeDecisions_receivedTxIds`
  mix up `makeDecisions` and `receivedTxIds`
* `prop_makeDecisions_collectTxIds`
  mix up `makeDecisions` and `collectTxIds`
Export everything from the `Ouroboros.Network.TxSubmission.Inbound`
module.
bolt12 and others added 7 commits September 16, 2024 21:28
- Factors out common type definitions and their generators and
  properties to a Common.hs file.
- Adds a TxSubmissionV2 file with the boilerplate to run the new, more
  accurate submission that uses the V2 version of TxSubmission protocol
Refactored SimResult name to not clash with IOSim's
- Updated txSubmissionV2 test
- Fixed TODO about passing an STM action inside receivedTxIds
- Fixed usage of partial function `(!)`
- Fixed wrong usage of MVars in decisionLogicThread that lead to
  deadlock.
There was a race condition between the `decisionLogicThread` producing
the right policy and inbound server picking up the most up to date
policy. This would lead to the inbound side issuing a blocking request
when the client was awaiting for a non-blocking request. This blocking
request isn't wrong considering the policy it was used, it is a legit
decision that's made which leads to the inbound server issuing a
blocking request but because we have received a txid in the meantime and
didn't manage to read it soon enough we didn't create a more important
decision. The fix involved being aware of how many requests for txs we
have in flight and not generate "low priority" policies.

`hasTxIdsToAcknowledge` is not used anywhere in the code so it is
removed.

`filterActivePeers` is improved by making its decision logic more closed
to `pickTxsToDownload`.

`filterActivePeers` test is fixed, since it doesn't hold under the new
logic:

  `filterActivePeers` will not compute a decision for peers which have
  `requestedTxIdsInflight` and `makeDecisions` computes non-empty decisions
  for peers with no `requestedTxIdsInflight`. So:

  1. "The set of active peers is a superset of peers for which a decision
     was made" this is not true since it is possible that a non active
     peer has a legitimate decision, but due to our race-condition
     protection condition we just don't generate it.
  2. "The set of active peer which can acknowledge txids is a subset of
     peers for which a decision was made" this is removed since
     hasTxIdsToAcknowledge function is removed
  3. "Decisions made from the results of `filterActivePeers` is the same
     as from the original set" this isn't true because of what I said
     above

  So I refactored the test to  check that the number of filtered decisions
  is a subset of the total number of decisions, which I believe to be a
  more accurate test for the current logic
- Adds tx submission diffusion testnet test

  This test checks that even in the presence of a node that keeps
  disconnecting, but eventually stays online, we manage to learn about
  all its transactions.
@coot coot removed request for a team and newhoggy September 16, 2024 19:36
Module structure needs to be reorganised to have just one debug tracer.
Use `IOSim` API.  `evaluateTrace` from
`Test.Ouroboros.Network.LedgerPeers` has the annoying property that once
the trace was evaluated in won't show the trace again, which makes it
hard to work with `cabal repl`.

Refactored `checkMempools` to improve readablity.

Should be squashed onto `c9d45673ca New txSubmissionV2 simulation`
Copy link
Contributor

@coot coot left a comment

Choose a reason for hiding this comment

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

Some remarks on the PR.

Comment on lines +37 to +45
defaultTxDecisionPolicy :: TxDecisionPolicy
defaultTxDecisionPolicy =
TxDecisionPolicy {
maxNumTxIdsToRequest = 1,
maxUnacknowledgedTxIds = 2,
txsSizeInflightPerPeer = 2,
maxTxsSizeInflight = maxBound,
txInflightMultiplicity = 2
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These numbers are far from production configuration.

Suggested change
defaultTxDecisionPolicy :: TxDecisionPolicy
defaultTxDecisionPolicy =
TxDecisionPolicy {
maxNumTxIdsToRequest = 1,
maxUnacknowledgedTxIds = 2,
txsSizeInflightPerPeer = 2,
maxTxsSizeInflight = maxBound,
txInflightMultiplicity = 2
}
defaultTxDecisionPolicy :: TxDecisionPolicy
defaultTxDecisionPolicy =
TxDecisionPolicy {
maxNumTxIdsToRequest = 3,
maxUnacknowledgedTxIds = 10,
txsSizeInflightPerPeer = error "TODO", -- currently we download at most 2 tx-s in `MsgReplytTxs`.
maxTxsSizeInflight = error "TODO", -- ?
txInflightMultiplicity = 1
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines 256 to 262
( 0
, 0
, []
, RefCountDiff Map.empty
, ps
)
where
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
( 0
, 0
, []
, RefCountDiff Map.empty
, ps
)
where
emptyAck
where
emptyAck = (0, 0, [], RefCoundDiff Map.empty, ps)

Comment on lines +355 to +368
Left err -> counterexample (ppTrace trace)
$ counterexample (show err)
$ property False
Copy link
Contributor

Choose a reason for hiding this comment

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

indentation

Suggested change
Left err -> counterexample (ppTrace trace)
$ counterexample (show err)
$ property False
Left err -> counterexample (ppTrace trace)
$ counterexample (show err)
$ property False

)
Map.empty
inmp
in resultRepeatedValidTxs === maxRepeatedValidTxs
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this only works because there's no attenuation. The logic here counts how many times a tx is downloaded over the whole simulation rather than from how many peers it is being downloaded from at the same time. The latter could be done using tx-submission message traces, e.g. MsgRequestTxs and MsgReplyTxs. Each tx is in flight for some time between sending MsgRequestTxs and getting MsgReplyTxs back. Having a list of (startTime, endTime) for each tx's we'd need to check that we never have more than the configured number of them at each time. So we'd need a function:

maxOverlapped :: [(Time, Time)] -> Int

which counts the maximal number of overlapping intervals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's true, in Diffusion Sim we have the same test but with attenuation.

@coot coot force-pushed the coot/tx-submission branch 5 times, most recently from 76c0d13 to 11d833b Compare September 18, 2024 11:26
@bolt12
Copy link
Contributor Author

bolt12 commented Sep 18, 2024

closed due to it being merged into #4887

@bolt12 bolt12 closed this Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants