Skip to content

Commit

Permalink
Merge pull request #75 from peaqnetwork/feat/1208500128481486_evm_fee…
Browse files Browse the repository at this point in the history
…_unreachable

Feat/1208500128481486 evm fee unreachable
  • Loading branch information
sfffaaa authored Oct 15, 2024
2 parents c5da549 + 7266cdf commit 9cdcba1
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 142 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ eth-account==0.9.0
web3==6.11.2
pytest==7.4.3
python-on-whales==0.66.0
eth-typing==3.5.2
20 changes: 1 addition & 19 deletions tests/bridge_asset_factory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import calculate_asset_to_evm_address
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
from tools.peaq_eth_utils import get_eth_info
from tools.constants import KP_GLOBAL_SUDO
from tools.peaq_eth_utils import sign_and_submit_evm_transaction
from web3 import Web3
Expand Down Expand Up @@ -58,9 +58,6 @@ def evm_asset_create(self, contract, eth_kp_src, asset_id, eth_admin, min_balanc
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
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(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(10, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand Down Expand Up @@ -123,9 +120,6 @@ def evm_asset_start_destroy(self, contract, eth_kp_src, asset_id):
asset_id,
).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(10, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -138,9 +132,6 @@ def evm_asset_finish_destroy(self, contract, eth_kp_src, asset_id):
asset_id,
).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(50000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(10, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -153,9 +144,6 @@ def evm_asset_destroy_accounts(self, contract, eth_kp_src, asset_id):
asset_id,
).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': 10633039,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(10, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -168,9 +156,6 @@ def evm_asset_destroy_approvals(self, contract, eth_kp_src, asset_id):
asset_id,
).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': 10633039,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(1, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand Down Expand Up @@ -210,9 +195,6 @@ def batch_all_execute(self, eth_kp, addrs, values, calls):
[0] * len(addrs)
).build_transaction({
'from': self._kp_creator['kp'].ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': self._w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': self._w3.to_wei(10, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id
})
Expand Down
11 changes: 1 addition & 10 deletions tests/bridge_balance_erc20_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tools.constants import KP_GLOBAL_SUDO
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
from tools.peaq_eth_utils import get_eth_info
from peaq.utils import get_chain
from tools.utils import batch_fund
from web3 import Web3
Expand Down Expand Up @@ -68,9 +68,6 @@ def evm_erc20_transfer(self, contract, eth_kp_src, eth_dst, token_num):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.transfer(eth_dst, token_num).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -81,9 +78,6 @@ def evm_erc20_approval(self, contract, eth_kp_src, eth_approval, token_num):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.approve(eth_approval, token_num).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -94,9 +88,6 @@ def evm_balance_erc20_transfer_from(self, contract, eth_kp, eth_from, eth_to, to
nonce = w3.eth.get_transaction_count(eth_kp.ss58_address)
tx = contract.functions.transferFrom(eth_from, eth_to, token_num).build_transaction({
'from': eth_kp.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand Down
8 changes: 2 additions & 6 deletions tests/bridge_batch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ def _fund_eth_account(self):
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(21000, 'gwei'),
'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'),
'nonce': 0,
'chainId': self.eth_chain_id})
return tx['data']
Expand All @@ -76,9 +73,6 @@ def test_batch_all(self):
[0, 0],
).build_transaction({
'from': kp_sign.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': self.w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self.eth_chain_id
})
Expand All @@ -101,6 +95,7 @@ def test_batch_some(self):
kp_sign = self.kp_eth['kp']
contract = get_contract(self.w3, BATCH_ADDRESS, ABI_FILE)
nonce = self.w3.eth.get_transaction_count(kp_sign.ss58_address)
# We have to setup the fee by ourselves to avoid the fee error
tx = contract.functions.batchSome(
[Web3.to_checksum_address(STORAGE_ADDRESS),
Web3.to_checksum_address(STORAGE_ADDRESS),
Expand Down Expand Up @@ -136,6 +131,7 @@ def test_batch_some_until_fail(self):
kp_sign = self.kp_eth['kp']
contract = get_contract(self.w3, BATCH_ADDRESS, ABI_FILE)
nonce = self.w3.eth.get_transaction_count(kp_sign.ss58_address)
# We have to setup the fee by ourselves to avoid the fee error
tx = contract.functions.batchSomeUntilFailure(
[Web3.to_checksum_address(STORAGE_ADDRESS),
Web3.to_checksum_address(STORAGE_ADDRESS),
Expand Down
10 changes: 0 additions & 10 deletions tests/bridge_did_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import pprint
pp = pprint.PrettyPrinter(indent=4)
GAS_LIMIT = 4294967

KEY = generate_random_hex()
VALUE = generate_random_hex()
Expand All @@ -33,9 +32,6 @@ def _eth_add_attribute(self, contract, eth_kp_src, evm_addr, key, value):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.addAttribute(evm_addr, key, value, VALIDITY).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self.eth_chain_id})

Expand All @@ -49,9 +45,6 @@ def _eth_update_attribute(self, contract, eth_kp_src, evm_addr, key, value):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.updateAttribute(evm_addr, key, value, VALIDITY).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self.eth_chain_id})

Expand All @@ -65,9 +58,6 @@ def _eth_remove_attribute(self, contract, eth_kp_src, evm_addr, key):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.removeAttribute(evm_addr, key).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self.eth_chain_id})

