mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
reject share for small cuckoo size (#2197)
This commit is contained in:
parent
ecf736d78a
commit
bc7780354c
1 changed files with 33 additions and 15 deletions
|
@ -13,9 +13,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//! Mining Stratum Server
|
//! Mining Stratum Server
|
||||||
|
use crate::util::{Mutex, RwLock};
|
||||||
use bufstream::BufStream;
|
use bufstream::BufStream;
|
||||||
use chrono::prelude::Utc;
|
use chrono::prelude::Utc;
|
||||||
use crate::util::{Mutex, RwLock};
|
|
||||||
use serde;
|
use serde;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
@ -447,8 +447,8 @@ impl StratumServer {
|
||||||
if b.is_none() {
|
if b.is_none() {
|
||||||
// Return error status
|
// Return error status
|
||||||
error!(
|
error!(
|
||||||
"(Server ID: {}) Failed to validate solution at height {}, nonce {}, with {} edge_bits: invalid job_id {}",
|
"(Server ID: {}) Failed to validate solution at height {}, edge_bits {}, nonce {}, job_id {}: block data not found",
|
||||||
self.id, params.height, params.nonce, params.edge_bits, params.job_id,
|
self.id, params.height, params.edge_bits, params.nonce, params.job_id,
|
||||||
);
|
);
|
||||||
worker_stats.num_rejected += 1;
|
worker_stats.num_rejected += 1;
|
||||||
let e = RpcError {
|
let e = RpcError {
|
||||||
|
@ -463,11 +463,25 @@ impl StratumServer {
|
||||||
b.header.pow.nonce = params.nonce;
|
b.header.pow.nonce = params.nonce;
|
||||||
b.header.pow.proof.nonces = params.pow;
|
b.header.pow.proof.nonces = params.pow;
|
||||||
|
|
||||||
|
if !b.header.pow.is_primary() && !b.header.pow.is_secondary() {
|
||||||
|
// Return error status
|
||||||
|
error!(
|
||||||
|
"(Server ID: {}) Failed to validate solution at height {}, hash {}, edge_bits {}, nonce {}, job_id {}: cuckoo size too small",
|
||||||
|
self.id, params.height, b.hash(), params.edge_bits, params.nonce, params.job_id,
|
||||||
|
);
|
||||||
|
worker_stats.num_rejected += 1;
|
||||||
|
let e = RpcError {
|
||||||
|
code: -32502,
|
||||||
|
message: "Failed to validate solution".to_string(),
|
||||||
|
};
|
||||||
|
return Err(serde_json::to_value(e).unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
if params.height != self.current_block_versions.last().unwrap().header.height {
|
if params.height != self.current_block_versions.last().unwrap().header.height {
|
||||||
// Return error status
|
// Return error status
|
||||||
error!(
|
error!(
|
||||||
"(Server ID: {}) Share at height {}, nonce {}, hash {}, with {} edge_bits submitted too late",
|
"(Server ID: {}) Share at height {}, hash {}, edge_bits {}, nonce {}, job_id {} submitted too late",
|
||||||
self.id, params.height, params.nonce, b.hash(), params.edge_bits,
|
self.id, params.height, b.hash(), params.edge_bits, params.nonce, params.job_id,
|
||||||
);
|
);
|
||||||
worker_stats.num_stale += 1;
|
worker_stats.num_stale += 1;
|
||||||
let e = RpcError {
|
let e = RpcError {
|
||||||
|
@ -482,8 +496,8 @@ impl StratumServer {
|
||||||
if share_difficulty < self.minimum_share_difficulty {
|
if share_difficulty < self.minimum_share_difficulty {
|
||||||
// Return error status
|
// Return error status
|
||||||
error!(
|
error!(
|
||||||
"(Server ID: {}) Share at height {}, nonce {}, hash {}, with {} edge_bits rejected due to low difficulty: {}/{}",
|
"(Server ID: {}) Share at height {}, hash {}, edge_bits {}, nonce {}, job_id {} rejected due to low difficulty: {}/{}",
|
||||||
self.id, params.height, params.nonce, b.hash(), params.edge_bits, share_difficulty, self.minimum_share_difficulty,
|
self.id, params.height, b.hash(), params.edge_bits, params.nonce, params.job_id, share_difficulty, self.minimum_share_difficulty,
|
||||||
);
|
);
|
||||||
worker_stats.num_rejected += 1;
|
worker_stats.num_rejected += 1;
|
||||||
let e = RpcError {
|
let e = RpcError {
|
||||||
|
@ -499,12 +513,13 @@ impl StratumServer {
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
// Return error status
|
// Return error status
|
||||||
error!(
|
error!(
|
||||||
"(Server ID: {}) Failed to validate solution at height {}, nonce {}, hash {}, with {} edge_bits: {}: {}",
|
"(Server ID: {}) Failed to validate solution at height {}, hash {}, edge_bits {}, nonce {}, job_id {}, {}: {}",
|
||||||
self.id,
|
self.id,
|
||||||
params.height,
|
params.height,
|
||||||
params.nonce,
|
b.hash(),
|
||||||
b.hash(),
|
|
||||||
params.edge_bits,
|
params.edge_bits,
|
||||||
|
params.nonce,
|
||||||
|
params.job_id,
|
||||||
e,
|
e,
|
||||||
e.backtrace().unwrap(),
|
e.backtrace().unwrap(),
|
||||||
);
|
);
|
||||||
|
@ -527,16 +542,18 @@ impl StratumServer {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Do some validation but dont submit
|
// Do some validation but dont submit
|
||||||
if !pow::verify_size(&b.header).is_ok() {
|
let res = pow::verify_size(&b.header);
|
||||||
|
if !res.is_ok() {
|
||||||
// Return error status
|
// Return error status
|
||||||
error!(
|
error!(
|
||||||
"(Server ID: {}) Failed to validate share at height {}, hash {}, with {} edge_bits with nonce {} using job_id {}",
|
"(Server ID: {}) Failed to validate share at height {}, hash {}, edge_bits {}, nonce {}, job_id {}. {:?}",
|
||||||
self.id,
|
self.id,
|
||||||
params.height,
|
params.height,
|
||||||
b.hash(),
|
b.hash(),
|
||||||
params.edge_bits,
|
params.edge_bits,
|
||||||
b.header.pow.nonce,
|
b.header.pow.nonce,
|
||||||
params.job_id,
|
params.job_id,
|
||||||
|
res,
|
||||||
);
|
);
|
||||||
worker_stats.num_rejected += 1;
|
worker_stats.num_rejected += 1;
|
||||||
let e = RpcError {
|
let e = RpcError {
|
||||||
|
@ -552,12 +569,13 @@ impl StratumServer {
|
||||||
Some(login) => login.clone(),
|
Some(login) => login.clone(),
|
||||||
};
|
};
|
||||||
info!(
|
info!(
|
||||||
"(Server ID: {}) Got share for block: hash {}, height {}, edge_bits {}, nonce {}, difficulty {}/{}, submitted by {}",
|
"(Server ID: {}) Got share at height {}, hash {}, edge_bits {}, nonce {}, job_id {}, difficulty {}/{}, submitted by {}",
|
||||||
self.id,
|
self.id,
|
||||||
b.hash(),
|
|
||||||
b.header.height,
|
b.header.height,
|
||||||
|
b.hash(),
|
||||||
b.header.pow.proof.edge_bits,
|
b.header.pow.proof.edge_bits,
|
||||||
b.header.pow.nonce,
|
b.header.pow.nonce,
|
||||||
|
params.job_id,
|
||||||
share_difficulty,
|
share_difficulty,
|
||||||
self.current_difficulty,
|
self.current_difficulty,
|
||||||
submitted_by,
|
submitted_by,
|
||||||
|
|
Loading…
Reference in a new issue