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:
Antioch Peverell 2018-02-07 12:23:48 -05:00 committed by GitHub
parent 78a6447a09
commit ad594b53de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 44 deletions

View file

@ -44,16 +44,6 @@ pub fn reward(fee: u64) -> u64 {
/// Number of blocks before a coinbase matures and can be spent
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
/// 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

View file

@ -73,10 +73,6 @@ pub enum Error {
/// The lock_height needed to be reached for the coinbase output to mature
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(String)
}
@ -234,14 +230,10 @@ impl Writeable for CompactBlock {
try!(self.header.write(writer));
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!(
writer,
[write_u8, self.out_full.len() as u8],
[write_u8, self.kern_full.len() as u8],
[write_u64, self.out_full.len() as u64],
[write_u64, self.kern_full.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 (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 kern_full = read_and_verify_sorted(reader, kern_full_len as u64)?;
@ -670,12 +662,11 @@ impl Block {
Ok(())
}
/// Validate the coinbase outputs generated by miners. Entails 3 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 blinding factors for all coinbase-marked outputs match
/// the coinbase-marked kernels.
// Validate the coinbase outputs generated by miners. Entails 2 main checks:
//
// * That the sum of all coinbase-marked outputs equal the supply.
// * That the sum of blinding factors for all coinbase-marked outputs match
// the coinbase-marked kernels.
fn verify_coinbase(&self) -> Result<(), Error> {
let cb_outs = self.outputs
.iter()
@ -689,16 +680,6 @@ impl Block {
.cloned()
.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 out_adjust_sum;
let kerns_sum;
@ -1054,7 +1035,7 @@ mod test {
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
assert_eq!(
vec.len(),
5_662
5_676
);
}
@ -1067,7 +1048,7 @@ mod test {
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
assert_eq!(
vec.len(),
5_668
5_682
);
}
@ -1111,7 +1092,7 @@ mod test {
ser::serialize(&mut vec, &b.as_compact_block()).expect("serialization failed");
assert_eq!(
vec.len(),
5_722
5_736
);
}