Skip to content

Commit 76ff2df

Browse files
committed
fix PushSolution field order
1 parent 0efbe21 commit 76ff2df

7 files changed

Lines changed: 34 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

stratum-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ channels_sv2 = { path = "../sv2/channels-sv2", version = "^6.0.0" }
2424
common_messages_sv2 = { path = "../sv2/subprotocols/common-messages", version = "^7.2.0" }
2525
mining_sv2 = { path = "../sv2/subprotocols/mining", version = "^10.0.0" }
2626
template_distribution_sv2 = { path = "../sv2/subprotocols/template-distribution", version = "^5.1.0" }
27-
job_declaration_sv2 = { path = "../sv2/subprotocols/job-declaration", version = "^7.1.0" }
27+
job_declaration_sv2 = { path = "../sv2/subprotocols/job-declaration", version = "^8.0.0" }
2828
sv1_api = { path = "../sv1", version = "^4.0.0", optional = true }
2929
stratum_translation = { path = "stratum-translation", version = "^0.3.0", optional = true }
3030
bitcoin = { workspace = true }

sv2/handlers-sv2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ common_messages_sv2 = { path = "../subprotocols/common-messages", version = "^7.
1818
framing_sv2 = { path = "../framing-sv2", version = "^6.0.0" }
1919
mining_sv2 = { path = "../subprotocols/mining", version = "^10.0.0" }
2020
template_distribution_sv2 = { path = "../subprotocols/template-distribution", version = "^5.1.0" }
21-
job_declaration_sv2 = { path = "../subprotocols/job-declaration", version = "^7.1.0" }
21+
job_declaration_sv2 = { path = "../subprotocols/job-declaration", version = "^8.0.0" }
2222
extensions_sv2 = { path = "../extensions-sv2", version = "^0.1.0" }
2323
trait-variant = { workspace = true }

sv2/parsers-sv2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ framing_sv2 = { path = "../framing-sv2", version = "^6.0.0" }
1717
common_messages_sv2 = { path = "../subprotocols/common-messages", version = "^7.2.0" }
1818
mining_sv2 = { path = "../subprotocols/mining", version = "^10.0.0" }
1919
template_distribution_sv2 = { path = "../subprotocols/template-distribution", version = "^5.1.0" }
20-
job_declaration_sv2 = { path = "../subprotocols/job-declaration", version = "^7.1.0" }
20+
job_declaration_sv2 = { path = "../subprotocols/job-declaration", version = "^8.0.0" }
2121
extensions_sv2 = { path = "../extensions-sv2", version = "^0.1.0" }
2222

2323
[dev-dependencies]

sv2/parsers-sv2/src/lib.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,14 +1748,15 @@ impl<'a> TryFrom<AnyMessage<'a>> for MiningDeviceMessages<'a> {
17481748

17491749
#[cfg(test)]
17501750
mod test {
1751-
use crate::{AnyMessage, Extensions, ExtensionsNegotiation, Mining};
1751+
use crate::{AnyMessage, Extensions, ExtensionsNegotiation, JobDeclaration, Mining};
17521752
use alloc::string::String;
17531753
use alloc::vec;
17541754
use alloc::vec::Vec;
1755-
use binary_sv2::{Seq0255, Seq064K, Str0255, Sv2Option, B0255, B064K, U256};
1755+
use binary_sv2::{Seq0255, Seq064K, Str0255, Sv2Option, B0255, B032, B064K, U256};
17561756
use codec_sv2::StandardSv2Frame;
17571757
use core::convert::{TryFrom, TryInto};
17581758
use extensions_sv2::{RequestExtensions, EXTENSION_TYPE_EXTENSIONS_NEGOTIATION};
1759+
use job_declaration_sv2::PushSolution;
17591760
use mining_sv2::{
17601761
NewMiningJob, SetCustomMiningJob, SetCustomMiningJobError, SetCustomMiningJobSuccess,
17611762
};
@@ -1853,6 +1854,28 @@ mod test {
18531854
}
18541855
}
18551856

1857+
#[test]
1858+
fn push_solution_serialization() {
1859+
let mut correctly_serialized_msg = vec![0, 0, 0x60, 53, 0, 0, 4, 1, 2, 3, 4];
1860+
correctly_serialized_msg.extend(5_u8..37);
1861+
correctly_serialized_msg.extend(0x11223344_u32.to_le_bytes());
1862+
correctly_serialized_msg.extend(0x55667788_u32.to_le_bytes());
1863+
correctly_serialized_msg.extend(0x99aabbcc_u32.to_le_bytes());
1864+
correctly_serialized_msg.extend(0xddeeff00_u32.to_le_bytes());
1865+
1866+
let job_declaration_message =
1867+
AnyMessage::JobDeclaration(JobDeclaration::PushSolution(PushSolution {
1868+
extranonce: B032::try_from(vec![1, 2, 3, 4]).unwrap(),
1869+
prev_hash: U256::try_from((5_u8..37).collect::<Vec<u8>>()).unwrap(),
1870+
nonce: 0x11223344,
1871+
ntime: 0x55667788,
1872+
nbits: 0x99aabbcc,
1873+
version: 0xddeeff00,
1874+
}));
1875+
1876+
message_serialization_check(job_declaration_message, &correctly_serialized_msg);
1877+
}
1878+
18561879
fn message_serialization_check(message: AnyMessage<'static>, expected_result: &[u8]) {
18571880
let frame = StdFrame::try_from(message).unwrap();
18581881
let encoded_frame_length = frame.encoded_length();

sv2/subprotocols/job-declaration/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "job_declaration_sv2"
3-
version = "7.1.0"
3+
version = "8.0.0"
44
authors = ["The Stratum V2 Developers"]
55
edition = "2021"
66
readme = "README.md"

sv2/subprotocols/job-declaration/src/push_solution.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ pub struct PushSolution<'decoder> {
1919
pub extranonce: B032<'decoder>,
2020
/// Previous block hash.
2121
pub prev_hash: U256<'decoder>,
22-
/// Contains the time the block was constructed as a Unix timestamp.
23-
pub ntime: u32,
2422
/// Nonce of the block.
2523
pub nonce: u32,
24+
/// Contains the time the block was constructed as a Unix timestamp.
25+
pub ntime: u32,
2626
/// The bits field is compact representation of the target at the time the block was mined.
2727
pub nbits: u32,
2828
/// The version field in a Bitcoin header initially indicated protocol rule changes. [`BIP9`]
@@ -40,11 +40,11 @@ impl fmt::Display for PushSolution<'_> {
4040
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4141
write!(
4242
f,
43-
"PushSolution(extranonce: {}, prev_hash: {}, ntime: {}, nonce: 0x{:08x}, nbits: 0x{:08x}, version: 0x{:08x})",
43+
"PushSolution(extranonce: {}, prev_hash: {}, nonce: 0x{:08x}, ntime: {}, nbits: 0x{:08x}, version: 0x{:08x})",
4444
self.extranonce,
4545
self.prev_hash,
46-
self.ntime,
4746
self.nonce,
47+
self.ntime,
4848
self.nbits,
4949
self.version
5050
)

0 commit comments

Comments
 (0)