Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
SamWilsn committed Jun 19, 2024
1 parent b912261 commit fb1892b
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/ethereum/prague/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
state_root,
)
from .transactions import (
COST_FLOOR_PER_CALLDATA_TOKEN,
LEGACY_CALLDATA_TOKEN_COST,
TX_ACCESS_LIST_ADDRESS_COST,
TX_ACCESS_LIST_STORAGE_KEY_COST,
TX_BASE_COST,
TX_CREATE_COST,
LEGACY_CALLDATA_TOKEN_COST,
COST_FLOOR_PER_CALLDATA_TOKEN,
AccessListTransaction,
BlobTransaction,
FeeMarketTransaction,
Expand Down Expand Up @@ -877,17 +877,19 @@ def process_transaction(
)

output = process_message_call(message, env)

floor = Uint(tokens_in_calldata * COST_FLOOR_PER_CALLDATA_TOKEN + TX_BASE_COST)


floor = Uint(
tokens_in_calldata * COST_FLOOR_PER_CALLDATA_TOKEN + TX_BASE_COST
)

legacy_cost = Uint(gas_used + tokens_in_calldata * LEGACY_TOKEN_COST)

if legacy_cost < floor:
output.gas_left -= floor - gas_used
gas_used = floor
else:
gas_used = tx.gas - output.gas_left

gas_refund = min(gas_used // 5, output.refund_counter)
gas_refund_amount = (output.gas_left + gas_refund) * env.gas_price

Expand Down Expand Up @@ -950,14 +952,14 @@ def calculate_intrinsic_cost(tx: Transaction) -> Tuple[Uint, Uint]:
The eip-7623 calldata tokens used by the transaction.
"""
data_cost = 0

zerobytes = 0
for byte in tx.data:
if byte == 0:
zerobytes += 1

tokens_in_calldata = zerobytes + (len(tx.data) - zerobytes) * 4

data_cost = tokens_in_calldata * COST_FLOOR_PER_CALLDATA_TOKEN

if tx.to == Bytes0(b""):
Expand All @@ -973,9 +975,10 @@ def calculate_intrinsic_cost(tx: Transaction) -> Tuple[Uint, Uint]:
access_list_cost += TX_ACCESS_LIST_ADDRESS_COST
access_list_cost += len(keys) * TX_ACCESS_LIST_STORAGE_KEY_COST

return Uint(TX_BASE_COST +
data_cost +
create_cost + access_list_cost), tokens_in_calldata
return (
Uint(TX_BASE_COST + data_cost + create_cost + access_list_cost),
tokens_in_calldata,
)


def recover_sender(chain_id: U64, tx: Transaction) -> Address:
Expand Down

0 comments on commit fb1892b

Please sign in to comment.