diff --git a/tests/bridge_asset_factory_test.py b/tests/bridge_asset_factory_test.py index 1dc9b43..9c95238 100644 --- a/tests/bridge_asset_factory_test.py +++ b/tests/bridge_asset_factory_test.py @@ -40,7 +40,7 @@ def _fund_users(self): 'transfer_keep_alive', { 'dest': self._kp_creator['substrate'], - 'value': 100 * 10 ** 18, + 'value': 10000 * 10 ** 18, } ) batch.compose_call( @@ -48,7 +48,7 @@ def _fund_users(self): 'transfer_keep_alive', { 'dest': self._kp_admin['substrate'], - 'value': 100 * 10 ** 18, + 'value': 10000 * 10 ** 18, } ) batch.execute() @@ -59,8 +59,8 @@ def evm_asset_create(self, contract, eth_kp_src, asset_id, eth_admin, min_balanc tx = contract.functions.create(asset_id, eth_admin.ss58_address, min_balance).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), - 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), + 'maxPriorityFeePerGas': w3.to_wei(10, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -124,8 +124,8 @@ def evm_asset_start_destroy(self, contract, eth_kp_src, asset_id): ).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), - 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), + 'maxPriorityFeePerGas': w3.to_wei(10, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -139,8 +139,8 @@ def evm_asset_finish_destroy(self, contract, eth_kp_src, asset_id): ).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), - 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), + 'maxFeePerGas': w3.to_wei(50000, 'gwei'), + 'maxPriorityFeePerGas': w3.to_wei(10, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -154,8 +154,8 @@ def evm_asset_destroy_accounts(self, contract, eth_kp_src, asset_id): ).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': 10633039, - 'maxFeePerGas': w3.to_wei(300, 'gwei'), - 'maxPriorityFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), + 'maxPriorityFeePerGas': w3.to_wei(10, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -169,8 +169,8 @@ def evm_asset_destroy_approvals(self, contract, eth_kp_src, asset_id): ).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': 10633039, - 'maxFeePerGas': w3.to_wei(300, 'gwei'), - 'maxPriorityFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), + 'maxPriorityFeePerGas': w3.to_wei(1, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -211,8 +211,8 @@ def batch_all_execute(self, eth_kp, addrs, values, calls): ).build_transaction({ 'from': self._kp_creator['kp'].ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': self._w3.to_wei(250, 'gwei'), - 'maxPriorityFeePerGas': self._w3.to_wei(2, 'gwei'), + 'maxFeePerGas': self._w3.to_wei(21000, 'gwei'), + 'maxPriorityFeePerGas': self._w3.to_wei(10, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id }) diff --git a/tests/bridge_balance_erc20_test.py b/tests/bridge_balance_erc20_test.py index 4d743d8..bd8090b 100644 --- a/tests/bridge_balance_erc20_test.py +++ b/tests/bridge_balance_erc20_test.py @@ -69,7 +69,7 @@ def evm_erc20_transfer(self, contract, eth_kp_src, eth_dst, token_num): tx = contract.functions.transfer(eth_dst, token_num).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -82,7 +82,7 @@ def evm_erc20_approval(self, contract, eth_kp_src, eth_approval, token_num): tx = contract.functions.approve(eth_approval, token_num).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -95,7 +95,7 @@ def evm_balance_erc20_transfer_from(self, contract, eth_kp, eth_from, eth_to, to tx = contract.functions.transferFrom(eth_from, eth_to, token_num).build_transaction({ 'from': eth_kp.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) diff --git a/tests/bridge_batch_test.py b/tests/bridge_batch_test.py index bc19172..4cc9dc1 100644 --- a/tests/bridge_batch_test.py +++ b/tests/bridge_batch_test.py @@ -53,7 +53,7 @@ def get_did_calldata(self, eth_kp, addr, contract, key, value): tx = contract.functions.add_attribute(eth_kp.ss58_address, key, value, 1000000).build_transaction({ 'from': eth_kp.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': self.w3.to_wei(250, 'gwei'), + 'maxFeePerGas': self.w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'), 'nonce': 0, 'chainId': self.eth_chain_id}) @@ -77,7 +77,7 @@ def test_batch_all(self): ).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': self.w3.to_wei(250, 'gwei'), + 'maxFeePerGas': self.w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self.eth_chain_id @@ -113,7 +113,7 @@ def test_batch_some(self): ).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': self.w3.to_wei(250, 'gwei'), + 'maxFeePerGas': self.w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self.eth_chain_id @@ -148,7 +148,7 @@ def test_batch_some_until_fail(self): ).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': self.w3.to_wei(250, 'gwei'), + 'maxFeePerGas': self.w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self.eth_chain_id diff --git a/tests/bridge_did_test.py b/tests/bridge_did_test.py index fc5ce09..ac1a1f2 100644 --- a/tests/bridge_did_test.py +++ b/tests/bridge_did_test.py @@ -34,7 +34,7 @@ def _eth_add_attribute(self, contract, eth_kp_src, evm_addr, key, value): tx = contract.functions.addAttribute(evm_addr, key, value, VALIDITY).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self.eth_chain_id}) @@ -50,7 +50,7 @@ def _eth_update_attribute(self, contract, eth_kp_src, evm_addr, key, value): tx = contract.functions.updateAttribute(evm_addr, key, value, VALIDITY).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self.eth_chain_id}) @@ -66,7 +66,7 @@ def _eth_remove_attribute(self, contract, eth_kp_src, evm_addr, key): tx = contract.functions.removeAttribute(evm_addr, key).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self.eth_chain_id}) diff --git a/tests/bridge_erc20_test.py b/tests/bridge_erc20_test.py index c24e9df..3fdccc0 100644 --- a/tests/bridge_erc20_test.py +++ b/tests/bridge_erc20_test.py @@ -49,7 +49,7 @@ def evm_erc20_transfer(self, contract, eth_kp_src, eth_dst, token_num): tx = contract.functions.transfer(eth_dst, token_num).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) diff --git a/tests/bridge_parachain_staking_test.py b/tests/bridge_parachain_staking_test.py index 2b14e44..61801c2 100644 --- a/tests/bridge_parachain_staking_test.py +++ b/tests/bridge_parachain_staking_test.py @@ -67,7 +67,7 @@ def evm_join_delegators(self, contract, eth_kp_src, sub_collator_addr, stake): tx = contract.functions.joinDelegators(sub_collator_addr, stake).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': 10633039, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -80,7 +80,7 @@ def evm_delegator_stake_more(self, contract, eth_kp_src, sub_collator_addr, stak tx = contract.functions.delegatorStakeMore(sub_collator_addr, stake).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -93,7 +93,7 @@ def evm_delegator_stake_less(self, contract, eth_kp_src, sub_collator_addr, stak tx = contract.functions.delegatorStakeLess(sub_collator_addr, stake).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -106,7 +106,7 @@ def evm_delegator_leave_delegators(self, contract, eth_kp_src): tx = contract.functions.leaveDelegators().build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -119,7 +119,7 @@ def evm_delegator_revoke_delegation(self, contract, eth_kp_src, sub_collator_add tx = contract.functions.revokeDelegation(sub_collator_addr).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -132,7 +132,7 @@ def evm_delegator_unlock_unstaked(self, contract, eth_kp_src, eth_addr): tx = contract.functions.unlockUnstaked(eth_addr).build_transaction({ 'from': eth_kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) diff --git a/tests/bridge_rbac_test.py b/tests/bridge_rbac_test.py index c37f9a1..f525eae 100644 --- a/tests/bridge_rbac_test.py +++ b/tests/bridge_rbac_test.py @@ -69,8 +69,8 @@ def _calcualte_evm_basic_req(substrate, w3, addr): return { 'from': addr, 'gas': 10633039, - 'maxFeePerGas': w3.to_wei(300, 'gwei'), - 'maxPriorityFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), + 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': w3.eth.get_transaction_count(addr), 'chainId': get_eth_chain_id(substrate) } diff --git a/tests/bridge_storage_test.py b/tests/bridge_storage_test.py index 547fa32..33a7b94 100644 --- a/tests/bridge_storage_test.py +++ b/tests/bridge_storage_test.py @@ -32,7 +32,7 @@ def _calcualte_evm_basic_req(substrate, w3, addr): return { 'from': addr, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': w3.eth.get_transaction_count(addr), 'chainId': get_eth_chain_id(substrate) diff --git a/tests/bridge_vest_test.py b/tests/bridge_vest_test.py index d303802..3781bf1 100644 --- a/tests/bridge_vest_test.py +++ b/tests/bridge_vest_test.py @@ -36,8 +36,8 @@ def evm_vest_transfer(self, contract, eth_kp_src, evm_dst, number, now): per_block = int(number / VEST_PERIOD) tx = contract.functions.vestedTransfer(evm_dst, int(number), per_block, now).build_transaction({ 'from': eth_kp_src.ss58_address, - 'gas': 10633039, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'gas': 42940, + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -49,8 +49,8 @@ def evm_vest(self, contract, eth_kp_src): nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address) tx = contract.functions.vest().build_transaction({ 'from': eth_kp_src.ss58_address, - 'gas': 10633039, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'gas': 42940, + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) @@ -62,8 +62,8 @@ def evm_vest_other(self, contract, eth_kp_src, evm_dst): nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address) tx = contract.functions.vestOther(evm_dst).build_transaction({ 'from': eth_kp_src.ss58_address, - 'gas': 10633039, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'gas': 42940, + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self._eth_chain_id}) diff --git a/tests/bridge_xcmutils_test.py b/tests/bridge_xcmutils_test.py index 11d734e..a59c3dc 100644 --- a/tests/bridge_xcmutils_test.py +++ b/tests/bridge_xcmutils_test.py @@ -4,7 +4,7 @@ from tools.constants import ACA_PD_CHAIN_ID from tools.runtime_upgrade import wait_until_block_height from tools.peaq_eth_utils import get_contract -from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info +from tools.peaq_eth_utils import get_eth_info from tools.peaq_eth_utils import get_eth_chain_id from substrateinterface import SubstrateInterface, Keypair from peaq.utils import ExtrinsicBatch @@ -20,6 +20,7 @@ import pytest +GAS_LIMIT = 10633039 ABI_FILE = 'ETH/xcmutils/abi' XCMUTILS_ADDRESS = '0x0000000000000000000000000000000000000804' @@ -65,7 +66,7 @@ def _fund_eth_account(self): 'transfer_keep_alive', { 'dest': self.kp_eth['substrate'], - 'value': 100 * 10 ** 18, + 'value': 1000 * 10 ** 18, } ) batch.execute() @@ -205,7 +206,7 @@ def test_xcm_execute(self): ).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': self.w3.to_wei(250, 'gwei'), + 'maxFeePerGas': self.w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self.eth_chain_id @@ -241,7 +242,7 @@ def test_xcm_send(self): ).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': self.w3.to_wei(250, 'gwei'), + 'maxFeePerGas': self.w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': self.eth_chain_id diff --git a/tests/bridge_xtokens_test.py b/tests/bridge_xtokens_test.py index 1436ff6..717d558 100644 --- a/tests/bridge_xtokens_test.py +++ b/tests/bridge_xtokens_test.py @@ -144,7 +144,7 @@ def send_xtoken_transfer(w3, eth_chain_id, kp_sign, kp_dst, parachain_id, asset_ 10 ** 12).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id @@ -164,7 +164,7 @@ def send_xtoken_transfer_multi_asset(w3, eth_chain_id, kp_sign, kp_dst, parachai 10 ** 12).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id @@ -185,7 +185,7 @@ def send_xtoken_transfer_multi_currencies(w3, eth_chain_id, kp_sign, kp_dst, par 10 ** 12).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id @@ -206,7 +206,7 @@ def send_xtoken_transfer_multi_assets(w3, eth_chain_id, kp_sign, kp_dst, paracha 10 ** 12).build_transaction({ 'from': kp_sign.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id diff --git a/tests/delegator_issue_test.py b/tests/delegator_issue_test.py index 4291a43..278bbcc 100644 --- a/tests/delegator_issue_test.py +++ b/tests/delegator_issue_test.py @@ -8,6 +8,7 @@ from tools.constants import WS_URL, KP_GLOBAL_SUDO, KP_COLLATOR from peaq.utils import ExtrinsicBatch, get_account_balance from tests.utils_func import restart_parachain_and_runtime_upgrade +from tools.utils import set_block_reward_configuration def add_delegator(substrate, kp_delegator, addr_collator, stake_number): @@ -64,6 +65,8 @@ def set_reward_rate(substrate, collator, delegator): @pytest.mark.substrate class TestDelegatorIssue(unittest.TestCase): def setUp(self): + restart_parachain_and_runtime_upgrade() + self.substrate = SubstrateInterface( url=WS_URL, ) @@ -72,9 +75,28 @@ def setUp(self): Keypair.create_from_mnemonic(Keypair.generate_mnemonic()), Keypair.create_from_mnemonic(Keypair.generate_mnemonic()) ] + self.ori_reward_config = self.substrate.query( + module='BlockReward', + storage_function='RewardDistributionConfigStorage', + ) + self.set_collator_delegator_precentage() def tearDown(self): - restart_parachain_and_runtime_upgrade() + receipt = set_block_reward_configuration(self.substrate, self.ori_reward_config.value) + self.assertTrue(receipt.is_success, 'cannot reset the block reward configuration') + + def set_collator_delegator_precentage(self): + set_value = { + 'treasury_percent': 20000000, + 'depin_incentivization_percent': 10000000, + 'collators_delegators_percent': 20000000, + 'depin_staking_percent': 50000000, + 'coretime_percent': 40000000, + 'subsidization_pool_percent': 860000000, + } + receipt = set_block_reward_configuration(self.substrate, set_value) + self.assertTrue(receipt.is_success, + 'cannot setup the block reward configuration') def get_one_collator_without_delegator(self, keys): for key in keys: diff --git a/tests/evm_eth_rpc_test.py b/tests/evm_eth_rpc_test.py index 5005be7..f125450 100644 --- a/tests/evm_eth_rpc_test.py +++ b/tests/evm_eth_rpc_test.py @@ -3,6 +3,8 @@ from substrateinterface import SubstrateInterface, Keypair, KeypairType from peaq.eth import calculate_evm_account, calculate_evm_addr from peaq.extrinsic import transfer +from peaq.utils import ExtrinsicBatch +from tools.constants import KP_GLOBAL_SUDO from tools.constants import WS_URL, ETH_URL from tools.peaq_eth_utils import sign_and_submit_evm_transaction from tools.peaq_eth_utils import get_eth_chain_id @@ -10,6 +12,9 @@ from tools.peaq_eth_utils import call_eth_transfer_a_lot from tools.peaq_eth_utils import get_eth_balance, get_contract from tools.peaq_eth_utils import TX_SUCCESS_STATUS +from tests import utils_func as TestUtils +from tools.peaq_eth_utils import get_eth_info +from tools.utils import batch_fund from web3 import Web3 import unittest @@ -41,7 +46,7 @@ def send_eth_token(w3, kp_src, kp_dst, token_num, eth_chain_id): 'to': kp_dst.ss58_address, 'value': token_num, 'gas': gas, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id @@ -62,7 +67,7 @@ def call_copy(w3, address, kp_src, eth_chain_id, file_name, data): tx = contract.functions.callDatacopy(bytes.fromhex(data)).build_transaction({ 'from': kp_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id}) @@ -83,6 +88,33 @@ def setUp(self): self._w3 = Web3(Web3.HTTPProvider(ETH_URL)) self._eth_deposited_src = calculate_evm_account(self._eth_src) + @pytest.mark.skipif(TestUtils.is_not_peaq_chain() is True, reason='Only peaq chain evm tx change') + def test_evm_fee(self): + self._kp_moon = get_eth_info() + self._kp_mars = get_eth_info() + batch = ExtrinsicBatch(self._conn, KP_GLOBAL_SUDO) + batch_fund(batch, self._kp_moon['substrate'], 1000 * 10 ** 18) + receipt = batch.execute() + self.assertTrue(receipt.is_success) + + prev_balance = self._w3.eth.get_balance(self._kp_moon['kp'].ss58_address) + nonce = self._w3.eth.get_transaction_count(self._kp_moon['kp'].ss58_address) + tx = { + 'from': self._kp_moon['kp'].ss58_address, + 'to': self._kp_mars['kp'].ss58_address, + 'value': 1 * 10 ** 18, + 'gas': 21000, + 'maxFeePerGas': 100 * 10 ** 9, + 'maxPriorityFeePerGas': 1 * 10 ** 9, + 'nonce': nonce, + 'chainId': self._eth_chain_id + } + response = sign_and_submit_evm_transaction(tx, self._w3, self._kp_moon['kp']) + self.assertTrue(response['status'] == TX_SUCCESS_STATUS, f'failed: {response}') + + new_balance = self._w3.eth.get_balance(self._kp_moon['kp'].ss58_address) + self.assertGreater(prev_balance - new_balance - 1 * 10 ** 18, 0.002 * 10 ** 18) + def test_evm_rpc_transfer(self): conn = self._conn eth_chain_id = self._eth_chain_id diff --git a/tests/evm_substrate_test.py b/tests/evm_substrate_test.py index f1ffafa..28b7dd2 100644 --- a/tests/evm_substrate_test.py +++ b/tests/evm_substrate_test.py @@ -39,8 +39,8 @@ def create_constract(substrate, kp_src, eth_src, erc20_bytecode): 'init': erc20_bytecode, 'value': int('0x0', 16), 'gas_limit': 4294967, - 'max_fee_per_gas': 250000000000, - 'max_priority_fee_per_gas': 2000000000, + 'max_fee_per_gas': 21000 * 10 ** 9, + 'max_priority_fee_per_gas': 2 * 10 ** 9, 'nonce': None, 'access_list': [] } @@ -65,7 +65,7 @@ def call_eth_transfer(substrate, kp_src, eth_src, eth_dst): 'input': '0x', 'value': int('0xffff', 16), 'gas_limit': GAS_LIMIT, - 'max_fee_per_gas': 250 * 10 ** 9, + 'max_fee_per_gas': 21000 * 10 ** 9, 'max_priority_fee_per_gas': 2 * 10 ** 9, 'nonce': None, 'access_list': [] @@ -85,7 +85,7 @@ def transfer_erc20_token(substrate, kp_src, eth_src, eth_dst, contract_addr): 'input': f'0xa9059cbb000000000000000000000000{eth_dst.lower()[2:]}00000000000000000000000000000000000000000000000000000000000000{hex(ERC_TOKEN_TRANSFER)[2:]}', # noqa: E501 'value': int('0x0', 16), 'gas_limit': GAS_LIMIT, - 'max_fee_per_gas': 250 * 10 ** 9, + 'max_fee_per_gas': 21000 * 10 ** 9, 'max_priority_fee_per_gas': 2 * 10 ** 9, 'nonce': None, 'access_list': [] diff --git a/tests/pallet_address_unification.py b/tests/pallet_address_unification.py index 142b2c6..c6c26ce 100644 --- a/tests/pallet_address_unification.py +++ b/tests/pallet_address_unification.py @@ -57,7 +57,7 @@ def evm_erc20_trasfer(asset_id, kp_eth_src, kp_eth_dst, amount, eth_chain_id): tx = contract.functions.transfer(kp_eth_dst.ss58_address, amount).build_transaction({ 'from': kp_eth_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id}) diff --git a/tests/pallet_inflation_manager_test.py b/tests/pallet_inflation_manager_test.py index a1703ae..85d9641 100644 --- a/tests/pallet_inflation_manager_test.py +++ b/tests/pallet_inflation_manager_test.py @@ -68,7 +68,7 @@ INFLATION_RECALCULATION = { 'peaq-network': 5256000, - 'peaq-network-fork': 3617954, + 'peaq-network-fork': 5684095, 'peaq-dev': 5256000, 'peaq-dev-fork': 5084632, # Because of the delay TGE diff --git a/tests/pallet_vesting_test.py b/tests/pallet_vesting_test.py index 968eccc..63d0bbc 100644 --- a/tests/pallet_vesting_test.py +++ b/tests/pallet_vesting_test.py @@ -233,10 +233,10 @@ def merge_schedule_test(self, substrate, kp_source, kp_target_second): max(first_starting_block_number, second_starting_block_number)) first_schedule = {'locked': 100 * TOKEN_NUM_BASE_DEV, - 'per_block': 10 * TOKEN_NUM_BASE_DEV, + 'per_block': 1 * TOKEN_NUM_BASE_DEV, 'starting_block': first_starting_block_number} second_schedule = {'locked': 200 * TOKEN_NUM_BASE_DEV, - 'per_block': 20 * TOKEN_NUM_BASE_DEV, + 'per_block': 2 * TOKEN_NUM_BASE_DEV, 'starting_block': second_starting_block_number} print("First vested trasnfer") diff --git a/tests/token_economy_test.py b/tests/token_economy_test.py index 15f1ea4..39f7fb1 100644 --- a/tests/token_economy_test.py +++ b/tests/token_economy_test.py @@ -64,6 +64,14 @@ 'subsidization_pool_percent': 50000000, 'depin_staking_percent': 50000000, 'depin_incentivization_percent': 150000000, + }, + 'peaq-network-fork': { + 'treasury_percent': 650000000, + 'collators_delegators_percent': 0, + 'coretime_percent': 100000000, + 'subsidization_pool_percent': 50000000, + 'depin_staking_percent': 50000000, + 'depin_incentivization_percent': 150000000, } } }] @@ -205,7 +213,7 @@ def test_block_reward(self): block_reward = { 'peaq-dev-fork': int(3.805175038 * 10 ** 18), 'krest-network-fork': int(3.805175038 * 10 ** 18), - 'peaq-network-fork': int(55.93607306 * 10 ** 18), + 'peaq-network-fork': int(27.96803653 * 10 ** 18), } result = get_event( diff --git a/tests/utils_func.py b/tests/utils_func.py index 1e109e2..d342cf4 100644 --- a/tests/utils_func.py +++ b/tests/utils_func.py @@ -36,10 +36,15 @@ def restart_parachain_and_runtime_upgrade(): def is_not_dev_chain(): ws = SubstrateInterface(url=WS_URL) chain_name = get_chain(ws) - print(f'chain_name: {chain_name}') return chain_name not in ['peaq-dev', 'peaq-dev-fork'] +def is_not_peaq_chain(): + ws = SubstrateInterface(url=WS_URL) + chain_name = get_chain(ws) + return chain_name not in ['peaq', 'peaq-network-fork'] + + def is_krest_related_chain(): ws = SubstrateInterface(url=WS_URL) chain_name = get_chain(ws) diff --git a/tests/xcm_transfer_test.py b/tests/xcm_transfer_test.py index 472514a..9d24854 100644 --- a/tests/xcm_transfer_test.py +++ b/tests/xcm_transfer_test.py @@ -275,6 +275,7 @@ def get_parachain_id(self, peaq_substrate): @classmethod def setUpClass(cls): restart_parachain_and_runtime_upgrade() + wait_until_block_height(SubstrateInterface(url=RELAYCHAIN_WS_URL), 3) wait_until_block_height(SubstrateInterface(url=PARACHAIN_WS_URL), 3) wait_until_block_height(SubstrateInterface(url=ACA_WS_URL), 3) diff --git a/tools/evm_sample.py b/tools/evm_sample.py index ccb151b..85cfced 100644 --- a/tools/evm_sample.py +++ b/tools/evm_sample.py @@ -45,7 +45,7 @@ def setup(kp_eth_src): tx = contract.functions.test().build_transaction({ 'from': kp_eth_src.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': ETH_CHAIN_ID}) diff --git a/tools/peaq_eth_utils.py b/tools/peaq_eth_utils.py index e80b840..c854be6 100644 --- a/tools/peaq_eth_utils.py +++ b/tools/peaq_eth_utils.py @@ -40,8 +40,8 @@ def call_eth_transfer_a_lot(substrate, kp_src, eth_src, eth_dst): 'input': '0x', 'value': int('0xfffffffffffffffff', 16), 'gas_limit': GAS_LIMIT, - 'max_fee_per_gas': 250 * 10 ** 9, - 'max_priority_fee_per_gas': 2 * 10 ** 9, + 'max_fee_per_gas': 21000 * 10 ** 9, + 'max_priority_fee_per_gas': 1 * 10 ** 9, 'nonce': None, 'access_list': [] }) @@ -63,7 +63,7 @@ def deploy_contract(w3, kp_src, eth_chain_id, abi_file_name, bytecode): bytecode=bytecode).constructor().build_transaction({ 'from': kp_src.ss58_address, 'gas': 429496, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id}) diff --git a/tools/runtime_upgrade.py b/tools/runtime_upgrade.py index 76b7808..5d93a73 100644 --- a/tools/runtime_upgrade.py +++ b/tools/runtime_upgrade.py @@ -2,6 +2,7 @@ sys.path.append('./') import os import time +import importlib from peaq.utils import ExtrinsicBatch from tools.monkey.monkey_reorg_batch import monkey_execute_extrinsic_batch @@ -145,7 +146,7 @@ def do_runtime_upgrade(wasm_path): remove_asset_id(substrate) upgrade(wasm_path) - wait_for_n_blocks(substrate, 20) + wait_for_n_blocks(substrate, 15) # Cannot move in front of the upgrade because V4 only exists in 1.7.2 update_xcm_default_version(substrate) @@ -178,4 +179,11 @@ def main(): if __name__ == '__main__': + # For the monkey patching to work, the module must be reloaded + # Avoid the dependency on the module name + if 'substrateinterface' in sys.modules: + importlib.reload(sys.modules['substrateinterface']) + if 'peaq.utils' in sys.modules: + importlib.reload(sys.modules['peaq.utils']) + main() diff --git a/tools/uniswap_test_setup.py b/tools/uniswap_test_setup.py index 2541f02..712e2c3 100644 --- a/tools/uniswap_test_setup.py +++ b/tools/uniswap_test_setup.py @@ -44,7 +44,7 @@ def create_asset(substrate, w3, eth_chain_id, contract, owner_kp): tx = contract.functions.create(asset_id, owner_kp.ss58_address, 1000).build_transaction({ 'from': owner_kp.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id}) @@ -82,7 +82,7 @@ def mint_asset(substrate, w3, eth_chain_id, asset_addr, owner_kp, dest_kp, amoun tx = contract.functions.mint(dest_kp.ss58_address, amount).build_transaction({ 'from': owner_kp.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id}) @@ -99,7 +99,7 @@ def approval_asset(substrate, w3, eth_chain_id, asset_addr, owner_kp, addr, amou tx = contract.functions.approve(addr, amount).build_transaction({ 'from': owner_kp.ss58_address, 'gas': GAS_LIMIT, - 'maxFeePerGas': w3.to_wei(250, 'gwei'), + 'maxFeePerGas': w3.to_wei(21000, 'gwei'), 'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'), 'nonce': nonce, 'chainId': eth_chain_id})