Skip to content

Commit

Permalink
remove extra gas for guarded txs & remove field from config
Browse files Browse the repository at this point in the history
  • Loading branch information
popenta committed Apr 18, 2024
1 parent 3b490fd commit 6912288
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class IConfig(Protocol):
gas_limit_set_guardian: int
gas_limit_guard_account: int
gas_limit_unguard_account: int
extra_gas_limit_for_guarded_transaction: int


class AccountTransactionsFactory:
Expand Down Expand Up @@ -56,42 +55,36 @@ def create_transaction_for_setting_guardian(
service_id.encode().hex()
]

gas_limit = self.config.gas_limit_set_guardian + self.config.extra_gas_limit_for_guarded_transaction

return TransactionBuilder(
config=self.config,
sender=sender,
receiver=sender,
data_parts=data_parts,
gas_limit=gas_limit,
gas_limit=self.config.gas_limit_set_guardian,
add_data_movement_gas=True
).build()

def create_transaction_for_guarding_account(self, sender: IAddress) -> Transaction:
data_parts = ["GuardAccount"]

gas_limit = self.config.gas_limit_guard_account + self.config.extra_gas_limit_for_guarded_transaction

return TransactionBuilder(
config=self.config,
sender=sender,
receiver=sender,
data_parts=data_parts,
gas_limit=gas_limit,
gas_limit=self.config.gas_limit_guard_account,
add_data_movement_gas=True
).build()

def create_transaction_for_unguarding_account(self, sender: IAddress) -> Transaction:
data_parts = ["UnGuardAccount"]

gas_limit = self.config.gas_limit_unguard_account + self.config.extra_gas_limit_for_guarded_transaction

transaction = TransactionBuilder(
config=self.config,
sender=sender,
receiver=sender,
data_parts=data_parts,
gas_limit=gas_limit,
gas_limit=self.config.gas_limit_unguard_account,
add_data_movement_gas=True
).build()
transaction.options = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_set_guardian(self):
assert tx.sender == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
assert tx.receiver == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
assert tx.data.decode() == "SetGuardian@8049d639e5a6980d1cd2392abcce41029cda74a1563523a202f09641cc2618f8@4d756c7469766572735854435353657276696365"
assert tx.gas_limit == 525500
assert tx.gas_limit == 475500

def test_guard_account(self):
sender = Address.new_from_bech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th")
Expand All @@ -51,7 +51,7 @@ def test_guard_account(self):
assert tx.sender == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
assert tx.receiver == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
assert tx.data.decode() == "GuardAccount"
assert tx.gas_limit == 368000
assert tx.gas_limit == 318000

def test_unguard_account(self):
sender = Address.new_from_bech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th")
Expand All @@ -60,4 +60,4 @@ def test_unguard_account(self):
assert tx.sender == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
assert tx.receiver == "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
assert tx.data.decode() == "UnGuardAccount"
assert tx.gas_limit == 371000
assert tx.gas_limit == 321000
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, chain_id: str) -> None:
self.gas_limit_esdt_nft_update_attributes: int = 1_000_000
self.gas_limit_esdt_nft_add_quantity: int = 1_000_000
self.gas_limit_esdt_nft_burn: int = 1_000_000
self.gas_limit_store_per_byte: int = 50_000
self.gas_limit_store_per_byte: int = 10_000
self.issue_cost: int = 50_000_000_000_000_000
self.esdt_contract_address: IAddress = Address.new_from_bech32("erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u")

Expand All @@ -45,11 +45,9 @@ def __init__(self, chain_id: str) -> None:
# Configuration for account operations
self.gas_limit_save_key_value = 100_000
self.gas_limit_persist_per_byte = 1_000
self.gas_limit_store_per_byte = 10_000
self.gas_limit_set_guardian = 250_000
self.gas_limit_guard_account = 250_000
self.gas_limit_unguard_account = 250_000
self.extra_gas_limit_for_guarded_transaction = 50_000

# Configuration for smart contract operations
self.gas_limit_claim_developer_rewards = 6_000_000
Expand Down

0 comments on commit 6912288

Please sign in to comment.