feat: expose more ledger error types#1449
Merged
Merged
Conversation
Variants like MalformedTransaction::EffectsCheckFailure(EffectsCheckError) were previously collapsed to a single flat code, hiding the inner cause from end-users. Flatten the inner enums (EffectsCheckError, SequencingCheckError, DisjointCheckError, FeeCalculationError, MalformedContractDeploy, TransactionApplicationError, zswap MalformedOffer and TransactionInvalid) into granular variants in InvalidError, MalformedError, and SystemTransactionError, with stable u8 codes in the free 212-250 range. Add version-specific error_ext modules (versions/error_ext/ledger_7.rs, ledger_8.rs) wired through lib.rs in the same style as block_context. Each version maps only the variants it knows about; unknown variants fall through to UnknownError + log rather than being silently misclassified. This replaces the prior '_ => Ste::MerkleTreeError' pattern, which would have masked any future ledger 9+ additions as MerkleTreeError. Adds InvalidError variants for ledger 8's MerkleTreeError (top-level and zswap-nested) and DivideByZero (present in both versions). Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Covers both the node-side host conversion changes and the runtime-side pallet error variants exposed to end-users. Runtime metadata rebuild is required as a result of the new variants. Fixes: #1374 Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Granular error codes don't resolve the underlying issue, just make it easier to debug. Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Contributor
Author
|
/bot rebuild-metadata |
Contributor
|
✅ Metadata rebuild complete! Changes have been committed. |
Replace flattened variant names like `EffectsCheckRealCallsSubsetCheckFailure` with nested wrappers like `MalformedError::EffectsCheck(EffectsCheckErrorCode::RealCallsSubsetCheckFailure)`. Variant names now mirror upstream `mn_ledger` types directly. Each sub-enum gets its own 256-variant budget, and the compile-time `MAX_MODULE_ERROR_ENCODED_SIZE` check enforces correctness. Flatten `LedgerApiError` into `cnight-observation::Error<T>` and `midnight-system::Error<T>` (mirroring the `midnight` pallet pattern). The previous `Error::LedgerApiError(LedgerApiError)` wrapper added an extra byte that, combined with the new nesting, exceeded the 4-byte module error budget. u8 codes via `From<LedgerApiError>` are preserved for all reachable variants. Two fallback paths now produce more specific bytes: unmapped upstream ZswapTransactionInvalid -> 103 (was 109) and unmapped MalformedOffer -> 127 (was 139), reusing what were previously vestigial flat catch-all bytes. SCALE pallet error encoding for granular variants changes shape: e.g. `Error::Transaction(Malformed(EffectsCheck(RealCallsSubsetCheckFailure)))` is 4 bytes vs the previous 3-byte flat encoding. Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Contributor
Author
|
/bot rebuild-metadata |
Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com> # Conflicts: # metadata/static/midnight_metadata.scale # metadata/static/midnight_metadata_1.0.0.scale
Contributor
Author
|
/bot rebuild-metadata |
Contributor
|
❌ Metadata rebuild failed. Check the workflow logs for details. |
Codes 168, 182, 186, 187, 188, 193, 205 were assigned to flat catch-all variants (`MalformedError::FeeCalculation` etc.) on `main` and were observable to mempool clients via `InvalidTransaction::Custom`. They are no longer produced by the nested encoding, but reusing them for new variants would silently collide on the wire. Document the reservation in `RETIRED_U8_ERROR_CODES` and assert at test time that no `LedgerApiError` value encodes to one of them. Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Post-merge: `LedgerApiError::BeneficiaryNotFound` was added on `main` (#1359). The flattened `From<LedgerApiError> for Error<T>` impls in `cnight-observation` and `midnight-system` need a matching arm now that they enumerate variants explicitly rather than wrapping the whole type. Signed-off-by: Oscar Bailey <79094698+ozgb@users.noreply.github.com>
Contributor
Author
|
/bot rebuild-metadata |
Contributor
|
✅ Metadata rebuild complete! Changes have been committed. |
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.
Overview
Exposes more detailed Ledger error enums that were previously discarded. Addresses comment: #1374 (comment)
Changes are backwards-compatible - existing error types evaluate to the same error code, unless a more precise variant can now be used.
🗹 TODO before merging
📌 Submission Checklist
git commit -s) for the DCO🧪 Testing Evidence
Please describe any additional testing aside from CI:
🔱 Fork Strategy
Links