Withdrawals rework in ENTITIES - #5997
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reworks how withdrawals are validated and reported in the Dijkstra era by moving batch-wide withdrawal checks into the ENTITIES rule (instead of UTXO), adding clearer predicate failures for missing “original” accounts, and expanding Imp tests to cover batch aggregation and legacy-mode edge cases.
Changes:
- Introduce
withdrawalsWithUnacceptableAmountand a sharedlookupAccountAddresshelper incardano-ledger-core, and update internal withdrawal categorization to use it. - Move/remove Dijkstra batch-withdrawal validation from
UTXOand implement aggregated (top + subtx) withdrawal validation inENTITIES, with new failures for missing original accounts. - Update Dijkstra/Conway Imp tests and failure expectations to match the new validation behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libs/cardano-ledger-core/src/Cardano/Ledger/State/Account.hs | Adds a new withdrawal-filtering helper and centralizes account-address lookup (network-aware). |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Entities.hs | Implements new aggregated withdrawal checks (legacy vs non-legacy) and adds missing-original-account failures. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Ledger.hs | Updates ENTITIES signal/environment wiring to pass the full annotated tx and original accounts. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/Utxo.hs | Removes the prior batch-withdrawal validation and corresponding predicate failure/CBOR tags. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubEntities.hs | Reuses shared withdrawal-missing validations and maps new ENTITIES failures into sub-rule failures. |
| eras/dijkstra/impl/src/Cardano/Ledger/Dijkstra/Rules/SubUtxo.hs | Drops the now-removed WithdrawalsExceedAccountBalance “impossible” case. |
| eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/Imp/EntitiesSpec.hs | Updates/extends Imp tests for batch aggregation, legacy-mode behavior, and updated failure sets. |
| eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/CertsSpec.hs | Adds a Conway Imp test clarifying wrong-network withdrawal behavior and associated failures. |
| eras/dijkstra/impl/CHANGELOG.md | Updates changelog entries to reflect removal of the old Dijkstra withdrawal failure. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
4 times, most recently
from
August 10, 2026 23:02
0f9d95e to
1db4272
Compare
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
August 17, 2026 18:44
1db4272 to
a028427
Compare
Test Failures |
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
2 times, most recently
from
August 22, 2026 20:20
0255b9d to
70c9998
Compare
teodanciu
changed the base branch from
master
to
td/conservation-of-value-in-legacy-mode
August 22, 2026 20:20
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
2 times, most recently
from
August 23, 2026 14:04
f37c6f0 to
fdbc28d
Compare
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
August 24, 2026 12:15
fdbc28d to
9b68736
Compare
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
August 24, 2026 17:14
9b68736 to
0aafdd1
Compare
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
August 24, 2026 19:50
0aafdd1 to
89d3375
Compare
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
August 24, 2026 23:23
89d3375 to
9b45352
Compare
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
August 25, 2026 08:20
9b45352 to
39320fe
Compare
Base automatically changed from
td/conservation-of-value-in-legacy-mode
to
master
August 28, 2026 18:29
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
August 30, 2026 20:29
39320fe to
7e8c9cd
Compare
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
7 times, most recently
from
September 3, 2026 19:40
3ae3d30 to
ee48dc1
Compare
lehins
reviewed
Sep 8, 2026
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
4 times, most recently
from
September 9, 2026 21:57
e21dae2 to
8413eda
Compare
Contributor
Author
|
More tests to come in another PR that has now become stale, I will bring that up-to date next. |
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
September 9, 2026 22:22
8413eda to
f1287e7
Compare
Fire `SubWithdrawalAccountsMissing`/ `SubWithdrawalAccountsMissingPreBatch` if the network is wrong, even if the stake credential is registered.
now replaced by logic in ENTITIES
teodanciu
force-pushed
the
td/entities-withdrawals-rework
branch
from
September 10, 2026 10:45
f1287e7 to
2502efa
Compare
lehins
approved these changes
Sep 10, 2026
lehins
left a comment
Collaborator
There was a problem hiding this comment.
Awesome work!!!!
Thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
According to the spec, ENTITIES has the following responsibilities with respect to withdrawals:
This is what this PR is achieving, alongside some tests and some clean-up.
Checklist
CHANGELOG.mdfiles updated for packages with externally visible changes.NOTE: New section is never added with the code changes. (See RELEASING.md).
.cabalandCHANGELOG.mdfiles when necessary, according to theversioning process.
.cabalfiles updated when necessary.NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
scripts/fourmolize.sh).scripts/cabal-format.sh).cleret cabal run generate-cddl)hie.yamlupdated (usescripts/gen-hie.sh).