forked from openethereum/openethereum
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split tx fee to author and governance
- Loading branch information
Showing
15 changed files
with
513 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[ | ||
{ | ||
"inputs": [], | ||
"name": "getFeesParams", | ||
"outputs": [ | ||
{ | ||
"internalType": "address", | ||
"name": "addr", | ||
"type": "address" | ||
}, | ||
{ | ||
"internalType": "uint256", | ||
"name": "percent", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "getGasPrice", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
crates/ethcore/src/engines/authority_round/block_gas_price.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2015-2019 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity Ethereum. | ||
|
||
// Parity Ethereum is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity Ethereum is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! A client interface for interacting with the block gas limit contract. | ||
use client::{BlockChainClient, BlockId}; | ||
use types::header::Header; | ||
use ethabi::FunctionOutputDecoder; | ||
use ethabi_contract::use_contract; | ||
use ethereum_types::{Address, U256}; | ||
use log::{debug, error}; | ||
|
||
use_contract!(contract, "res/contracts/fees.json"); | ||
|
||
pub fn block_gas_price(full_client: &dyn BlockChainClient, header: &Header, address: Address) -> Option<U256> { | ||
let (data, decoder) = contract::functions::get_gas_price::call(); | ||
let value = full_client.call_contract(BlockId::Hash(*header.parent_hash()), address, data).map_err(|err| { | ||
error!(target: "fees", "Contract call failed. Not changing the block gas price. {:?}", err); | ||
}).ok()?; | ||
if value.is_empty() { | ||
debug!(target: "fees", "Contract call returned nothing. Not changing the block gas price."); | ||
None | ||
} else { | ||
decoder.decode(&value).ok() | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
crates/ethcore/src/engines/authority_round/block_tx_fee.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2015-2019 Parity Technologies (UK) Ltd. | ||
// This file is part of Parity Ethereum. | ||
|
||
// Parity Ethereum is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Parity Ethereum is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! A client interface for interacting with the block gas limit contract. | ||
use client::{BlockChainClient, BlockId}; | ||
use types::header::Header; | ||
use ethabi::{self, ParamType}; | ||
use ethabi_contract::use_contract; | ||
use ethereum_types::{Address}; | ||
use log::{debug, error}; | ||
use crate::executive::FeesParams; | ||
|
||
use_contract!(contract, "res/contracts/fees.json"); | ||
|
||
pub fn block_tx_fee(full_client: &dyn BlockChainClient, header: &Header, address: Address) -> Option<FeesParams> { | ||
let (data, _decoder) = contract::functions::get_fees_params::call(); | ||
let output = full_client.call_contract(BlockId::Hash(*header.parent_hash()), address, data).map_err(|err| { | ||
error!(target: "fees", "Contract call failed. Not changing the tx fee params. {:?}", err); | ||
}).ok()?; | ||
if output.is_empty() { | ||
debug!(target: "fees", "Contract call returned nothing. Not changing the tx fee params."); | ||
None | ||
} else { | ||
let types = &[ | ||
ParamType::Address, | ||
ParamType::Uint(256), | ||
]; | ||
|
||
let tokens = ethabi::decode(types, &output).ok()?; | ||
|
||
assert!(tokens.len() == 2); | ||
|
||
let params = FeesParams { | ||
address: tokens[0].clone().to_address().unwrap(), | ||
governance_part: tokens[1].clone().to_uint().unwrap(), | ||
}; | ||
Some(params) | ||
} | ||
} |
Oops, something went wrong.