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

LocalTxMonitor: Add support for GetMeasures #4918

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fraser-iohk
Copy link

@fraser-iohk fraser-iohk commented Jul 26, 2024

Description

This PR adds a new message to LocalTxMonitor, GetMeasures, which is similar to GetSize (returning the current mempool transaction count, the size of those transactions, and the total mempool capacity), but returns information about several other metrics in addition to the byte size and capacity of the mempool. GetMeasures currently returns size and capacity information for transaction byte size, ledger's execution units (both their memory and execution steps), and the reference scripts size, but can easily be extended to support any new metric types in future while remaining backwards compatible.

This change works towards ouroboros-consensus#1178, and has a dependent PR in ouroboros-consensus

Checklist

Quality

  • Commit sequence makes sense and have useful messages, see ref.
  • New tests are added and existing tests are updated.
  • Self-reviewed the PR.

Maintenance

  • Linked an issue or added the PR to the current sprint of ouroboros-network project.
  • Added labels.
  • Updated changelog files.
  • The documentation has been properly updated, see ref.

@fraser-iohk fraser-iohk force-pushed the fraser-iohk/localtxmonitor-measures branch from 9488451 to d6eb7bb Compare September 4, 2024 16:55
@fraser-iohk fraser-iohk force-pushed the fraser-iohk/localtxmonitor-measures branch from d6eb7bb to 0a00293 Compare December 11, 2024 14:56
@fraser-iohk fraser-iohk marked this pull request as ready for review December 12, 2024 11:09
@fraser-iohk fraser-iohk requested a review from a team as a code owner December 12, 2024 11:09
@fraser-iohk fraser-iohk force-pushed the fraser-iohk/localtxmonitor-measures branch 2 times, most recently from 118738a to 1007422 Compare December 12, 2024 11:25
@fraser-iohk fraser-iohk force-pushed the fraser-iohk/localtxmonitor-measures branch from 1007422 to e415888 Compare December 12, 2024 11:28
@fraser-iohk fraser-iohk added consensus issues related to ouroboros-consensus local-tx-monitor LocalTxMonitor protocol labels Dec 12, 2024
Comment on lines +87 to +92
MsgReplyGetMeasures measures ->
CBOR.encodeListLen 2
<> CBOR.encodeWord 12
<> CBOR.encodeListLen 2
<> CBOR.encodeWord32 (txCount measures)
<> encodeMeasureMap (measuresMap measures)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not?

Suggested change
MsgReplyGetMeasures measures ->
CBOR.encodeListLen 2
<> CBOR.encodeWord 12
<> CBOR.encodeListLen 2
<> CBOR.encodeWord32 (txCount measures)
<> encodeMeasureMap (measuresMap measures)
MsgReplyGetMeasures measures ->
CBOR.encodeListLen 3
<> CBOR.encodeWord 12
<> CBOR.encodeWord32 (txCount measures)
<> encodeMeasureMap (measuresMap measures)

Comment on lines +162 to +163
f mn sc =
encodeMeasureName mn <> encodeSizeAndCapacity sc
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be ⬇️ for it to produce valid CBOR?

Suggested change
f mn sc =
encodeMeasureName mn <> encodeSizeAndCapacity sc
f mn sc =
encodeListLen 2
<> encodeMeasureName mn
<> encodeSizeAndCapacity sc

, recvMsgGetMeasures =
let measures = MempoolMeasures
{ txCount = fromIntegral (length allTxs)
, measuresMap = mempty
Copy link
Contributor

Choose a reason for hiding this comment

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

mempty? Is it unfinished?

Comment on lines 309 to +313
data TokBusyKind (k :: StBusyKind) where
TokNextTx :: TokBusyKind NextTx
TokHasTx :: TokBusyKind HasTx
TokGetSizes :: TokBusyKind GetSizes
TokNextTx :: TokBusyKind NextTx
TokHasTx :: TokBusyKind HasTx
TokGetSizes :: TokBusyKind GetSizes
TokGetMeasures :: TokBusyKind GetMeasures
Copy link
Contributor

Choose a reason for hiding this comment

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

We have SingBusyKind; I suspect TokBusyKind is not needed at all (either I missed removing it, or it resurfaced after a rebase).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus local-tx-monitor LocalTxMonitor protocol
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants