fix: ensure unique epochs in BlobSchedule initialization #8401
+75
−6
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.
Issue Addressed
#8400
Proposed Changes
1.
consensus/types/src/chain_spec.rs-BlobSchedule::new()MethodChange: Modified to return
Result<Self, String>and validate epoch uniqueness.Before:
After:
2.
consensus/types/src/chain_spec.rs-DeserializeImplementationChange: Updated to properly handle and propagate validation errors from
BlobSchedule::new().Before:
After:
3.
consensus/types/src/chain_spec.rs-mainnet()MethodChange: Updated to handle the
Resultreturn type fromBlobSchedule::new().Before:
After:
4.
consensus/types/src/fork_context.rs- Test HelperChange: Updated the test helper
make_chain_spec()to handle theResultreturn type.Before:
After:
5. Added Comprehensive Test Suite
Added
blob_schedule_testsmodule with 4 tests:test_unique_epochs_accepted()- Verifies that valid schedules with unique epochs are acceptedtest_duplicate_epochs_rejected()- Verifies that schedules with duplicate epochs are rejected with proper error messagetest_empty_schedule()- Verifies that empty schedules are acceptedtest_single_entry()- Verifies that single-entry schedules are acceptedAdditional Info