Fee burning no more. Fixes

This commit is contained in:
Ignotus Peverell 2018-03-13 02:39:22 +00:00
parent a8fcc37a36
commit 65c0a4b7b0
No known key found for this signature in database
GPG key ID: 99CD25F39F8F8211
5 changed files with 6 additions and 73 deletions

View file

@ -24,7 +24,7 @@ use std::sync::Arc;
use util::static_secp_instance;
use util::secp::pedersen::{Commitment, RangeProof};
use core::consensus::reward;
use core::consensus::REWARD;
use core::core::{Block, BlockHeader, Input, Output, OutputFeatures, OutputIdentifier,
OutputStoreable, TxKernel};
use core::core::pmmr::{self, MerkleProof, PMMR};
@ -567,7 +567,7 @@ impl<'a> Extension<'a> {
{
let secp = static_secp_instance();
let secp = secp.lock().unwrap();
let over_commit = secp.commit_value(header.height * reward(0) - fees / 2)?;
let over_commit = secp.commit_value(header.height * REWARD)?;
let adjusted_sum_output = secp.commit_sum(vec![output_sum], vec![over_commit])?;
if adjusted_sum_output != kernel_sum {

View file

@ -38,7 +38,7 @@ pub const REWARD: u64 = 60 * GRIN_BASE;
/// Actual block reward for a given total fee amount
pub fn reward(fee: u64) -> u64 {
REWARD + fee / 2
REWARD + fee
}
/// Number of blocks before a coinbase matures and can be spent

View file

@ -21,7 +21,7 @@ use std::collections::HashSet;
use core::{Committed, Input, KernelFeatures, Output, OutputFeatures, Proof, ProofMessageElements,
ShortId, SwitchCommitHash, Transaction, TxKernel};
use consensus;
use consensus::{exceeds_weight, reward, VerifySortOrder, REWARD};
use consensus::{exceeds_weight, reward, REWARD, VerifySortOrder};
use core::hash::{Hash, Hashed, ZERO_HASH};
use core::id::ShortIdentifiable;
use core::target::Difficulty;
@ -42,8 +42,6 @@ pub enum Error {
KernelSumMismatch,
/// Same as above but for the coinbase part of a block, including reward
CoinbaseSumMismatch,
/// Kernel fee can't be odd, due to half fee burning
OddKernelFee,
/// Too many inputs, outputs or kernels in the block
WeightExceeded,
/// Kernel not valid due to lock_height exceeding block header height
@ -360,7 +358,7 @@ impl Committed for Block {
&self.outputs
}
fn overage(&self) -> i64 {
((self.total_fees() / 2) as i64) - (REWARD as i64)
-(REWARD as i64)
}
}
@ -674,10 +672,6 @@ impl Block {
/// and that all kernel signatures are valid.
fn verify_kernels(&self) -> Result<(), Error> {
for k in &self.kernels {
if k.fee & 1 != 0 {
return Err(Error::OddKernelFee);
}
// check we have no kernels with lock_heights greater than current height
// no tx can be included in a block earlier than its lock_height
if k.lock_height > self.header.height {

View file

@ -413,58 +413,6 @@ mod test {
}
}
// #[test]
// fn tx_build_aggsig() {
// let keychain = Keychain::from_random_seed().unwrap();
// let key_id1 = keychain.derive_key_id(1).unwrap();
// let key_id2 = keychain.derive_key_id(2).unwrap();
// let key_id3 = keychain.derive_key_id(3).unwrap();
// let key_id4 = keychain.derive_key_id(4).unwrap();
//
// let (tx_alice, blind_sum) = {
// // Alice gets 2 of her pre-existing outputs to send 5 coins to Bob, they
// // become inputs in the new transaction
// let (in1, in2) = (input(4, ZERO_HASH, key_id1), input(3, ZERO_HASH,
// key_id2));
//
// // Alice builds her transaction, with change, which also produces the sum
// // of blinding factors before they're obscured.
// let (tx, sum) = build::partial_transaction(
// vec![in1, in2, output(1, key_id3),
// with_fee(2)],
// &keychain,
// ).unwrap();
//
// (tx, sum)
// };
//
// let blind = blind_sum.secret_key(&keychain.secp())?;
// keychain.aggsig_create_context(blind);
// let (pub_excess, pub_nonce) = keychain.aggsig_get_public_keys();
//
// let sig_part = keychain.aggsig_calculate_partial_sig(
// &pub_nonce,
// tx.fee(),
// tx.lock_height(),
// ).unwrap();
//
//
// // From now on, Bob only has the obscured transaction and the sum of
// // blinding factors. He adds his output, finalizes the transaction so it's
// // ready for broadcast.
// let tx_final = build::transaction(
// vec![
// initial_tx(tx_alice),
// with_excess(blind_sum),
// output(4, key_id4),
// ],
// &keychain,
// ).unwrap();
//
// tx_final.validate().unwrap();
//
// }
/// Simulate the standard exchange between 2 parties when creating a basic
/// 2 inputs, 2 outputs transaction.
#[test]

View file

@ -324,7 +324,7 @@ impl Committed for Transaction {
&self.outputs
}
fn overage(&self) -> i64 {
(self.fee() as i64)
self.fee() as i64
}
}
@ -406,15 +406,6 @@ impl Transaction {
/// * sum of input/output commitments matches sum of kernel commitments after applying offset
/// * each kernel sig is valid (i.e. tx commitments sum to zero, given above is true)
fn verify_kernels(&self) -> Result<(), Error> {
// check that each individual kernel fee is even
// TODO - is this strictly necessary given that we check overall tx fee?
// TODO - move this into verify_fee() check or maybe kernel.verify()?
for k in &self.kernels {
if k.fee & 1 != 0 {
return Err(Error::OddKernelFee);
}
}
// sum all input and output commitments
let io_sum = self.sum_commitments()?;