-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix CandidateDescriptor debug logs #9255
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3bffe37
Fix CandidateDescriptor debug logs
AlexandruCihodaru 9a8a985
renamed pr_doc file
AlexandruCihodaru 2639caa
rename prdoc file
AlexandruCihodaru f110782
Implement review suggestions
AlexandruCihodaru c0c0933
fix CI 1st attempt
AlexandruCihodaru 730e325
Merge branch 'master' into acihodaru/8457-CandidateDesciptor-debug-logs
AlexandruCihodaru d2bb356
fix prdoc 2nd attempt
AlexandruCihodaru fdad38b
fix prdoc
AlexandruCihodaru 43512ce
fix prdoc
AlexandruCihodaru 70f1936
Merge branch 'master' into acihodaru/8457-CandidateDesciptor-debug-logs
AlexandruCihodaru 8b1c51f
Update polkadot/primitives/src/vstaging/mod.rs
bkchr d558d8e
Merge branch 'master' into acihodaru/8457-CandidateDesciptor-debug-logs
bkchr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,8 @@ | |||||
| // along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||||||
|
|
||||||
| //! Staging Primitives. | ||||||
| use core::fmt::Formatter; | ||||||
|
|
||||||
| use crate::{slashing::DisputesTimeSlot, ValidatorId, ValidatorIndex, ValidityAttestation}; | ||||||
|
|
||||||
| // Put any primitives used by staging APIs functions here | ||||||
|
|
@@ -66,8 +68,9 @@ pub enum CandidateDescriptorVersion { | |||||
| } | ||||||
|
|
||||||
| /// A unique descriptor of the candidate receipt. | ||||||
| #[derive(PartialEq, Eq, Clone, Encode, Decode, DecodeWithMemTracking, TypeInfo, RuntimeDebug)] | ||||||
| #[derive(PartialEq, Eq, Clone, Encode, Decode, DecodeWithMemTracking, TypeInfo)] | ||||||
| #[cfg_attr(feature = "std", derive(Hash))] | ||||||
| #[cfg_attr(not(feature = "std"), derive(RuntimeDebug))] | ||||||
| pub struct CandidateDescriptorV2<H = Hash> { | ||||||
| /// The ID of the para this is a candidate for. | ||||||
| para_id: ParaId, | ||||||
|
|
@@ -99,6 +102,57 @@ pub struct CandidateDescriptorV2<H = Hash> { | |||||
| /// The blake2-256 hash of the validation code bytes. | ||||||
| validation_code_hash: ValidationCodeHash, | ||||||
| } | ||||||
| impl<H> CandidateDescriptorV2<H> { | ||||||
| /// Returns the candidate descriptor version. | ||||||
bkchr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| /// The candidate is at version 2 if the reserved fields are zeroed out | ||||||
| /// and the internal `version` field is 0. | ||||||
| pub fn version(&self) -> CandidateDescriptorVersion { | ||||||
| if self.reserved2 != [0u8; 64] || self.reserved1 != [0u8; 25] { | ||||||
| return CandidateDescriptorVersion::V1 | ||||||
| } | ||||||
|
|
||||||
| match self.version.0 { | ||||||
| 0 => CandidateDescriptorVersion::V2, | ||||||
| _ => CandidateDescriptorVersion::Unknown, | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| #[cfg(feature = "std")] | ||||||
|
||||||
| #[cfg(feature = "std")] |
Outdated
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| .debug_struct("CandidateDescriptor") | |
| .debug_struct("CandidateDescriptorV1") |
Outdated
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| _ => { | |
| CandidateDescriptorVersion::Unknown => { |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 | ||
| # See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json | ||
|
|
||
| title: Fix CandidateDescriptor debug logs | ||
|
|
||
| doc: | ||
| - audience: Node Dev | ||
| description: | | ||
| Implement core::fmt::Debug by hand when std is not enabled and print the | ||
| structure differently depending on the CandidateDescriptor version. | ||
|
|
||
| crates: [ polkadot-primitives ] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking we want to keep the empty implementation for when std is not enabled, similarly to what it was before this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slowly removing this everywhere, it just makes stuff more complicated when you want to debug stuff.