mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 11:31:08 +03:00
Revert "add block validation consensus rule for block coinbase output" (#691)
also fix tests for size of blocks etc.
This reverts commit ecda870d70
.
This commit is contained in:
parent
78a6447a09
commit
ad594b53de
2 changed files with 15 additions and 44 deletions
|
@ -44,16 +44,6 @@ pub fn reward(fee: u64) -> u64 {
|
||||||
/// Number of blocks before a coinbase matures and can be spent
|
/// Number of blocks before a coinbase matures and can be spent
|
||||||
pub const COINBASE_MATURITY: u64 = 1_000;
|
pub const COINBASE_MATURITY: u64 = 1_000;
|
||||||
|
|
||||||
/// Max number of coinbase outputs in a valid block.
|
|
||||||
/// This is to prevent a miner generating an excessively large "compact block".
|
|
||||||
/// But we do techincally support blocks with multiple coinbase outputs/kernels.
|
|
||||||
pub const MAX_BLOCK_COINBASE_OUTPUTS: u64 = 1;
|
|
||||||
|
|
||||||
/// Max number of coinbase kernels in a valid block.
|
|
||||||
/// This is to prevent a miner generating an excessively large "compact block".
|
|
||||||
/// But we do techincally support blocks with multiple coinbase outputs/kernels.
|
|
||||||
pub const MAX_BLOCK_COINBASE_KERNELS: u64 = 1;
|
|
||||||
|
|
||||||
/// Block interval, in seconds, the network will tune its next_target for. Note
|
/// Block interval, in seconds, the network will tune its next_target for. Note
|
||||||
/// that we may reduce this value in the future as we get more data on mining
|
/// that we may reduce this value in the future as we get more data on mining
|
||||||
/// with Cuckoo Cycle, networks improve and block propagation is optimized
|
/// with Cuckoo Cycle, networks improve and block propagation is optimized
|
||||||
|
|
|
@ -73,10 +73,6 @@ pub enum Error {
|
||||||
/// The lock_height needed to be reached for the coinbase output to mature
|
/// The lock_height needed to be reached for the coinbase output to mature
|
||||||
lock_height: u64,
|
lock_height: u64,
|
||||||
},
|
},
|
||||||
/// Limit on number of coinbase outputs in a valid block.
|
|
||||||
CoinbaseOutputCountExceeded,
|
|
||||||
/// Limit on number of coinbase kernels in a valid block.
|
|
||||||
CoinbaseKernelCountExceeded,
|
|
||||||
/// Other unspecified error condition
|
/// Other unspecified error condition
|
||||||
Other(String)
|
Other(String)
|
||||||
}
|
}
|
||||||
|
@ -234,14 +230,10 @@ impl Writeable for CompactBlock {
|
||||||
try!(self.header.write(writer));
|
try!(self.header.write(writer));
|
||||||
|
|
||||||
if writer.serialization_mode() != ser::SerializationMode::Hash {
|
if writer.serialization_mode() != ser::SerializationMode::Hash {
|
||||||
// TODO - make these constants and put them somewhere reusable?
|
|
||||||
assert!(self.out_full.len() < 16);
|
|
||||||
assert!(self.kern_full.len() < 16);
|
|
||||||
|
|
||||||
ser_multiwrite!(
|
ser_multiwrite!(
|
||||||
writer,
|
writer,
|
||||||
[write_u8, self.out_full.len() as u8],
|
[write_u64, self.out_full.len() as u64],
|
||||||
[write_u8, self.kern_full.len() as u8],
|
[write_u64, self.kern_full.len() as u64],
|
||||||
[write_u64, self.kern_ids.len() as u64]
|
[write_u64, self.kern_ids.len() as u64]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -265,7 +257,7 @@ impl Readable for CompactBlock {
|
||||||
let header = try!(BlockHeader::read(reader));
|
let header = try!(BlockHeader::read(reader));
|
||||||
|
|
||||||
let (out_full_len, kern_full_len, kern_id_len) =
|
let (out_full_len, kern_full_len, kern_id_len) =
|
||||||
ser_multiread!(reader, read_u8, read_u8, read_u64);
|
ser_multiread!(reader, read_u64, read_u64, read_u64);
|
||||||
|
|
||||||
let out_full = read_and_verify_sorted(reader, out_full_len as u64)?;
|
let out_full = read_and_verify_sorted(reader, out_full_len as u64)?;
|
||||||
let kern_full = read_and_verify_sorted(reader, kern_full_len as u64)?;
|
let kern_full = read_and_verify_sorted(reader, kern_full_len as u64)?;
|
||||||
|
@ -670,12 +662,11 @@ impl Block {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validate the coinbase outputs generated by miners. Entails 3 main checks:
|
// Validate the coinbase outputs generated by miners. Entails 2 main checks:
|
||||||
///
|
//
|
||||||
/// * That the block does not exceed the number of permitted coinbase outputs or kernels.
|
// * That the sum of all coinbase-marked outputs equal the supply.
|
||||||
/// * That the sum of all coinbase-marked outputs equal the supply.
|
// * That the sum of blinding factors for all coinbase-marked outputs match
|
||||||
/// * That the sum of blinding factors for all coinbase-marked outputs match
|
// the coinbase-marked kernels.
|
||||||
/// the coinbase-marked kernels.
|
|
||||||
fn verify_coinbase(&self) -> Result<(), Error> {
|
fn verify_coinbase(&self) -> Result<(), Error> {
|
||||||
let cb_outs = self.outputs
|
let cb_outs = self.outputs
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -689,16 +680,6 @@ impl Block {
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<TxKernel>>();
|
.collect::<Vec<TxKernel>>();
|
||||||
|
|
||||||
// First check that we do not have too many coinbase outputs in the block.
|
|
||||||
if cb_outs.len() as u64 > consensus::MAX_BLOCK_COINBASE_OUTPUTS {
|
|
||||||
return Err(Error::CoinbaseOutputCountExceeded);
|
|
||||||
}
|
|
||||||
|
|
||||||
// And that we do not have too many coinbase kernels in the block.
|
|
||||||
if cb_kerns.len() as u64 > consensus::MAX_BLOCK_COINBASE_KERNELS {
|
|
||||||
return Err(Error::CoinbaseKernelCountExceeded);
|
|
||||||
}
|
|
||||||
|
|
||||||
let over_commit;
|
let over_commit;
|
||||||
let out_adjust_sum;
|
let out_adjust_sum;
|
||||||
let kerns_sum;
|
let kerns_sum;
|
||||||
|
@ -1054,7 +1035,7 @@ mod test {
|
||||||
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
|
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vec.len(),
|
vec.len(),
|
||||||
5_662
|
5_676
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1067,7 +1048,7 @@ mod test {
|
||||||
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
|
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vec.len(),
|
vec.len(),
|
||||||
5_668
|
5_682
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,7 +1092,7 @@ mod test {
|
||||||
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
|
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
vec.len(),
|
vec.len(),
|
||||||
5_722
|
5_736
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue