-
Notifications
You must be signed in to change notification settings - Fork 132
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
common_messages_sv2
docs
#1242
base: main
Are you sure you want to change the base?
common_messages_sv2
docs
#1242
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1242 +/- ##
=======================================
Coverage 19.30% 19.30%
=======================================
Files 164 164
Lines 10849 10849
=======================================
Hits 2094 2094
Misses 8755 8755
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
bf46414
to
920076b
Compare
protocols/v2/subprotocols/common-messages/src/channel_endpoint_changed.rs
Outdated
Show resolved
Hide resolved
protocols/v2/subprotocols/common-messages/src/channel_endpoint_changed.rs
Outdated
Show resolved
Hide resolved
protocols/v2/subprotocols/common-messages/src/setup_connection.rs
Outdated
Show resolved
Hide resolved
protocols/v2/subprotocols/common-messages/src/setup_connection.rs
Outdated
Show resolved
Hide resolved
protocols/v2/subprotocols/common-messages/src/setup_connection.rs
Outdated
Show resolved
Hide resolved
protocols/v2/subprotocols/common-messages/src/setup_connection.rs
Outdated
Show resolved
Hide resolved
protocols/v2/subprotocols/common-messages/src/setup_connection.rs
Outdated
Show resolved
Hide resolved
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.
@jbesraa, could you also update the sv2.h
file to match the changes in the docs? I noticed a few public structures, methods, and enums missing documentation. Maybe add #![deny(missing_docs)]
at the top level to catch those and see what's missing?
Also, these methods seem a bit off:
pub fn set_requires_standard_job(&mut self) {
self.flags |= 0b_0000_0000_0000_0000_0000_0000_0000_0001;
}
pub fn set_async_job_negotiation(&mut self) {
self.flags |= 0b_0000_0000_0000_0000_0000_0000_0000_0001;
}
Both are setting the LSB and set_requires_standard_job
looks like it's only used in tests.
/// | ||
/// This message is sent in response to a [`SetupConnection`] message. | ||
/// | ||
/// The connection setup process could fail because of protocol version negotiation. In order |
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.
/// The connection setup process could fail because of protocol version negotiation. In order | |
/// The connection setup process could fail because of protocol version negotiation. In order |
b1d08ac
to
aa72fcd
Compare
Thanks for the review. What exactly should be changed in In regards to the function that might be wrong/unused, I would leave that to a separate PR. |
@GitGab19 Thanks for the review. I believe I addressed all of your comments. Some of the structs throw a warning(https://github.com/stratum-mining/stratum/actions/runs/11878855683/job/33100048008?pr=1242) for missing documentation for the |
Bencher Report
🚨 2 Alerts
Click to view all benchmark results
|
Bencher Report
Click to view all benchmark results
|
Bencher Report
Click to view all benchmark results
|
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.
LGTM. Left two minor things. For me we can open the PR review process to everyone now. What do you think @jbesraa ?
Why do you say it will be fixed when |
aa72fcd
to
27d54cf
Compare
Because it is complaining about functions inside |
sounds good |
27d54cf
to
a23801f
Compare
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.
LGTM. Let's open the review process to anyone to move on with this PR. I also saw that @Shourya742 already started to review it partially, don't know if he can complete it with a second one.
[![license](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](https://github.com/stratum-mining/stratum/blob/main/LICENSE.md) | ||
[![codecov](https://codecov.io/gh/stratum-mining/stratum/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stratum-mining/stratum/tree/main/protocols%2Fv2%2Fcommon_messages_sv2) | ||
|
||
`common_messages_sv2` is a Rust crate that implements a set of shared messages used by multiple Stratum V2 roles. |
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.
Isn't this a bit too much generic?
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 think a more accurate description should highlight that these messages are shared across all Sv2 subprotocols.
@@ -1,7 +1,13 @@ | |||
//! # Stratum V2 Common Messages Crate. | |||
//! | |||
//! The following crate defines a set of shared messages used across multiple Stratum V2 roles. |
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.
//! The following crate defines a set of shared messages used across multiple Stratum V2 roles. | |
//! This crate defines a set of shared messages used across all Stratum V2 subprotocols. |
[![license](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](https://github.com/stratum-mining/stratum/blob/main/LICENSE.md) | ||
[![codecov](https://codecov.io/gh/stratum-mining/stratum/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stratum-mining/stratum/tree/main/protocols%2Fv2%2Fcommon_messages_sv2) | ||
|
||
`common_messages_sv2` is a Rust crate that implements a set of shared messages used by multiple Stratum V2 roles. |
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.
`common_messages_sv2` is a Rust crate that implements a set of shared messages used by multiple Stratum V2 roles. | |
`common_messages_sv2` is a Rust crate that implements a set of messages shared across all Stratum V2 subprotocols. |
pub fn requires_standard_job(&self) -> bool { | ||
has_requires_std_job(self.flags) | ||
} | ||
} | ||
|
||
/// Checks if the flags include the Requires Standard Job flag. |
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.
/// Checks if the flags include the Requires Standard Job flag. | |
/// Helper function to check if [`SetupConnection`] has `REQUIRES_STANDARD_JOBS` bit flag. |
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.
Those functions dont know anything about SetupConnection
really, they just receive the flags
pub fn has_requires_std_job(flags: u32) -> bool { | ||
let flags = flags.reverse_bits(); | ||
let flag = flags >> 31; | ||
flag != 0 | ||
} | ||
|
||
/// Checks if the flags include the Version Rolling flag. |
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.
/// Checks if the flags include the Version Rolling flag. | |
/// Helper function to check if [`SetupConnection`] has `REQUIRES_VERSION_ROLLING` bit flag. |
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.
Those functions dont know anything about SetupConnection
really, they just receive the flags
pub fn has_version_rolling(flags: u32) -> bool { | ||
let flags = flags.reverse_bits(); | ||
let flags = flags << 1; | ||
let flag = flags >> 31; | ||
flag != 0 | ||
} | ||
|
||
/// Checks if the flags include the Work Selection flag. |
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.
/// Checks if the flags include the Work Selection flag. | |
/// Helper function to check if [`SetupConnection`] has `REQUIRES_WORK_SELECTION ` bit flag. |
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.
Those functions dont know anything about SetupConnection
really, they just receive the flags
/// ASCII representation of the device vendor name. | ||
#[cfg_attr(feature = "with_serde", serde(borrow))] | ||
pub vendor: Str0255<'decoder>, | ||
/// ASCII representation of the device hardware version. | ||
#[cfg_attr(feature = "with_serde", serde(borrow))] | ||
pub hardware_version: Str0255<'decoder>, | ||
/// ASCII representation of the device firmware version. | ||
#[cfg_attr(feature = "with_serde", serde(borrow))] | ||
pub firmware: Str0255<'decoder>, | ||
/// ASCII representation of the device identifier. | ||
#[cfg_attr(feature = "with_serde", serde(borrow))] | ||
pub device_id: Str0255<'decoder>, |
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.
do we know for sure this is restricted to ASCII? where did you get this info?
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.
is in the spec
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.
no only for the enpoint. so device id can be anyhting
/// ASCII representation of the connection hostname or IP address. | ||
pub endpoint_host: CVec, | ||
/// Connection port value. | ||
pub endpoint_port: u16, | ||
/// ASCII representation of the device vendor name. | ||
pub vendor: CVec, | ||
/// ASCII representation of the device hardware version. | ||
pub hardware_version: CVec, | ||
/// ASCII representation of the device firmware version. | ||
pub firmware: CVec, | ||
/// ASCII representation of the device identifier. |
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.
do we know for sure this is ASCII? where did you get this info?
/// Unsupported feature flags. | ||
/// | ||
/// If set to 0, then this error is not due to unsupported flags. |
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.
semantics of this field should be primarily conditioned to error_code
/// Unsupported feature flags. | |
/// | |
/// If set to 0, then this error is not due to unsupported flags. | |
/// In case `error_code` is `unsupported-feature-flags`, this field is used to indicate which flag is causing an error |
#[cfg_attr(feature = "with_serde", serde(borrow))] | ||
pub error_code: Str0255<'decoder>, | ||
} | ||
|
||
#[repr(C)] | ||
#[cfg(not(feature = "with_serde"))] | ||
#[derive(Debug, Clone)] | ||
/// C representation of [`SetupConnectionSuccess`] |
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.
/// C representation of [`SetupConnectionSuccess`] | |
/// C representation of [`SetupConnectionError`] |
/// Message used by a downstream role to initiate a Stratum V2 channel connection with an upstream | ||
/// role. | ||
/// | ||
/// This is usually the first message sent by a downstream role on a newly opened connection, | ||
/// after completing the handshake process. | ||
/// | ||
/// Downstreams that do not wish to provide telemetry data to the upstream role **should** set | ||
/// [`SetupConnection::device_id`] to an empty string. However, they **must** set | ||
/// [`SetupConnection::vendor`] to a string describing the manufacturer/developer and firmware | ||
/// version and **should** set [`SetupConnection::hardware_version`] to a string describing, at | ||
/// least, the particular hardware/software package in use. | ||
/// | ||
/// A valid response to this message from the upstream role can either be [`SetupConnectionSuccess`] | ||
/// or [`SetupConnectionError`] message. |
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.
do we want to duplicate this?
CSetupConnectionError
only says:
/// C representation of [`SetupConnectionError`]
I prefer providing a summary rather than duplicating the comments
/// MiningProtocol = [`SV2_MINING_PROTOCOL_DISCRIMINANT`], | ||
/// JobDeclarationProtocol = [`SV2_JOB_DECLARATION_PROTOCOL_DISCRIMINANT`], | ||
/// TemplateDistributionProtocol = [`SV2_TEMPLATE_DISTR_PROTOCOL_DISCRIMINANT`], | ||
/// Represents the different Stratum V2 protocols. |
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.
/// Represents the different Stratum V2 protocols. | |
/// This enum has a list of the different Stratum V2 subprotocols that [`SetupConnection`] can be used under. |
We can track the methods mentioned in the refactor issue for this crate to ensure they aren't forgotten. Regarding the |
This crate offers feature flags to enable or disable the use of `std`, `serde` or `quickcheck` | ||
dependencies. |
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.
Should we add a subheading, such as build-options,
for this segment and then explain each feature flag?
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.
And should we place it above the usage, to keep it consistent with other crate readme's.
@@ -1,7 +1,13 @@ | |||
//! # Stratum V2 Common Messages Crate. |
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.
This isn't directly related to documentation, but we can create a separate prop_test
module to consolidate all the generation code, instead of applying the feature gate to individual lines. This could be included as part of a refactoring issue.
/// `extension_type`. | ||
/// | ||
/// When a downstream receives such a message, any extension state (including version and extension | ||
/// support) must be reset and renegotiated. | ||
#[repr(C)] | ||
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)] |
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.
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)] | |
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] |
This isn't related to documentation, but either Copy
or Clone
can be removed, as both aren't necessary. Additionally, Eq
is not required. This could be added to the refactoring tracker.
/// Currently must be set to 2. | ||
pub min_version: u16, | ||
/// The maximum protocol version the client supports (currently must be 2). | ||
/// The maximum protocol version supported. | ||
/// | ||
/// Currently must be set to 2. |
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.
Why default for these are set to 2?
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 guess we only have stratum v2
2dd5ca0
to
ff01340
Compare
@jbesraa is it ready for a final round of review? I see you still need to address some comments from @Shourya742 |
I still need to fix the header thing, but feel free to review. Addressed all comments. |
.. and fix some styling inconsistency
ff01340
to
fc1540f
Compare
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.
LGTM. Left only a single minor comment.
/// vendor to a string describing the manufacturer/developer and firmware version and SHOULD | ||
/// always set hardware_version to a string describing, at least, the particular hardware/software | ||
/// package in use. | ||
/// Message used by a downstream role to initiate a Stratum V2 channel connection with an upstream |
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.
/// Message used by a downstream role to initiate a Stratum V2 channel connection with an upstream | |
/// Message used by a downstream role to initiate a Stratum V2 connection with an upstream |
This crate can be built with the following features: | ||
|
||
- `std`: Enables support for standard library features. | ||
- `serde`: Enables support for serialization and deserialization using Serde. |
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.
- `serde`: Enables support for serialization and deserialization using Serde. | |
- `serde`: Enables support for serialization and deserialization using Serde. Note that this feature flag is only used for the Message Generator, and deprecated for any other kind of usage. It will likely be fully deprecated in the future. |
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.
Thanks!
As part of the effort to improve Stratum V2 protocols docs, this commit aims to improves and make the documentation more comprehensive and accessible for contributors and end users alike.
fc1540f
to
6a776a4
Compare
Use the template README used across the different Stratum V2 protocol crates to `common_messages_sv2` crate.
6a776a4
to
19651b5
Compare
resolves #1203