Skip to content

Commit

Permalink
Fractional gas factor
Browse files Browse the repository at this point in the history
  • Loading branch information
dvush committed Jun 17, 2020
1 parent 068ad05 commit 01e4387
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions core/eth_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct ETHClient<T: Transport> {
pub contract_addr: H160,
pub contract: ethabi::Contract,
pub chain_id: u8,
pub gas_price_factor: usize,
pub gas_price_factor: f64,
pub web3: Web3<T>,
}

Expand Down Expand Up @@ -60,7 +60,7 @@ impl<T: Transport> ETHClient<T> {
operator_pk: H256,
contract_eth_addr: H160,
chain_id: u8,
gas_price_factor: usize,
gas_price_factor: f64,
) -> Self {
Self {
sender_account: operator_eth_addr,
Expand Down Expand Up @@ -105,7 +105,8 @@ impl<T: Transport> ETHClient<T> {

pub async fn get_gas_price(&self) -> Result<U256, failure::Error> {
let mut network_gas_price = self.web3.eth().gas_price().compat().await?;
network_gas_price *= U256::from(self.gas_price_factor);
let percent_gas_price_factor = U256::from((self.gas_price_factor * 100.0).round() as u64);
network_gas_price = (network_gas_price * percent_gas_price_factor) / U256::from(100);
Ok(network_gas_price)
}

Expand Down
2 changes: 1 addition & 1 deletion core/models/src/config_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub struct ConfigurationOptions {
pub operator_commit_eth_addr: H160,
pub operator_private_key: Option<H256>,
pub chain_id: u8,
pub gas_price_factor: usize,
pub gas_price_factor: f64,
pub prover_server_address: SocketAddr,
pub confirmations_for_eth_event: u64,
pub api_requests_caches_size: usize,
Expand Down
2 changes: 1 addition & 1 deletion core/testkit/src/eth_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<T: Transport> EthereumAccount<T> {
transport: T,
contract_address: Address,
chain_id: u8,
gas_price_factor: usize,
gas_price_factor: f64,
) -> Self {
let main_contract_eth_client = ETHClient::new(
transport,
Expand Down
2 changes: 1 addition & 1 deletion core/testkit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ pub fn perform_basic_operations(token: u16, test_setup: &mut TestSetup, deposit_

pub struct TestkitConfig {
pub chain_id: u8,
pub gas_price_factor: usize,
pub gas_price_factor: f64,
pub web3_url: String,
}

Expand Down
2 changes: 1 addition & 1 deletion etc/env/dev.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ VERIFIER_ADDR=0xDAbb67b676F5b01FcC8997Cc8439846D0d8078ca
DEPLOY_FACTORY_ADDR=0xFC073319977e314F251EAE6ae6bE76B0B3BAeeCF
GENESIS_TX_HASH=0xb99ebfea46cbe05a21cd80fe5597d97b204befc52a16303f579c607dc1ac2e2e
CHAIN_ID=9
GAS_PRICE_FACTOR=1
GAS_PRICE_FACTOR=1.5
ETH_NETWORK=localhost

# Set in env file only for local development, for production, staging and testnet it is configured on k8s only.
Expand Down

0 comments on commit 01e4387

Please sign in to comment.