From 65c0a4b7b0a48423fc4ca6e70796dbeadfa6fdd4 Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Tue, 13 Mar 2018 02:39:22 +0000 Subject: [PATCH] Fee burning no more. Fixes #767 --- chain/src/txhashset.rs | 4 +-- core/src/consensus.rs | 2 +- core/src/core/block.rs | 10 ++----- core/src/core/mod.rs | 52 ------------------------------------ core/src/core/transaction.rs | 11 +------- 5 files changed, 6 insertions(+), 73 deletions(-) diff --git a/chain/src/txhashset.rs b/chain/src/txhashset.rs index ce3a2d24..f1c30631 100644 --- a/chain/src/txhashset.rs +++ b/chain/src/txhashset.rs @@ -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 { diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 8d222bd4..9d8d5b66 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -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 diff --git a/core/src/core/block.rs b/core/src/core/block.rs index 8da53a54..d16df61b 100644 --- a/core/src/core/block.rs +++ b/core/src/core/block.rs @@ -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 { diff --git a/core/src/core/mod.rs b/core/src/core/mod.rs index d21e149d..3cacb370 100644 --- a/core/src/core/mod.rs +++ b/core/src/core/mod.rs @@ -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] diff --git a/core/src/core/transaction.rs b/core/src/core/transaction.rs index d0e419be..0f05c59b 100644 --- a/core/src/core/transaction.rs +++ b/core/src/core/transaction.rs @@ -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()?;