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

Made MEMPOOL call LEDGER #4880

Closed
wants to merge 2 commits into from
Closed

Made MEMPOOL call LEDGER #4880

wants to merge 2 commits into from

Conversation

Soupstraw
Copy link
Contributor

Description

closes #4864

Checklist

  • Commits in meaningful sequence and with useful messages
  • Tests added or updated when needed
  • CHANGELOG.md files updated for packages with externally visible changes

    New section is never added with the code changes. (See RELEASING.md)
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary

    If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • Code formatted (use scripts/fourmolize.sh)
  • Cabal files formatted (use scripts/cabal-format.sh)
  • hie.yaml updated (use scripts/gen-hie.sh)
  • Self-reviewed the diff

@Soupstraw Soupstraw marked this pull request as ready for review February 10, 2025 14:27
@Soupstraw Soupstraw requested a review from a team as a code owner February 10, 2025 14:27
@@ -84,7 +84,6 @@ instance RuleListEra ConwayEra where
, "GOV"
, "LEDGER"
, "LEDGERS"
, "MEMPOOL"
Copy link
Contributor Author

@Soupstraw Soupstraw Feb 10, 2025

Choose a reason for hiding this comment

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

If I leave this here, I get a compiler error that says that it can't find an EraRuleFailure instance for the MEMPOOL predicate failures. However I can't add EraRuleFailure type instance for MEMPOOL because that violates type injectivity since MEMPOOL shares the predicate failure with LEDGER.

Copy link
Contributor

@teodanciu teodanciu left a comment

Choose a reason for hiding this comment

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

I understand that applyTxOpts calls directly MEMPOOL rule, which calls LEDGER.
Some things I don't understand:

  • Is it necessary to stop emitting events from the MEMPOOL rule? If yes, then probably the mempoolevents-related tests in LedgerSpec should be deleted
  • Why do we need the ApplyTxRule associated type in ApplyTx?

I'm sure it's because I'm missing some details, we can discuss it in the meeting if it's easier!

@@ -256,7 +254,7 @@ spec = do
Left e ->
assertFailure $ "Unexpected failure while applyingTx: " <> show tx <> ": " <> show e
Right (_, evs) ->
length [ev | ev@(MempoolEvent (ConwayMempoolEvent _)) <- evs] `shouldBe` 1
length [ev | ev <- evs] `shouldBe` 1
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 the list comprehension is unnecessary

Suggested change
length [ev | ev <- evs] `shouldBe` 1
length evs `shouldBe` 1

) =>
ApplyTx era
where
type ApplyTxRule era :: Type
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this associated type improve on the version without it, or is it necessary for the solution to work?

@@ -235,7 +233,7 @@ spec = do
(LedgersEnv slotNo epochNo pp account)
ls
(Seq.singleton tx)
let mempoolEvents = [ev | LedgerEvent ev@(MempoolEvent (ConwayMempoolEvent _)) <- evs]
let mempoolEvents = [ev | LedgerEvent ev <- evs]
Copy link
Contributor

Choose a reason for hiding this comment

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

If Mempool is no longer emitting events, then I'm not sure if Mempool events test makes sense at all? It just counts all the events emitted from Ledger, nothing to do with the Mempool rule. The count is also wrong right now and the tests should be failing

@@ -286,22 +281,19 @@ data ConwayLedgerEvent era
= UtxowEvent (Event (EraRule "UTXOW" era))
| CertsEvent (Event (EraRule "CERTS" era))
| GovEvent (Event (EraRule "GOV" era))
| MempoolEvent (Event (EraRule "MEMPOOL" era))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this without breaking node-to-client protocol?
If so, we should probably reflect it in the CHANGELOG

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah we can, ledger events aren't part of the node-to-client protocol.
However, after giving more thought to how actual mempool uses ledger, made me realize there is no point in making events available in ApplyTx, since they will never be used.
Adding a changelog about it the removal is a good idea.

, BaseM (someLEDGER era) ~ ShelleyBase
, STS (someLEDGER era)
) =>
TransitionRule (someLEDGER era)
ledgerTransition = do
TRC
( le@(LedgerEnv slot mbCurEpochNo _txIx pp account mempool)
, ls@(LedgerState utxoState certState)
( LedgerEnv slot mbCurEpochNo _txIx pp account _mempool
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no point to keep this ledgerMempool Bool around in LedgerEnv, no?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed there is no point.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fixed in #4890

@lehins lehins mentioned this pull request Feb 13, 2025
9 tasks
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

As I've mentioned in the meeting on Monday, I didn't think that we need this whole complication with a type family. I went ahead and experimented with it today and indeed I converged on a much simpler approach that avoids whole lot of unnecessary nonsense that didn't need to be there to begin with.
See my PR #4890 It uses the first commit from this PR.

@@ -286,22 +281,19 @@ data ConwayLedgerEvent era
= UtxowEvent (Event (EraRule "UTXOW" era))
| CertsEvent (Event (EraRule "CERTS" era))
| GovEvent (Event (EraRule "GOV" era))
| MempoolEvent (Event (EraRule "MEMPOOL" era))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah we can, ledger events aren't part of the node-to-client protocol.
However, after giving more thought to how actual mempool uses ledger, made me realize there is no point in making events available in ApplyTx, since they will never be used.
Adding a changelog about it the removal is a good idea.

, BaseM (someLEDGER era) ~ ShelleyBase
, STS (someLEDGER era)
) =>
TransitionRule (someLEDGER era)
ledgerTransition = do
TRC
( le@(LedgerEnv slot mbCurEpochNo _txIx pp account mempool)
, ls@(LedgerState utxoState certState)
( LedgerEnv slot mbCurEpochNo _txIx pp account _mempool
Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed there is no point.

@Soupstraw
Copy link
Contributor Author

Closing in favor of #4890

@Soupstraw Soupstraw closed this Feb 13, 2025
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.

Invert calling of MEMPOOL rule
3 participants