Expand Down
5 changes: 1 addition & 4 deletions tests/bridge_erc20_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import get_eth_chain_id
from tools.peaq_eth_utils import calculate_asset_to_evm_address
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
from tools.peaq_eth_utils import get_eth_info
from web3 import Web3


Expand Down Expand Up @@ -48,9 +48,6 @@ def evm_erc20_transfer(self, contract, eth_kp_src, eth_dst, token_num):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.transfer(eth_dst, token_num).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand Down
20 changes: 1 addition & 19 deletions tests/bridge_parachain_staking_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from tools.peaq_eth_utils import get_contract
from tools.peaq_eth_utils import get_eth_chain_id
# , calculate_evm_default_addr
from tools.peaq_eth_utils import GAS_LIMIT, get_eth_info
from tools.peaq_eth_utils import get_eth_info
from tools.evm_claim_sign import calculate_claim_signature, claim_account
from tools.constants import KP_GLOBAL_SUDO, KP_COLLATOR
from peaq.utils import get_block_hash
Expand Down Expand Up @@ -66,9 +66,6 @@ def evm_join_delegators(self, contract, eth_kp_src, sub_collator_addr, stake):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.joinDelegators(sub_collator_addr, stake).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': 10633039,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -79,9 +76,6 @@ def evm_delegator_stake_more(self, contract, eth_kp_src, sub_collator_addr, stak
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.delegatorStakeMore(sub_collator_addr, stake).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -92,9 +86,6 @@ def evm_delegator_stake_less(self, contract, eth_kp_src, sub_collator_addr, stak
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.delegatorStakeLess(sub_collator_addr, stake).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -105,9 +96,6 @@ def evm_delegator_leave_delegators(self, contract, eth_kp_src):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.leaveDelegators().build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -118,9 +106,6 @@ def evm_delegator_revoke_delegation(self, contract, eth_kp_src, sub_collator_add
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.revokeDelegation(sub_collator_addr).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -131,9 +116,6 @@ def evm_delegator_unlock_unstaked(self, contract, eth_kp_src, eth_addr):
nonce = w3.eth.get_transaction_count(eth_kp_src.ss58_address)
tx = contract.functions.unlockUnstaked(eth_addr).build_transaction({
'from': eth_kp_src.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand Down
3 changes: 0 additions & 3 deletions tests/bridge_rbac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ class RbacErrorType(enum.Enum):
def _calcualte_evm_basic_req(substrate, w3, addr):
return {
'from': addr,
'gas': 10633039,
'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)
}
Expand Down
3 changes: 0 additions & 3 deletions tests/bridge_storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
def _calcualte_evm_basic_req(substrate, w3, addr):
return {
'from': addr,
'gas': GAS_LIMIT,
'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)
}
Expand Down
9 changes: 0 additions & 9 deletions tests/bridge_vest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ 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': 42940,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -49,9 +46,6 @@ 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': 42940,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand All @@ -62,9 +56,6 @@ 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': 42940,
'maxFeePerGas': w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self._eth_chain_id})

Expand Down
10 changes: 2 additions & 8 deletions tests/bridge_xcmutils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def setup_sibling_parachain_account(self):
chain = get_modified_chain_spec(chain_spec)
if chain == 'peaq-dev':
self.sibling_parachain_addr = '5HYXs9665LtfnxvBz9FrXCrUGwNTWBrkotqtdFw1VAsYAiiJ'
elif chain == 'krest':
elif chain == 'krest-network':
self.sibling_parachain_addr = '5Ex5h1ExXEX3DkLc3gPr7yhCgvUmovLV16A7NATbeJH6UScH'
elif chain == 'peaq':
elif chain == 'peaq-network':
self.sibling_parachain_addr = '5HSpy8Hc4ciygtDTHTdj6FKpPvwXDjY8riWMaqDkCgbiHfAx'

def _fund_eth_account(self):
Expand Down Expand Up @@ -205,9 +205,6 @@ def test_xcm_execute(self):
encoded_calldata, 20000000000,
).build_transaction({
'from': kp_sign.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': self.w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self.eth_chain_id
})
Expand Down Expand Up @@ -241,9 +238,6 @@ def test_xcm_send(self):
[1, ['0x00'+f'00000{hex(ACA_PD_CHAIN_ID)[2:]}']], encoded_calldata,
).build_transaction({
'from': kp_sign.ss58_address,
'gas': GAS_LIMIT,
'maxFeePerGas': self.w3.to_wei(21000, 'gwei'),
'maxPriorityFeePerGas': self.w3.to_wei(2, 'gwei'),
'nonce': nonce,
'chainId': self.eth_chain_id
})
Expand Down
Loading

0 comments on commit 9cdcba1

Please sign in to comment.