Invalidate ASIC work when pool version mask changes
main-release-gate / verify-and-release (push) Failing after 2m15s
main-release-gate / verify-and-release (push) Failing after 2m15s
This commit is contained in:
+13
-4
@@ -105,8 +105,12 @@ impl PoolSession {
|
||||
Ok(false)
|
||||
}
|
||||
PoolNotification::SetVersionMask(mask) => {
|
||||
if self.version_mask == Some(mask) {
|
||||
return Ok(false);
|
||||
}
|
||||
self.version_mask = Some(mask);
|
||||
Ok(false)
|
||||
self.tracked = std::array::from_fn(|_| None);
|
||||
Ok(true)
|
||||
}
|
||||
PoolNotification::SetExtranonce(subscription) => {
|
||||
self.subscription = subscription;
|
||||
@@ -119,7 +123,7 @@ impl PoolSession {
|
||||
}
|
||||
|
||||
/// Apply a pool control message and invalidate the hardware miner's work
|
||||
/// when an extranonce change makes earlier jobs stale.
|
||||
/// when an extranonce or version-mask change makes earlier jobs stale.
|
||||
pub fn control_with_miner<B: HardwareBackend>(
|
||||
&mut self,
|
||||
miner: &mut Bm1366Miner<'_, B>,
|
||||
@@ -360,10 +364,15 @@ mod tests {
|
||||
),
|
||||
Err(SessionError::UnverifiedShare)
|
||||
);
|
||||
session.version_mask = VersionMask::new(0x0000_2000);
|
||||
assert_eq!(
|
||||
session.control(
|
||||
b"{\"id\":null,\"method\":\"mining.set_version_mask\",\"params\":[\"00002000\"]}"
|
||||
),
|
||||
Ok(true)
|
||||
);
|
||||
assert_eq!(
|
||||
session.submission(share, "miner.worker", 8),
|
||||
Err(SessionError::Submit(SubmitError::UnrepresentableVersion))
|
||||
Err(SessionError::StaleShare)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,9 +52,27 @@ fn difficulty_changes_on_next_job_and_old_work_keeps_its_target() {
|
||||
assert_eq!(second.work_id, 8);
|
||||
assert_eq!(&second.target_le[26..28], &[0xff, 0x7f]);
|
||||
assert_ne!(first.header, second.header);
|
||||
assert!(pool
|
||||
.control(br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#)
|
||||
.is_ok());
|
||||
assert_eq!(
|
||||
pool.control(br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#),
|
||||
Ok(true)
|
||||
);
|
||||
assert_eq!(
|
||||
pool.submission(
|
||||
ValidShare {
|
||||
nonce: 0xedad_ff38,
|
||||
work_id: first.work_id,
|
||||
rolled_version: 0x2000_0000,
|
||||
hash_le: [0; 32],
|
||||
},
|
||||
"worker",
|
||||
10,
|
||||
),
|
||||
Err(SessionError::StaleShare)
|
||||
);
|
||||
assert_eq!(
|
||||
pool.control(br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#),
|
||||
Ok(false)
|
||||
);
|
||||
let clean = pool.issue_notify(notify("third", true).as_bytes()).unwrap();
|
||||
assert!(clean.clean_jobs);
|
||||
assert_eq!(clean.work_id, 16);
|
||||
@@ -201,7 +219,7 @@ impl HardwareBackend for FakeBackend {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pool_job_dispatch_and_extranonce_invalidation_reach_the_miner() {
|
||||
fn pool_job_dispatch_and_version_mask_invalidation_reach_the_miner() {
|
||||
let mut backend = FakeBackend {
|
||||
powered: false,
|
||||
sent: 0,
|
||||
@@ -226,7 +244,7 @@ fn pool_job_dispatch_and_extranonce_invalidation_reach_the_miner() {
|
||||
}
|
||||
pool.control_with_miner(
|
||||
&mut miner,
|
||||
br#"{"id":null,"method":"mining.set_extranonce","params":["aabbccdd",4]}"#,
|
||||
br#"{"id":null,"method":"mining.set_version_mask","params":["00006000"]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(miner.poll(), Err(MinerError::StaleReport));
|
||||
|
||||
Reference in New Issue
Block a user