Skip to content

Commit

Permalink
fix: max_priority_fee_per_gas_percentage_multiplier can cause a faile…
Browse files Browse the repository at this point in the history
…d bundle transaction
  • Loading branch information
sherifahmed990 committed Oct 26, 2024
1 parent 0f7f2a2 commit 6a13431
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions voltaire_bundler/bundle/bundle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def send_bundle(
* (self.max_fee_per_gas_percentage_multiplier / 100)
* (self.gas_price_percentage_multiplier / 100)
)
block_max_fee_per_gas = hex(block_max_fee_per_gas_dec_mod)
block_max_fee_per_gas_hex = hex(block_max_fee_per_gas_dec_mod)

block_max_priority_fee_per_gas_hex = "0x"
if not self.is_legacy_mode:
Expand All @@ -200,6 +200,10 @@ async def send_bundle(
block_max_priority_fee_per_gas_hex = hex(
block_max_priority_fee_per_gas_dec_mod)

# max priority fee per gas can't be higher than max fee per gas
if block_max_priority_fee_per_gas_dec_mod > block_max_fee_per_gas_dec_mod:
block_max_priority_fee_per_gas_hex = block_max_fee_per_gas_hex

txnDict = {
"chainId": self.chain_id,
"from": self.bundler_address,
Expand All @@ -212,13 +216,13 @@ async def send_bundle(
if self.is_legacy_mode:
txnDict.update(
{
"gasPrice": block_max_fee_per_gas,
"gasPrice": block_max_fee_per_gas_hex,
}
)
else:
txnDict.update(
{
"maxFeePerGas": block_max_fee_per_gas,
"maxFeePerGas": block_max_fee_per_gas_hex,
"maxPriorityFeePerGas": block_max_priority_fee_per_gas_hex,
}
)
Expand Down
4 changes: 4 additions & 0 deletions voltaire_bundler/gas/v6/gas_manager_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ async def verify_gas_fees_and_get_price(
/ 100)
)

# max priority fee per gas can't be higher than max fee per gas
if block_max_priority_fee_per_gas > block_max_fee_per_gas:
block_max_priority_fee_per_gas = block_max_fee_per_gas

estimated_base_fee = max(
block_max_fee_per_gas - block_max_priority_fee_per_gas, 1
)
Expand Down
4 changes: 4 additions & 0 deletions voltaire_bundler/gas/v7/gas_manager_v7.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ async def verify_gas_fees_and_get_price(
/ 100)
)

# max priority fee per gas can't be higher than max fee per gas
if block_max_priority_fee_per_gas > block_max_fee_per_gas:
block_max_priority_fee_per_gas = block_max_fee_per_gas

estimated_base_fee = max(
block_max_fee_per_gas - block_max_priority_fee_per_gas, 1
)
Expand Down

0 comments on commit 6a13431

Please sign in to comment.