Skip to content

Commit

Permalink
Fix NewMiningJob message format
Browse files Browse the repository at this point in the history
- Fix unit test new_mining_job_serialization
  • Loading branch information
jakubtrnka committed Jan 24, 2025
1 parent c7c5e91 commit 63d214b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions protocols/v2/subprotocols/mining/src/new_mining_job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use alloc::vec::Vec;
#[cfg(not(feature = "with_serde"))]
use binary_sv2::binary_codec_sv2;
use binary_sv2::{Deserialize, Seq0255, Serialize, Sv2Option, B032, B064K, U256};
use binary_sv2::{Deserialize, Seq0255, Serialize, Sv2Option, B064K, U256};
#[cfg(not(feature = "with_serde"))]
use core::convert::TryInto;

Expand Down Expand Up @@ -49,7 +49,7 @@ pub struct NewMiningJob<'decoder> {
///
/// Note that this field is fixed and cannot be modified by the downstream node.
#[cfg_attr(feature = "with_serde", serde(borrow))]
pub merkle_root: B032<'decoder>,
pub merkle_root: U256<'decoder>,
}

impl<'d> NewMiningJob<'d> {
Expand Down
9 changes: 4 additions & 5 deletions roles/pool/src/lib/mining_pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,16 +734,16 @@ impl Pool {
mod test {
use super::{Configuration, StdFrame};

use binary_sv2::{Sv2Option, B0255, B032, B064K, U256};
use binary_sv2::{Sv2Option, B0255, B064K, U256};
use ext_config::{Config, File, FileFormat};
use roles_logic_sv2::mining_sv2::{NewMiningJob};
use roles_logic_sv2::mining_sv2::NewMiningJob;
use roles_logic_sv2::parsers::Mining;
use roles_logic_sv2::parsers::PoolMessages;
use tracing::error;
use stratum_common::{
bitcoin,
bitcoin::{util::psbt::serialize::Serialize, Transaction, Witness},
};
use tracing::error;

use std::convert::{TryFrom, TryInto};

Expand All @@ -759,8 +759,7 @@ mod test {
job_id: u32::from_le_bytes([5, 6, 7, 8]),
min_ntime: Sv2Option::new(Some(u32::from_le_bytes([9, 10, 11, 12]))),
version: u32::from_le_bytes([13, 14, 15, 16]),
merkle_root: B032::try_from((17_u8..(17 + 32)).collect::<Vec<u8>>()).unwrap(),
// merkle_root: U256::try_from((17_u8..(17 + 32)).collect::<Vec<u8>>()).unwrap(),
merkle_root: U256::try_from((17_u8..(17 + 32)).collect::<Vec<u8>>()).unwrap(),
}));
message_serialization_check(mining_message, CORRECTLY_SERIALIZED_MSG);
}
Expand Down

0 comments on commit 63d214b

Please sign in to comment.