Sensible gas limits for eth_sendTransaction (#953)
* Sensible gas limits for eth_sendTransaction Fixes #859 * Compile fix. * Remove !.
This commit is contained in:
parent
01e7d2d872
commit
d909bc05c4
@ -132,8 +132,11 @@ pub trait MinerService : Send + Sync {
|
|||||||
/// Returns highest transaction nonce for given address.
|
/// Returns highest transaction nonce for given address.
|
||||||
fn last_nonce(&self, address: &Address) -> Option<U256>;
|
fn last_nonce(&self, address: &Address) -> Option<U256>;
|
||||||
|
|
||||||
/// Suggested gas price
|
/// Suggested gas price.
|
||||||
fn sensible_gas_price(&self) -> U256 { x!(20000000000u64) }
|
fn sensible_gas_price(&self) -> U256 { x!(20000000000u64) }
|
||||||
|
|
||||||
|
/// Suggested gas limit.
|
||||||
|
fn sensible_gas_limit(&self) -> U256 { x!(21000) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mining status
|
/// Mining status
|
||||||
|
@ -201,6 +201,10 @@ impl MinerService for Miner {
|
|||||||
*self.transaction_queue.lock().unwrap().minimal_gas_price() * x!(110) / x!(100)
|
*self.transaction_queue.lock().unwrap().minimal_gas_price() * x!(110) / x!(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sensible_gas_limit(&self) -> U256 {
|
||||||
|
*self.gas_floor_target.read().unwrap() / x!(5)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the author that we will seal blocks as.
|
/// Get the author that we will seal blocks as.
|
||||||
fn author(&self) -> Address {
|
fn author(&self) -> Address {
|
||||||
*self.author.read().unwrap()
|
*self.author.read().unwrap()
|
||||||
|
@ -622,9 +622,9 @@ impl Configuration {
|
|||||||
let mut secret_store = SecretStore::new_in(Path::new(&self.keys_path()));
|
let mut secret_store = SecretStore::new_in(Path::new(&self.keys_path()));
|
||||||
if self.args.cmd_new {
|
if self.args.cmd_new {
|
||||||
println!("Please note that password is NOT RECOVERABLE.");
|
println!("Please note that password is NOT RECOVERABLE.");
|
||||||
println!("Type password: ");
|
print!("Type password: ");
|
||||||
let password = read_password().unwrap();
|
let password = read_password().unwrap();
|
||||||
println!("Repeat password: ");
|
print!("Repeat password: ");
|
||||||
let password_repeat = read_password().unwrap();
|
let password_repeat = read_password().unwrap();
|
||||||
if password != password_repeat {
|
if password != password_repeat {
|
||||||
println!("Passwords do not match!");
|
println!("Passwords do not match!");
|
||||||
|
@ -40,14 +40,6 @@ use v1::helpers::{PollFilter, PollManager, ExternalMinerService, ExternalMiner};
|
|||||||
use util::keys::store::AccountProvider;
|
use util::keys::store::AccountProvider;
|
||||||
use serde;
|
use serde;
|
||||||
|
|
||||||
fn default_gas() -> U256 {
|
|
||||||
U256::from(21_000)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_call_gas() -> U256 {
|
|
||||||
U256::from(50_000_000)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Eth rpc implementation.
|
/// Eth rpc implementation.
|
||||||
pub struct EthClient<C, S, A, M, EM = ExternalMiner>
|
pub struct EthClient<C, S, A, M, EM = ExternalMiner>
|
||||||
where C: BlockChainClient,
|
where C: BlockChainClient,
|
||||||
@ -180,7 +172,7 @@ impl<C, S, A, M, EM> EthClient<C, S, A, M, EM>
|
|||||||
Ok(EthTransaction {
|
Ok(EthTransaction {
|
||||||
nonce: request.nonce.unwrap_or_else(|| client.nonce(&from)),
|
nonce: request.nonce.unwrap_or_else(|| client.nonce(&from)),
|
||||||
action: request.to.map_or(Action::Create, Action::Call),
|
action: request.to.map_or(Action::Create, Action::Call),
|
||||||
gas: request.gas.unwrap_or_else(default_call_gas),
|
gas: request.gas.unwrap_or(U256::from(50_000_000)),
|
||||||
gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()),
|
gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()),
|
||||||
value: request.value.unwrap_or_else(U256::zero),
|
value: request.value.unwrap_or_else(U256::zero),
|
||||||
data: request.data.map_or_else(Vec::new, |d| d.to_vec())
|
data: request.data.map_or_else(Vec::new, |d| d.to_vec())
|
||||||
@ -498,7 +490,7 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
.map(|nonce| nonce + U256::one()))
|
.map(|nonce| nonce + U256::one()))
|
||||||
.unwrap_or_else(|| client.nonce(&request.from)),
|
.unwrap_or_else(|| client.nonce(&request.from)),
|
||||||
action: request.to.map_or(Action::Create, Action::Call),
|
action: request.to.map_or(Action::Create, Action::Call),
|
||||||
gas: request.gas.unwrap_or_else(default_gas),
|
gas: request.gas.unwrap_or_else(|| miner.sensible_gas_limit()),
|
||||||
gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()),
|
gas_price: request.gas_price.unwrap_or_else(|| miner.sensible_gas_price()),
|
||||||
value: request.value.unwrap_or_else(U256::zero),
|
value: request.value.unwrap_or_else(U256::zero),
|
||||||
data: request.data.map_or_else(Vec::new, |d| d.to_vec()),
|
data: request.data.map_or_else(Vec::new, |d| d.to_vec()),
|
||||||
@ -524,6 +516,7 @@ impl<C, S, A, M, EM> Eth for EthClient<C, S, A, M, EM>
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn call(&self, params: Params) -> Result<Value, Error> {
|
fn call(&self, params: Params) -> Result<Value, Error> {
|
||||||
|
trace!(target: "jsonrpc", "call: {:?}", params);
|
||||||
from_params_discard_second(params).and_then(|(request, )| {
|
from_params_discard_second(params).and_then(|(request, )| {
|
||||||
let signed = try!(self.sign_call(request));
|
let signed = try!(self.sign_call(request));
|
||||||
let client = take_weak!(self.client);
|
let client = take_weak!(self.client);
|
||||||
|
Loading…
Reference in New Issue
Block a user