Skip to content

Commit

Permalink
use the name convert_to_default_chain_token_gasprice
Browse files Browse the repository at this point in the history
  • Loading branch information
qizhou committed Mar 25, 2020
1 parent 1285983 commit c3a6205
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions quarkchain/cluster/shard_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
apply_transaction,
validate_transaction,
apply_xshard_deposit,
get_genesis_gasprice,
convert_to_default_chain_token_gasprice,
)
from quarkchain.evm.specials import SystemContract
from quarkchain.evm.state import State as EvmState
Expand Down Expand Up @@ -543,10 +543,10 @@ def add_tx(self, tx: TypedTransaction, xshard_gas_limit=None):
# Don't add the tx if the gasprice in QKC is too low.
# Note that this is not enforced by consensus,
# but miners will likely discard the tx if the gasprice is too low.
genesis_gasprice = get_genesis_gasprice(
default_gasprice = convert_to_default_chain_token_gasprice(
evm_state, evm_tx.gas_token_id, evm_tx.gasprice
)
if genesis_gasprice < self.env.quark_chain_config.MIN_TX_POOL_GAS_PRICE:
if default_gasprice < self.env.quark_chain_config.MIN_TX_POOL_GAS_PRICE:
return False

self.tx_queue.add_transaction(tx)
Expand Down Expand Up @@ -1202,11 +1202,11 @@ def __add_transactions_to_block(self, block: MinorBlock, evm_state: EvmState):
evm_tx = tx.tx.to_evm_tx()
evm_tx.set_quark_chain_config(self.env.quark_chain_config)

genesis_gasprice = get_genesis_gasprice(
default_gasprice = convert_to_default_chain_token_gasprice(
evm_state, evm_tx.gas_token_id, evm_tx.gasprice
)
# simply ignore tx with lower gas price than specified
if genesis_gasprice < self.env.quark_chain_config.MIN_MINING_GAS_PRICE:
if default_gasprice < self.env.quark_chain_config.MIN_MINING_GAS_PRICE:
continue

# check if TX is disabled
Expand Down
6 changes: 4 additions & 2 deletions quarkchain/cluster/tests/test_shard_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
get_gas_utility_info,
pay_native_token_as_gas,
validate_transaction,
get_genesis_gasprice,
convert_to_default_chain_token_gasprice,
)
from quarkchain.evm.specials import SystemContract
from quarkchain.evm.state import State as EvmState
Expand Down Expand Up @@ -3275,7 +3275,9 @@ def tx_gen(data: str, value=None, transfer_token_id=None):
# get the gas utility information by calling the get_gas_utility_info function
refund_percentage, gas_price = get_gas_utility_info(evm_state, token_id, 60000)
self.assertEqual((refund_percentage, gas_price), (60, 2))
self.assertEqual(get_genesis_gasprice(evm_state, token_id, 60000), 2)
self.assertEqual(
convert_to_default_chain_token_gasprice(evm_state, token_id, 60000), 2
)
# exchange the Qkc with the native token
refund_percentage, gas_price = pay_native_token_as_gas(
evm_state, token_id, 1, 60000
Expand Down
2 changes: 1 addition & 1 deletion quarkchain/evm/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def mk_receipt(state, success, logs, contract_address, contract_full_shard_key):
return o


def get_genesis_gasprice(state, token_id, gas_price):
def convert_to_default_chain_token_gasprice(state, token_id, gas_price):
if token_id == state.shard_config.default_chain_token:
return gas_price
snapshot = state.snapshot()
Expand Down

0 comments on commit c3a6205

Please sign in to comment.