mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Removed limit on number of inputs or outputs in blocks and transactions. For DoS protection only a total message size needs to be enforced by the p2p layer.
This commit is contained in:
parent
2e860d04cf
commit
eb56d40807
3 changed files with 3 additions and 15 deletions
|
@ -107,9 +107,8 @@ pub const SOFT_MIN_TARGET: Target = Target([0, 0, 0xf, 0xff, 0xff, 0xff, 0, 0, 0
|
|||
/// easier to reason about.
|
||||
pub const CUT_THROUGH_HORIZON: u32 = 48 * 3600 / (BLOCK_TIME_SEC as u32);
|
||||
|
||||
/// The maximum number of inputs or outputs a transaction may have
|
||||
/// and be deserializable. Only for DoS protection.
|
||||
pub const MAX_IN_OUT_LEN: u64 = 50000;
|
||||
/// The maximum size we're willing to accept for any message. Enforced by the peer-to-peer networking layer only for DoS protection.
|
||||
pub const MAX_MSG_LEN: u64 = 20_000_000;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
|
|
@ -23,7 +23,7 @@ use std::collections::HashSet;
|
|||
use core::Committed;
|
||||
use core::{Input, Output, Proof, TxProof, Transaction};
|
||||
use core::transaction::merkle_inputs_outputs;
|
||||
use consensus::{PROOFSIZE, REWARD, DEFAULT_SIZESHIFT, MAX_IN_OUT_LEN, MAX_TARGET};
|
||||
use consensus::{PROOFSIZE, REWARD, DEFAULT_SIZESHIFT, MAX_TARGET};
|
||||
use core::hash::{Hash, Hashed, ZERO_HASH};
|
||||
use core::target::Target;
|
||||
use ser::{self, Readable, Reader, Writeable, Writer};
|
||||
|
@ -162,11 +162,6 @@ impl Readable<Block> for Block {
|
|||
let (input_len, output_len, proof_len) =
|
||||
ser_multiread!(reader, read_u64, read_u64, read_u64);
|
||||
|
||||
if input_len > MAX_IN_OUT_LEN || output_len > MAX_IN_OUT_LEN || proof_len > MAX_IN_OUT_LEN {
|
||||
return Err(ser::Error::TooLargeReadErr("Too many inputs, outputs or proofs."
|
||||
.to_string()));
|
||||
}
|
||||
|
||||
let inputs = try!((0..input_len).map(|_| Input::read(reader)).collect());
|
||||
let outputs = try!((0..output_len).map(|_| Output::read(reader)).collect());
|
||||
let proofs = try!((0..proof_len).map(|_| TxProof::read(reader)).collect());
|
||||
|
|
|
@ -19,7 +19,6 @@ use secp::{self, Secp256k1, Message, Signature};
|
|||
use secp::key::SecretKey;
|
||||
use secp::pedersen::{RangeProof, Commitment};
|
||||
|
||||
use consensus::MAX_IN_OUT_LEN;
|
||||
use core::Committed;
|
||||
use core::MerkleRow;
|
||||
use core::hash::{Hash, Hashed};
|
||||
|
@ -109,11 +108,6 @@ impl Readable<Transaction> for Transaction {
|
|||
let (fee, zerosig, input_len, output_len) =
|
||||
ser_multiread!(reader, read_u64, read_vec, read_u64, read_u64);
|
||||
|
||||
// in case a facetious miner sends us more than what we can allocate
|
||||
if input_len > MAX_IN_OUT_LEN || output_len > MAX_IN_OUT_LEN {
|
||||
return Err(ser::Error::TooLargeReadErr("Too many inputs or outputs.".to_string()));
|
||||
}
|
||||
|
||||
let inputs = try!((0..input_len).map(|_| Input::read(reader)).collect());
|
||||
let outputs = try!((0..output_len).map(|_| Output::read(reader)).collect());
|
||||
|
||||
|
|
Loading…
Reference in a new issue